From 75a24bc9ab957ddf4889779f5e5db14fec4dad8d Mon Sep 17 00:00:00 2001 From: Hu Gang <18768366022@163.com> Date: Mon, 14 Apr 2025 09:23:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=8C=BA=E5=88=86web=E7=AB=AF?= =?UTF-8?q?=E5=92=8C=E5=AE=A2=E6=88=B7=E7=AB=AF=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 4 +++- src/utils/electron.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/router/index.ts b/src/router/index.ts index e9d2db1e..e9124f97 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -11,6 +11,7 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'; import NotFoundComponent from '@/views/404.vue'; import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; import { dynamicRoutes } from './route'; +import { isElectron } from '@/utils/electron'; const staticRoutes: Array = [ { @@ -74,7 +75,8 @@ const staticRoutes: Array = [ }, ]; -const routes = [...staticRoutes, ...dynamicRoutes]; +const dynamic = isElectron ? dynamicRoutes : []; +const routes = [...staticRoutes, ...dynamic]; const router = createRouter({ history: createWebHashHistory( diff --git a/src/utils/electron.ts b/src/utils/electron.ts index 5bc4da72..a72d74e5 100644 --- a/src/utils/electron.ts +++ b/src/utils/electron.ts @@ -9,6 +9,7 @@ export const electronProcess = window.eulercopilot ? window.eulercopilot.process : undefined; +export const isElectron = !!electronProcess; // 为了向后兼容,设置window.electronProcess if (window.eulercopilot && !window.electronProcess) { window.electronProcess = window.eulercopilot.process; -- Gitee From 678284287401897fddea5b2d9b5134b0f2f7b353 Mon Sep 17 00:00:00 2001 From: Hu Gang <18768366022@163.com> Date: Mon, 14 Apr 2025 09:37:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E5=AF=B9=E8=AF=9Dconversation=20id=EF=BC=8C=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=90=AF=E5=8A=A8=E6=B2=A1=E9=85=8D=E7=BD=AE=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=BB=E9=A2=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/index.ts | 5 +++-- src/views/chat/index.vue | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index e33a816e..9d5ae3af 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -22,7 +22,7 @@ interface ICacheConf { theme: 'system' | 'light' | 'dark'; } -const commonCacheConf: Partial = {}; +let commonCacheConf: Partial = {}; const osLocale = processZhLocale( (app.getPreferredSystemLanguages()?.[0] ?? 'en').toLowerCase(), @@ -59,7 +59,7 @@ app.on('activate', () => { async function onReady() { try { await mkdirpIgnoreError(cachePath); - await getUserDefinedConf(commonCacheConfPath); + commonCacheConf = await getUserDefinedConf(commonCacheConfPath); const [nlsConfig, themeConfig] = await Promise.all([ resolveNlsConfiguration(), resolveThemeConfiguration(), @@ -166,6 +166,7 @@ function getUserDefinedConf(dir: string) { if (!fs.existsSync(dir)) { fs.writeFileSync(dir, JSON.stringify({})); } + return JSON.parse(fs.readFileSync(dir, 'utf-8')); } catch (error) { // Ignore error diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index d18af468..f870de06 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -9,6 +9,7 @@ import robotAvatar from '@/assets/svgs/robot.svg'; import { computed, ref, onBeforeMount, onBeforeUnmount, h } from 'vue'; import { fetchStream } from '@/utils/fetchStream'; import marked from '@/utils/marked'; +import { useHistorySessionStore } from '@/store/historySession'; const headerStyles = computed(() => { if (window.eulercopilot.process.platform === 'win32') { @@ -125,13 +126,14 @@ function useConversations() { } function onSend(q: string) { + const { currentSelectedSession } = useHistorySessionStore(); conversations.value.push({ id: `user-${conversations.value.length / 2 + 1}`, content: q, role: 'user', }); isStreaming.value = true; - queryStream(q, '1d190929-910d-49e7-8064-39f3bdbee695'); + queryStream(q, currentSelectedSession); } const markedContent = computed( -- Gitee