feat: 1.统一右侧抽屉关闭按钮布局 2.统一 UI 组件为 Ant Design 移除 radix-ui、floating-ui 组件 3. 修复 ESLint 文件格式错误的问题
This commit is contained in:
+174
-21
@@ -23,27 +23,136 @@ const MAX_COUNT = 300;
|
||||
|
||||
// 优先级分层:数字越小越先翻译。一个 key 被多个区域引用时取最小值(最高优先级)。
|
||||
const TIERS = [
|
||||
{ tier: 1, name: '入口/认证', areas: ['components/auth', 'pages/OrgLogin', 'pages/OrgRegister', 'pages/Setup', 'components/setup'] },
|
||||
{ tier: 2, name: '全局外壳', areas: ['components/layout', 'components/common', 'helpers', 'pages/NotFound', 'pages/Forbidden'] },
|
||||
{ tier: 3, name: '个人高频主链路', areas: ['pages/UserCenter', 'pages/KeyManagement', 'pages/Token', 'pages/Recharge', 'pages/TopUp', 'components/topup', 'pages/Home', 'pages/Dashboard', 'pages/Pricing'] },
|
||||
{ tier: 4, name: '核心业务', areas: ['pages/ExperienceCenter', 'pages/CloudBrain', 'pages/SkillMarket', 'pages/Chat', 'pages/Chat2Link', 'pages/Playground', 'pages/ImageGeneration', 'pages/Midjourney', 'components/playground', 'components/image', 'components/skill'] },
|
||||
{ tier: 5, name: '通用交互层', areas: ['hooks', 'components/table', 'components/customer-service', 'pages/Log', 'pages/Task', 'pages/Subscription', 'components/membership', 'pages/Tutorial', 'pages/Docs', 'pages/About', 'pages/PrivacyPolicy', 'pages/UserAgreement', 'pages/Status'] },
|
||||
{ tier: 6, name: '企业侧', areas: ['pages/Organization', 'pages/ExpertPlatform', 'pages/SkillPlatform', 'pages/ExperienceCenterAudit'] },
|
||||
{ tier: 7, name: '管理/运营后台', areas: ['pages/Setting', 'components/settings', 'pages/AdminOrganizations', 'pages/AdminInvoice', 'pages/AdminOrder', 'pages/Channel', 'pages/Model', 'pages/Redemption', 'pages/Monitoring', 'pages/MonitorCenter', 'pages/ServiceDashboard', 'pages/Analytics', 'pages/User', 'components/analytics', 'components/dashboard'] },
|
||||
{ tier: 8, name: '提成/合作伙伴', areas: ['pages/MyCommission', 'pages/PartnerPortal', 'components/promotion'] },
|
||||
{
|
||||
tier: 1,
|
||||
name: '入口/认证',
|
||||
areas: [
|
||||
'components/auth',
|
||||
'pages/OrgLogin',
|
||||
'pages/OrgRegister',
|
||||
'pages/Setup',
|
||||
'components/setup',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 2,
|
||||
name: '全局外壳',
|
||||
areas: [
|
||||
'components/layout',
|
||||
'components/common',
|
||||
'helpers',
|
||||
'pages/NotFound',
|
||||
'pages/Forbidden',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 3,
|
||||
name: '个人高频主链路',
|
||||
areas: [
|
||||
'pages/UserCenter',
|
||||
'pages/KeyManagement',
|
||||
'pages/Token',
|
||||
'pages/Recharge',
|
||||
'pages/TopUp',
|
||||
'components/topup',
|
||||
'pages/Home',
|
||||
'pages/Dashboard',
|
||||
'pages/Pricing',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 4,
|
||||
name: '核心业务',
|
||||
areas: [
|
||||
'pages/ExperienceCenter',
|
||||
'pages/CloudBrain',
|
||||
'pages/SkillMarket',
|
||||
'pages/Chat',
|
||||
'pages/Chat2Link',
|
||||
'pages/Playground',
|
||||
'pages/ImageGeneration',
|
||||
'pages/Midjourney',
|
||||
'components/playground',
|
||||
'components/image',
|
||||
'components/skill',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 5,
|
||||
name: '通用交互层',
|
||||
areas: [
|
||||
'hooks',
|
||||
'components/table',
|
||||
'components/customer-service',
|
||||
'pages/Log',
|
||||
'pages/Task',
|
||||
'pages/Subscription',
|
||||
'components/membership',
|
||||
'pages/Tutorial',
|
||||
'pages/Docs',
|
||||
'pages/About',
|
||||
'pages/PrivacyPolicy',
|
||||
'pages/UserAgreement',
|
||||
'pages/Status',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 6,
|
||||
name: '企业侧',
|
||||
areas: [
|
||||
'pages/Organization',
|
||||
'pages/ExpertPlatform',
|
||||
'pages/SkillPlatform',
|
||||
'pages/ExperienceCenterAudit',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 7,
|
||||
name: '管理/运营后台',
|
||||
areas: [
|
||||
'pages/Setting',
|
||||
'components/settings',
|
||||
'pages/AdminOrganizations',
|
||||
'pages/AdminInvoice',
|
||||
'pages/AdminOrder',
|
||||
'pages/Channel',
|
||||
'pages/Model',
|
||||
'pages/Redemption',
|
||||
'pages/Monitoring',
|
||||
'pages/MonitorCenter',
|
||||
'pages/ServiceDashboard',
|
||||
'pages/Analytics',
|
||||
'pages/User',
|
||||
'components/analytics',
|
||||
'components/dashboard',
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 8,
|
||||
name: '提成/合作伙伴',
|
||||
areas: [
|
||||
'pages/MyCommission',
|
||||
'pages/PartnerPortal',
|
||||
'components/promotion',
|
||||
],
|
||||
},
|
||||
];
|
||||
const TIER_OTHER = 9; // 源码中有引用但未归入上表的区域
|
||||
const TIER_DEAD = 99; // 源码已无引用的历史 key(en.json 里还在,为「一一对应」保留)
|
||||
|
||||
const AREA_TIER = new Map();
|
||||
const TIER_NAME = new Map([[TIER_OTHER, '其他区域'], [TIER_DEAD, '无调用点(历史键)']]);
|
||||
const TIER_NAME = new Map([
|
||||
[TIER_OTHER, '其他区域'],
|
||||
[TIER_DEAD, '无调用点(历史键)'],
|
||||
]);
|
||||
for (const { tier, name, areas } of TIERS) {
|
||||
TIER_NAME.set(tier, name);
|
||||
for (const a of areas) AREA_TIER.set(a, tier);
|
||||
}
|
||||
|
||||
const load = (n) =>
|
||||
JSON.parse(fs.readFileSync(path.join(LOCALES_DIR, `${n}.json`), 'utf8')).translation;
|
||||
JSON.parse(fs.readFileSync(path.join(LOCALES_DIR, `${n}.json`), 'utf8'))
|
||||
.translation;
|
||||
// 已译状态唯一事实源就是 locales/{ko,th}.json 本身;不另存快照文件,避免两份
|
||||
// 数据漂移(快照落后时会把已译 key 重新切进批次,覆盖掉已有译文)。
|
||||
const loadDone = (l) => {
|
||||
@@ -62,7 +171,11 @@ function walk(dir, files = []) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (['node_modules', 'dist'].includes(entry.name) || entry.name.startsWith('.')) continue;
|
||||
if (
|
||||
['node_modules', 'dist'].includes(entry.name) ||
|
||||
entry.name.startsWith('.')
|
||||
)
|
||||
continue;
|
||||
walk(full, files);
|
||||
} else if (/\.(jsx?|tsx?)$/.test(entry.name)) {
|
||||
files.push(full);
|
||||
@@ -72,15 +185,24 @@ function walk(dir, files = []) {
|
||||
}
|
||||
|
||||
const unescape = (raw) =>
|
||||
raw.replace(/\\'/g, "'").replace(/\\"/g, '"').replace(/\\\\/g, '\\').replace(/\\n/g, '\n');
|
||||
raw
|
||||
.replace(/\\'/g, "'")
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/\\\\/g, '\\')
|
||||
.replace(/\\n/g, '\n');
|
||||
|
||||
// 1) 建立 key -> 最高优先级 + 代表区域
|
||||
const keyTier = new Map();
|
||||
const keyArea = new Map();
|
||||
for (const file of walk(SRC_DIR).filter((f) => !f.includes(path.join('src', 'i18n')))) {
|
||||
for (const file of walk(SRC_DIR).filter(
|
||||
(f) => !f.includes(path.join('src', 'i18n')),
|
||||
)) {
|
||||
const content = fs.readFileSync(file, 'utf8');
|
||||
const rel = path.relative(SRC_DIR, file).split(path.sep);
|
||||
const area = rel[0] === 'pages' || rel[0] === 'components' ? `${rel[0]}/${rel[1]}` : rel[0];
|
||||
const area =
|
||||
rel[0] === 'pages' || rel[0] === 'components'
|
||||
? `${rel[0]}/${rel[1]}`
|
||||
: rel[0];
|
||||
const tier = AREA_TIER.get(area) ?? TIER_OTHER;
|
||||
let m;
|
||||
T_CALL_RE.lastIndex = 0;
|
||||
@@ -117,7 +239,11 @@ const flush = () => {
|
||||
if (!batch.length) return;
|
||||
n += 1;
|
||||
const name = `batch_${String(n).padStart(3, '0')}.json`;
|
||||
fs.writeFileSync(path.join(OUT_DIR, name), JSON.stringify(batch, null, 2), 'utf8');
|
||||
fs.writeFileSync(
|
||||
path.join(OUT_DIR, name),
|
||||
JSON.stringify(batch, null, 2),
|
||||
'utf8',
|
||||
);
|
||||
const areas = [...new Set(batch.map((x) => x.area))];
|
||||
manifest.push({
|
||||
file: name,
|
||||
@@ -134,29 +260,56 @@ const flush = () => {
|
||||
for (const { k, tier } of pending) {
|
||||
const zhText = k in zh ? zh[k] || k : k;
|
||||
// 优先级换档必须断批:一批只属于一个层级,进度才能对应到「哪些页面已可用」
|
||||
if (batch.length && (tier !== curTier || used + zhText.length > CHAR_BUDGET || batch.length >= MAX_COUNT)) {
|
||||
if (
|
||||
batch.length &&
|
||||
(tier !== curTier ||
|
||||
used + zhText.length > CHAR_BUDGET ||
|
||||
batch.length >= MAX_COUNT)
|
||||
) {
|
||||
flush();
|
||||
}
|
||||
curTier = tier;
|
||||
// cur:各语种已有译文。批次按「任一语种未译」切,已译的那一侧回填 "" 即保留原值
|
||||
const cur = Object.fromEntries(LANGS.map((l) => [l, done[l][k] || '']));
|
||||
batch.push({ key: k, zh: zhText, en: en[k], cur, area: keyArea.get(k) || '-', tier });
|
||||
batch.push({
|
||||
key: k,
|
||||
zh: zhText,
|
||||
en: en[k],
|
||||
cur,
|
||||
area: keyArea.get(k) || '-',
|
||||
tier,
|
||||
});
|
||||
used += zhText.length;
|
||||
}
|
||||
flush();
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(OUT_DIR, '_manifest.json'),
|
||||
JSON.stringify({ langs: LANGS, totalEnKeys: enKeys.length, pending: pending.length, batches: manifest }, null, 2),
|
||||
JSON.stringify(
|
||||
{
|
||||
langs: LANGS,
|
||||
totalEnKeys: enKeys.length,
|
||||
pending: pending.length,
|
||||
batches: manifest,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
const perTier = new Map();
|
||||
for (const { tier } of pending) perTier.set(tier, (perTier.get(tier) || 0) + 1);
|
||||
const doneSummary = LANGS.map((l) => `${l}已译 ${enKeys.filter((k) => done[l][k]).length}`).join(' / ');
|
||||
console.log(`en 全集 ${enKeys.length} | ${doneSummary} | 待译(任一语种缺) ${pending.length} | 切成 ${n} 批`);
|
||||
const doneSummary = LANGS.map(
|
||||
(l) => `${l}已译 ${enKeys.filter((k) => done[l][k]).length}`,
|
||||
).join(' / ');
|
||||
console.log(
|
||||
`en 全集 ${enKeys.length} | ${doneSummary} | 待译(任一语种缺) ${pending.length} | 切成 ${n} 批`,
|
||||
);
|
||||
console.log('待译量按优先级:');
|
||||
for (const [tier, cnt] of [...perTier.entries()].sort((a, b) => a[0] - b[0])) {
|
||||
const bs = manifest.filter((b) => b.tier === tier).length;
|
||||
console.log(` T${String(tier).padStart(2)} ${String(TIER_NAME.get(tier)).padEnd(16)} ${String(cnt).padStart(5)} 条 / ${String(bs).padStart(2)} 批`);
|
||||
console.log(
|
||||
` T${String(tier).padStart(2)} ${String(TIER_NAME.get(tier)).padEnd(16)} ${String(cnt).padStart(5)} 条 / ${String(bs).padStart(2)} 批`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user