Skip to content

Commit 1287da6

Browse files
committed
feat: toolStoreDialog
1 parent 9777c92 commit 1287da6

File tree

11 files changed

+360
-7
lines changed

11 files changed

+360
-7
lines changed

ui/src/api/tool/tool.ts

Lines changed: 28 additions & 6 deletions
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

88
import useStore from '@/stores'
@@ -84,16 +84,16 @@ const getToolById: (tool_id: string, loading?: Ref<boolean>) => Promise<Result<a
8484
* @param 参数 tool_id
8585
*/
8686
const delTool: (
87-
tool_id: String,
87+
tool_id: string,
8888
loading?: Ref<boolean>
8989
) => Promise<Result<boolean>> = (tool_id, loading) => {
9090
return del(`${prefix.value}/${tool_id}`, undefined, {}, loading)
9191
}
9292

9393
const putToolIcon: (
94-
id: string,
95-
data: any,
96-
loading?: Ref<boolean>
94+
id: string,
95+
data: any,
96+
loading?: Ref<boolean>
9797
) => Promise<Result<any>> = (id, data, loading) => {
9898
return put(`${prefix.value}/${id}/edit_icon`, data, undefined, loading)
9999
}
@@ -128,6 +128,26 @@ 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 getInternalToolList: (
135+
param?: any,
136+
loading?: Ref<boolean>,
137+
) => Promise<Result<any>> = (param, loading) => {
138+
return get('/workspace/internal/tool', param, loading)
139+
}
140+
141+
/**
142+
* 工具商店-添加系统内置
143+
*/
144+
const addInternalTool: (tool_id: string, param: AddInternalToolParam, loading?: Ref<boolean>) => Promise<Result<any>> = (
145+
tool_id,
146+
param,
147+
loading,
148+
) => {
149+
return post(`${prefix.value}/${tool_id}/add_internal_tool`, param, undefined, loading)
150+
}
131151
export default {
132152
getToolList,
133153
getToolListPage,
@@ -139,5 +159,7 @@ export default {
139159
postPylint,
140160
exportTool,
141161
putToolIcon,
142-
delTool
162+
delTool,
163+
getInternalToolList,
164+
addInternalTool
143165
}

ui/src/api/type/tool.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ interface toolData {
1010
folder_id?: string
1111
}
1212

13-
export type { toolData }
13+
interface AddInternalToolParam {
14+
name: string,
15+
folder_id: string
16+
}
17+
18+
export type { toolData, AddInternalToolParam }

ui/src/locales/lang/en-US/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ export default {
8787
otherSetting: 'Other Settings',
8888
username: 'username',
8989
importCreate: 'Import Create',
90+
detail: 'Detail'
9091
}

ui/src/locales/lang/en-US/views/tool.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ export default {
66
editTool: 'Edit Tool',
77
copyTool: 'Copy Tool',
88
importTool: 'Import Tool',
9+
toolStore: {
10+
title: 'Tool Store',
11+
createFromToolStore: 'Create from Tool Store',
12+
recommend: 'Recommended',
13+
webSearch: 'Web Search',
14+
databaseQuery: 'Database Query',
15+
image: 'Image',
16+
developer: 'Developer',
17+
communication: 'Communication',
18+
searchResult: '{count} search results for'
19+
},
920
searchBar: {
1021
placeholder: 'Search by tool name',
1122
},

ui/src/locales/lang/zh-CN/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ export default {
9191
otherSetting: '其他设置',
9292
username: '用户名',
9393
importCreate: '导入创建',
94+
detail: '详情'
9495
}

ui/src/locales/lang/zh-CN/views/tool.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ export default {
44
editTool: '编辑工具',
55
copyTool: '复制函数',
66
importTool: '导入函数',
7+
toolStore: {
8+
title: '工具商店',
9+
createFromToolStore: '从工具商店创建',
10+
recommend: '推荐',
11+
webSearch: '联网搜索',
12+
databaseQuery: '数据库查询',
13+
image: '图像',
14+
developer: '开发者',
15+
communication: '通信',
16+
searchResult: '的搜索结果 {count} 个'
17+
},
718
enabled: '启用',
819
disabled: {
920
confirmTitle: '是否禁用工具:',

ui/src/locales/lang/zh-Hant/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ export default {
8787
otherSetting: '其他設定',
8888
username: '用戶名',
8989
importCreate: '導入創建',
90+
detail: '详情'
9091
}

ui/src/locales/lang/zh-Hant/views/tool.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ export default {
66
editTool: '編輯工具',
77
copyTool: '複製工具',
88
importTool: '匯入工具',
9+
toolStore: {
10+
title: '工具商店',
11+
createFromToolStore: '從工具商店創建',
12+
recommend: '推薦',
13+
webSearch: '聯網搜索',
14+
databaseQuery: '數據庫查詢',
15+
image: '圖像',
16+
developer: '開發者',
17+
communication: '通信',
18+
searchResult: '的搜索結果 {count} 個'
19+
},
920
searchBar: {
1021
placeholder: '按工具名稱搜尋',
1122
},
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<template>
2+
<CardBox :title="props.tool.name" :description="props.tool.desc" class="cursor">
3+
<template #icon>
4+
<!-- TODO -->
5+
<LogoIcon style="width: 28px; height: 28px; display: block" />
6+
</template>
7+
<template #subTitle>
8+
<el-text class="color-secondary" size="small">
9+
{{ getSubTitle(props.tool) }}
10+
</el-text>
11+
</template>
12+
<template #footer>
13+
<span class="card-footer-left color-secondary">
14+
{{ `${$t('common.author')}: MaxKB` }}
15+
</span>
16+
<div class="card-footer-operation" @click.stop>
17+
<el-button>
18+
{{ $t('common.detail') }}
19+
</el-button>
20+
<el-button type="primary" :loading="props.addLoading" @click="emit('handleAdd')">
21+
{{ $t('common.add') }}
22+
</el-button>
23+
</div>
24+
</template>
25+
</CardBox>
26+
</template>
27+
28+
<script setup lang="ts">
29+
const props = defineProps<{
30+
tool: any,
31+
getSubTitle: (v: any) => string
32+
addLoading: boolean
33+
}>()
34+
35+
const emit = defineEmits<{
36+
(e: 'handleAdd'): void;
37+
}>();
38+
</script>
39+
40+
<style lang="scss" scoped>
41+
.el-card {
42+
:deep(.card-footer) {
43+
&>div:first-of-type {
44+
flex: 1;
45+
}
46+
47+
.card-footer-operation {
48+
display: none;
49+
}
50+
}
51+
52+
&:hover {
53+
.card-footer-left {
54+
display: none;
55+
}
56+
57+
.card-footer-operation {
58+
display: flex !important;
59+
60+
.el-button {
61+
flex: 1;
62+
}
63+
}
64+
}
65+
}
66+
</style>

0 commit comments

Comments
 (0)