feat(web): add prompt editor with split-pane and Markdown editing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 02:34:04 +08:00
parent 66f0f82fde
commit e35778ebea
3 changed files with 157 additions and 24 deletions

View File

@@ -0,0 +1,25 @@
import { useState, useCallback } from 'react';
import { api } from '@/lib/api';
export function usePrompts() {
const [content, setContent] = useState<string>('');
const [path, setPath] = useState<string>('');
const [loading, setLoading] = useState(false);
const load = useCallback(async (accountId: string, type: string) => {
setLoading(true);
try {
const result = await api.getPrompt(accountId, type);
setContent(result.content);
setPath(result.path);
} catch { setContent(''); setPath(''); }
setLoading(false);
}, []);
const save = useCallback(async (accountId: string, type: string, newContent: string) => {
await api.savePrompt(accountId, type, newContent);
setContent(newContent);
}, []);
return { content, path, loading, load, save, setContent };
}