diff --git a/electron/main/common/conf.ts b/electron/main/common/conf.ts index 0fb68b2ff8314cf5ba0c480208d50a60ac67e724..5f4c99ef5d9a0f81797a6c502a30ee268daeb533 100644 --- a/electron/main/common/conf.ts +++ b/electron/main/common/conf.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/common/nls.ts b/electron/main/common/nls.ts index 0c3e1c5965a4649111f2c99b1a64f63671fb42f6..e16be02f0d6001cd3b52dc428d4a27b5de07cc16 100644 --- a/electron/main/common/nls.ts +++ b/electron/main/common/nls.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/common/platform.ts b/electron/main/common/platform.ts index c339dd859f4972a34d2853281dd4c47f56892742..7f78c8a47a1d35ad43247c36a2b3602409780371 100644 --- a/electron/main/common/platform.ts +++ b/electron/main/common/platform.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/common/product.ts b/electron/main/common/product.ts index f2aca9707062fd0874ef88a86a1a6f6152419211..b90384f8b1dfe872ce81ba7864e8386771259014 100644 --- a/electron/main/common/product.ts +++ b/electron/main/common/product.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/index.ts b/electron/main/index.ts index 9d5ae3af1dff42ef758ba8d913a6d07111d912e6..22c68d6a2aacbb0e05fbd4fe9e6c174b82c07a65 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 @@ -12,8 +14,9 @@ import { globalShortcut, nativeTheme, BrowserWindow, + dialog, } from 'electron'; -import { createDefaultWindow, createTray, createChatWindow } from './window'; +import { createDefaultWindow, createChatWindow, createTray } from './window'; import type { INLSConfiguration } from './common/nls'; import { cachePath, commonCacheConfPath, updateConf } from './common/conf'; @@ -28,9 +31,71 @@ const osLocale = processZhLocale( (app.getPreferredSystemLanguages()?.[0] ?? 'en').toLowerCase(), ); +// 定义全局快捷键 +const CHAT_SHORTCUT_KEY = + process.platform === 'darwin' ? 'Cmd+Option+O' : 'Ctrl+Alt+O'; + // 添加表示应用是否正在退出的标志位 let isQuitting = false; +// 添加是否已注册快捷键的标志 +let isShortcutRegistered = false; + +// 在macOS上,检查是否已经获得辅助功能权限 +function checkAccessibilityPermission(): boolean { + if (process.platform !== 'darwin') return true; + + try { + return app.isAccessibilitySupportEnabled(); + } catch (err) { + console.error('Failed to check accessibility permission:', err); + return false; + } +} + +// 注册全局快捷键 +function registerGlobalShortcut() { + // 如果已经注册了快捷键,先取消注册 + if (isShortcutRegistered) { + globalShortcut.unregister(CHAT_SHORTCUT_KEY); + } + + // 注册新的快捷键 + const success = globalShortcut.register(CHAT_SHORTCUT_KEY, () => { + const chatWindow = BrowserWindow.getAllWindows().find((win) => + win.webContents.getURL().includes('chat'), + ); + + if (chatWindow) { + if (chatWindow.isMinimized()) chatWindow.restore(); + chatWindow.show(); + chatWindow.focus(); + } else { + // 如果没有找到聊天窗口,则创建一个新的 + const newChatWindow = createChatWindow(); + newChatWindow.show(); + newChatWindow.focus(); + } + }); + + isShortcutRegistered = success; + + if (!success) { + console.error('Failed to register global shortcut'); + // 在macOS上,提示用户需要授予辅助功能权限 + if (process.platform === 'darwin' && !checkAccessibilityPermission()) { + dialog.showMessageBox({ + type: 'info', + title: '需要辅助功能权限', + message: `要使用快捷键 ${CHAT_SHORTCUT_KEY} 功能,请在系统偏好设置中,授予应用辅助功能权限。`, + buttons: ['好的'], + }); + } + } + + return success; +} + app.once('ready', () => { onReady(); }); @@ -51,7 +116,7 @@ app.on('window-all-closed', () => { } }); -// 在macOS上,当应用图标被点击时重置退出标志 +// 在macOS上,当应用图标被点击时重置退出标志和显示主窗口 app.on('activate', () => { isQuitting = false; }); @@ -71,6 +136,27 @@ async function onReady() { process.env['EULERCOPILOT_CACHE_PATH'] = cachePath || ''; await startup(); + + // 注册全局快捷键 + registerGlobalShortcut(); + + // 在macOS上,监听辅助功能权限变化,重新注册快捷键 + if (process.platform === 'darwin') { + app.accessibilitySupportEnabled = checkAccessibilityPermission(); + + app.on( + 'accessibility-support-changed', + (event, accessibilitySupportEnabled) => { + console.log( + 'Accessibility support changed:', + accessibilitySupportEnabled, + ); + if (accessibilitySupportEnabled) { + registerGlobalShortcut(); + } + }, + ); + } } catch (error) {} } @@ -84,16 +170,21 @@ async function startup() { win = createDefaultWindow(); chatWindow = createChatWindow(); + app.on('activate', () => { + isQuitting = false; if (BrowserWindow.getAllWindows().length === 0) { + // 如果没有窗口,则创建新窗口 win = createDefaultWindow(); chatWindow = createChatWindow(); + } else { + // 如果窗口存在但被隐藏,则显示主窗口 + if (win && !win.isDestroyed()) { + win.show(); + } } }); - tray.on('click', () => { - win.show(); - }); win.on('close', (event) => { // 如果应用正在退出(例如通过Cmd+Q触发),则允许窗口正常关闭 if (isQuitting) { diff --git a/electron/main/node/userDataPath.ts b/electron/main/node/userDataPath.ts index fdfe26114a5a68755e5cab133eaf2fcf9d2058ff..806e9ecb89a0ed24049d6fe104dc9bbcd4c096d9 100644 --- a/electron/main/node/userDataPath.ts +++ b/electron/main/node/userDataPath.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/window/create.ts b/electron/main/window/create.ts index 3400e993725e820d45f6213f06130c5551e950fc..1f29b725c379ef45c243dfa3d93ad10eba5336fb 100644 --- a/electron/main/window/create.ts +++ b/electron/main/window/create.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 @@ -63,13 +65,6 @@ function setupWindowControls(win: BrowserWindow) { win.webContents.send('window-maximized-change', false); } }); - - // 添加关闭前确认 - win.on('close', (e) => { - if (win === defaultWindow) { - // 可以在这里添加关闭确认逻辑 - } - }); } let defaultWindow: BrowserWindow | null = null; @@ -120,13 +115,6 @@ export function createChatWindow(): BrowserWindow { chatWindow = createWindow(chatWindowOptions, hash, 'chatWindow'); - const shortcutKey = - process.platform === 'darwin' ? 'Cmd+Option+O' : 'Ctrl+Alt+O'; - - globalShortcut.register(shortcutKey, () => { - chatWindow && chatWindow.show(); - }); - return chatWindow; } diff --git a/electron/main/window/index.ts b/electron/main/window/index.ts index 21a4390f99c572b070edceeb60a2c5a978096dcf..b7773d63f389fb870c652544dd9157291a697817 100644 --- a/electron/main/window/index.ts +++ b/electron/main/window/index.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/window/options.ts b/electron/main/window/options.ts index f48f00eb770e125ad11b02c484435f7c8a5268aa..e7049c863424f9ac1502eaac307c612651987bd8 100644 --- a/electron/main/window/options.ts +++ b/electron/main/window/options.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/main/window/tray.ts b/electron/main/window/tray.ts index 1c07b916e439755b7c9e16026e0aea6c56675f17..246afec825706ba47057b7e687dd2bba28e99f3c 100644 --- a/electron/main/window/tray.ts +++ b/electron/main/window/tray.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/electron/preload/index.ts b/electron/preload/index.ts index cbea3f1db0941e0466bf60282c433d048ba22456..2700a192cc1a5447f015ce29bb8b0ea283227a6b 100644 --- a/electron/preload/index.ts +++ b/electron/preload/index.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/env.d.ts b/env.d.ts index 4c00dafc4f90054125e8989dde6ef7ba8c559737..43df7b98287cdcdfc7b3a48603a071a08312bde7 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/appCenter/appCenterService.ts b/src/apis/appCenter/appCenterService.ts index 9ec8328b2c16aa7d3e272635b07cd7b3cd58e073..ac2b346c819cd83c7a9e907f36767bca0964bb20 100644 --- a/src/apis/appCenter/appCenterService.ts +++ b/src/apis/appCenter/appCenterService.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. import { post, get, del, put } from 'src/apis/server'; import type { FcResponse } from 'src/apis/server'; import { QueryAppListParamsType, CreateOrUpdateAppParamsType } from './type'; diff --git a/src/apis/appCenter/index.ts b/src/apis/appCenter/index.ts index 95d1ce017d353e0157bca4a5084afd72ec08da1a..f842150bd2908630a43f1a4bd19153ea84711d29 100644 --- a/src/apis/appCenter/index.ts +++ b/src/apis/appCenter/index.ts @@ -1,2 +1,2 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. export * from './appCenterService'; diff --git a/src/apis/index.ts b/src/apis/index.ts index 859159858c830cb67fa914f44b013681c1771c3f..530a741cfaa0e2f40bd4f0340fb64d15a2512767 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/paths/account.ts b/src/apis/paths/account.ts index 6ff6b4c230bfba8c2004ba9390adbb4e4583a534..27fe83360ccc8941caf8d8f92b3372351b5d59b7 100644 --- a/src/apis/paths/account.ts +++ b/src/apis/paths/account.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/paths/api.ts b/src/apis/paths/api.ts index 8538d5dcf1975fed1ddb6797bdae9121c46bc0da..96c5d1dbf9704bd262a30fb2a7d4324a7ce8068d 100644 --- a/src/apis/paths/api.ts +++ b/src/apis/paths/api.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. import { post, get, del, put } from 'src/apis/server'; import type { FcResponse } from 'src/apis/server'; import { QueryApiListParamsType, CreateOrUpdateApiParamsType } from './type'; diff --git a/src/apis/paths/apikey.ts b/src/apis/paths/apikey.ts index 3848437900e7ba0429072e64cb88e7495d548d82..6ffdb0c64c85f936f7de85111d709fd2dde562a4 100644 --- a/src/apis/paths/apikey.ts +++ b/src/apis/paths/apikey.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -14,9 +14,17 @@ import type { FcResponse } from 'src/apis/server'; * 验证用户信息 * @returns */ -export const getApiKey = (): Promise<[any, FcResponse<{ - api_key: string; -}> | undefined]> => { +export const getApiKey = (): Promise< + [ + any, + ( + | FcResponse<{ + api_key: string; + }> + | undefined + ), + ] +> => { return get('/api/auth/key'); }; diff --git a/src/apis/paths/app.ts b/src/apis/paths/app.ts index 3a87663be2ee3a4f15d8da921df5acb2f1bd7ada..51995ec6dd6e4ff4837cea60d22b13cb397fce6a 100644 --- a/src/apis/paths/app.ts +++ b/src/apis/paths/app.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/paths/conversation.ts b/src/apis/paths/conversation.ts index 08a052f29ad1e973398990f887a95322e3828aac..bfeb68e414fffccad034aa160a1b1d1f1cfbd224 100644 --- a/src/apis/paths/conversation.ts +++ b/src/apis/paths/conversation.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -18,13 +18,7 @@ const BASE_URL = '/api/conversation'; * @returns */ export const stopGeneration = (): Promise< - [ - any, - ( - | FcResponse - | undefined - ), - ] + [any, FcResponse | undefined] > => { return post(`/api/stop`); }; diff --git a/src/apis/paths/external.ts b/src/apis/paths/external.ts index d46588efafc0d15f9a2aa62dd08fae334c3e30be..7bd1730a4333ee1235662d0e0cc379a58629158b 100644 --- a/src/apis/paths/external.ts +++ b/src/apis/paths/external.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/paths/index.ts b/src/apis/paths/index.ts index 17d6d4b602720cb8515517f3cf0fd2e1ef654a94..f87c8a52a3f108f09f6a402fe230565e7f71db51 100644 --- a/src/apis/paths/index.ts +++ b/src/apis/paths/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/paths/knowledge.ts b/src/apis/paths/knowledge.ts index 8016773ede2a22bcf8dadc39e4fcfb7978d8633d..7ce9d72b5b0cbe3e7a809ae4bcdc4708f02fb6fa 100644 --- a/src/apis/paths/knowledge.ts +++ b/src/apis/paths/knowledge.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/server.ts b/src/apis/server.ts index 64d34b33b5dd22beb56e7f0d5a773c49e49007cd..3e165fcd4942be9d612f7f747c1c2256447ea684 100644 --- a/src/apis/server.ts +++ b/src/apis/server.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -34,8 +34,10 @@ export interface IAnyObj { export type Fn = (data: FcResponse) => unknown; - -const baseURL = import.meta.env.MODE === 'electron-production' ? import.meta.env.VITE_BASE_PROXY_URL : './'; +const baseURL = + import.meta.env.MODE === 'electron-production' + ? import.meta.env.VITE_BASE_PROXY_URL + : './'; // 创建 axios 实例 export const server = axios.create({ baseURL, diff --git a/src/apis/tools.ts b/src/apis/tools.ts index ad08b016a804ea3cbf9beacb3dd8ee7a403cca9e..df279e1c7926663554b816d066b69f2ee8ffb4ac 100644 --- a/src/apis/tools.ts +++ b/src/apis/tools.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/apis/workFlow/index.ts b/src/apis/workFlow/index.ts index fba2fe856dd1d995c5960174fd10a8865ea7a46b..516f17bd2760432fc4a2a39d72bf14a3802d0402 100644 --- a/src/apis/workFlow/index.ts +++ b/src/apis/workFlow/index.ts @@ -1,2 +1,2 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. export * from './workFlowService'; diff --git a/src/apis/workFlow/workFlowService.ts b/src/apis/workFlow/workFlowService.ts index d6b6a39fdcd5aa989d926834a050b611c2ea6a47..3f094d9ab2ad15d94c5f30d2fe2e196d24abc8aa 100644 --- a/src/apis/workFlow/workFlowService.ts +++ b/src/apis/workFlow/workFlowService.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. import { post, get, del, put } from 'src/apis/server'; import type { FcResponse } from 'src/apis/server'; import { diff --git a/src/components/dialoguePanel/type.ts b/src/components/dialoguePanel/type.ts index 68ce23927a153898b46be56294af259ef7106718..5d02cb4ca2a2bb100cf69d1ee6a23f9de834b0bb 100644 --- a/src/components/dialoguePanel/type.ts +++ b/src/components/dialoguePanel/type.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/components/sessionCard/type.ts b/src/components/sessionCard/type.ts index a6d0d04d9db020044383ce2503292dcf344a6265..91d1be3f8fac7353e6e03704b44a0b73da82fa47 100644 --- a/src/components/sessionCard/type.ts +++ b/src/components/sessionCard/type.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/conf/version.ts b/src/conf/version.ts index c54a707e20134fa7ed84375cf4e818947d5710ee..82f3d1e5f4a9c89a6b1549901109ec746f843a35 100644 --- a/src/conf/version.ts +++ b/src/conf/version.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/main.ts b/src/main.ts index a3853b3b8cc751fd0f025bb4ccffeab103576fb6..769aad853064a39dac0b9cdabc6a0f76af2677ba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/router/index.ts b/src/router/index.ts index e9124f977838c928c5a6f8e65783bfbf8f2521b0..78d861647dc5fd88a0daf2e7226fb5130179ade2 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/store/account.ts b/src/store/account.ts index 89385b6125ba4f83434bf2bd55cac0caf23bd60e..81fc318e6b1ec2d1d1c25a40e775a65858dc1440 100644 --- a/src/store/account.ts +++ b/src/store/account.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -49,7 +49,7 @@ export const useAccountStore = defineStore('account', () => { async function getAuthUrl(action: string) { const [_, res] = await api.queryAuthUrl(action); - if (!_&&res) { + if (!_ && res) { return res.result.url; } return null; diff --git a/src/store/conversation.ts b/src/store/conversation.ts index 51d0cd6deab8d9e184ad6e51eca4fa6f4a5a973e..67802330a3ff74753f4fa02e5f31d18ca484626d 100644 --- a/src/store/conversation.ts +++ b/src/store/conversation.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -89,15 +89,15 @@ export const useSessionStore = defineStore('conversation', () => { **/ function splitDataString(input) { if (input.includes('"data: ')) { - return [input]; + return [input]; } - const parts = input.split(/data: /g).filter(part => part.trim() !== ''); + const parts = input.split(/data: /g).filter((part) => part.trim() !== ''); if (input.startsWith('data: ')) { - return parts.map(part => 'data: ' + part); + return parts.map((part) => 'data: ' + part); } else { - return [parts[0], ...parts.slice(1).map(part => 'data: ' + part)]; + return [parts[0], ...parts.slice(1).map((part) => 'data: ' + part)]; } -} + } /** * 请求流式数据 * @param params diff --git a/src/store/historySession.ts b/src/store/historySession.ts index 6157073c9aad6694918758aeb4b7798952ecf94c..61e1c189c4ec64ceceabef98fec1358aba2519e0 100644 --- a/src/store/historySession.ts +++ b/src/store/historySession.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/store/index.ts b/src/store/index.ts index 3119618c904d8d7ba79250ce067944aaf5e6949f..1152883ca6579f12655cb888cac273e8094a4d10 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/utils/electron.ts b/src/utils/electron.ts index a72d74e58c88e5d15b0b57cb46704a9f7f3841be..59f257537418c45bf69d71e49fc139569877ad81 100644 --- a/src/utils/electron.ts +++ b/src/utils/electron.ts @@ -1,3 +1,5 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. +// licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 diff --git a/src/utils/index.ts b/src/utils/index.ts index d13927398394abb2316c4c05b1fc132c56b329f5..9d09235a6137224e57b4de301a3d233283955c87 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/utils/marked.ts b/src/utils/marked.ts index 34861d2229eff2e44cfa3730d0f8d8cfed126452..2677e495af5f652e699b07c958cc9b92b340a1c6 100644 --- a/src/utils/marked.ts +++ b/src/utils/marked.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/utils/tools.ts b/src/utils/tools.ts index af58040213f2a8a40ef14a003a9a81e6a3997289..9a4474dc9e723eb45a159ab7395d01bba7033d16 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/views/createapp/components/types.ts b/src/views/createapp/components/types.ts index e80c3b4df5b17267d080800b073e4a0968ad2478..b66bfee0cfa861fe823ce608dcc21bfe1a9b239a 100644 --- a/src/views/createapp/components/types.ts +++ b/src/views/createapp/components/types.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/views/dialogue/constants.ts b/src/views/dialogue/constants.ts index 6b25d81688c874c316f4c119da7a884549aa7621..2836a40b14ac15db9198da9317bb454874a9fa1d 100644 --- a/src/views/dialogue/constants.ts +++ b/src/views/dialogue/constants.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/views/dialogue/types.ts b/src/views/dialogue/types.ts index 8ede5f9ad24fd11d071c81f06b4907a9f523110e..2789fff90ce060dd09246bda74561f31670cc287 100644 --- a/src/views/dialogue/types.ts +++ b/src/views/dialogue/types.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/vite.config.ts b/vite.config.ts index 179aadd2b4a2d4141fa5e5bb1e98bbaa0f3da556..4e3ead95b625ea961423b28b8423df61285a4f08 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,4 @@ -// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved. // licensed under the Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -7,57 +7,58 @@ // IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR // PURPOSE. // See the Mulan PSL v2 for more details. -import { defineConfig, loadEnv } from "vite"; -import vue from "@vitejs/plugin-vue"; -import Qiankun from 'vite-plugin-qiankun' +import { defineConfig, loadEnv } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import Qiankun from 'vite-plugin-qiankun'; -import { resolve } from "path"; -import type { UserConfigExport } from "vite"; +import { resolve } from 'path'; +import type { UserConfigExport } from 'vite'; // import babel from '@rollup/plugin-babel'; // https://vitejs.dev/config/ export default ({ mode }): UserConfigExport => { const env = loadEnv(mode, process.cwd()); - const { - VITE_BASE_URL - } = env - - const baseUrl = mode === 'micro' ? VITE_BASE_URL : './' + const { VITE_BASE_URL } = env; + + const baseUrl = mode === 'micro' ? VITE_BASE_URL : './'; return defineConfig({ base: baseUrl, resolve: { alias: { - "@": resolve(__dirname, "./src"), - src: resolve(__dirname, "./src"), - assets: resolve(__dirname, "./src/assets"), - components: resolve(__dirname, "./src/components"), + '@': resolve(__dirname, './src'), + src: resolve(__dirname, './src'), + assets: resolve(__dirname, './src/assets'), + components: resolve(__dirname, './src/components'), }, }, plugins: [ vue(), - Qiankun("copilot", { - useDevMode: mode === 'development' - }) + Qiankun('copilot', { + useDevMode: mode === 'development', + }), ], build: { rollupOptions: { output: { manualChunks(id) { if (/\/opendesign2\/themes\/es\/(.*?)\//.test(id)) { - return "opendesign2"; + return 'opendesign2'; } if (/\/opendesign-icons\/themes\/es\/(.*?)\//.test(id)) { - return "opendesign-icons"; + return 'opendesign-icons'; } - if (/\/element-plus\/es\/components\/(.*?)\/(.*)\/?style/.test(id)) { - return "element-plus"; + if ( + /\/element-plus\/es\/components\/(.*?)\/(.*)\/?style/.test(id) + ) { + return 'element-plus'; } }, chunkFileNames: (chunkInfo: any) => { const faceadeModuleId = chunkInfo.faceadeModuleId - ? chunkInfo.faceadeModuleId.split("/") + ? chunkInfo.faceadeModuleId.split('/') : []; - const fileName = faceadeModuleId[faceadeModuleId.length - 2] || "[name]"; + const fileName = + faceadeModuleId[faceadeModuleId.length - 2] || '[name]'; return `assets/${fileName}.[hash].js`; }, }, @@ -65,20 +66,20 @@ export default ({ mode }): UserConfigExport => { }, server: { - host: "localhost", + host: 'localhost', hmr: true, port: 3000, origin: 'http://localhost:3000', headers: { - "Access-Control-Allow-Origin": "*", + 'Access-Control-Allow-Origin': '*', }, proxy: { - "/api": { + '/api': { target: env.VITE_BASE_PROXY_URL, changeOrigin: true, ws: false, rewrite: (path: string) => path, - cookieDomainRewrite: '.euler-copilot-master.test.osinfra.cn' + cookieDomainRewrite: '.euler-copilot-master.test.osinfra.cn', }, }, },