更新运行时资源查找路径
This commit is contained in:
@@ -59,9 +59,8 @@ export function getPlaywrightChromiumPath(): string | undefined {
|
||||
const runtimePath = getRuntimeBundlePath('playwright');
|
||||
const basePaths = [
|
||||
runtimePath,
|
||||
path.join(process.resourcesPath || app.getAppPath(), 'extra/common/playwright'),
|
||||
path.join(app.getAppPath(), 'resources/extra/common/playwright'),
|
||||
path.join(app.getAppPath(), 'electron/resources/extra/common/playwright'),
|
||||
path.join(app.getAppPath(), 'packaging/vendor/playwright'),
|
||||
path.join(process.cwd(), 'packaging/vendor/playwright'),
|
||||
].filter(Boolean);
|
||||
|
||||
const chromiumVersions = ['chromium-1200'];
|
||||
|
||||
@@ -19,11 +19,15 @@ export function isDevelopment(): boolean {
|
||||
return false;
|
||||
}
|
||||
// 🔧 修复:不硬编码项目文件夹名,改用检查开发目录结构是否存在
|
||||
// 开发环境特征:项目根目录有 electron/resources/extra 目录
|
||||
const devResourcePath = path.join(appRoot, 'electron', 'resources', 'extra');
|
||||
// 开发环境特征:项目根目录有 packaging/resources 目录
|
||||
const devResourcePath = path.join(appRoot, 'packaging', 'resources');
|
||||
if (fs.existsSync(devResourcePath)) {
|
||||
return true;
|
||||
}
|
||||
const legacyDevResourcePath = path.join(appRoot, 'electron', 'resources', 'extra');
|
||||
if (fs.existsSync(legacyDevResourcePath)) {
|
||||
return true;
|
||||
}
|
||||
// 回退:检查旧的文件夹名(兼容)
|
||||
return appRoot.includes('aigcpanel-main');
|
||||
}
|
||||
@@ -35,8 +39,12 @@ export function getResourceRoot(): string {
|
||||
const isDev = isDevelopment();
|
||||
|
||||
if (isDev) {
|
||||
// 开发环境:项目根目录/electron/resources/extra
|
||||
// 开发环境:项目根目录/packaging/resources
|
||||
const appRoot = process.env.APP_ROOT || process.cwd();
|
||||
const devResourcePath = path.join(appRoot, 'packaging', 'resources');
|
||||
if (fs.existsSync(devResourcePath)) {
|
||||
return devResourcePath;
|
||||
}
|
||||
return path.join(appRoot, 'electron', 'resources', 'extra');
|
||||
} else {
|
||||
// 生产环境:使用 process.resourcesPath 获取 resources 目录
|
||||
@@ -142,6 +150,10 @@ export function getPythonExecutablePath(): string {
|
||||
if (fs.existsSync(runtimePath)) {
|
||||
return runtimePath;
|
||||
}
|
||||
const devPath = path.join(process.env.APP_ROOT || process.cwd(), 'packaging', 'vendor', 'python-runtime', pythonFileName);
|
||||
if (fs.existsSync(devPath)) {
|
||||
return devPath;
|
||||
}
|
||||
return getCommonResourcePath(path.join('python', pythonFileName));
|
||||
}
|
||||
|
||||
@@ -160,6 +172,11 @@ export function getFFmpegExecutablePath(): string {
|
||||
return runtimePath;
|
||||
}
|
||||
|
||||
const devPath = path.join(process.env.APP_ROOT || process.cwd(), 'packaging', 'vendor', 'ffmpeg', ffmpegFileName);
|
||||
if (fs.existsSync(devPath)) {
|
||||
return devPath;
|
||||
}
|
||||
|
||||
return getPlatformResourcePath(ffmpegFileName);
|
||||
}
|
||||
|
||||
@@ -178,6 +195,11 @@ export function getFFprobeExecutablePath(): string {
|
||||
return runtimePath;
|
||||
}
|
||||
|
||||
const devPath = path.join(process.env.APP_ROOT || process.cwd(), 'packaging', 'vendor', 'ffmpeg', ffprobeFileName);
|
||||
if (fs.existsSync(devPath)) {
|
||||
return devPath;
|
||||
}
|
||||
|
||||
return getPlatformResourcePath(ffprobeFileName);
|
||||
}
|
||||
|
||||
@@ -190,6 +212,10 @@ export function getModelPath(modelFileName: string): string {
|
||||
if (fs.existsSync(runtimePath)) {
|
||||
return runtimePath;
|
||||
}
|
||||
const devPath = path.join(process.env.APP_ROOT || process.cwd(), 'packaging', 'vendor', 'models', modelFileName);
|
||||
if (fs.existsSync(devPath)) {
|
||||
return devPath;
|
||||
}
|
||||
return getCommonResourcePath(path.join('models', modelFileName));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user