@@ -3,14 +3,22 @@ import { reactive, ref } from 'vue'
33import type { FormInstance , FormRules } from ' element-plus'
44import ToolApi from ' @/api/admin/workspace/tool/tool'
55import WorkspaceToolStoreApi from ' @/api/admin/workspace/tool/store'
6+ import SystemSharedToolApi from ' @/api/admin/system/shared-resources/tool/tool'
7+ import SystemSharedToolStoreApi from ' @/api/admin/system/shared-resources/tool/store'
68import { TOOL_TYPE } from ' @/api/enums'
79import type { ToolItem , ToolStoreItem } from ' @/api/types'
810import { useStore } from ' @/stores'
911import { MsgSuccess } from ' @/utils/message'
12+ import { isSystemSharedResource } from ' @/utils/resource-context'
1013
1114defineOptions ({ name: ' StoreToolFormDialog' })
1215
13- const props = defineProps <{ folderId? : string }>()
16+ const props = withDefaults (
17+ defineProps <{
18+ folderId: string
19+ }>(),
20+ { folderId: ' default' },
21+ )
1422
1523const { auth } = useStore ()
1624
@@ -36,14 +44,17 @@ function handleSubmit() {
3644 loading .value = true
3745
3846 const commonPayload = { folder_id: props .folderId || ' default' , name }
47+ const isSharedResource = isSystemSharedResource ()
48+ const toolApi = isSharedResource ? SystemSharedToolApi : ToolApi
49+ const toolStoreApi = isSharedResource ? SystemSharedToolStoreApi : WorkspaceToolStoreApi
3950 let request: Promise <ToolItem >
4051
4152 if (tool .source === ' internal' ) {
42- request = WorkspaceToolStoreApi .postInternalTool (tool .id , commonPayload )
53+ request = toolStoreApi .postInternalTool (tool .id , commonPayload )
4354 } else if (tool .label === ' workflow_template' ) {
44- request = ToolApi .postTool ({ ... commonPayload , code: ' {}' , tool_type: TOOL_TYPE .WORKFLOW , work_flow_template: tool })
55+ request = toolApi .postTool ({ ... commonPayload , code: ' {}' , tool_type: TOOL_TYPE .WORKFLOW , work_flow_template: tool })
4556 } else {
46- request = WorkspaceToolStoreApi .postStoreTool (tool .id , {
57+ request = toolStoreApi .postStoreTool (tool .id , {
4758 ... commonPayload ,
4859 download_callback_url: tool .downloadCallbackUrl ?? ' ' ,
4960 download_url: tool .downloadUrl ?? ' ' ,
0 commit comments