From 86ad2c54c62b7261964819ced76eee2f4fef02b7 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 30 Jul 2025 19:36:37 +0800 Subject: [PATCH] feat: applicaiton resource managment --- ui/src/api/application/chat-log.ts | 5 - .../application-key.ts | 66 +++++ .../system-resource-management/application.ts | 217 ++++++-------- .../system-resource-management/chat-log.ts | 192 ++++++++++++ .../workflow-version.ts | 51 ++++ ui/src/api/type/application.ts | 1 + .../components/folder-tree/MoveToDialog.vue | 3 +- .../generate-related-dialog/index.vue | 39 ++- ui/src/layout/components/breadcrumb/index.vue | 10 +- .../layout/components/sidebar/SidebarItem.vue | 4 +- ui/src/layout/layout-template/MainLayout.vue | 9 +- .../layout/layout-template/SimpleLayout.vue | 9 +- ui/src/permission/application/index.ts | 2 + .../permission/application/system-manage.ts | 31 +- ui/src/router/modules/application-detail.ts | 12 +- ui/src/router/routes.ts | 2 +- ui/src/stores/index.ts | 2 - ui/src/stores/modules/application.ts | 43 +-- ui/src/stores/modules/chat-log.ts | 42 --- ui/src/utils/dynamics-api/shared-api.ts | 16 + .../component/APIKeyDialog.vue | 52 ++-- .../component/DisplaySettingDialog.vue | 30 +- .../component/LimitDialog.vue | 31 +- .../component/SettingAPIKeyDialog.vue | 29 +- ui/src/views/application-overview/index.vue | 107 +++---- .../XPackDisplaySettingDialog.vue | 24 +- .../xpack-component/XPackLimitDrawer.vue | 33 ++- .../component/DropdownMenu.vue | 15 +- .../component/PublishHistory.vue | 33 ++- ui/src/views/application-workflow/index.vue | 127 ++++---- .../views/application/ApplicationAccess.vue | 42 +-- .../views/application/ApplicationSetting.vue | 116 +++++--- .../component/AIModeParamSettingDialog.vue | 32 +- .../component/AccessSettingDrawer.vue | 147 +++++----- .../component/CopyApplicationDialog.vue | 1 - .../component/TTSModeParamSettingDialog.vue | 77 ++--- ui/src/views/application/index.vue | 51 ++-- .../chat-log/component/ChatRecordDrawer.vue | 17 +- .../chat-log/component/EditContentDialog.vue | 15 +- .../chat-log/component/EditMarkDialog.vue | 40 +-- ui/src/views/chat-log/index.vue | 51 ++-- ui/src/views/document/index.vue | 2 +- ui/src/views/knowledge/KnowledgeSetting.vue | 4 +- ui/src/views/knowledge/component/BaseForm.vue | 18 +- .../knowledge/component/SyncWebDialog.vue | 4 +- .../CreateLarkKnowledgeDialog.vue | 2 +- .../CreateWebKnowledgeDialog.vue | 2 +- .../paragraph/component/ParagraphCard.vue | 8 +- ui/src/views/paragraph/index.vue | 50 +++- .../ApplicationResourceIndex.vue | 274 +++++++++++++++++- .../ModelResourceIndex.vue | 2 +- ui/src/workflow/nodes/ai-chat-node/index.vue | 36 ++- .../workflow/nodes/application-node/index.vue | 38 +-- ui/src/workflow/nodes/base-node/index.vue | 47 ++- .../workflow/nodes/image-generate/index.vue | 36 ++- .../workflow/nodes/image-understand/index.vue | 32 +- ui/src/workflow/nodes/mcp-node/index.vue | 28 +- ui/src/workflow/nodes/question-node/index.vue | 32 +- ui/src/workflow/nodes/reranker-node/index.vue | 31 +- .../nodes/search-knowledge-node/index.vue | 2 - .../nodes/speech-to-text-node/index.vue | 33 ++- .../nodes/text-to-speech-node/index.vue | 35 ++- ui/src/workflow/nodes/tool-lib-node/index.vue | 19 +- 63 files changed, 1730 insertions(+), 831 deletions(-) create mode 100644 ui/src/api/system-resource-management/application-key.ts create mode 100644 ui/src/api/system-resource-management/chat-log.ts create mode 100644 ui/src/api/system-resource-management/workflow-version.ts delete mode 100644 ui/src/stores/modules/chat-log.ts diff --git a/ui/src/api/application/chat-log.ts b/ui/src/api/application/chat-log.ts index dd0a7056f..2c14a48da 100644 --- a/ui/src/api/application/chat-log.ts +++ b/ui/src/api/application/chat-log.ts @@ -3,15 +3,10 @@ import { get, post, exportExcelPost, - postStream, del, put, - request, - download, - exportFile, } from '@/request/index' import type {pageRequest} from '@/api/type/common' -import type {ApplicationFormType} from '@/api/type/application' import {type Ref} from 'vue' import useStore from '@/stores' diff --git a/ui/src/api/system-resource-management/application-key.ts b/ui/src/api/system-resource-management/application-key.ts new file mode 100644 index 000000000..e45b2b71b --- /dev/null +++ b/ui/src/api/system-resource-management/application-key.ts @@ -0,0 +1,66 @@ +import { Result } from '@/request/Result' +import { get, post, del, put } from '@/request/index' +import { type Ref } from 'vue' + +const prefix = '/system/resource/application' +/** + * API_KEY列表 + * @param 参数 application_id + */ +const getAPIKey: (application_id: string, loading?: Ref) => Promise> = ( + application_id, + loading, +) => { + return get(`${prefix}/${application_id}/application_key`, undefined, loading) +} + +/** + * 新增API_KEY + * @param 参数 application_id + */ +const postAPIKey: (application_id: string, loading?: Ref) => Promise> = ( + application_id, + loading, +) => { + return post(`${prefix}/${application_id}/application_key`, {}, undefined, loading) +} + +/** + * 删除API_KEY + * @param 参数 application_id api_key_id + */ +const delAPIKey: ( + application_id: string, + api_key_id: string, + loading?: Ref, +) => Promise> = (application_id, api_key_id, loading) => { + return del( + `${prefix}/${application_id}/application_key/${api_key_id}`, + undefined, + undefined, + loading, + ) +} + +/** + * 修改API_KEY + * @param 参数 application_id,api_key_id + * data { + * is_active: boolean + * } + */ +const putAPIKey: ( + application_id: string, + api_key_id: string, + data: any, + loading?: Ref, +) => Promise> = (application_id, api_key_id, data, loading) => { + return put(`${prefix}/${application_id}/application_key/${api_key_id}`, data, undefined, loading) +} + +export default { + getAPIKey, + postAPIKey, + delAPIKey, + putAPIKey, +} diff --git a/ui/src/api/system-resource-management/application.ts b/ui/src/api/system-resource-management/application.ts index 813f7393c..72155d00c 100644 --- a/ui/src/api/system-resource-management/application.ts +++ b/ui/src/api/system-resource-management/application.ts @@ -1,21 +1,11 @@ -import {Result} from '@/request/Result' -import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index' -import type {pageRequest} from '@/api/type/common' -import type {ApplicationFormType} from '@/api/type/application' -import {type Ref} from 'vue' +import { Result } from '@/request/Result' +import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index' +import type { pageRequest } from '@/api/type/common' +import type { ApplicationFormType } from '@/api/type/application' +import { type Ref } from 'vue' const prefix = '/system/resource/application' -/** - * 获取全部应用 - * @param 参数 - */ -const getAllApplication: (param?: any, loading?: Ref) => Promise> = ( - param, - loading, -) => { - return get(`${prefix}`, param, loading) -} /** * 获取分页应用 @@ -31,17 +21,6 @@ const getApplication: ( return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading) } -/** - * 创建应用 - * @param 参数 - */ -const postApplication: ( - data: ApplicationFormType, - loading?: Ref, -) => Promise> = (data, loading) => { - return post(`${prefix}`, data, undefined, loading) -} - /** * 修改应用 * @param 参数 @@ -86,19 +65,6 @@ const getAccessToken: (application_id: string, loading?: Ref) => Promis ) => { return get(`${prefix}/${application_id}/access_token`, undefined, loading) } -/** - * 获取应用设置 - * @param application_id 应用id - * @param loading 加载器 - * @returns - */ -const getApplicationSetting: ( - application_id: string, - loading?: Ref, -) => Promise> = (application_id, loading) => { - return get(`${prefix}/${application_id}/setting`, undefined, loading) -} - /** * 修改AccessToken * @param 参数 application_id @@ -114,6 +80,93 @@ const putAccessToken: ( return put(`${prefix}/${application_id}/access_token`, data, undefined, loading) } +/** + * 统计 + * @param 参数 application_id, data + */ +const getStatistics: ( + application_id: string, + data: any, + loading?: Ref, +) => Promise> = (application_id, data, loading) => { + return get(`${prefix}/${application_id}/application_stats`, data, loading) +} +/** + * 打开调试对话id + * @param application_id 应用id + * @param loading 加载器 + * @returns + */ +const open: (application_id: string, loading?: Ref) => Promise> = ( + application_id, + loading, +) => { + return get(`${prefix}/${application_id}/open`, {}, loading) +} + +/** + * 应用发布 + * @param application_id + * @param loading + * @returns + */ +const publish: ( + application_id: string, + data: any, + loading?: Ref, +) => Promise> = (application_id, data, loading) => { + return put(`${prefix}/${application_id}/publish`, data, {}, loading) +} + +/** + * + * @param application_id + * @param data + * @param loading + * @returns + */ +const playDemoText: (application_id: string, data: any, loading?: Ref) => Promise = ( + application_id, + data, + loading, +) => { + return download(`${prefix}/${application_id}/play_demo_text`, 'post', data, undefined, loading) +} + +/** + * 文本转语音 + */ +const postTextToSpeech: ( + application_id: String, + data: any, + loading?: Ref, +) => Promise> = (application_id, data, loading) => { + return download(`${prefix}/${application_id}/text_to_speech`, 'post', data, undefined, loading) +} +/** + * 语音转文本 + */ +const speechToText: ( + application_id: String, + data: any, + loading?: Ref, +) => Promise> = (application_id, data, loading) => { + return post(`${prefix}/${application_id}/speech_to_text`, data, undefined, loading) +} + +/** + * 获取应用设置 + * @param application_id 应用id + * @param loading 加载器 + * @returns + */ +const getApplicationSetting: ( + application_id: string, + loading?: Ref, +) => Promise> = (application_id, loading) => { + return get(`${prefix}/${application_id}/setting`, undefined, loading) +} + /** * 导出应用 */ @@ -141,29 +194,6 @@ const importApplication: (data: any, loading?: Ref) => Promise, -) => Promise> = (application_id, data, loading) => { - return get(`${prefix}/${application_id}/application_stats`, data, loading) -} -/** - * 打开调试对话id - * @param application_id 应用id - * @param loading 加载器 - * @returns - */ -const open: (application_id: string, loading?: Ref) => Promise> = ( - application_id, - loading, -) => { - return get(`${prefix}/${application_id}/open`, {}, loading) -} /** * 对话 * @param 参数 @@ -218,67 +248,6 @@ const updatePlatformConfig: ( ) => Promise> = (application_id, type, data, loading) => { return post(`${prefix}/${application_id}/platform/${type}`, data, undefined, loading) } -/** - * 应用发布 - * @param application_id - * @param loading - * @returns - */ -const publish: ( - application_id: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return put(`${prefix}/${application_id}/publish`, data, {}, loading) -} - -/** - * - * @param application_id - * @param data - * @param loading - * @returns - */ -const playDemoText: (application_id: string, data: any, loading?: Ref) => Promise = ( - application_id, - data, - loading, -) => { - return download( - `${prefix}/${application_id}/play_demo_text`, - 'post', - data, - undefined, - loading, - ) -} - -/** - * 文本转语音 - */ -const postTextToSpeech: ( - application_id: String, - data: any, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return download( - `${prefix}/${application_id}/text_to_speech`, - 'post', - data, - undefined, - loading, - ) -} -/** - * 语音转文本 - */ -const speechToText: ( - application_id: String, - data: any, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return post(`${prefix}/${application_id}/speech_to_text`, data, undefined, loading) -} /** * mcp 节点 @@ -291,9 +260,7 @@ const getMcpTools: (application_id: String, loading?: Ref) => Promise, +) => Promise> = (application_id, data, loading) => { + return post(`${prefix}/${application_id}/add_knowledge`, data, undefined, loading) +} + +/** + * 对话日志 + * @param 参数 + * application_id + * param { + "start_time": "string", + "end_time": "string", + } + */ +const getChatLog: ( + application_id: String, + page: pageRequest, + param: any, + loading?: Ref, +) => Promise> = (application_id, page, param, loading) => { + return get( + `${prefix}/${application_id}/chat/${page.current_page}/${page.page_size}`, + param, + loading, + ) +} + +/** + * 获得对话日志记录 + * @param 参数 + * application_id, chart_id,order_asc + */ +const getChatRecordLog: ( + application_id: String, + chart_id: String, + page: pageRequest, + loading?: Ref, + order_asc?: boolean, +) => Promise> = (application_id, chart_id, page, loading, order_asc) => { + return get( + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${page.current_page}/${page.page_size}`, + { order_asc: order_asc !== undefined ? order_asc : true }, + loading, + ) +} + +/** + * 获取标注段落列表信息 + * @param 参数 + * application_id, chart_id, chart_record_id + */ +const getMarkChatRecord: ( + application_id: string, + chart_id: string, + chart_record_id: string, + loading?: Ref, +) => Promise> = (application_id, chart_id, chart_record_id, loading) => { + return get( + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/improve`, + undefined, + loading, + ) +} + +/** + * 修改日志记录内容 + * @param 参数 + * application_id, chart_id, chart_record_id, knowledge_id, document_id + * data { + "title": "string", + "content": "string", + "problem_text": "string" + } + */ +const putChatRecordLog: ( + application_id: String, + chart_id: String, + chart_record_id: String, + knowledge_id: String, + document_id: String, + data: any, + loading?: Ref, +) => Promise> = ( + application_id, + chart_id, + chart_record_id, + knowledge_id, + document_id, + data, + loading, +) => { + return put( + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/improve`, + data, + undefined, + loading, + ) +} + +/** + * 删除标注 + * @param 参数 + * application_id, chart_id, chart_record_id, knowledge_id, document_id,paragraph_id + */ +const delMarkChatRecord: ( + application_id: String, + chart_id: String, + chart_record_id: String, + knowledge_id: String, + document_id: String, + paragraph_id: String, + loading?: Ref, +) => Promise> = ( + application_id, + chart_id, + chart_record_id, + knowledge_id, + document_id, + paragraph_id, + loading, +) => { + return del( + `${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/paragraph/${paragraph_id}/improve`, + undefined, + {}, + loading, + ) +} + +/** + * 导出对话日志 + * @param 参数 + * application_id + * param { + "start_time": "string", + "end_time": "string", + } + */ +const postExportChatLog: ( + application_id: string, + application_name: string, + param: any, + data: any, + loading?: Ref, +) => void = (application_id, application_name, param, data, loading) => { + exportExcelPost( + application_name + '.xlsx', + `${prefix}/${application_id}/chat/export`, + param, + data, + loading, + ) +} +const getChatRecordDetails: ( + application_id: string, + chat_id: string, + chat_record_id: string, + loading?: Ref, +) => Promise = (application_id, chat_id, chat_record_id, loading) => { + return get( + `${prefix}/${application_id}/chat/${chat_id}/chat_record/${chat_record_id}`, + {}, + loading, + ) +} +export default { + postChatLogAddKnowledge, + getChatLog, + getChatRecordLog, + getMarkChatRecord, + putChatRecordLog, + delMarkChatRecord, + postExportChatLog, + getChatRecordDetails, +} diff --git a/ui/src/api/system-resource-management/workflow-version.ts b/ui/src/api/system-resource-management/workflow-version.ts new file mode 100644 index 000000000..e889e52ad --- /dev/null +++ b/ui/src/api/system-resource-management/workflow-version.ts @@ -0,0 +1,51 @@ +import { Result } from '@/request/Result' +import { get, put } from '@/request/index' +import { type Ref } from 'vue' + +const prefix = '/system/resource/application' + +/** + * workflow历史版本 + */ +const getWorkFlowVersion: ( + application_id: string, + loading?: Ref, +) => Promise> = (application_id, loading) => { + return get(`${prefix}/${application_id}/application_version`, undefined, loading) +} + +/** + * workflow历史版本详情 + */ +const getWorkFlowVersionDetail: ( + application_id: string, + application_version_id: string, + loading?: Ref, +) => Promise> = (application_id, application_version_id, loading) => { + return get( + `${prefix}/${application_id}/application_version/${application_version_id}`, + undefined, + loading, + ) +} +/** + * 修改workflow历史版本 + */ +const putWorkFlowVersion: ( + application_id: string, + application_version_id: string, + data: any, + loading?: Ref, +) => Promise> = (application_id, application_version_id, data, loading) => { + return put( + `${prefix}/${application_id}/application_version/${application_version_id}`, + data, + undefined, + loading, + ) +} +export default { + getWorkFlowVersion, + getWorkFlowVersionDetail, + putWorkFlowVersion, +} diff --git a/ui/src/api/type/application.ts b/ui/src/api/type/application.ts index d391d759f..a52cc0b6f 100644 --- a/ui/src/api/type/application.ts +++ b/ui/src/api/type/application.ts @@ -25,6 +25,7 @@ interface ApplicationFormType { tts_autoplay?: boolean stt_autosend?: boolean folder_id?: string + workspace_id?: string } interface Chunk { real_node_id: string diff --git a/ui/src/components/folder-tree/MoveToDialog.vue b/ui/src/components/folder-tree/MoveToDialog.vue index e056bc71f..ae34bdd73 100644 --- a/ui/src/components/folder-tree/MoveToDialog.vue +++ b/ui/src/components/folder-tree/MoveToDialog.vue @@ -41,6 +41,7 @@ import { t } from '@/locales' import useStore from '@/stores' import { SourceTypeEnum } from '@/enums/common' import KnowledgeApi from '@/api/knowledge/knowledge' +import ApplicationApi from '@/api/application/application' import ToolApi from '@/api/tool/tool' const { folder, application } = useStore() const emit = defineEmits(['refresh']) @@ -119,7 +120,7 @@ const submitHandle = async () => { dialogVisible.value = false }) } else if (props.source === SourceTypeEnum.APPLICATION) { - application.asyncPutApplication(detail.value.id, obj, loading).then((res) => { + ApplicationApi.putApplication(detail.value.id, obj, loading).then((res) => { MsgSuccess(t('common.saveSuccess')) emit('refresh', detail.value) dialogVisible.value = false diff --git a/ui/src/components/generate-related-dialog/index.vue b/ui/src/components/generate-related-dialog/index.vue index 31c760309..12baa0229 100644 --- a/ui/src/components/generate-related-dialog/index.vue +++ b/ui/src/components/generate-related-dialog/index.vue @@ -191,27 +191,24 @@ const submitHandle = async (formEl: FormInstance) => { function getModelFn() { loading.value = true - if (props.apiType === 'systemManage') { - modelResourceApi - .getSelectModelList({ model_type: 'LLM' }, currentKnowledge.value?.workspace_id) - .then((res: any) => { - modelOptions.value = groupBy(res?.data, 'provider') - loading.value = false - }) - .catch(() => { - loading.value = false - }) - } else { - loadSharedApi({ type: 'model', systemType: props.apiType }) - .getSelectModelList({ model_type: 'LLM' }) - .then((res: any) => { - modelOptions.value = groupBy(res?.data, 'provider') - loading.value = false - }) - .catch(() => { - loading.value = false - }) - } + const obj = + props.apiType === 'systemManage' + ? { + model_type: 'LLM', + workspace_id: currentKnowledge.value?.workspace_id, + } + : { + model_type: 'LLM', + } + loadSharedApi({ type: 'model', systemType: props.apiType }) + .getSelectModelList(obj) + .then((res: any) => { + modelOptions.value = groupBy(res?.data, 'provider') + loading.value = false + }) + .catch(() => { + loading.value = false + }) } defineExpose({ open, dialogVisible }) diff --git a/ui/src/layout/components/breadcrumb/index.vue b/ui/src/layout/components/breadcrumb/index.vue index 1b0e9c59d..a505cdaaf 100644 --- a/ui/src/layout/components/breadcrumb/index.vue +++ b/ui/src/layout/components/breadcrumb/index.vue @@ -36,13 +36,13 @@ const route = useRoute() const { meta: { activeMenu }, params: { id, folderId }, - query: { isShared, type }, + query: { isShared }, } = route as any const apiType = computed(() => { if (route.path.includes('shared')) { return 'systemShare' - } else if (route.path.includes('resource-management') || type === 'systemManage') { + } else if (route.path.includes('resource-management')) { return 'systemManage' } else { return 'workspace' @@ -71,7 +71,7 @@ const isKnowledge = computed(() => { const toBackPath = computed(() => { if (route.path.includes('shared')) { return '/system/shared' + activeMenu - } else if (route.path.includes('resource-management') || type === 'systemManage') { + } else if (route.path.includes('resource-management')) { return '/system/resource-management' + activeMenu } else { return activeMenu @@ -93,8 +93,8 @@ function getKnowledgeDetail() { function getApplicationDetail() { loading.value = true - application - .asyncGetApplicationDetail(id) + loadSharedApi({ type: 'application', systemType: apiType.value }) + .getApplicationDetail(id) .then((res: any) => { current.value = res.data loading.value = false diff --git a/ui/src/layout/components/sidebar/SidebarItem.vue b/ui/src/layout/components/sidebar/SidebarItem.vue index 04ca08a7f..5d0d54dd9 100644 --- a/ui/src/layout/components/sidebar/SidebarItem.vue +++ b/ui/src/layout/components/sidebar/SidebarItem.vue @@ -47,7 +47,7 @@ const props = defineProps<{ const router = useRouter() const route = useRoute() const { - params: { id, type }, + params: { id, type, from }, } = route as any function showMenu() { @@ -60,7 +60,7 @@ function showMenu() { function clickHandle(item?: any) { if (isWorkFlow(type) && item?.name === 'AppSetting') { - router.push({ path: `/application/${id}/workflow` }) + router.push({ path: `/application/${from}/${id}/workflow` }) } } const menuIcon = computed(() => { diff --git a/ui/src/layout/layout-template/MainLayout.vue b/ui/src/layout/layout-template/MainLayout.vue index 752b9173b..b82844384 100644 --- a/ui/src/layout/layout-template/MainLayout.vue +++ b/ui/src/layout/layout-template/MainLayout.vue @@ -33,10 +33,15 @@ import { useRoute } from 'vue-router' const route = useRoute() const { params: { folderId }, // id为knowledgeID - query: { type }, + query: { from }, } = route as any const isShared = computed(() => { - return folderId === 'shared' || type === 'systemShare' || type === 'systemManage' + return ( + folderId === 'shared' || + from === 'systemShare' || + from === 'systemManage' || + folderId === 'resource-management' + ) }) const { theme, user } = useStore() const isDefaultTheme = computed(() => { diff --git a/ui/src/layout/layout-template/SimpleLayout.vue b/ui/src/layout/layout-template/SimpleLayout.vue index 32a80a35d..3458fab32 100644 --- a/ui/src/layout/layout-template/SimpleLayout.vue +++ b/ui/src/layout/layout-template/SimpleLayout.vue @@ -12,10 +12,15 @@ const isDefaultTheme = computed(() => { }) const { params: { folderId }, // id为knowledgeID - query: { type }, + query: { from }, } = route as any const isShared = computed(() => { - return folderId === 'shared' || type === 'systemShare' || type === 'systemManage' + return ( + folderId === 'shared' || + from === 'systemShare' || + from === 'systemManage' || + folderId === 'resource-management' + ) }) diff --git a/ui/src/permission/application/index.ts b/ui/src/permission/application/index.ts index 38104dbd8..b8b483800 100644 --- a/ui/src/permission/application/index.ts +++ b/ui/src/permission/application/index.ts @@ -1,5 +1,7 @@ import workspace from './workspace' +import systemManage from './system-manage' const permission = { workspace, + systemManage, } export default permission diff --git a/ui/src/permission/application/system-manage.ts b/ui/src/permission/application/system-manage.ts index 782ecaaae..fccb4568f 100644 --- a/ui/src/permission/application/system-manage.ts +++ b/ui/src/permission/application/system-manage.ts @@ -4,7 +4,7 @@ import {PermissionConst, RoleConst} from '@/utils/permission/data' const systemManage = { create: () => false, folderCreate: () => false, - edit: () => + edit: () => hasPermission( [ RoleConst.ADMIN, @@ -13,7 +13,7 @@ const systemManage = { 'OR' ), folderEdit: () => false, - export: () => + export: () => hasPermission( [ RoleConst.ADMIN, @@ -21,16 +21,16 @@ const systemManage = { ], 'OR' ), - delete: () => + delete: () => hasPermission( [ RoleConst.ADMIN, - PermissionConst.RESOURCE_APPLICATION_DELETE + PermissionConst.RESOURCE_APPLICATION_DELETE ], 'OR' ), folderDelete: () => false, - overview_embed: () => + overview_embed: () => hasPermission( [ RoleConst.ADMIN, @@ -38,7 +38,7 @@ const systemManage = { ], 'OR' ), - overview_access: () => + overview_access: () => hasPermission( [ RoleConst.ADMIN, @@ -46,7 +46,7 @@ const systemManage = { ], 'OR' ), - overview_display: () => + overview_display: () => hasPermission( [ RoleConst.ADMIN, @@ -54,7 +54,7 @@ const systemManage = { ], 'OR' ), - overview_api_key: () => + overview_api_key: () => hasPermission( [ RoleConst.ADMIN, @@ -62,7 +62,7 @@ const systemManage = { ], 'OR' ), - access_edit: () => + access_edit: () => hasPermission( [ RoleConst.ADMIN, @@ -70,7 +70,7 @@ const systemManage = { ], 'OR' ), - application_chat_user_edit: () => + application_chat_user_edit: () => hasPermission( [ RoleConst.ADMIN, @@ -78,7 +78,7 @@ const systemManage = { ], 'OR' ), - chat_log_clear: () => + chat_log_clear: () => hasPermission( [ RoleConst.ADMIN, @@ -86,7 +86,7 @@ const systemManage = { ], 'OR' ), - chat_log_export: () => + chat_log_export: () => hasPermission( [ RoleConst.ADMIN, @@ -94,12 +94,13 @@ const systemManage = { ], 'OR' ), - chat_log_add_knowledge: () => + chat_log_add_knowledge: () => hasPermission( [ RoleConst.ADMIN, PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_ADD_KNOWLEDGE ], 'OR' - ), -} \ No newline at end of file + ), +} +export default systemManage diff --git a/ui/src/router/modules/application-detail.ts b/ui/src/router/modules/application-detail.ts index a5288a531..f253bb2e6 100644 --- a/ui/src/router/modules/application-detail.ts +++ b/ui/src/router/modules/application-detail.ts @@ -5,7 +5,7 @@ import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/dat import { ComplexPermission } from '@/utils/permission/type' const ApplicationDetailRouter = { - path: '/application/:id/:type', + path: '/application/:from/:id/:type', name: 'ApplicationDetail', meta: { title: 'views.applicationOverview.title', activeMenu: '/application', breadcrumb: true }, component: () => import('@/layout/layout-template/MainLayout.vue'), @@ -19,7 +19,7 @@ const ApplicationDetailRouter = { iconActive: 'app-all-menu-active', title: 'views.applicationOverview.title', active: 'overview', - parentPath: '/application/:id/:type', + parentPath: '/application/:from/:id/:type', parentName: 'ApplicationDetail', permission: [ () => { @@ -46,7 +46,7 @@ const ApplicationDetailRouter = { iconActive: 'app-setting-active', title: 'common.setting', active: 'setting', - parentPath: '/application/:id/:type', + parentPath: '/application/:from/:id/:type', parentName: 'ApplicationDetail', permission: [ () => { @@ -72,7 +72,7 @@ const ApplicationDetailRouter = { iconActive: 'app-access-active', title: 'views.application.applicationAccess.title', active: 'access', - parentPath: '/application/:id/:type', + parentPath: '/application/:from/:id/:type', parentName: 'ApplicationDetail', permission: [ () => { @@ -96,7 +96,7 @@ const ApplicationDetailRouter = { iconActive: 'app-user-chat', title: 'views.chatUser.title', active: 'chat-user', - parentPath: '/application/:id/:type', + parentPath: '/application/:from/:id/:type', parentName: 'ApplicationDetail', resourceType: SourceTypeEnum.APPLICATION, permission: [ @@ -122,7 +122,7 @@ const ApplicationDetailRouter = { iconActive: 'app-document-active', title: 'views.chatLog.title', active: 'chat-log', - parentPath: '/application/:id/:type', + parentPath: '/application/:from/:id/:type', parentName: 'ApplicationDetail', permission: [ () => { diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts index e4246d179..e18753816 100644 --- a/ui/src/router/routes.ts +++ b/ui/src/router/routes.ts @@ -31,7 +31,7 @@ export const routes: Array = [ // 高级编排 { - path: '/application/:id/workflow', + path: '/application/:from/:id/workflow', name: 'ApplicationWorkflow', meta: {activeMenu: '/application'}, component: () => import('@/views/application-workflow/index.vue'), diff --git a/ui/src/stores/index.ts b/ui/src/stores/index.ts index 98f066d45..28d28d674 100644 --- a/ui/src/stores/index.ts +++ b/ui/src/stores/index.ts @@ -7,7 +7,6 @@ import useKnowledgeStore from './modules/knowledge' import useModelStore from './modules/model' import usePromptStore from './modules/prompt' import useApplicationStore from './modules/application' -import useChatLogStore from './modules/chat-log' import useChatUserStore from './modules/chat-user' import useToolStore from './modules/tool' const useStore = () => ({ @@ -20,7 +19,6 @@ const useStore = () => ({ model: useModelStore(), prompt: usePromptStore(), application: useApplicationStore(), - chatLog: useChatLogStore(), chatUser: useChatUserStore(), tool: useToolStore(), }) diff --git a/ui/src/stores/modules/application.ts b/ui/src/stores/modules/application.ts index 73e86a0b8..c5feb0ff7 100644 --- a/ui/src/stores/modules/application.ts +++ b/ui/src/stores/modules/application.ts @@ -1,51 +1,10 @@ import { defineStore } from 'pinia' -import applicationApi from '@/api/application/application' import { type Ref } from 'vue' const useApplicationStore = defineStore('application', { state: () => ({ location: `${window.location.origin}${window.MaxKB.chatPrefix ? window.MaxKB.chatPrefix : window.MaxKB.prefix}/`, }), - actions: { - async asyncGetApplicationDetail(id: string, loading?: Ref) { - return new Promise((resolve, reject) => { - applicationApi - .getApplicationDetail(id, loading) - .then((data) => { - resolve(data) - }) - .catch((error) => { - reject(error) - }) - }) - }, - - async asyncGetAccessToken(id: string, loading?: Ref) { - return new Promise((resolve, reject) => { - applicationApi - .getAccessToken(id, loading) - .then((data) => { - resolve(data) - }) - .catch((error) => { - reject(error) - }) - }) - }, - - // 修改应用 - async asyncPutApplication(id: string, data: any, loading?: Ref) { - return new Promise((resolve, reject) => { - applicationApi - .putApplication(id, data, loading) - .then((data) => { - resolve(data) - }) - .catch((error) => { - reject(error) - }) - }) - }, - }, + actions: {}, }) export default useApplicationStore diff --git a/ui/src/stores/modules/chat-log.ts b/ui/src/stores/modules/chat-log.ts deleted file mode 100644 index ed1c11a7c..000000000 --- a/ui/src/stores/modules/chat-log.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { defineStore } from 'pinia' -import chatLogApi from '@/api/application/chat-log' -import { type Ref } from 'vue' -import type { pageRequest } from '@/api/type/common' - -const useChatLogStore = defineStore('chatLog',{ - state: () => ({}), - actions: { - async asyncGetChatLog(id: string, page: pageRequest, param: any, loading?: Ref) { - return new Promise((resolve, reject) => { - chatLogApi - .getChatLog(id, page, param, loading) - .then((data) => { - resolve(data) - }) - .catch((error) => { - reject(error) - }) - }) - }, - async asyncChatRecordLog( - id: string, - chatId: string, - page: pageRequest, - loading?: Ref, - order_asc?: boolean - ) { - return new Promise((resolve, reject) => { - chatLogApi - .getChatRecordLog(id, chatId, page, loading, order_asc) - .then((data) => { - resolve(data) - }) - .catch((error) => { - reject(error) - }) - }) - }, - } -}) - -export default useChatLogStore diff --git a/ui/src/utils/dynamics-api/shared-api.ts b/ui/src/utils/dynamics-api/shared-api.ts index f8a2beeac..00211dcb5 100644 --- a/ui/src/utils/dynamics-api/shared-api.ts +++ b/ui/src/utils/dynamics-api/shared-api.ts @@ -5,6 +5,10 @@ import problemWorkspaceApi from '@/api/knowledge/problem' import modelWorkspaceApi from '@/api/model/model' import toolWorkspaceApi from '@/api/tool/tool' import chatUserWorkspaceApi from '@/api/chat-user/chat-user' +import applicationWorkspaceApi from '@/api/application/application' +import applicationKeyWorkspaceApi from '@/api/application/application-key' +import workflowVersionWorkspaceApi from '@/api/application/workflow-version' +import chatLogWorkspaceApi from '@/api/application/chat-log' import sharedWorkspaceApi from '@/api/shared-workspace' import toolSystemShareApi from '@/api/system-shared/tool' import modelSystemShareApi from '@/api/system-shared/model' @@ -22,6 +26,10 @@ import paragraphResourceApi from '@/api/system-resource-management/paragraph' import problemResourceApi from '@/api/system-resource-management/problem' import modelResourceApi from '@/api/system-resource-management/model' import chatUserResourceApi from '@/api/system-resource-management/chat-user' +import applicationResourceApi from '@/api/system-resource-management/application' +import applicationKeyResourceApi from '@/api/system-resource-management/application-key' +import workflowVersionResourceApi from '@/api/system-resource-management/workflow-version' +import chatLogWResourceApi from '@/api/system-resource-management/chat-log' // 普通 API const workspaceApiMap = { @@ -33,6 +41,10 @@ const workspaceApiMap = { problem: problemWorkspaceApi, chatUser: chatUserWorkspaceApi, workspace: workspaceApi, + application: applicationWorkspaceApi, + applicationKey: applicationKeyWorkspaceApi, + workflowVersion: workflowVersionWorkspaceApi, + chatLog: chatLogWorkspaceApi, } as any // 系统分享 API @@ -56,6 +68,10 @@ const systemManageApiMap = { model: modelResourceApi, tool: ToolResourceApi, chatUser: chatUserResourceApi, + application: applicationResourceApi, + applicationKey: applicationKeyResourceApi, + workflowVersion: workflowVersionResourceApi, + chatLog: chatLogWResourceApi, } as any const data = { diff --git a/ui/src/views/application-overview/component/APIKeyDialog.vue b/ui/src/views/application-overview/component/APIKeyDialog.vue index 085cb8377..7d2bda1f5 100644 --- a/ui/src/views/application-overview/component/APIKeyDialog.vue +++ b/ui/src/views/application-overview/component/APIKeyDialog.vue @@ -58,19 +58,27 @@ - + diff --git a/ui/src/views/application-overview/component/SettingAPIKeyDialog.vue b/ui/src/views/application-overview/component/SettingAPIKeyDialog.vue index d9580741f..e62fc9a19 100644 --- a/ui/src/views/application-overview/component/SettingAPIKeyDialog.vue +++ b/ui/src/views/application-overview/component/SettingAPIKeyDialog.vue @@ -34,25 +34,33 @@