From 16b1a79c0bfbd0ac5276e67c45bc5bdeaaf6093c Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Fri, 13 Jun 2025 21:56:01 +0800 Subject: [PATCH] feat: chat --- ui/env/.env.chat | 2 +- ui/src/router/chat/routes.ts | 8 +- ui/src/router/routes.ts | 2 +- ui/src/stores/modules/application.ts | 39 +-- .../component/XPackDisplaySettingDialog.vue | 10 +- ui/src/views/application-workflow/index.vue | 26 +- ui/src/views/chat/auth/index.vue | 33 +- ui/src/views/chat/pc/index.vue | 292 +++++++++--------- 8 files changed, 190 insertions(+), 222 deletions(-) diff --git a/ui/env/.env.chat b/ui/env/.env.chat index 34e86c5b4..6d60a20bc 100644 --- a/ui/env/.env.chat +++ b/ui/env/.env.chat @@ -1,5 +1,5 @@ VITE_APP_NAME=chat VITE_BASE_PATH=/chat/ -VITE_APP_PORT=3000 +VITE_APP_PORT=3001 VITE_APP_TITLE = 'MaxKB' VITE_ENTRY="entry/chat/index.html" \ No newline at end of file diff --git a/ui/src/router/chat/routes.ts b/ui/src/router/chat/routes.ts index 744c54dac..c44bf3d6c 100644 --- a/ui/src/router/chat/routes.ts +++ b/ui/src/router/chat/routes.ts @@ -3,8 +3,14 @@ import type { RouteRecordRaw } from 'vue-router' export const routes: Array = [ // 对话 { - path: '/chat/:accessToken', + path: '/:accessToken', name: 'Chat', component: () => import('@/views/chat/index.vue'), }, + // 对话用户登录 + { + path: '/user-login/:accessToken', + name: 'UserLogin', + component: () => import('@/views/chat/user-login/index.vue'), + }, ] diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.ts index 7f1220e3f..c6e140d7a 100644 --- a/ui/src/router/routes.ts +++ b/ui/src/router/routes.ts @@ -24,7 +24,7 @@ export const routes: Array = [ component: () => import('@/views/chat/index.vue'), }, - // 对话用户登录 + // 对话用户登录 { path: '/user-login/:accessToken', name: 'UserLogin', diff --git a/ui/src/stores/modules/application.ts b/ui/src/stores/modules/application.ts index 9c876199e..3ba9294cc 100644 --- a/ui/src/stores/modules/application.ts +++ b/ui/src/stores/modules/application.ts @@ -62,15 +62,16 @@ const useApplicationStore = defineStore('application', { async asyncGetAppProfile(loading?: Ref) { return new Promise((resolve, reject) => { - // applicationApi - // .getAppProfile(loading) - // .then((res) => { - // sessionStorage.setItem('language', res.data?.language || getBrowserLang()) - // resolve(res) - // }) - // .catch((error) => { - // reject(error) - // }) + console.log('xxxx') + applicationApi + .getAppProfile(loading) + .then((res) => { + sessionStorage.setItem('language', res.data?.language || getBrowserLang()) + resolve(res) + }) + .catch((error) => { + reject(error) + }) }) }, @@ -80,16 +81,16 @@ const useApplicationStore = defineStore('application', { authentication_value?: any, ) { return new Promise((resolve, reject) => { - // applicationApi - // .postAppAuthentication(token, loading, authentication_value) - // .then((res) => { - // localStorage.setItem(`${token}-accessToken`, res.data) - // sessionStorage.setItem(`${token}-accessToken`, res.data) - // resolve(res) - // }) - // .catch((error) => { - // reject(error) - // }) + applicationApi + .postAppAuthentication(token, loading, authentication_value) + .then((res) => { + localStorage.setItem(`${token}-accessToken`, res.data) + sessionStorage.setItem(`${token}-accessToken`, res.data) + resolve(res) + }) + .catch((error) => { + reject(error) + }) }) }, async refreshAccessToken(token: string) { diff --git a/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue b/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue index 3453ce743..ce43ecb9c 100644 --- a/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue +++ b/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue @@ -41,12 +41,10 @@ > - diff --git a/ui/src/views/application-workflow/index.vue b/ui/src/views/application-workflow/index.vue index bbfa5cba7..b85dd6cb4 100644 --- a/ui/src/views/application-workflow/index.vue +++ b/ui/src/views/application-workflow/index.vue @@ -92,13 +92,7 @@ > - +

@@ -157,7 +151,7 @@ const isDefaultTheme = computed(() => { return user.isDefaultTheme() }) const { - params: { id } + params: { id }, } = route as any let interval: any @@ -182,7 +176,7 @@ function back() { confirmButtonText: t('views.applicationWorkflow.setting.exitSave'), cancelButtonText: t('views.applicationWorkflow.setting.exit'), type: 'warning', - distinguishCancelAndClose: true + distinguishCancelAndClose: true, }) .then(() => { saveApplication(true, true) @@ -268,7 +262,7 @@ async function publicHandle() { ?.validate() .then(async () => { const obj = { - work_flow: getGraphData() + work_flow: getGraphData(), } await application.asyncPutApplication(id, obj, loading) const workflow = new WorkFlowInstance(obj.work_flow) @@ -293,14 +287,14 @@ async function publicHandle() { MsgError( res.node.properties?.stepName + ` ${t('views.applicationWorkflow.node').toLowerCase()} ` + - err_message.toLowerCase() + err_message.toLowerCase(), ) } else { const keys = Object.keys(err_message) MsgError( node.properties?.stepName + ` ${t('views.applicationWorkflow.node').toLowerCase()} ` + - err_message[keys[0]]?.[0]?.message.toLowerCase() + err_message[keys[0]]?.[0]?.message.toLowerCase(), ) } }) @@ -318,7 +312,7 @@ const clickShowDebug = () => { ...detail.value, type: 'WORK_FLOW', ...workflow.get_base_node()?.properties.node_data, - work_flow: getGraphData() + work_flow: getGraphData(), } showDebug.value = true @@ -331,14 +325,14 @@ const clickShowDebug = () => { const err_message = res.errMessage if (typeof err_message == 'string') { MsgError( - res.node.properties?.stepName + ` ${t('views.applicationWorkflow.node')},` + err_message + res.node.properties?.stepName + ` ${t('views.applicationWorkflow.node')},` + err_message, ) } else { const keys = Object.keys(err_message) MsgError( node.properties?.stepName + ` ${t('views.applicationWorkflow.node')},` + - err_message[keys[0]]?.[0]?.message + err_message[keys[0]]?.[0]?.message, ) } }) @@ -376,7 +370,7 @@ function getDetail() { function saveApplication(bool?: boolean, back?: boolean) { const obj = { - work_flow: getGraphData() + work_flow: getGraphData(), } loading.value = back || false application diff --git a/ui/src/views/chat/auth/index.vue b/ui/src/views/chat/auth/index.vue index 948728301..5d1881316 100644 --- a/ui/src/views/chat/auth/index.vue +++ b/ui/src/views/chat/auth/index.vue @@ -1,27 +1,4 @@