From 330accb822542a1c72f42760ba234a688f399d56 Mon Sep 17 00:00:00 2001 From: xiongxiao Date: Thu, 19 Mar 2026 02:02:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96mark=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=96=87=E6=A1=A3=E5=92=8C=E5=B7=A5=E4=BD=9C=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E9=A1=B5=E9=9D=A2=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/mark-api.ts | 124 ++++++++++++++-- src/pages/workspaces/page.tsx | 214 ++++++++++++++++++++++++---- src/pages/workspaces/store/index.ts | 24 +++- 3 files changed, 317 insertions(+), 45 deletions(-) diff --git a/src/modules/mark-api.ts b/src/modules/mark-api.ts index 5d1924f..a25b14f 100644 --- a/src/modules/mark-api.ts +++ b/src/modules/mark-api.ts @@ -2,7 +2,7 @@ import { createQueryApi } from '@kevisual/query/api'; const api = { "mark": { /** - * mark list. + * 获取mark列表 * * @param data - Request parameters * @param data.page - {number} 页码 @@ -14,7 +14,7 @@ const api = { "list": { "path": "mark", "key": "list", - "description": "mark list.", + "description": "获取mark列表", "metadata": { "args": { "page": { @@ -58,12 +58,15 @@ const api = { } }, /** + * 获取mark版本信息 + * * @param data - Request parameters * @param data.id - {string} mark id */ "getVersion": { "path": "mark", "key": "getVersion", + "description": "获取mark版本信息", "metadata": { "args": { "id": { @@ -77,12 +80,15 @@ const api = { } }, /** + * 获取mark详情 + * * @param data - Request parameters * @param data.id - {string} mark id */ "get": { "path": "mark", "key": "get", + "description": "获取mark详情", "metadata": { "args": { "id": { @@ -96,18 +102,55 @@ const api = { } }, /** + * 更新mark内容 + * * @param data - Request parameters * @param data.id - {string} mark id + * @param data.data - {object} */ "update": { "path": "mark", "key": "update", + "description": "更新mark内容", "metadata": { "args": { "id": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "string", "description": "mark id" + }, + "data": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "title": { + "default": "", + "type": "string" + }, + "tags": { + "default": [] + }, + "link": { + "default": "", + "type": "string" + }, + "summary": { + "default": "", + "type": "string" + }, + "description": { + "default": "", + "type": "string" + } + }, + "required": [ + "title", + "tags", + "link", + "summary", + "description" + ], + "additionalProperties": false } }, "url": "/api/router", @@ -115,6 +158,8 @@ const api = { } }, /** + * 更新mark节点,支持更新和删除操作 + * * @param data - Request parameters * @param data.id - {string} mark id * @param data.operate - {"update" | "delete"} 节点操作类型,update或delete @@ -123,6 +168,7 @@ const api = { "updateNode": { "path": "mark", "key": "updateNode", + "description": "更新mark节点,支持更新和删除操作", "metadata": { "args": { "id": { @@ -166,6 +212,8 @@ const api = { } }, /** + * 批量更新mark节点,支持更新和删除操作 + * * @param data - Request parameters * @param data.id - {string} mark id * @param data.nodeOperateList - {array} 要更新的节点列表 @@ -173,6 +221,7 @@ const api = { "updateNodes": { "path": "mark", "key": "updateNodes", + "description": "批量更新mark节点,支持更新和删除操作", "metadata": { "args": { "id": { @@ -232,33 +281,77 @@ const api = { } }, /** - * 创建mark + * 创建一个新的mark. * * @param data - Request parameters - * @param data.name - {string} mark名称 - * @param data.markType - {string} mark类型,simple,wallnote,md,draw等 - * @param data.data - {object} mark数据 + * @param data.title - {string} 标题 + * @param data.tags - {unknown} 标签 + * @param data.link - {string} 链接 + * @param data.summary - {string} 摘要 + * @param data.description - {string} 描述 + * @param data.markType - {string} mark类型 + * @param data.config - {unknown} 配置 + * @param data.data - {unknown} 数据 */ "create": { "path": "mark", "key": "create", - "description": "创建mark", + "description": "创建一个新的mark.", "metadata": { "args": { - "name": { + "title": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "mark名称", - "type": "string" + "default": "", + "description": "标题", + "type": "string", + "optional": true + }, + "tags": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "items": { "type": "string" }, + "default": [], + "description": "标签", + "optional": true + }, + "link": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": "", + "description": "链接", + "type": "string", + "optional": true + }, + "summary": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": "", + "description": "摘要", + "type": "string", + "optional": true + }, + "description": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": "", + "description": "描述", + "type": "string", + "optional": true }, "markType": { "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": "md", "description": "mark类型", - "type": "string" + "type": "string", + "optional": true + }, + "config": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": {}, + "description": "配置", + "optional": true }, "data": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "mark数据", - "type": "object", + "default": {}, + "description": "数据", "optional": true } }, @@ -267,12 +360,12 @@ const api = { } }, /** - * 获取菜单 + * 获取mark菜单 */ "getMenu": { "path": "mark", "key": "getMenu", - "description": "获取菜单", + "description": "获取mark菜单", "metadata": { "url": "/api/router", "source": "query-proxy-api" @@ -281,4 +374,5 @@ const api = { } } as const; const queryApi = createQueryApi({ api }); + export { queryApi }; diff --git a/src/pages/workspaces/page.tsx b/src/pages/workspaces/page.tsx index 118989b..b6f971d 100644 --- a/src/pages/workspaces/page.tsx +++ b/src/pages/workspaces/page.tsx @@ -88,7 +88,7 @@ export const App = () => { boxShadow: '0 2px 4px rgba(0,0,0,0.1)' }} > -

{item.name || '未命名'}

+

{item.title || '未命名'}

ID: {item.id}

创建时间: {item.created_at ? new Date(item.created_at).toLocaleString() : '-'} @@ -156,22 +156,30 @@ export const App = () => { function CreateDialog({ open, onClose, onSubmit }: { open: boolean; onClose: () => void; - onSubmit: (data: { name: string, data?: any }) => Promise; + onSubmit: (data: { title: string, tags?: string[], link?: string, summary?: string, description?: string, data?: any }) => Promise; }) { - const [name, setName] = useState(''); + const [title, setTitle] = useState(''); + const [tags, setTags] = useState(''); + const [link, setLink] = useState(''); + const [summary, setSummary] = useState(''); + const [description, setDescription] = useState(''); const [data, setData] = useState(''); const [submitting, setSubmitting] = useState(false); useEffect(() => { if (open) { - setName(''); + setTitle(''); + setTags(''); + setLink(''); + setSummary(''); + setDescription(''); setData(''); } }, [open]); const handleSubmit = async () => { - if (!name.trim()) { - alert('请输入名称'); + if (!title.trim()) { + alert('请输入标题'); return; } setSubmitting(true); @@ -186,7 +194,14 @@ function CreateDialog({ open, onClose, onSubmit }: { return; } } - await onSubmit({ name: name.trim(), data: parsedData }); + await onSubmit({ + title: title.trim(), + tags: tags.split(',').map(t => t.trim()).filter(Boolean), + link: link.trim(), + summary: summary.trim(), + description: description.trim(), + data: parsedData + }); } finally { setSubmitting(false); } @@ -211,17 +226,19 @@ function CreateDialog({ open, onClose, onSubmit }: { background: '#fff', borderRadius: '8px', padding: '24px', - width: '480px', - maxWidth: '90%' + width: '520px', + maxWidth: '90%', + maxHeight: '90vh', + overflow: 'auto' }} onClick={e => e.stopPropagation()}>

创建Workspace

- + setName(e.target.value)} - placeholder="请输入名称" + value={title} + onChange={e => setTitle(e.target.value)} + placeholder="请输入标题" style={{ width: '100%', padding: '8px 12px', @@ -231,6 +248,71 @@ function CreateDialog({ open, onClose, onSubmit }: { }} />
+
+ + setTags(e.target.value)} + placeholder="标签1, 标签2, 标签3" + style={{ + width: '100%', + padding: '8px 12px', + border: '1px solid #ddd', + borderRadius: '4px', + boxSizing: 'border-box' + }} + /> +
+
+ + setLink(e.target.value)} + placeholder="https://..." + style={{ + width: '100%', + padding: '8px 12px', + border: '1px solid #ddd', + borderRadius: '4px', + boxSizing: 'border-box' + }} + /> +
+
+ + setSummary(e.target.value)} + placeholder="简要描述" + style={{ + width: '100%', + padding: '8px 12px', + border: '1px solid #ddd', + borderRadius: '4px', + boxSizing: 'border-box' + }} + /> +
+
+ +