Skip to content

Commit 9024925

Browse files
Merge remote-tracking branch 'origin/v2' into v2
2 parents 9ddee4e + 70f8abe commit 9024925

File tree

16 files changed

+324
-262
lines changed

16 files changed

+324
-262
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,30 @@
7070
</el-dialog>
7171
</template>
7272
<script setup lang="ts">
73-
import { reactive, ref, watch } from 'vue'
73+
import { reactive, ref, watch, computed } from 'vue'
7474
import { useRoute } from 'vue-router'
7575
import documentApi from '@/api/knowledge/document'
7676
import paragraphApi from '@/api/knowledge/paragraph'
77-
import knowledgeApi from '@/api/knowledge/knowledge'
7877
import useStore from '@/stores'
7978
import { groupBy } from 'lodash'
8079
import { MsgSuccess } from '@/utils/message'
8180
import { t } from '@/locales'
8281
import type { FormInstance } from 'element-plus'
82+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
8383
8484
const route = useRoute()
8585
const {
8686
params: { id, documentId }, // id为knowledgeID
8787
} = route as any
88-
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+
})
8997
const { model, prompt, user } = useStore()
9098
9199
const emit = defineEmits(['refresh'])
@@ -171,18 +179,20 @@ const submitHandle = async (formEl: FormInstance) => {
171179
...form.value,
172180
state_list: stateMap[state.value],
173181
}
174-
knowledgeApi.putGenerateRelated(id ? id : knowledgeId.value, data, loading).then(() => {
175-
MsgSuccess(t('views.document.generateQuestion.successMessage'))
176-
dialogVisible.value = false
177-
})
182+
loadSharedApi({ type: 'knowledge', systemType: type.value })
183+
.putGenerateRelated(id ? id : knowledgeId.value, data, loading)
184+
.then(() => {
185+
MsgSuccess(t('views.document.generateQuestion.successMessage'))
186+
dialogVisible.value = false
187+
})
178188
}
179189
}
180190
})
181191
}
182192
183193
function getModel() {
184194
loading.value = true
185-
knowledgeApi
195+
loadSharedApi({ type: 'knowledge', systemType: type.value })
186196
.getKnowledgeModel()
187197
.then((res: any) => {
188198
modelOptions.value = groupBy(res?.data, 'provider')

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

Lines changed: 15 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,35 @@
115115
<script setup lang="ts">
116116
import { ref, onMounted, computed } from 'vue'
117117
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router'
118-
import { isWorkFlow } from '@/utils/application'
119118
import { isAppIcon } from '@/utils/common'
119+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
120120
121121
import useStore from '@/stores'
122-
const { common, knowledge, application } = useStore()
122+
const { common, application } = useStore()
123123
const route = useRoute()
124-
const router = useRouter()
124+
125125
const {
126126
meta: { activeMenu },
127127
params: { id },
128128
} = route as any
129129
130+
const type = computed(() => {
131+
if (route.path.includes('shared')) {
132+
return 'systemShare'
133+
} else if (route.path.includes('resource-management')) {
134+
return 'systemManage'
135+
} else {
136+
return 'workspace'
137+
}
138+
})
139+
130140
onBeforeRouteLeave((to, from) => {
131141
common.saveBreadcrumb(null)
132142
})
133143
134-
const CreateKnowledgeDialogRef = ref()
135-
const CreateApplicationDialogRef = ref()
136-
const list = ref<any[]>([])
137144
const loading = ref(false)
138145
139-
const breadcrumbData = computed(() => common.breadcrumb)
140146
const current = ref<any>(null)
141-
// const current = computed(() => {
142-
// return list.value?.filter((v) => v.id === id)?.[0]
143-
// })
144147
145148
const isApplication = computed(() => {
146149
return activeMenu.includes('application')
@@ -151,8 +154,8 @@ const isKnowledge = computed(() => {
151154
152155
function getKnowledgeDetail() {
153156
loading.value = true
154-
knowledge
155-
.asyncGetKnowledgeDetail(id)
157+
loadSharedApi({ type: 'knowledge', systemType: type.value })
158+
.getKnowledgeDetail(id)
156159
.then((res: any) => {
157160
current.value = res.data
158161
loading.value = false
@@ -175,80 +178,12 @@ function getApplicationDetail() {
175178
})
176179
}
177180
178-
function openCreateDialog() {
179-
if (isKnowledge.value) {
180-
CreateKnowledgeDialogRef.value.open()
181-
} else if (isApplication.value) {
182-
CreateApplicationDialogRef.value.open()
183-
}
184-
}
185-
186-
function changeMenu(id: string) {
187-
const lastMatched = route.matched[route.matched.length - 1]
188-
if (lastMatched) {
189-
if (isKnowledge.value) {
190-
router.push({ name: lastMatched.name, params: { id: id } })
191-
} else if (isApplication.value) {
192-
const type = list.value?.filter((v) => v.id === id)?.[0]?.type
193-
if (
194-
isWorkFlow(type) &&
195-
(lastMatched.name === 'AppSetting' || lastMatched.name === 'AppHitTest')
196-
) {
197-
router.push({ path: `/application/${id}/${type}/overview` })
198-
} else {
199-
router.push({
200-
name: lastMatched.name,
201-
params: { id: id, type: type },
202-
})
203-
}
204-
}
205-
}
206-
}
207-
208-
function getKnowledge() {
209-
loading.value = true
210-
knowledge
211-
.asyncGetFolderKnowledge()
212-
.then((res: any) => {
213-
list.value = res.data
214-
common.saveBreadcrumb(list.value)
215-
loading.value = false
216-
})
217-
.catch(() => {
218-
loading.value = false
219-
})
220-
}
221-
function getApplication() {
222-
loading.value = true
223-
application
224-
.asyncGetAllApplication()
225-
.then((res: any) => {
226-
list.value = res.data
227-
common.saveBreadcrumb(list.value)
228-
loading.value = false
229-
})
230-
.catch(() => {
231-
loading.value = false
232-
})
233-
}
234-
function refresh() {
235-
common.saveBreadcrumb(null)
236-
}
237181
onMounted(() => {
238182
if (isKnowledge.value) {
239183
getKnowledgeDetail()
240184
} else if (isApplication.value) {
241185
getApplicationDetail()
242186
}
243-
// if (!breadcrumbData.value) {
244-
// if (isKnowledge.value) {
245-
// getKnowledge()
246-
// } else if (isApplication.value) {
247-
// getApplication()
248-
// }
249-
// } else {
250-
// list.value = breadcrumbData.value
251-
// }
252187
})
253188
</script>
254189

ui/src/stores/modules/knowledge.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface knowledgeStateTypes {
1313
webInfo: any
1414
documentsType: string
1515
documentsFiles: UploadUserFile[]
16-
knowledgeList: knowledgeData[]
16+
knowledgeList: any[]
1717
}
1818

1919
const useKnowledgeStore = defineStore('knowledge', {
@@ -56,7 +56,7 @@ const useKnowledgeStore = defineStore('knowledge', {
5656
...paramsData,
5757
}
5858
loadSharedApi({ type: 'knowledge', isShared, systemType })
59-
.getToolListPage(page, params, loading)
59+
.getKnowledgeListPage(page, params, loading)
6060
.then((res: any) => {
6161
resolve(res)
6262
})
@@ -80,18 +80,6 @@ const useKnowledgeStore = defineStore('knowledge', {
8080
})
8181
})
8282
},
83-
async asyncGetKnowledgeDetail(knowledge_id: string, loading?: Ref<boolean>) {
84-
return new Promise((resolve, reject) => {
85-
knowledgeApi
86-
.getKnowledgeDetail(knowledge_id, loading)
87-
.then((data) => {
88-
resolve(data)
89-
})
90-
.catch((error) => {
91-
reject(error)
92-
})
93-
})
94-
},
9583
},
9684
})
9785

ui/src/views/application/component/AddKnowledgeDialog.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
</template>
9595
<script setup lang="ts">
9696
import { computed, ref, watch } from 'vue'
97-
import KnowledgeApi from '@/api/knowledge/knowledge'
9897
import useStore from '@/stores'
9998
const props = defineProps({
10099
data: {

ui/src/views/document/component/SelectKnowledgeDialog.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,25 @@
5656
</el-dialog>
5757
</template>
5858
<script setup lang="ts">
59-
import { ref, watch } from 'vue'
59+
import { ref, watch, computed } from 'vue'
6060
import { useRoute } from 'vue-router'
6161
import documentApi from '@/api/knowledge/document'
62+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
6263
6364
import useStore from '@/stores'
64-
const { knowledge } = useStore()
6565
const route = useRoute()
6666
const {
6767
params: { id }, // id为knowledgeID
6868
} = route as any
69-
69+
const type = computed(() => {
70+
if (route.path.includes('shared')) {
71+
return 'systemShare'
72+
} else if (route.path.includes('resource-management')) {
73+
return 'systemManage'
74+
} else {
75+
return 'workspace'
76+
}
77+
})
7078
const emit = defineEmits(['refresh'])
7179
7280
const loading = ref<boolean>(false)
@@ -91,9 +99,11 @@ const loadTree = (node: any, resolve: any) => {
9199
console.log(node)
92100
if (node.isLeaf) return resolve([])
93101
const folder_id = node.level === 0 ? '' : node.data.id
94-
knowledge.asyncGetFolderKnowledge(folder_id, loading).then((res: any) => {
95-
resolve(res.data)
96-
})
102+
loadSharedApi({ type: 'knowledge', systemType: type.value })
103+
.getKnowledgeList(folder_id, loading)
104+
.then((res: any) => {
105+
resolve(res.data)
106+
})
97107
}
98108
99109
watch(dialogVisible, (bool) => {

0 commit comments

Comments
 (0)