fix: 修复登录报错key问题

This commit is contained in:
电摇小子
2026-07-14 11:07:35 +08:00
parent aebf56b3f7
commit eaf8e9b07d
11 changed files with 215 additions and 77 deletions
+35
View File
@@ -0,0 +1,35 @@
import { app } from 'electron'
import { existsSync } from 'fs'
import { dirname, join } from 'path'
function unique(values: string[]): string[] {
return Array.from(new Set(values.filter(Boolean)))
}
export function getResourceRoots(): string[] {
const appPath = app.getAppPath()
const appPathDir = dirname(appPath)
const execDir = dirname(process.execPath)
return unique([
process.env.WECHATEXPLORER_RESOURCES_PATH || '',
join(process.cwd(), 'resources'),
join(process.cwd(), 'resources', 'resources'),
join(process.resourcesPath || '', 'resources'),
process.resourcesPath || '',
join(appPath, 'resources'),
join(appPathDir, 'resources'),
appPathDir,
join(execDir, 'resources'),
join(dirname(execDir), 'Resources', 'resources'),
join(dirname(execDir), 'Resources')
]).filter((root) => existsSync(root))
}
export function getResourceCandidates(relativePath: string): string[] {
return unique(getResourceRoots().map((root) => join(root, relativePath)))
}
export function findResource(relativePath: string): string | null {
return getResourceCandidates(relativePath).find((candidate) => existsSync(candidate)) || null
}