Files
WYF-koubo/scripts/compare-historical-config.cjs
2026-06-20 18:38:06 +08:00

121 lines
4.0 KiB
JavaScript

const fs = require('fs');
const path = require('path');
// 读取历史配置
const historicalFile = path.join(__dirname, '../electron/config/default-subtitle-templates-v2.json');
const historical = JSON.parse(fs.readFileSync(historicalFile, 'utf-8'));
// 读取当前配置
const currentFile = path.join(__dirname, '../packaging/resources/common/config/system-templates.json');
const current = JSON.parse(fs.readFileSync(currentFile, 'utf-8'));
console.log('=== 历史配置 vs 当前配置对比 ===\n');
const historicalTemplates = historical.subtitleTemplates || [];
const currentTemplates = current.subtitleTemplates || [];
// 按ID匹配模板
const historicalMap = {};
historicalTemplates.forEach(t => {
historicalMap[t.id] = t;
});
const currentMap = {};
currentTemplates.forEach(t => {
currentMap[t.id] = t;
});
// 对比每个模板
['template_system_11', 'template_system_22', 'template_system_33', 'template_system_44',
'template_system_55', 'template_system_66', 'template_system_77', 'template_system_88'].forEach(templateId => {
const hist = historicalMap[templateId];
const curr = currentMap[templateId];
if (!hist || !curr) {
console.log(`模板 ${templateId}: 缺失配置`);
return;
}
console.log(`\n=== 模板 ${hist.name} (${templateId}) ===`);
// 对比关键词组样式
console.log('\n关键词组样式差异:');
const histKeywords = hist.config.keywordGroupsStyles || [];
const currKeywords = curr.config.keywordGroupsStyles || [];
histKeywords.forEach((histKw, idx) => {
const currKw = currKeywords[idx];
if (!currKw) return;
if (histKw.groupName === currKw.groupName) {
const histFont = histKw.styleOverride?.fontName || 'N/A';
const currFont = currKw.styleOverride?.fontName || 'N/A';
const histEffect = histKw.effectId || 'N/A';
const currEffect = currKw.effectId || 'N/A';
const histColor = histKw.color || 'N/A';
const currColor = currKw.color || 'N/A';
if (histFont !== currFont || histEffect !== currEffect || histColor !== currColor) {
console.log(` ${histKw.groupName}:`);
if (histFont !== currFont) {
console.log(` 字体: ${histFont} -> ${currFont}`);
}
if (histEffect !== currEffect) {
console.log(` 特效: ${histEffect} -> ${currEffect}`);
}
if (histColor !== currColor) {
console.log(` 颜色: ${histColor} -> ${currColor}`);
}
}
}
});
// 对比标题字幕配置
console.log('\n标题字幕配置:');
const histTitle = hist.config.titleSubtitleConfig;
const currTitle = curr.config.titleSubtitleConfig;
if (histTitle && currTitle) {
console.log(` 每行字符数: ${histTitle.maxCharsPerLine} (历史) vs ${currTitle.maxCharsPerLine} (当前)`);
console.log(` 行数: ${histTitle.lines.length} (历史) vs ${currTitle.lines.length} (当前)`);
if (histTitle.lines.length === currTitle.lines.length) {
histTitle.lines.forEach((histLine, idx) => {
const currLine = currTitle.lines[idx];
if (currLine) {
if (histLine.fontName !== currLine.fontName || histLine.fontColor !== currLine.fontColor) {
console.log(`${idx + 1}行:`);
if (histLine.fontName !== currLine.fontName) {
console.log(` 字体: ${histLine.fontName} -> ${currLine.fontName}`);
}
if (histLine.fontColor !== currLine.fontColor) {
console.log(` 颜色: ${histLine.fontColor} -> ${currLine.fontColor}`);
}
}
}
});
}
}
});
console.log('\n\n=== 总结 ===');
console.log('历史配置文件中,标题字幕配置:');
console.log('- 模板 11, 33, 55, 77: 8字符/行,2行');
console.log('- 模板 22, 44, 66, 88: 15字符/行,1行');
console.log('\n历史配置文件中,关键词组样式使用 "Noto Serif CJK" 字体');
console.log('当前配置文件中,关键词组样式已更新为不同字体');