同步模板维护脚本的资源路径
This commit is contained in:
@@ -2874,5 +2874,5 @@
|
|||||||
"is_system": 1
|
"is_system": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timestamp": "2026-06-16T08:45:31.753Z"
|
"timestamp": "2026-06-20T10:27:18.332Z"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4294,5 +4294,5 @@
|
|||||||
"is_system": 1
|
"is_system": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timestamp": "2026-06-16T08:45:31.753Z"
|
"timestamp": "2026-06-20T10:27:18.332Z"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ console.log('=== 全面分析所有配置源和数据库中的模板差异 ===\n
|
|||||||
// 1. 收集所有配置文件
|
// 1. 收集所有配置文件
|
||||||
const configFiles = [
|
const configFiles = [
|
||||||
{ name: 'C盘根目录', path: 'C:\\system-templates.json' },
|
{ name: 'C盘根目录', path: 'C:\\system-templates.json' },
|
||||||
{ name: '项目打包配置', path: 'electron/resources/extra/common/config/system-templates.json' },
|
{ name: '项目打包配置', path: 'packaging/resources/common/config/system-templates.json' },
|
||||||
{ name: '项目开发配置', path: 'electron/config/system-templates.json' },
|
{ name: '项目开发配置', path: 'electron/config/system-templates.json' },
|
||||||
{ name: '历史配置v2', path: 'electron/config/default-subtitle-templates-v2.json' },
|
{ name: '历史配置v2', path: 'electron/config/default-subtitle-templates-v2.json' },
|
||||||
{ name: 'TypeScript源文件', path: 'src/config/systemSubtitleTemplates.ts' },
|
{ name: 'TypeScript源文件', path: 'src/config/systemSubtitleTemplates.ts' },
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const content = fs.readFileSync('electron/resources/extra/common/config/system-templates.json', 'utf-8');
|
const content = fs.readFileSync('packaging/resources/common/config/system-templates.json', 'utf-8');
|
||||||
const data = JSON.parse(content);
|
const data = JSON.parse(content);
|
||||||
|
|
||||||
console.log('模板数量:', data.subtitleTemplates.length);
|
console.log('模板数量:', data.subtitleTemplates.length);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const path = require('path');
|
|||||||
|
|
||||||
// 读取 C 盘根目录的配置文件
|
// 读取 C 盘根目录的配置文件
|
||||||
const cDriveFile = 'C:\\system-templates.json';
|
const cDriveFile = 'C:\\system-templates.json';
|
||||||
const projectFile = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const projectFile = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
|
|
||||||
console.log('=== 对比 C 盘配置 vs 项目配置 ===\n');
|
console.log('=== 对比 C 盘配置 vs 项目配置 ===\n');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const cDriveFile = 'C:\\system-templates.json';
|
const cDriveFile = 'C:\\system-templates.json';
|
||||||
const projectFile = 'electron/resources/extra/common/config/system-templates.json';
|
const projectFile = 'packaging/resources/common/config/system-templates.json';
|
||||||
|
|
||||||
const cConfig = JSON.parse(fs.readFileSync(cDriveFile, 'utf-8'));
|
const cConfig = JSON.parse(fs.readFileSync(cDriveFile, 'utf-8'));
|
||||||
const pConfig = JSON.parse(fs.readFileSync(projectFile, 'utf-8'));
|
const pConfig = JSON.parse(fs.readFileSync(projectFile, 'utf-8'));
|
||||||
@@ -71,4 +71,3 @@ Object.keys(pGroups).forEach(key => {
|
|||||||
console.log(`模板 ${pGroups[key].join(', ')} 配置相同`);
|
console.log(`模板 ${pGroups[key].join(', ')} 配置相同`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const historicalFile = path.join(__dirname, '../electron/config/default-subtitle
|
|||||||
const historical = JSON.parse(fs.readFileSync(historicalFile, 'utf-8'));
|
const historical = JSON.parse(fs.readFileSync(historicalFile, 'utf-8'));
|
||||||
|
|
||||||
// 读取当前配置
|
// 读取当前配置
|
||||||
const currentFile = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const currentFile = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
const current = JSON.parse(fs.readFileSync(currentFile, 'utf-8'));
|
const current = JSON.parse(fs.readFileSync(currentFile, 'utf-8'));
|
||||||
|
|
||||||
console.log('=== 历史配置 vs 当前配置对比 ===\n');
|
console.log('=== 历史配置 vs 当前配置对比 ===\n');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// 读取 JSON 配置文件
|
// 读取 JSON 配置文件
|
||||||
const jsonFile = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const jsonFile = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
const data = JSON.parse(fs.readFileSync(jsonFile, 'utf-8'));
|
const data = JSON.parse(fs.readFileSync(jsonFile, 'utf-8'));
|
||||||
|
|
||||||
console.log('=== 模板标题字幕配置对比 ===\n');
|
console.log('=== 模板标题字幕配置对比 ===\n');
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ console.log('=== 查找8个模板的不同配置(普通字幕字体、特效
|
|||||||
// 检查所有可能的配置文件
|
// 检查所有可能的配置文件
|
||||||
const filesToCheck = [
|
const filesToCheck = [
|
||||||
{ name: 'default-ipagent-config.json', path: 'electron/config/default-ipagent-config.json' },
|
{ name: 'default-ipagent-config.json', path: 'electron/config/default-ipagent-config.json' },
|
||||||
{ name: 'default-ipagent-config.json (resources)', path: 'electron/resources/extra/common/config/default-ipagent-config.json' },
|
{ name: 'default-ipagent-config.json (resources)', path: 'packaging/resources/common/config/default-ipagent-config.json' },
|
||||||
{ name: 'default-subtitle-templates.json', path: 'electron/config/default-subtitle-templates.json' },
|
{ name: 'default-subtitle-templates.json', path: 'electron/config/default-subtitle-templates.json' },
|
||||||
{ name: 'C盘配置', path: 'C:\\system-templates.json' },
|
{ name: 'C盘配置', path: 'C:\\system-templates.json' },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ console.log('=== 查找8个模板的不同配置 ===\n');
|
|||||||
|
|
||||||
// 检查所有可能的配置文件
|
// 检查所有可能的配置文件
|
||||||
const filesToCheck = [
|
const filesToCheck = [
|
||||||
{ name: 'default-templates.json (subtitleStyles)', path: 'electron/resources/extra/common/config/default-templates.json' },
|
{ name: 'default-templates.json (subtitleStyles)', path: 'packaging/resources/common/config/default-templates.json' },
|
||||||
{ name: 'default-subtitle-templates.json', path: 'electron/config/default-subtitle-templates.json' },
|
{ name: 'default-subtitle-templates.json', path: 'electron/config/default-subtitle-templates.json' },
|
||||||
{ name: 'C盘配置', path: 'C:\\system-templates.json' },
|
{ name: 'C盘配置', path: 'C:\\system-templates.json' },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ console.log('=== 8个模板配置差异全面分析报告 ===\n');
|
|||||||
// 读取所有配置源
|
// 读取所有配置源
|
||||||
const sources = {
|
const sources = {
|
||||||
'C盘根目录': 'C:\\system-templates.json',
|
'C盘根目录': 'C:\\system-templates.json',
|
||||||
'项目打包配置': 'electron/resources/extra/common/config/system-templates.json',
|
'项目打包配置': 'packaging/resources/common/config/system-templates.json',
|
||||||
'项目开发配置': 'electron/config/system-templates.json',
|
'项目开发配置': 'electron/config/system-templates.json',
|
||||||
'历史配置v2': 'electron/config/default-subtitle-templates-v2.json',
|
'历史配置v2': 'electron/config/default-subtitle-templates-v2.json',
|
||||||
'TypeScript源': 'src/config/systemSubtitleTemplates.ts',
|
'TypeScript源': 'src/config/systemSubtitleTemplates.ts',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const configPath = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const configPath = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
|
|
||||||
console.log('📖 读取配置文件:', configPath);
|
console.log('📖 读取配置文件:', configPath);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const configPath = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const configPath = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
|
|
||||||
console.log('📖 读取配置文件:', configPath);
|
console.log('📖 读取配置文件:', configPath);
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ const path = require('path');
|
|||||||
|
|
||||||
const repoRoot = path.join(__dirname, '..');
|
const repoRoot = path.join(__dirname, '..');
|
||||||
const tsSourcePath = path.join(repoRoot, 'src', 'config', 'systemSubtitleTemplates.ts');
|
const tsSourcePath = path.join(repoRoot, 'src', 'config', 'systemSubtitleTemplates.ts');
|
||||||
|
const packagingResourceRoot = path.join(repoRoot, 'packaging', 'resources');
|
||||||
const runtimeDatabasePath = path.join(repoRoot, 'data', 'database.db');
|
const runtimeDatabasePath = path.join(repoRoot, 'data', 'database.db');
|
||||||
const runtimeExportPath = path.join(repoRoot, 'build', 'runtime-system-subtitle-templates.json');
|
const runtimeExportPath = path.join(repoRoot, 'build', 'runtime-system-subtitle-templates.json');
|
||||||
const previewAssetDir = path.join(repoRoot, 'electron', 'resources', 'extra', 'common', 'cover-templates');
|
const previewAssetDir = path.join(packagingResourceRoot, 'common', 'cover-templates');
|
||||||
const packagedPreviewPrefix = 'extra/common/cover-templates';
|
const packagedPreviewPrefix = 'extra/common/cover-templates';
|
||||||
const inlineTemplateIds = new Set([
|
const inlineTemplateIds = new Set([
|
||||||
'template_system_11',
|
'template_system_11',
|
||||||
@@ -27,12 +28,12 @@ const defaultTriggeredSoundConfig = {
|
|||||||
|
|
||||||
const systemTemplateJsonPaths = [
|
const systemTemplateJsonPaths = [
|
||||||
path.join(repoRoot, 'electron', 'config', 'system-templates.json'),
|
path.join(repoRoot, 'electron', 'config', 'system-templates.json'),
|
||||||
path.join(repoRoot, 'electron', 'resources', 'extra', 'common', 'config', 'system-templates.json'),
|
path.join(packagingResourceRoot, 'common', 'config', 'system-templates.json'),
|
||||||
];
|
];
|
||||||
|
|
||||||
const defaultSubtitleTemplateJsonPaths = [
|
const defaultSubtitleTemplateJsonPaths = [
|
||||||
path.join(repoRoot, 'electron', 'config', 'default-subtitle-templates.json'),
|
path.join(repoRoot, 'electron', 'config', 'default-subtitle-templates.json'),
|
||||||
path.join(repoRoot, 'electron', 'resources', 'extra', 'common', 'config', 'default-subtitle-templates.json'),
|
path.join(packagingResourceRoot, 'common', 'config', 'default-subtitle-templates.json'),
|
||||||
];
|
];
|
||||||
|
|
||||||
const isAbsoluteLocalPath = (value) => /^[a-zA-Z]:[\\/]/.test(value) || value.startsWith('\\\\');
|
const isAbsoluteLocalPath = (value) => /^[a-zA-Z]:[\\/]/.test(value) || value.startsWith('\\\\');
|
||||||
@@ -148,6 +149,19 @@ const readTemplatesFromTsSource = () => {
|
|||||||
return templates;
|
return templates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const readTemplatesFromJsonFile = (filePath) => {
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||||
|
const templates = json.subtitleTemplates;
|
||||||
|
if (!Array.isArray(templates) || templates.length !== 16) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return templates;
|
||||||
|
};
|
||||||
|
|
||||||
const readCanonicalTemplates = () => {
|
const readCanonicalTemplates = () => {
|
||||||
const dbTemplates = readTemplatesFromRuntimeDatabase();
|
const dbTemplates = readTemplatesFromRuntimeDatabase();
|
||||||
if (dbTemplates) {
|
if (dbTemplates) {
|
||||||
@@ -157,6 +171,16 @@ const readCanonicalTemplates = () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const filePath of systemTemplateJsonPaths) {
|
||||||
|
const jsonTemplates = readTemplatesFromJsonFile(filePath);
|
||||||
|
if (jsonTemplates) {
|
||||||
|
return {
|
||||||
|
source: filePath,
|
||||||
|
templates: jsonTemplates.map(normalizeTemplateForPackaging),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
source: 'ts-source',
|
source: 'ts-source',
|
||||||
templates: readTemplatesFromTsSource().map(normalizeTemplateForPackaging),
|
templates: readTemplatesFromTsSource().map(normalizeTemplateForPackaging),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const path = require('path');
|
|||||||
|
|
||||||
// 读取 TypeScript 配置文件
|
// 读取 TypeScript 配置文件
|
||||||
const tsFilePath = path.join(__dirname, '../src/config/systemSubtitleTemplates.ts');
|
const tsFilePath = path.join(__dirname, '../src/config/systemSubtitleTemplates.ts');
|
||||||
const jsonFilePath = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const jsonFilePath = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
|
|
||||||
console.log('读取 TypeScript 配置文件:', tsFilePath);
|
console.log('读取 TypeScript 配置文件:', tsFilePath);
|
||||||
const tsContent = fs.readFileSync(tsFilePath, 'utf-8');
|
const tsContent = fs.readFileSync(tsFilePath, 'utf-8');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const jsonFilePath = path.join(__dirname, '../electron/resources/extra/common/config/system-templates.json');
|
const jsonFilePath = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
|
||||||
const data = JSON.parse(fs.readFileSync(jsonFilePath, 'utf-8'));
|
const data = JSON.parse(fs.readFileSync(jsonFilePath, 'utf-8'));
|
||||||
|
|
||||||
console.log('验证字幕模板配置:\n');
|
console.log('验证字幕模板配置:\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user