Skip to content

Commit 11fa3c4

Browse files
feat: tool
1 parent 2ab5780 commit 11fa3c4

File tree

32 files changed

+929
-619
lines changed

32 files changed

+929
-619
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<template>
2+
<el-breadcrumb separator-icon="ArrowRight" style="line-height: 22px">
3+
<h4 v-if="breadcrumbData?.length === 1">{{ breadcrumbData[0]?.name }}</h4>
4+
<el-breadcrumb-item v-for="(item, index) in breadcrumbData" :key="index" v-else>
5+
<h5 class="ml-4" v-if="index === breadcrumbData.length - 1">{{ item.name }}</h5>
6+
<el-button v-else link @click="handleClick(item)">{{ item.name }}</el-button>
7+
</el-breadcrumb-item>
8+
</el-breadcrumb>
9+
</template>
10+
11+
<script setup lang="ts">
12+
import { computed } from 'vue'
13+
import { TreeToFlatten } from '@/utils/array'
14+
defineOptions({ name: 'FolderBreadcrumb' })
15+
import useStore from '@/stores'
16+
const { folder, user } = useStore()
17+
18+
const props = defineProps({
19+
folderList: {
20+
type: Array,
21+
default: () => [],
22+
},
23+
})
24+
25+
const breadcrumbData = computed(() => {
26+
return folder.currentFolder?.id && getBreadcrumbData()
27+
})
28+
29+
const emit = defineEmits(['click'])
30+
31+
function getBreadcrumbData() {
32+
const targetId = folder.currentFolder?.id
33+
const list = TreeToFlatten(props.folderList)
34+
if (!folder.currentFolder) return [] // 如果没有 id,返回空数组
35+
const breadcrumbList: any[] = []
36+
let currentId: string | null = targetId
37+
while (currentId) {
38+
const currentNode = list.find((item: any) => item.id === currentId)
39+
if (!currentNode) break // 如果找不到节点,终止循环
40+
breadcrumbList.unshift(currentNode) // 添加到面包屑
41+
currentId = currentNode.parent_id // 继续查找父级
42+
}
43+
return breadcrumbList
44+
}
45+
46+
function handleClick(item: any) {
47+
emit('click', item)
48+
}
49+
</script>
50+
51+
<style lang="scss" scoped></style>

ui/src/components/folder-tree/CreateFolderDialog.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import { ref, watch, reactive } from 'vue'
5252
import folderApi from '@/api/folder'
5353
import { MsgSuccess, MsgAlert } from '@/utils/message'
5454
import { t } from '@/locales'
55+
import useStore from '@/stores'
56+
const { tool } = useStore()
5557
const emit = defineEmits(['refresh'])
5658
5759
const props = defineProps({
@@ -122,12 +124,14 @@ const submitHandle = async () => {
122124
.then((res) => {
123125
MsgSuccess(t('common.editSuccess'))
124126
emit('refresh')
127+
tool.setToolList([])
125128
dialogVisible.value = false
126129
})
127130
} else {
128131
folderApi.postFolder(sourceType.value, folderForm.value, loading).then((res) => {
129132
MsgSuccess(t('common.createSuccess'))
130133
emit('refresh')
134+
tool.setToolList([])
131135
dialogVisible.value = false
132136
})
133137
}

ui/src/components/folder-tree/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:class="currentNodeKey === 'share' && 'active'"
1515
>
1616
<AppIcon :iconName="iconName" style="font-size: 18px"></AppIcon>
17-
<span class="ml-8 lighter">{{ $t(shareTitle) }}</span>
17+
<span class="ml-8 lighter">{{ shareTitle }}</span>
1818
</div>
1919
<el-tree
2020
ref="treeRef"
@@ -37,7 +37,7 @@
3737
</div>
3838

3939
<div
40-
v-if="canOperation"
40+
v-if="canOperation && node.level !== 3"
4141
@click.stop
4242
v-show="hoverNodeId === data.id"
4343
@mouseenter.stop="handleMouseEnter(data)"
@@ -61,7 +61,7 @@
6161
<el-dropdown-item
6262
divided
6363
@click.stop="deleteFolder(data)"
64-
:disabled="data.id === 'default'"
64+
:disabled="!data.parent_id"
6565
>
6666
<el-icon><Delete /></el-icon>
6767
{{ $t('common.delete') }}
@@ -109,7 +109,7 @@ const props = defineProps({
109109
},
110110
shareTitle: {
111111
type: String,
112-
default: 'views.system.share_knowledge',
112+
default: 'views.system.shared.shared_knowledge',
113113
},
114114
canOperation: {
115115
type: Boolean,
@@ -162,7 +162,7 @@ const handleNodeClick = (data: Tree) => {
162162
163163
const handleSharedNodeClick = () => {
164164
treeRef.value?.setCurrentKey(undefined)
165-
emit('handleNodeClick', { id: 'share', name: t(props.shareTitle) })
165+
emit('handleNodeClick', { id: 'share', name: props.shareTitle })
166166
}
167167
168168
function deleteFolder(row: Tree) {

ui/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import AiChat from './ai-chat/index.vue'
2525
import KnowledgeIcon from './app-icon/KnowledgeIcon.vue'
2626
import TagGroup from './tag-group/index.vue'
2727
import WorkspaceDropdown from './workspace-dropdown/index.vue'
28+
import FolderBreadcrumb from './folder-breadcrumb/index.vue'
2829
export default {
2930
install(app: App) {
3031
app.component('LogoFull', LogoFull)
@@ -53,5 +54,6 @@ export default {
5354
app.component('KnowledgeIcon', KnowledgeIcon)
5455
app.component('TagGroup', TagGroup)
5556
app.component('WorkspaceDropdown', WorkspaceDropdown)
57+
app.component('FolderBreadcrumb', FolderBreadcrumb)
5658
},
5759
}

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

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
export default {
22
title: 'System',
33
subTitle: 'Syetem Settings',
4-
shared: 'Shared',
5-
shared_resources: 'Shared Resources',
6-
share_knowledge: 'Shared Knowledge',
7-
authorized_workspace: 'Authorize Workspace',
84
test: 'Test Connection',
95
testSuccess: 'Successful',
106
testFailed: 'Test connection failed',
@@ -23,7 +19,7 @@ export default {
2319
ldap_filterPlaceholder: 'Please enter user filter',
2420
ldap_mapping: 'LDAP Attribute Mapping',
2521
ldap_mappingPlaceholder: 'Please enter LDAP attribute mapping',
26-
enableAuthentication: 'Enable LDAP Authentication'
22+
enableAuthentication: 'Enable LDAP Authentication',
2723
},
2824
cas: {
2925
title: 'CAS',
@@ -33,7 +29,7 @@ export default {
3329
validateUrlPlaceholder: 'Please enter validation address',
3430
redirectUrl: 'Callback Address',
3531
redirectUrlPlaceholder: 'Please enter callback address',
36-
enableAuthentication: 'Enable CAS Authentication'
32+
enableAuthentication: 'Enable CAS Authentication',
3733
},
3834
oidc: {
3935
title: 'OIDC',
@@ -52,7 +48,7 @@ export default {
5248
logoutEndpointPlaceholder: 'Please enter logout endpoint',
5349
redirectUrl: 'Redirect URL',
5450
redirectUrlPlaceholder: 'Please enter redirect URL',
55-
enableAuthentication: 'Enable OIDC Authentication'
51+
enableAuthentication: 'Enable OIDC Authentication',
5652
},
5753

5854
oauth2: {
@@ -73,7 +69,7 @@ export default {
7369
redirectUrlPlaceholder: 'Please enter redirect URL',
7470
filedMapping: 'Field Mapping',
7571
filedMappingPlaceholder: 'Please enter field mapping',
76-
enableAuthentication: 'Enable OAuth2 Authentication'
72+
enableAuthentication: 'Enable OAuth2 Authentication',
7773
},
7874
scanTheQRCode: {
7975
title: 'Scan the QR code',
@@ -95,10 +91,10 @@ export default {
9591
larkQrCode: 'Lark Scan Code Login',
9692
dingtalkQrCode: 'DingTalk Scan Code Login',
9793
setting: ' Setting',
98-
access: 'Access'
99-
}
94+
access: 'Access',
95+
},
10096
},
101-
theme: {
97+
theme: {
10298
title: 'Appearance Settings',
10399
platformDisplayTheme: 'Platform Display Theme',
104100
customTheme: 'Custom Theme',
@@ -115,8 +111,10 @@ export default {
115111
loginLogo: 'Login Logo',
116112
websiteLogo: 'Website Logo',
117113
replacePicture: 'Replace Picture',
118-
websiteLogoTip: "The logo displayed on the top of the website. The recommended size is 48*48. It supports JPG, PNG, and GIF formats, with a size not exceeding 10MB.",
119-
loginLogoTip: "Login page right-side logo. Recommended size is 204*52. Supports JPG, PNG, GIF formats, with a maximum file size of 10 MB.",
114+
websiteLogoTip:
115+
'The logo displayed on the top of the website. The recommended size is 48*48. It supports JPG, PNG, and GIF formats, with a size not exceeding 10MB.',
116+
loginLogoTip:
117+
'Login page right-side logo. Recommended size is 204*52. Supports JPG, PNG, GIF formats, with a maximum file size of 10 MB.',
120118
loginBackgroundTip:
121119
'Left background image, vector image recommended size 576 * 900, bitmap recommended size 1152 * 1800; Supports JPG, PNG, GIF, with a size not exceeding 10 MB.',
122120
websiteName: 'Website Name',
@@ -146,14 +144,14 @@ export default {
146144
smtpPortPlaceholder: 'Please enter SMTP port',
147145
smtpUser: 'SMTP User',
148146
smtpUserPlaceholder: 'Please enter SMTP user',
149-
sendEmail: 'Sender\'s Email',
150-
sendEmailPlaceholder: 'Please enter the sender\'s email',
147+
sendEmail: "Sender's Email",
148+
sendEmailPlaceholder: "Please enter the sender's email",
151149
smtpPassword: 'SMTP Password',
152150
smtpPasswordPlaceholder: 'Please enter SMTP password',
153151
enableSSL: 'Enable SSL (if the SMTP port is 465, you usually need to enable SSL)',
154-
enableTLS: 'Enable TLS (if the SMTP port is 587, you usually need to enable TLS)'
152+
enableTLS: 'Enable TLS (if the SMTP port is 587, you usually need to enable TLS)',
155153
},
156-
group: {
154+
group: {
157155
title: 'Team Member',
158156
member: 'Member',
159157
manage: 'Owner',
@@ -166,7 +164,8 @@ export default {
166164
delete: {
167165
button: 'Remove',
168166
confirmTitle: 'Wheather to remove the member:',
169-
confirmMessage: "After removal, the member's knowledge base and application permissions will be revoked.",
167+
confirmMessage:
168+
"After removal, the member's knowledge base and application permissions will be revoked.",
170169
},
171170
setting: {
172171
management: 'manegement',
@@ -180,5 +179,16 @@ export default {
180179
requiredMessage: 'Please enter Username/Email',
181180
},
182181
},
183-
},
182+
},
183+
shared: {
184+
label: 'Shared',
185+
shared_resources: 'Shared Resources',
186+
shared_tool: 'Shared Tool',
187+
shared_model: 'Shared Model',
188+
shared_knowledge: 'Shared Knowledge',
189+
authorized_workspace: 'Authorize Workspace',
190+
},
191+
resource_management: {
192+
label: 'Resource Management',
193+
},
184194
}

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
export default {
22
title: '系统管理',
33
subTitle: '系统设置',
4-
shared: '共享',
5-
shared_resources: '共享资源',
6-
resource_management: '资源管理',
7-
share_tool: '共享工具',
8-
share_model: '共享模型',
9-
share_knowledge: '共享知识库',
10-
authorized_workspace: '授权工作空间',
114
test: '测试连接',
125
testSuccess: '测试连接成功',
136
testFailed: '测试连接失败',
@@ -184,4 +177,15 @@ export default {
184177
},
185178
},
186179
},
180+
shared: {
181+
label: '共享',
182+
shared_resources: '共享资源',
183+
shared_tool: '共享工具',
184+
shared_model: '共享模型',
185+
shared_knowledge: '共享知识库',
186+
authorized_workspace: '授权工作空间',
187+
},
188+
resource_management: {
189+
label: '资源管理',
190+
},
187191
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,15 @@ export default {
110110
enableSSL: '啟用 SSL(如果 SMTP 端口是 465,通常需要啟用 SSL)',
111111
enableTLS: '啟用 TLS(如果 SMTP 端口是 587,通常需要啟用 TLS)',
112112
},
113+
shared: {
114+
label: '共享',
115+
shared_resources: '共享资源',
116+
shared_tool: '共享工具',
117+
shared_model: '共享模型',
118+
shared_knowledge: '共享知识',
119+
authorized_workspace: '授权工作区',
120+
},
121+
resource_management: {
122+
label: '资源管理',
123+
},
113124
}

ui/src/router/modules/system.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const systemRouter = {
7070
meta: {
7171
icon: 'app-folder-share',
7272
iconActive: 'app-folder-share-active',
73-
title: 'views.system.resource_management',
73+
title: 'views.system.resource_management.label',
7474
activeMenu: '/system',
7575
parentPath: '/system',
7676
parentName: 'system',
@@ -119,7 +119,7 @@ const systemRouter = {
119119
meta: {
120120
icon: 'app-folder-share',
121121
iconActive: 'app-folder-share-active',
122-
title: 'views.system.shared_resources',
122+
title: 'views.system.shared.shared_resources',
123123
activeMenu: '/system',
124124
parentPath: '/system',
125125
parentName: 'system',
@@ -146,7 +146,7 @@ const systemRouter = {
146146
parentPath: '/system',
147147
parentName: 'system',
148148
},
149-
component: () => import('@/views/shared/tool-shared/index.vue'),
149+
component: () => import('@/views/system-shared/ToolSharedIndex.vue'),
150150
},
151151
{
152152
path: '/system/shared/model',

ui/src/stores/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import useDocumentStore from './modules/document'
1212
import useApplicationStore from './modules/application'
1313
import useChatLogStore from './modules/chat-log'
1414
import useChatUserStore from './modules/chat-user'
15+
import useToolStore from './modules/tool'
1516
const useStore = () => ({
1617
common: useCommonStore(),
1718
login: useLoginStore(),
@@ -27,6 +28,7 @@ const useStore = () => ({
2728
application: useApplicationStore(),
2829
chatLog: useChatLogStore(),
2930
chatUser: useChatUserStore(),
31+
tool: useToolStore(),
3032
})
3133

3234
export default useStore

ui/src/stores/modules/folder.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import {defineStore} from 'pinia'
2-
import {type Ref} from 'vue'
1+
import { defineStore } from 'pinia'
2+
import { type Ref } from 'vue'
33
import folderApi from '@/api/folder'
44

55
const useFolderStore = defineStore('folder', {
6-
state: () => ({}),
6+
state: () => ({
7+
currentFolder: {} as any,
8+
}),
79
actions: {
10+
setCurrentFolder(folder: any) {
11+
this.currentFolder = folder
12+
},
813
async asyncGetFolder(source: string, data: any, loading?: Ref<boolean>) {
914
return new Promise((resolve, reject) => {
1015
folderApi

0 commit comments

Comments
 (0)