稳定测试版

This commit is contained in:
2025-10-28 19:40:13 +08:00
commit 183feef2ea
24 changed files with 11631 additions and 0 deletions

21
main/utils/paths.js Normal file
View File

@@ -0,0 +1,21 @@
// main/utils/paths.js
const path = require('path')
const { fileURLToPath } = require('node:url')
const { app } = require('electron')
function normalizePath(targetPath, baseDir) {
if (typeof targetPath !== 'string' || !targetPath.trim()) throw new Error('无效的路径参数')
if (targetPath.startsWith('file://')) return fileURLToPath(new URL(targetPath))
if (!path.isAbsolute(targetPath)) {
const base = baseDir && typeof baseDir === 'string' ? baseDir : process.cwd()
return path.resolve(base, targetPath)
}
return path.resolve(targetPath)
}
function resolveResource(relPath) {
const base = app.isPackaged ? process.resourcesPath : path.resolve(__dirname, '..')
return path.join(base, relPath)
}
module.exports = { normalizePath, resolveResource }