From a0291bea88669f833571b4d3c2a62169b3c59bb1 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 4 Jun 2025 11:24:04 +0800 Subject: [PATCH] feat: tool --- ui/package.json | 1 + ui/src/api/tool/tool.ts | 15 +- ui/src/components/codemirror-editor/index.vue | 133 ++++++++++++++++++ ui/src/components/index.ts | 2 + ui/src/views/knowledge/index.vue | 23 +-- ui/src/views/tool/index.vue | 25 ++-- 6 files changed, 176 insertions(+), 23 deletions(-) create mode 100644 ui/src/components/codemirror-editor/index.vue diff --git a/ui/package.json b/ui/package.json index f76c53ddc..e74a8e006 100644 --- a/ui/package.json +++ b/ui/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@codemirror/lang-json": "^6.0.1", + "@codemirror/lang-python": "^6.2.1", "@codemirror/theme-one-dark": "^6.1.2", "axios": "^1.8.4", "element-plus": "^2.9.10", diff --git a/ui/src/api/tool/tool.ts b/ui/src/api/tool/tool.ts index f3be669cf..6c3670b5e 100644 --- a/ui/src/api/tool/tool.ts +++ b/ui/src/api/tool/tool.ts @@ -75,8 +75,16 @@ const getToolById: ( wordspace_id: string, tool_id: String, loading?: Ref, -) => Promise> = (wordspace_id, function_lib_id, loading) => { - return get(`${prefix}/${wordspace_id}/tool/${function_lib_id}`, undefined, loading) +) => Promise> = (wordspace_id, tool_id, loading) => { + return get(`${prefix}/${wordspace_id}/tool/${tool_id}`, undefined, loading) +} + +const postPylint: ( + wordspace_id: string, + code: string, + loading?: Ref, +) => Promise> = (wordspace_id, code, loading) => { + return post(`${prefix}/${wordspace_id}/tool/pylint`, { code }, {}, loading) } /** @@ -96,5 +104,6 @@ export default { getToolList, putTool, getToolById, - postTool + postTool, + postPylint } diff --git a/ui/src/components/codemirror-editor/index.vue b/ui/src/components/codemirror-editor/index.vue new file mode 100644 index 000000000..a5c5dd7e7 --- /dev/null +++ b/ui/src/components/codemirror-editor/index.vue @@ -0,0 +1,133 @@ + + + + + diff --git a/ui/src/components/index.ts b/ui/src/components/index.ts index 83abdbd2c..213de8ab6 100644 --- a/ui/src/components/index.ts +++ b/ui/src/components/index.ts @@ -11,6 +11,7 @@ import FolderTree from './folder-tree/index.vue' import CommonList from './common-list/index.vue' import BackButton from './back-button/index.vue' import AppTable from './app-table/index.vue' +import CodemirrorEditor from './codemirror-editor/index.vue' export default { install(app: App) { app.component('LogoFull', LogoFull) @@ -25,5 +26,6 @@ export default { app.component('CommonList', CommonList) app.component('BackButton', BackButton) app.component('AppTable', AppTable) + app.component('CodemirrorEditor', CodemirrorEditor) }, } diff --git a/ui/src/views/knowledge/index.vue b/ui/src/views/knowledge/index.vue index 1359736b7..f4ebdc6de 100644 --- a/ui/src/views/knowledge/index.vue +++ b/ui/src/views/knowledge/index.vue @@ -45,9 +45,17 @@
- -