feat: 解决了一些问题

This commit is contained in:
cc
2026-01-28 23:04:29 +08:00
parent a215886015
commit 77689ec528
19 changed files with 2032 additions and 454 deletions

39
electron/preload-env.ts Normal file
View File

@@ -0,0 +1,39 @@
import { join, dirname } from 'path'
/**
* 强制将本地资源目录添加到 PATH 最前端,确保优先加载本地 DLL
* 解决系统中存在冲突版本的 DLL 导致的应用崩溃问题
*/
function enforceLocalDllPriority() {
const isDev = !!process.env.VITE_DEV_SERVER_URL
const sep = process.platform === 'win32' ? ';' : ':'
let possiblePaths: string[] = []
if (isDev) {
// 开发环境
possiblePaths.push(join(process.cwd(), 'resources'))
} else {
// 生产环境
possiblePaths.push(dirname(process.execPath))
if (process.resourcesPath) {
possiblePaths.push(process.resourcesPath)
}
}
const dllPaths = possiblePaths.join(sep)
if (process.env.PATH) {
process.env.PATH = dllPaths + sep + process.env.PATH
} else {
process.env.PATH = dllPaths
}
console.log('[WeFlow] Environment PATH updated to enforce local DLL priority:', dllPaths)
}
try {
enforceLocalDllPriority()
} catch (e) {
console.error('[WeFlow] Failed to enforce local DLL priority:', e)
}