更新运行时资源查找路径
This commit is contained in:
@@ -59,9 +59,8 @@ export function getPlaywrightChromiumPath(): string | undefined {
|
|||||||
const runtimePath = getRuntimeBundlePath('playwright');
|
const runtimePath = getRuntimeBundlePath('playwright');
|
||||||
const basePaths = [
|
const basePaths = [
|
||||||
runtimePath,
|
runtimePath,
|
||||||
path.join(process.resourcesPath || app.getAppPath(), 'extra/common/playwright'),
|
path.join(app.getAppPath(), 'packaging/vendor/playwright'),
|
||||||
path.join(app.getAppPath(), 'resources/extra/common/playwright'),
|
path.join(process.cwd(), 'packaging/vendor/playwright'),
|
||||||
path.join(app.getAppPath(), 'electron/resources/extra/common/playwright'),
|
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
const chromiumVersions = ['chromium-1200'];
|
const chromiumVersions = ['chromium-1200'];
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ export function isDevelopment(): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 🔧 修复:不硬编码项目文件夹名,改用检查开发目录结构是否存在
|
// 🔧 修复:不硬编码项目文件夹名,改用检查开发目录结构是否存在
|
||||||
// 开发环境特征:项目根目录有 electron/resources/extra 目录
|
// 开发环境特征:项目根目录有 packaging/resources 目录
|
||||||
const devResourcePath = path.join(appRoot, 'electron', 'resources', 'extra');
|
const devResourcePath = path.join(appRoot, 'packaging', 'resources');
|
||||||
if (fs.existsSync(devResourcePath)) {
|
if (fs.existsSync(devResourcePath)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
const legacyDevResourcePath = path.join(appRoot, 'electron', 'resources', 'extra');
|
||||||
|
if (fs.existsSync(legacyDevResourcePath)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// 回退:检查旧的文件夹名(兼容)
|
// 回退:检查旧的文件夹名(兼容)
|
||||||
return appRoot.includes('aigcpanel-main');
|
return appRoot.includes('aigcpanel-main');
|
||||||
}
|
}
|
||||||
@@ -35,8 +39,12 @@ export function getResourceRoot(): string {
|
|||||||
const isDev = isDevelopment();
|
const isDev = isDevelopment();
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
// 开发环境:项目根目录/electron/resources/extra
|
// 开发环境:项目根目录/packaging/resources
|
||||||
const appRoot = process.env.APP_ROOT || process.cwd();
|
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');
|
return path.join(appRoot, 'electron', 'resources', 'extra');
|
||||||
} else {
|
} else {
|
||||||
// 生产环境:使用 process.resourcesPath 获取 resources 目录
|
// 生产环境:使用 process.resourcesPath 获取 resources 目录
|
||||||
@@ -142,6 +150,10 @@ export function getPythonExecutablePath(): string {
|
|||||||
if (fs.existsSync(runtimePath)) {
|
if (fs.existsSync(runtimePath)) {
|
||||||
return 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));
|
return getCommonResourcePath(path.join('python', pythonFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +172,11 @@ export function getFFmpegExecutablePath(): string {
|
|||||||
return runtimePath;
|
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);
|
return getPlatformResourcePath(ffmpegFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +195,11 @@ export function getFFprobeExecutablePath(): string {
|
|||||||
return runtimePath;
|
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);
|
return getPlatformResourcePath(ffprobeFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +212,10 @@ export function getModelPath(modelFileName: string): string {
|
|||||||
if (fs.existsSync(runtimePath)) {
|
if (fs.existsSync(runtimePath)) {
|
||||||
return 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));
|
return getCommonResourcePath(path.join('models', modelFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ export async function copyPreCacheFromResources(): Promise<boolean> {
|
|||||||
path.join(app.getAppPath(), 'voice-preview-cache'),
|
path.join(app.getAppPath(), 'voice-preview-cache'),
|
||||||
path.join(app.getAppPath().replace(/\.asar$/, '.asar.unpacked'), 'voice-preview-cache'),
|
path.join(app.getAppPath().replace(/\.asar$/, '.asar.unpacked'), 'voice-preview-cache'),
|
||||||
// 开发环境
|
// 开发环境
|
||||||
path.join(process.cwd(), 'electron/resources/voice-preview-cache'),
|
path.join(process.cwd(), 'packaging/resources/voice-preview-cache'),
|
||||||
// 备选路径
|
// 备选路径
|
||||||
path.join(process.resourcesPath, 'voice-preview-cache'),
|
path.join(process.resourcesPath, 'voice-preview-cache'),
|
||||||
path.join(process.resourcesPath, '../voice-preview-cache'),
|
path.join(process.resourcesPath, '../voice-preview-cache'),
|
||||||
|
|||||||
@@ -144,8 +144,12 @@ function getZitiDir(): string {
|
|||||||
console.warn('[FontManager] 所有 ziti 路径都不存在,返回默认路径');
|
console.warn('[FontManager] 所有 ziti 路径都不存在,返回默认路径');
|
||||||
return path.join(fallbackRoot, 'resources-bundles', 'ziti');
|
return path.join(fallbackRoot, 'resources-bundles', 'ziti');
|
||||||
} else {
|
} else {
|
||||||
// 开发环境:ziti 在项目根目录
|
// 开发环境:ziti 在 packaging/vendor/ziti
|
||||||
const appRoot = getAppRoot();
|
const appRoot = getAppRoot();
|
||||||
|
const devZitiDir = path.join(appRoot, 'packaging', 'vendor', 'ziti');
|
||||||
|
if (fs.existsSync(devZitiDir)) {
|
||||||
|
return devZitiDir;
|
||||||
|
}
|
||||||
return path.join(appRoot, 'ziti');
|
return path.join(appRoot, 'ziti');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +255,11 @@ function scanZitiFonts(): any[] {
|
|||||||
*/
|
*/
|
||||||
function getBundledFonts(): any[] {
|
function getBundledFonts(): any[] {
|
||||||
const appRoot = getAppRoot();
|
const appRoot = getAppRoot();
|
||||||
const metadataFile = path.join(appRoot, 'fonts', 'bundled', 'fonts_metadata.json');
|
const metadataCandidates = [
|
||||||
|
path.join(appRoot, 'packaging', 'vendor', 'fonts', 'bundled', 'fonts_metadata.json'),
|
||||||
|
path.join(appRoot, 'fonts', 'bundled', 'fonts_metadata.json'),
|
||||||
|
];
|
||||||
|
const metadataFile = metadataCandidates.find(file => fs.existsSync(file)) || metadataCandidates[0];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!fs.existsSync(metadataFile)) {
|
if (!fs.existsSync(metadataFile)) {
|
||||||
@@ -554,6 +562,9 @@ function getBundledFontDirs(): string[] {
|
|||||||
pushIfExists(path.join(bundleRoot, 'fonts', 'ziti'));
|
pushIfExists(path.join(bundleRoot, 'fonts', 'ziti'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pushIfExists(path.join(appRoot, 'packaging', 'vendor', 'ziti'));
|
||||||
|
pushIfExists(path.join(appRoot, 'packaging', 'vendor', 'fonts'));
|
||||||
|
pushIfExists(path.join(appRoot, 'packaging', 'vendor', 'fonts', 'ziti'));
|
||||||
pushIfExists(path.join(appRoot, 'ziti'));
|
pushIfExists(path.join(appRoot, 'ziti'));
|
||||||
pushIfExists(path.join(appRoot, 'resources-bundles', 'ziti'));
|
pushIfExists(path.join(appRoot, 'resources-bundles', 'ziti'));
|
||||||
pushIfExists(path.join(appRoot, 'resources-bundles', 'fonts'));
|
pushIfExists(path.join(appRoot, 'resources-bundles', 'fonts'));
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ function getBundledZitiDirs(): string[] {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
|
pushIfExists(path.join(process.env.APP_ROOT || process.cwd(), 'packaging', 'vendor', 'ziti'));
|
||||||
pushIfExists(path.join(process.env.APP_ROOT || process.cwd(), 'ziti'));
|
pushIfExists(path.join(process.env.APP_ROOT || process.cwd(), 'ziti'));
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
@@ -4875,14 +4876,17 @@ ${subtitleText}
|
|||||||
let defaultPath = "";
|
let defaultPath = "";
|
||||||
|
|
||||||
// 尝试查找bgm目录
|
// 尝试查找bgm目录
|
||||||
// 开发环境: 项目根目录/bgm
|
// 开发环境: packaging/vendor/bgm
|
||||||
// 生产环境: resources/app.asar.unpacked/bgm (由asarUnpack解压)
|
// 生产环境: resources-bundles/bgm
|
||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
|
path.join(process.cwd(), 'packaging', 'vendor', 'bgm'),
|
||||||
|
AppEnv.resourceBundleRoot ? path.join(AppEnv.resourceBundleRoot, 'bgm') : '',
|
||||||
|
path.join(process.cwd(), 'resources-bundles', 'bgm'),
|
||||||
path.join(process.cwd(), 'bgm'),
|
path.join(process.cwd(), 'bgm'),
|
||||||
path.join(process.resourcesPath, 'app.asar.unpacked', 'bgm'),
|
path.join(process.resourcesPath, 'app.asar.unpacked', 'bgm'),
|
||||||
path.join(process.resourcesPath, 'bgm'),
|
path.join(process.resourcesPath, 'bgm'),
|
||||||
path.join(app.getAppPath(), 'bgm')
|
path.join(app.getAppPath(), 'bgm')
|
||||||
];
|
].filter(Boolean);
|
||||||
|
|
||||||
for (const p of possiblePaths) {
|
for (const p of possiblePaths) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { app } from 'electron';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 音效 ID 到文件名的映射
|
* 音效 ID 到文件名的映射
|
||||||
* 这些音效文件存储在 resources/extra/common/soundEffects/ 目录下
|
* 这些音效文件存储在 packaging/resources/common/soundEffects/ 目录下
|
||||||
*/
|
*/
|
||||||
export const SOUND_EFFECT_FILES: Record<string, string> = {
|
export const SOUND_EFFECT_FILES: Record<string, string> = {
|
||||||
// 原有音效
|
// 原有音效
|
||||||
@@ -81,7 +81,7 @@ export function getSoundEffectsDir(): string {
|
|||||||
const isDev = !app.isPackaged;
|
const isDev = !app.isPackaged;
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
// 开发模式:使用 app.getAppPath() 获取项目根目录
|
// 开发模式:使用 app.getAppPath() 获取项目根目录
|
||||||
return path.join(app.getAppPath(), 'electron/resources/extra/common/soundEffects');
|
return path.join(app.getAppPath(), 'packaging/resources/common/soundEffects');
|
||||||
} else {
|
} else {
|
||||||
// 生产模式:使用 process.resourcesPath
|
// 生产模式:使用 process.resourcesPath
|
||||||
return path.join(process.resourcesPath, 'extra/common/soundEffects');
|
return path.join(process.resourcesPath, 'extra/common/soundEffects');
|
||||||
|
|||||||
@@ -161,10 +161,10 @@
|
|||||||
<a-card :title="t('字体目录')" :bordered="false">
|
<a-card :title="t('字体目录')" :bordered="false">
|
||||||
<a-descriptions :column="1" bordered>
|
<a-descriptions :column="1" bordered>
|
||||||
<a-descriptions-item :label="t('预置字体目录')">
|
<a-descriptions-item :label="t('预置字体目录')">
|
||||||
<code class="text-xs">fonts/bundled/</code>
|
<code class="text-xs">packaging/vendor/fonts/bundled/</code>
|
||||||
</a-descriptions-item>
|
</a-descriptions-item>
|
||||||
<a-descriptions-item :label="t('ziti字体目录')">
|
<a-descriptions-item :label="t('ziti字体目录')">
|
||||||
<code class="text-xs">ziti/</code>
|
<code class="text-xs">packaging/vendor/ziti/</code>
|
||||||
<a-button size="mini" type="text" @click="openZitiDir" class="ml-2">
|
<a-button size="mini" type="text" @click="openZitiDir" class="ml-2">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<icon-folder />
|
<icon-folder />
|
||||||
@@ -429,7 +429,7 @@ const openFontDir = async () => {
|
|||||||
const openZitiDir = async () => {
|
const openZitiDir = async () => {
|
||||||
try {
|
try {
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const zitiPath = path.join(process.cwd(), 'ziti');
|
const zitiPath = path.join(process.cwd(), 'packaging', 'vendor', 'ziti');
|
||||||
console.log('打开 ziti 目录:', zitiPath);
|
console.log('打开 ziti 目录:', zitiPath);
|
||||||
|
|
||||||
// 🔧 使用 $mapi 代替直接 require('electron')
|
// 🔧 使用 $mapi 代替直接 require('electron')
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ const handleOpenConfigPath = async () => {
|
|||||||
<div class="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4">
|
<div class="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4">
|
||||||
<p class="font-semibold text-sm mb-2">{{ t('配置文件位置') }}</p>
|
<p class="font-semibold text-sm mb-2">{{ t('配置文件位置') }}</p>
|
||||||
<div class="text-xs bg-gray-200 dark:bg-gray-800 rounded p-2 font-mono break-all">
|
<div class="text-xs bg-gray-200 dark:bg-gray-800 rounded p-2 font-mono break-all">
|
||||||
electron/resources/extra/common/config/system-templates.json
|
packaging/resources/common/config/system-templates.json
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-gray-600 dark:text-gray-400 mt-2">
|
<p class="text-xs text-gray-600 dark:text-gray-400 mt-2">
|
||||||
此文件在应用打包时会被包含,所有系统模板都会被初始化。
|
此文件在应用打包时会被包含,所有系统模板都会被初始化。
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import systemTemplatesConfig from '../../electron/resources/extra/common/config/system-templates.json';
|
import systemTemplatesConfig from '../../packaging/resources/common/config/system-templates.json';
|
||||||
|
|
||||||
const rawSystemTemplates = Array.isArray(systemTemplatesConfig?.subtitleTemplates)
|
const rawSystemTemplates = Array.isArray(systemTemplatesConfig?.subtitleTemplates)
|
||||||
? systemTemplatesConfig.subtitleTemplates
|
? systemTemplatesConfig.subtitleTemplates
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ export class ZimuShengcheng {
|
|||||||
|
|
||||||
// 鑾峰彇璧勬簮璺緞
|
// 鑾峰彇璧勬簮璺緞
|
||||||
const path = await import('path');
|
const path = await import('path');
|
||||||
let resourcesPath = path.join(process.cwd(), 'electron/resources/extra');
|
let resourcesPath = path.join(process.cwd(), 'packaging/resources');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
Reference in New Issue
Block a user