diff --git a/frontend/electron/modules/backend.ts b/frontend/electron/modules/backend.ts index abe9bf567..51fda07c7 100644 --- a/frontend/electron/modules/backend.ts +++ b/frontend/electron/modules/backend.ts @@ -135,7 +135,12 @@ export function startBackend(): void { appendBackendLog(`[Backend] Starting from ${cwd}`) appendBackendLog(`[Backend] Command: ${cmd} ${args.join(' ')}`) - const env: Record = { ...process.env, PYTHONUNBUFFERED: '1' } + const env: Record = { + ...process.env, + PYTHONUNBUFFERED: '1', + PYTHONIOENCODING: 'utf-8', + PYTHONUTF8: '1', + } const useDebugConsole = process.platform === 'win32' && shouldOpenDebugConsole() @@ -200,14 +205,15 @@ export function startBackend(): void { detached: process.platform !== 'win32', }) - backendProcess.stdout?.on('data', (data: Buffer) => { - const text = data.toString() + backendProcess.stdout?.setEncoding('utf-8') + backendProcess.stderr?.setEncoding('utf-8') + + backendProcess.stdout?.on('data', (text: string) => { consumeStdoutChunk(text) console.log(`[Backend] ${text.trimEnd()}`) }) - backendProcess.stderr?.on('data', (data: Buffer) => { - const text = data.toString() + backendProcess.stderr?.on('data', (text: string) => { console.error(`[Backend] ${text.trimEnd()}`) consumeStderrChunk(text) }) diff --git a/frontend/package.json b/frontend/package.json index 75ceecaca..a8c611607 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,7 +7,7 @@ "scripts": { "lint": "node scripts/run-eslint.mjs", "lint:fix": "node scripts/run-eslint.mjs --fix", - "dev": "vite", + "dev": "node scripts/dev.mjs", "dev:web": "npx cross-env WEB_ONLY=1 vite", "build": "node scripts/run-build.mjs", "preview": "vite preview", diff --git a/frontend/scripts/dev.mjs b/frontend/scripts/dev.mjs new file mode 100644 index 000000000..7f04ea542 --- /dev/null +++ b/frontend/scripts/dev.mjs @@ -0,0 +1,16 @@ +import { execSync, spawn } from 'node:child_process' +import process from 'node:process' + +if (process.platform === 'win32') { + try { + execSync('chcp 65001', { stdio: 'ignore' }) + } + catch {} +} + +const child = spawn('npx', ['vite'], { + stdio: 'inherit', + shell: true, +}) + +child.on('exit', code => process.exit(code ?? 0)) diff --git a/frontend/src/components/LoginDialog.vue b/frontend/src/components/LoginDialog.vue index 6d1088791..572b78dc5 100644 --- a/frontend/src/components/LoginDialog.vue +++ b/frontend/src/components/LoginDialog.vue @@ -213,7 +213,7 @@ function handleSkip() { trackTelemetry('login_skip', { mode: mode.value, }) - window.open('https://github.com/RTGS2017/NagaAgent.git', '_blank') + emit('skip') } function openForgotPassword() { @@ -314,7 +314,7 @@ const stopWatch = watch(backendConnected, (connected) => { @@ -407,7 +407,7 @@ const stopWatch = watch(backendConnected, (connected) => { diff --git a/frontend/src/views/ConfigView.vue b/frontend/src/views/ConfigView.vue index 03bdee83b..eacb875cc 100644 --- a/frontend/src/views/ConfigView.vue +++ b/frontend/src/views/ConfigView.vue @@ -235,6 +235,27 @@ async function testConnection() {
+ +
+
+ + +
+
+
+ {{ isNagaLoggedIn ? '网关模式' : '本地模式' }} +
+
+ + +
+
+
+ @@ -254,14 +275,21 @@ async function testConnection() {
- - ✓ 已登陆 ({{ nagaUser?.username }}),使用 NagaModel 网关 - - - - ✓ 已登陆 ({{ nagaUser?.username }}),无需输入 - - + + + + @@ -287,31 +315,32 @@ async function testConnection() {
- - ✓ 已登陆,无需填写 - - - - ✓ 已登陆,使用 NagaModel 网关 - - - - ✓ 已登陆,无需输入 - - - - - ✓ 已登陆,无需填写 - - - - ✓ 已登陆,使用 NagaModel 网关 - - - - ✓ 已登陆,无需输入 - - + +
@@ -327,11 +356,15 @@ async function testConnection() {
- - ✓ 已登陆,无需填写 - - -