Skip to content

Commit 1c96897

Browse files
feat: shared
1 parent bba7a60 commit 1c96897

File tree

37 files changed

+422
-377
lines changed

37 files changed

+422
-377
lines changed

ui/src/components/codemirror-editor/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const emit = defineEmits(['update:modelValue', 'submitDialog'])
5757
5858
const route = useRoute()
5959
60-
const type = computed(() => {
60+
const apiType = computed(() => {
6161
if (route.path.includes('shared')) {
6262
return 'systemShare'
6363
} else if (route.path.includes('resource-management')) {
@@ -88,7 +88,7 @@ function getRangeFromLineAndColumn(state: any, line: number, column: number, end
8888
8989
const regexpLinter = linter(async (view) => {
9090
const diagnostics: Diagnostic[] = []
91-
await loadSharedApi({ type: 'tool', systemType: type.value })
91+
await loadSharedApi({ type: 'tool', systemType: apiType.value })
9292
.postPylint(view.state.doc.toString())
9393
.then((ok: any) => {
9494
ok.data.forEach((element: any) => {

ui/src/components/generate-related-dialog/index.vue

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
/>
4747
</el-form-item>
4848
<el-form-item
49-
v-if="['document', 'knowledge'].includes(apiType)"
49+
v-if="['document', 'knowledge'].includes(apiSubmitType)"
5050
:label="$t('components.selectParagraph.title')"
5151
prop="state"
5252
>
@@ -72,28 +72,22 @@
7272
<script setup lang="ts">
7373
import { reactive, ref, watch, computed } from 'vue'
7474
import { useRoute } from 'vue-router'
75-
import documentApi from '@/api/knowledge/document'
76-
import paragraphApi from '@/api/knowledge/paragraph'
7775
import useStore from '@/stores'
7876
import { groupBy } from 'lodash'
7977
import { MsgSuccess } from '@/utils/message'
8078
import { t } from '@/locales'
8179
import type { FormInstance } from 'element-plus'
8280
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
8381
82+
const props = defineProps<{
83+
apiType: 'systemShare' | 'workspace' | 'systemManage'
84+
}>()
85+
8486
const route = useRoute()
8587
const {
8688
params: { id, documentId }, // id为knowledgeID
8789
} = route as any
88-
const type = computed(() => {
89-
if (route.path.includes('shared')) {
90-
return 'systemShare'
91-
} else if (route.path.includes('resource-management')) {
92-
return 'systemManage'
93-
} else {
94-
return 'workspace'
95-
}
96-
})
90+
9791
const { model, prompt, user } = useStore()
9892
9993
const emit = defineEmits(['refresh'])
@@ -103,7 +97,7 @@ const loading = ref<boolean>(false)
10397
const dialogVisible = ref<boolean>(false)
10498
const modelOptions = ref<any>(null)
10599
const idList = ref<string[]>([])
106-
const apiType = ref('') // 文档document或段落paragraph
100+
const apiSubmitType = ref('') // 文档document或段落paragraph
107101
const state = ref<'all' | 'error'>('error')
108102
const stateMap = {
109103
all: ['0', '1', '2', '3', '4', '5', 'n'],
@@ -141,7 +135,7 @@ const open = (ids: string[], type: string, _knowledgeId?: string) => {
141135
knowledgeId.value = _knowledgeId
142136
getModel()
143137
idList.value = ids
144-
apiType.value = type
138+
apiSubmitType.value = type
145139
dialogVisible.value = true
146140
}
147141
@@ -153,33 +147,37 @@ const submitHandle = async (formEl: FormInstance) => {
153147
if (valid) {
154148
// 保存提示词
155149
prompt.save(user.userInfo?.id as string, form.value)
156-
if (apiType.value === 'paragraph') {
150+
if (apiSubmitType.value === 'paragraph') {
157151
const data = {
158152
...form.value,
159153
paragraph_id_list: idList.value,
160154
}
161-
paragraphApi.putBatchGenerateRelated(id, documentId, data, loading).then(() => {
162-
MsgSuccess(t('views.document.generateQuestion.successMessage'))
163-
emit('refresh')
164-
dialogVisible.value = false
165-
})
166-
} else if (apiType.value === 'document') {
155+
loadSharedApi({ type: 'paragraph', systemType: props.apiType })
156+
.putBatchGenerateRelated(id, documentId, data, loading)
157+
.then(() => {
158+
MsgSuccess(t('views.document.generateQuestion.successMessage'))
159+
emit('refresh')
160+
dialogVisible.value = false
161+
})
162+
} else if (apiSubmitType.value === 'document') {
167163
const data = {
168164
...form.value,
169165
document_id_list: idList.value,
170166
state_list: stateMap[state.value],
171167
}
172-
documentApi.putBatchGenerateRelated(id, data, loading).then(() => {
173-
MsgSuccess(t('views.document.generateQuestion.successMessage'))
174-
emit('refresh')
175-
dialogVisible.value = false
176-
})
177-
} else if (apiType.value === 'knowledge') {
168+
loadSharedApi({ type: 'knowledge', systemType: props.apiType })
169+
.putBatchGenerateRelated(id, data, loading)
170+
.then(() => {
171+
MsgSuccess(t('views.document.generateQuestion.successMessage'))
172+
emit('refresh')
173+
dialogVisible.value = false
174+
})
175+
} else if (apiSubmitType.value === 'knowledge') {
178176
const data = {
179177
...form.value,
180178
state_list: stateMap[state.value],
181179
}
182-
loadSharedApi({ type: 'knowledge', systemType: type.value })
180+
loadSharedApi({ type: 'knowledge', systemType: props.apiType })
183181
.putGenerateRelated(id ? id : knowledgeId.value, data, loading)
184182
.then(() => {
185183
MsgSuccess(t('views.document.generateQuestion.successMessage'))
@@ -192,7 +190,7 @@ const submitHandle = async (formEl: FormInstance) => {
192190
193191
function getModel() {
194192
loading.value = true
195-
loadSharedApi({ type: 'knowledge', systemType: type.value })
193+
loadSharedApi({ type: 'knowledge', systemType: props.apiType })
196194
.getKnowledgeModel()
197195
.then((res: any) => {
198196
modelOptions.value = groupBy(res?.data, 'provider')

ui/src/layout/components/breadcrumb/index.vue

Lines changed: 3 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="breadcrumb ml-4 mt-4 mb-12 flex">
3-
<back-button :to="activeMenu" class="mt-4"></back-button>
3+
<back-button to="-1" class="mt-4"></back-button>
44
<div class="flex align-center">
55
<el-avatar
66
v-if="isApplication && isAppIcon(current?.icon)"
@@ -21,94 +21,6 @@
2121

2222
<div class="ellipsis" :title="current?.name">{{ current?.name }}</div>
2323
</div>
24-
<!-- <el-dropdown
25-
placement="bottom"
26-
trigger="click"
27-
@command="changeMenu"
28-
class="w-full"
29-
style="display: block"
30-
>
31-
<div class="breadcrumb-hover flex-between cursor">
32-
<div class="flex align-center">
33-
<el-avatar
34-
v-if="isApplication && isAppIcon(current?.icon)"
35-
shape="square"
36-
:size="24"
37-
style="background: none"
38-
class="mr-8"
39-
>
40-
<img :src="current?.icon" alt="" />
41-
</el-avatar>
42-
<LogoIcon
43-
v-else-if="isApplication"
44-
height="28px"
45-
style="width: 28px; height: 28px; display: block"
46-
/>
47-
<KnowledgeIcon v-else-if="isKnowledge" :type="current?.type" />
48-
49-
<div class="ellipsis" :title="current?.name">{{ current?.name }}</div>
50-
</div>
51-
52-
<el-button text>
53-
<el-icon><CaretBottom /></el-icon>
54-
</el-button>
55-
</div>
56-
<template #dropdown>
57-
<el-scrollbar>
58-
<div style="max-height: 400px">
59-
<el-dropdown-menu>
60-
<template v-for="(item, index) in list" :key="index">
61-
<div :class="item.id === id ? 'dropdown-active' : ''">
62-
<el-dropdown-item :command="item.id">
63-
<div class="flex align-center">
64-
<el-avatar
65-
v-if="isApplication && isAppIcon(item?.icon)"
66-
shape="square"
67-
:size="24"
68-
style="background: none"
69-
class="mr-8"
70-
>
71-
<img :src="item?.icon" alt="" />
72-
</el-avatar>
73-
74-
<el-avatar
75-
v-else-if="isApplication"
76-
:name="item.name"
77-
pinyinColor
78-
class="mr-12"
79-
shape="square"
80-
:size="24"
81-
/>
82-
83-
<KnowledgeIcon v-if="isKnowledge" :type="item.type" />
84-
85-
<span class="ellipsis" :title="item?.name"> {{ item?.name }}</span>
86-
</div>
87-
</el-dropdown-item>
88-
</div>
89-
</template>
90-
</el-dropdown-menu>
91-
</div>
92-
</el-scrollbar>
93-
<div class="breadcrumb__footer border-t" style="padding: 8px 11px; min-width: 200px">
94-
<template v-if="isApplication">
95-
<div class="w-full text-left cursor" @click="openCreateDialog">
96-
<el-button link>
97-
<el-icon class="mr-4"><Plus /></el-icon>
98-
{{ $t('views.application.createApplication') }}
99-
</el-button>
100-
</div>
101-
</template>
102-
<template v-else-if="isKnowledge">
103-
<div class="w-full text-left cursor" @click="openCreateDialog">
104-
<el-button link>
105-
<el-icon class="mr-4"><Plus /></el-icon> {{ $t('views.knowledge.createKnowledge') }}
106-
</el-button>
107-
</div>
108-
</template>
109-
</div>
110-
</template>
111-
</el-dropdown> -->
11224
</div>
11325
</template>
11426

@@ -127,7 +39,7 @@ const {
12739
params: { id },
12840
} = route as any
12941
130-
const type = computed(() => {
42+
const apiType = computed(() => {
13143
if (route.path.includes('shared')) {
13244
return 'systemShare'
13345
} else if (route.path.includes('resource-management')) {
@@ -154,7 +66,7 @@ const isKnowledge = computed(() => {
15466
15567
function getKnowledgeDetail() {
15668
loading.value = true
157-
loadSharedApi({ type: 'knowledge', systemType: type.value })
69+
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
15870
.getKnowledgeDetail(id)
15971
.then((res: any) => {
16072
current.value = res.data

ui/src/layout/layout-template/MainLayout.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ import AppMain from '@/layout/app-main/index.vue'
2323
import useStore from '@/stores'
2424
import { useRoute } from 'vue-router'
2525
const route = useRoute()
26+
const {
27+
params: { folderId }, // id为knowledgeID
28+
} = route as any
2629
2730
const isShared = computed(() => {
28-
return route.path.endsWith('hared') || route.name.includes('ResourceManagement')
31+
return folderId === 'shared' || route.name.includes('ResourceManagement')
2932
})
3033
const { theme } = useStore()
3134
const isDefaultTheme = computed(() => {

ui/src/router/modules/system.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ const systemRouter = {
150150
[RoleConst.ADMIN],
151151
[PermissionConst.SHARED_TOOL_READ],
152152
[EditionConst.IS_EE],
153-
'OR'
154-
)
155-
]
153+
'OR',
154+
),
155+
],
156156
},
157157
component: () => import('@/views/system-shared/ToolSharedIndex.vue'),
158158
},
@@ -169,9 +169,9 @@ const systemRouter = {
169169
[RoleConst.ADMIN],
170170
[PermissionConst.SHARED_MODEL_READ],
171171
[EditionConst.IS_EE],
172-
'OR'
173-
)
174-
]
172+
'OR',
173+
),
174+
],
175175
},
176176
component: () => import('@/views/system-shared/ModelSharedIndex.vue'),
177177
},

ui/src/utils/dynamics-api/shared-api.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
import knowledgeWorkspaceApi from '@/api/knowledge/knowledge'
2+
import documentWorkspaceApi from '@/api/knowledge/document'
3+
import paragraphWorkspaceApi from '@/api/knowledge/paragraph'
24
import modelWorkspaceApi from '@/api/model/model'
35
import toolWorkspaceApi from '@/api/tool/tool'
46
import sharedWorkspaceApi from '@/api/shared-workspace'
57
import toolSystemShareApi from '@/api/system-shared/tool'
68
import modelSystemShareApi from '@/api/system-shared/model'
79
import knowledgeSystemShareApi from '@/api/system-shared/knowledge'
10+
import documentSystemShareApi from '@/api/system-shared/document'
11+
import paragraphSystemShareApi from '@/api/system-shared/paragraph'
812

913
// 普通 API
1014
const workspaceApiMap = {
1115
knowledge: knowledgeWorkspaceApi,
1216
model: modelWorkspaceApi,
1317
tool: toolWorkspaceApi,
18+
document: documentWorkspaceApi,
19+
paragraph: paragraphWorkspaceApi,
1420
} as any
1521

1622
// 系统分享 API
1723
const systemShareApiMap = {
1824
knowledge: knowledgeSystemShareApi,
1925
model: modelSystemShareApi,
2026
tool: toolSystemShareApi,
27+
document: documentSystemShareApi,
28+
paragraph: paragraphSystemShareApi,
2129
} as any
2230

2331
// 资源管理 API

ui/src/views/document/ImportLarkDocument.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ import { getImgUrl } from '@/utils/utils'
144144
import { t } from '@/locales'
145145
import type Node from 'element-plus/es/components/tree/src/model/node'
146146
import documentApi from '@/api/knowledge/document'
147+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
147148
148149
const router = useRouter()
149150
const route = useRoute()

0 commit comments

Comments
 (0)