Skip to content

Commit 5ab5ab7

Browse files
committed
feat: add functionality to add internal shared tools with API integration
1 parent 32dd4b4 commit 5ab5ab7

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

ui/src/api/system-shared/tool.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Result } from '@/request/Result'
22
import { get, post, del, put, exportFile } from '@/request/index'
33
import { type Ref } from 'vue'
44
import type { pageRequest } from '@/api/type/common'
5-
import type { toolData } from '@/api/type/tool'
5+
import type { toolData, AddInternalToolParam } from '@/api/type/tool'
66

77
const prefix = '/system/shared/tool'
88

@@ -121,6 +121,17 @@ const postPylint: (code: string, loading?: Ref<boolean>) => Promise<Result<any>>
121121
}
122122

123123

124+
/**
125+
* 工具商店-添加系统内置
126+
*/
127+
const addInternalTool: (
128+
tool_id: string,
129+
param: AddInternalToolParam,
130+
loading?: Ref<boolean>,
131+
) => Promise<Result<any>> = (tool_id, param, loading) => {
132+
return post(`${prefix}/${tool_id}/add_internal_tool`, param, undefined, loading)
133+
}
134+
124135

125136
export default {
126137
getToolList,
@@ -134,4 +145,5 @@ export default {
134145
exportTool,
135146
putToolIcon,
136147
delTool,
148+
addInternalTool
137149
}

ui/src/api/tool/tool.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Result } from '@/request/Result'
22
import { get, post, del, put, exportFile } from '@/request/index'
33
import { type Ref } from 'vue'
44
import type { pageRequest } from '@/api/type/common'
5-
import type { toolData } from '@/api/type/tool'
5+
import type {AddInternalToolParam, toolData} from '@/api/type/tool'
66

77

88
import useStore from '@/stores'
@@ -128,6 +128,17 @@ const postPylint: (code: string, loading?: Ref<boolean>) => Promise<Result<any>>
128128
return post(`${prefix.value}/pylint`, { code }, {}, loading)
129129
}
130130

131+
/**
132+
* 工具商店-添加系统内置
133+
*/
134+
const addInternalTool: (
135+
tool_id: string,
136+
param: AddInternalToolParam,
137+
loading?: Ref<boolean>,
138+
) => Promise<Result<any>> = (tool_id, param, loading) => {
139+
return post(`${prefix.value}/${tool_id}/add_internal_tool`, param, undefined, loading)
140+
}
141+
131142

132143
export default {
133144
getToolList,
@@ -141,4 +152,5 @@ export default {
141152
exportTool,
142153
putToolIcon,
143154
delTool,
155+
addInternalTool
144156
}

ui/src/views/tool/component/ToolListContainer.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
<InitParamDrawer ref="InitParamDrawerRef" @refresh="refresh" />
288288
<ToolFormDrawer ref="ToolFormDrawerRef" @refresh="refresh" :title="ToolDrawertitle" />
289289
<CreateFolderDialog ref="CreateFolderDialogRef" v-if="!isShared" />
290-
<ToolStoreDialog ref="toolStoreDialogRef" @refresh="refresh" />
290+
<ToolStoreDialog ref="toolStoreDialogRef" :api-type="apiType" @refresh="refresh" />
291291
<AddInternalToolDialog ref="AddInternalToolDialogRef" @refresh="confirmAddInternalTool" />
292292
<AuthorizedWorkspace
293293
ref="AuthorizedWorkspaceDialogRef"
@@ -319,7 +319,6 @@ import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
319319
import permissionMap from '@/permission'
320320
import useStore from '@/stores'
321321
import { t } from '@/locales'
322-
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
323322
const route = useRoute()
324323
const { folder, user, tool } = useStore()
325324
onBeforeRouteLeave((to, from) => {

ui/src/views/tool/toolStore/ToolStoreDialog.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,19 @@ import ToolCard from './ToolCard.vue'
6868
import { MsgSuccess } from '@/utils/message'
6969
import InternalDescDrawer from './InternalDescDrawer.vue'
7070
import AddInternalToolDialog from './AddInternalToolDialog.vue'
71+
import {loadSharedApi} from "@/utils/dynamics-api/shared-api.ts";
7172
7273
interface ToolCategory {
7374
id: string
7475
title: string
7576
tools: any[]
7677
}
77-
78+
const props = defineProps({
79+
apiType: {
80+
type: String as () => 'workspace' | 'systemShare' | 'systemManage',
81+
default: 'workspace'
82+
},
83+
})
7884
const emit = defineEmits(['refresh'])
7985
8086
const dialogVisible = ref(false)
@@ -171,7 +177,9 @@ function handleOpenAdd(data?: any, isEdit?: boolean) {
171177
const addLoading = ref(false)
172178
async function handleAdd(tool: any) {
173179
try {
174-
await ToolStoreApi.addInternalTool(tool.id, { name: tool.name, folder_id: folderId.value }, addLoading)
180+
await loadSharedApi({ type: 'tool', systemType: props.apiType })
181+
.addInternalTool(tool.id, { name: tool.name, folder_id: folderId.value }, addLoading)
182+
// await ToolStoreApi.addInternalTool(tool.id, { name: tool.name, folder_id: folderId.value }, addLoading)
175183
emit('refresh')
176184
MsgSuccess(t('common.addSuccess'))
177185
dialogVisible.value = false

0 commit comments

Comments
 (0)