Skip to content

Commit 7658c81

Browse files
committed
fix(misc): vite base 动态导入 504 / 流式路径正则 / mcpEnv 转义 / AuthGuard 依赖修正
- vite.config base 仅 Electron 构建产物用 ./,dev 模式保持 /(修复预构建依赖 504 动态导入失败) - streamHandler 流式路径白名单正则去转义冗余 - mcpEnv Windows 注册表读取转义修正 - AuthGuard useEffect 依赖数组修正 - framer-motion 12.42.2→12.43.0(修复 React 18.3 ref 警告 issue 3745)
1 parent 8f86127 commit 7658c81

6 files changed

Lines changed: 25 additions & 16 deletions

File tree

‎client/electron/ai/streamHandler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function registerStreamHandler(): void {
5858

5959
// CL-M1: API 路径白名单校验——method 实为路径,直接拼入 URL 可访问
6060
// 网关任意端点(含 ?/# 注入参数);仅允许受信任的 AI 功能路径
61-
const VALID_STREAM_PATH = /^\/api\/v1\/(ai|multimodal)\/[A-Za-z0-9_\/-]+$/;
61+
const VALID_STREAM_PATH = /^\/api\/v1\/(ai|multimodal)\/[A-Za-z0-9_/-]+$/;
6262
if (
6363
typeof method !== 'string' ||
6464
method.includes('?') ||

‎client/electron/mcpEnv.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function readWindowsRegistryEnv(): Record<string, string> {
6565
const output = execSync(
6666
'powershell -NoProfile -Command "' +
6767
'$e = [Environment]::GetEnvironmentVariables();' +
68-
'foreach ($k in $e.Keys) { Write-Output \"$k=$($e[$k])\" }"',
68+
'foreach ($k in $e.Keys) { Write-Output "$k=$($e[$k])" }"',
6969
{
7070
encoding: 'utf-8',
7171
timeout: 10000,

‎client/package-lock.json‎

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎client/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "tsc -b && vite build",
1313
"lint": "oxlint",
1414
"preview": "vite preview",
15-
"electron:dev": "concurrently -k -n vite,electron \"cross-env ELECTRON_BUILD=1 vite --mode test\" \"wait-on http://localhost:5173 && tsc -p electron/tsconfig.json && cross-env ELECTRON_BUILD=1 NODE_ENV=development NODE_OPTIONS=--use-system-ca electron .\"",
15+
"electron:dev": "concurrently -k -n vite,electron \"vite --mode test\" \"wait-on http://localhost:5173 && tsc -p electron/tsconfig.json && cross-env ELECTRON_BUILD=1 NODE_ENV=development NODE_OPTIONS=--use-system-ca electron .\"",
1616
"electron:build": "cross-env ELECTRON_BUILD=1 vite build && tsc -p electron/tsconfig.json && electron-builder",
1717
"native:build": "node native/process-audio/build.mjs",
1818
"native:install": "npm --prefix native/process-audio install --no-audit --no-fund",
@@ -66,7 +66,7 @@
6666
"dexie": "^4.4.4",
6767
"dompurify": "^3.4.12",
6868
"electron-updater": "^6.3.9",
69-
"framer-motion": "^12.42.2",
69+
"framer-motion": "^12.43.0",
7070
"lucide-react": "^1.23.0",
7171
"lxgw-wenkai-lite-webfont": "^1.7.0",
7272
"node-edge-tts": "^1.2.10",

‎client/src/lib/auth/AuthGuard.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ export function AuthGuard({ children }: AuthGuardProps) {
5050
if (location.pathname === '/login' || location.pathname === '/register') return;
5151

5252
navigate('/login', { replace: true });
53-
}, [isPlaceholder, loading, isAuthenticated, location.pathname, navigate]);
53+
}, [
54+
loading,
55+
isAuthenticated,
56+
location.pathname,
57+
navigate
58+
]);
5459

5560
return <>{children}</>;
5661
}

‎client/vite.config.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ function electronBuildConfigPlugin(): Plugin {
4848
};
4949
}
5050

51-
export default defineConfig({
52-
base: isElectronBuild ? './' : '/',
51+
export default defineConfig(({ command }) => ({
52+
// base 仅在 Electron 构建产物时使用 './'(file:// 协议加载需要);
53+
// dev 模式必须保持 '/'——否则 Vite 预构建依赖 URL 解析异常,
54+
// 全部 optimizeDeps 产物持续 504,lazy 页面动态导入失败
55+
// (曾因 ELECTRON_BUILD=1 vite --mode test 启动 dev server 触发)
56+
base: isElectronBuild && command === 'build' ? './' : '/',
5357
plugins: [
5458
react(),
5559
// Electron 构建时生成 build-config.json,供主进程运行时读取环境变量
@@ -185,4 +189,4 @@ export default defineConfig({
185189
optimizeDeps: {
186190
exclude: ['electron-updater', 'better-sqlite3', '@automerge/automerge'],
187191
},
188-
})
192+
}))

0 commit comments

Comments
 (0)