feat: 1.统一右侧抽屉关闭按钮布局 2.统一 UI 组件为 Ant Design 移除 radix-ui、floating-ui 组件 3. 修复 ESLint 文件格式错误的问题

This commit is contained in:
zhanjunhao
2026-11-10 14:08:10 +08:00
parent 5713d541b0
commit d224d5b6fa
202 changed files with 29195 additions and 12732 deletions
+22 -7
View File
@@ -20,7 +20,9 @@ const BATCH_DIR = path.join(__dirname, 'kt_batches');
const OUT_DIR = path.join(__dirname, 'kt_out');
const LANGS = require('./i18n_langs.cjs');
const manifest = JSON.parse(fs.readFileSync(path.join(BATCH_DIR, '_manifest.json'), 'utf8'));
const manifest = JSON.parse(
fs.readFileSync(path.join(BATCH_DIR, '_manifest.json'), 'utf8'),
);
// kt_out/ 按批次号对位,换一组语种重切批次后,旧语种的 {lng}_NNN.json 仍留在目录里,
// 却对应的是上一轮的批次内容;若靠长度校验兜底,同长批次会被静默错位回填。
// 这里要求本次语种必须属于当前批次清单的语种(旧清单无 langs 字段时按 ko,th)。
@@ -33,11 +35,13 @@ if (foreign.length) {
process.exit(1);
}
const enKeys = Object.keys(
JSON.parse(fs.readFileSync(path.join(LOCALES_DIR, 'en.json'), 'utf8')).translation,
JSON.parse(fs.readFileSync(path.join(LOCALES_DIR, 'en.json'), 'utf8'))
.translation,
);
const PH = /\{\{[^}]*\}\}/g;
const placeholders = (s) => new Set((String(s).match(PH) || []).map((x) => x.replace(/\s+/g, '')));
const placeholders = (s) =>
new Set((String(s).match(PH) || []).map((x) => x.replace(/\s+/g, '')));
let hardFail = false;
@@ -54,7 +58,9 @@ for (const lng of LANGS) {
for (const b of manifest.batches) {
const idx = b.file.match(/batch_(\d+)\.json/)[1];
const batch = JSON.parse(fs.readFileSync(path.join(BATCH_DIR, b.file), 'utf8'));
const batch = JSON.parse(
fs.readFileSync(path.join(BATCH_DIR, b.file), 'utf8'),
);
const outFile = path.join(OUT_DIR, `${lng}_${idx}.json`);
if (!fs.existsSync(outFile)) continue;
@@ -69,7 +75,10 @@ for (const lng of LANGS) {
batch.forEach((item, i) => {
const v = typeof vals[i] === 'string' ? vals[i] : '';
if (!v) return;
const allowed = new Set([...placeholders(item.zh), ...placeholders(item.en)]);
const allowed = new Set([
...placeholders(item.zh),
...placeholders(item.en),
]);
const unknown = [...placeholders(v)].filter((x) => !allowed.has(x));
if (unknown.length) {
problems.push(
@@ -92,7 +101,9 @@ for (const lng of LANGS) {
if (!v) continue;
if (k.startsWith('_')) continue; // "_" 前缀留给文件内注释
if (!enKeys.includes(k)) {
console.error(`[${lng}] 覆盖项 ${JSON.stringify(k)} 不在 en.json 中,已跳过`);
console.error(
`[${lng}] 覆盖项 ${JSON.stringify(k)} 不在 en.json 中,已跳过`,
);
hardFail = true;
continue;
}
@@ -110,7 +121,11 @@ for (const lng of LANGS) {
Object.keys(ordered).length === enKeys.length &&
Object.keys(ordered).every((k, i) => k === enKeys[i]);
fs.writeFileSync(localePath, JSON.stringify({ translation: ordered }, null, 2) + '\n', 'utf8');
fs.writeFileSync(
localePath,
JSON.stringify({ translation: ordered }, null, 2) + '\n',
'utf8',
);
console.log(
`[${lng}] keys=${enKeys.length} 已译=${filled} (原有${baseCount} + 新增${added} + 覆盖${overridden}) 待译=${enKeys.length - filled} key与en一一对应=${okKeys ? 'YES' : 'NO'}`,