From 20edb222d5aa11655c14d5df13488699da7061ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=E9=AD=8F?= Date: Tue, 19 Aug 2025 19:48:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=A7=E8=A1=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/appCenter/appCenterService.ts | 13 ++ src/apis/paths/account.ts | 1 + src/i18n/lang/en.ts | 1 + src/i18n/lang/zh-cn.ts | 1 + src/store/account.ts | 2 + .../dialogue/components/DialogueSession.vue | 215 ++++++++++++------ 6 files changed, 167 insertions(+), 66 deletions(-) diff --git a/src/apis/appCenter/appCenterService.ts b/src/apis/appCenter/appCenterService.ts index 025e789..b555393 100644 --- a/src/apis/appCenter/appCenterService.ts +++ b/src/apis/appCenter/appCenterService.ts @@ -108,6 +108,18 @@ export const getPartAppConfgUser = (): Promise< return get('/api/user'); }; +/** + * 修改用户设置 + * + * @param params + * @returns + */ +export const updateUserInfo = (params: { + autoExecute: boolean; +}): Promise<[any, FcResponse | undefined]> => { + return post(`/api/user`, {autoExecute: params.autoExecute}); +}; + export const appCenterApi = { queryAppList, createOrUpdateApp, @@ -116,4 +128,5 @@ export const appCenterApi = { releaseSingleAppData, changeSingleAppCollect, getPartAppConfgUser, + updateUserInfo, }; diff --git a/src/apis/paths/account.ts b/src/apis/paths/account.ts index 93411cd..af45218 100644 --- a/src/apis/paths/account.ts +++ b/src/apis/paths/account.ts @@ -24,6 +24,7 @@ export const authorizeUser = (): Promise< organization: string; revision_number: string | null; is_admin: boolean; + auto_execute?: boolean; }> | undefined ), diff --git a/src/i18n/lang/en.ts b/src/i18n/lang/en.ts index 2e32560..dad069f 100644 --- a/src/i18n/lang/en.ts +++ b/src/i18n/lang/en.ts @@ -263,6 +263,7 @@ export default { no_chat_history: 'No chat history available.', expand: 'Expand', myApp: 'My Apps', + auto_execute: 'Auto Execute', }, feedback: { noCopyMessage: 'No information to copy.', diff --git a/src/i18n/lang/zh-cn.ts b/src/i18n/lang/zh-cn.ts index 9e1a4b2..1e4eb87 100644 --- a/src/i18n/lang/zh-cn.ts +++ b/src/i18n/lang/zh-cn.ts @@ -266,6 +266,7 @@ export default { no_chat_history: '暂无历史对话', expand: '展开', myApp: '我的应用', + auto_execute: '自动执行', }, feedback: { noCopyMessage: '无可复制的信息', diff --git a/src/store/account.ts b/src/store/account.ts index fe7ab5e..d62ed20 100644 --- a/src/store/account.ts +++ b/src/store/account.ts @@ -25,6 +25,7 @@ export const useAccountStore = defineStore('account', () => { organization: string; user_sub: string; is_admin?: boolean; + auto_execute?: boolean; }>({ username: '', revsionNumber: null, @@ -98,6 +99,7 @@ export const useAccountStore = defineStore('account', () => { userinfo.organization = organization; userinfo.revsionNumber = revision_number; userinfo.is_admin = res.result.is_admin; + userinfo.auto_execute = res.result.auto_execute; return true; } return false; diff --git a/src/views/dialogue/components/DialogueSession.vue b/src/views/dialogue/components/DialogueSession.vue index 46da082..27c8ce1 100644 --- a/src/views/dialogue/components/DialogueSession.vue +++ b/src/views/dialogue/components/DialogueSession.vue @@ -30,6 +30,9 @@ import pptxSvg from '@/assets/svgs/pptx.svg'; import yamlSvg from '@/assets/svgs/yaml.svg'; import zipSvg from '@/assets/svgs/zip.svg'; import { ElMessage } from 'element-plus'; +import { useAccountStore } from 'src/store'; +const autoExecuteRef = ref(false); +const { userinfo } = storeToRefs(useAccountStore()); const typeSvgMap = { doc: docSvg, @@ -86,8 +89,9 @@ const dialogueInput = ref(''); // 对话列表 const { sendQuestion } = useSessionStore(); -const { conversationList, isAnswerGenerating, dialogueRef } = - storeToRefs(useSessionStore()); +const { conversationList, isAnswerGenerating, dialogueRef } = storeToRefs( + useSessionStore(), +); const { generateSession } = useHistorySessionStore(); const { currentSelectedSession } = storeToRefs(useHistorySessionStore()); /** @@ -166,7 +170,7 @@ const handleKeydown = (event: KeyboardEvent) => { * * @param item */ -const getItem = (item: ConversationItem, field: string): T | undefined => { +const getItem = (item: ConversationItem, field: string): T | undefined => { if (field in item) { return (item as RobotConversationItem)[field] as T; } @@ -554,6 +558,11 @@ const getProviderLLM = async () => { } }; +const autoExecuteChange = (value) => { + autoExecuteRef.value = value; + api.updateUserInfo({ autoExecute: value }); +}; + onMounted(() => { // 数据初始化 AppForm.value = props.createAppForm; @@ -562,6 +571,19 @@ onMounted(() => { getProviderLLM(); }); +watch( + [userinfo], + () => { + if (userinfo.value.auto_execute) { + autoExecuteRef.value = userinfo.value.auto_execute; + } + }, + { + immediate: true, + deep: true, + }, +); + watch(selectLLM, (newValue) => { if (newValue) { selectedLLM.value.modalName = newValue.modelName; @@ -679,14 +701,16 @@ function downloadFun(url: string) { let fileName = 'default-filename'; // 解析文件名(处理编码及格式) if (contentDisposition) { - const fileNameMatch = contentDisposition.match(/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i); + const fileNameMatch = contentDisposition.match( + /filename\*?=(?:UTF-8'')?"?([^";]+)"?/i, + ); if (fileNameMatch && fileNameMatch[1]) { fileName = decodeURIComponent(fileNameMatch[1].replace(/"/g, '')); } } - return response.blob().then((blob) => ({ blob,fileName })); + return response.blob().then((blob) => ({ blob, fileName })); }) - .then(({ blob,fileName }) => { + .then(({ blob, fileName }) => { const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = fileName; @@ -710,19 +734,19 @@ const formatDate = (timestamp: number) => { const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; -} +}; /** - * @description 处理并过滤文件列表,将文件列表中的字段名统一为指定格式 - * @param {ConversationItem} ConversationItem - 对话项对象 - * @param {string} str - 字段名 - * @returns {Array} 格式化后的文件列表 + * @description 处理并过滤文件列表,将文件列表中的字段名统一为指定格式 + * @param {ConversationItem} ConversationItem - 对话项对象 + * @param {string} str - 字段名 + * @returns {Array} 格式化后的文件列表 */ -const getFormatFileList = (ConversationItem,str)=>{ - let fileList: any= getItem(ConversationItem,str); +const getFormatFileList = (ConversationItem, str) => { + let fileList: any = getItem(ConversationItem, str); if (!fileList || fileList?.length === 0) return; - let newFileList:any = []; - fileList?.forEach((file) => { - if(file.associated === 'answer'){ + let newFileList: any = []; + fileList?.forEach((file) => { + if (file.associated === 'answer') { newFileList.push({ documentId: file._id, documentName: file.name, @@ -733,11 +757,11 @@ const getFormatFileList = (ConversationItem,str)=>{ documentOrder: file.order, createdAt: file.created_at, documentAuthor: file.author, - }) + }); } - }) + }); return newFileList; -} +};