Files
pangolin/web/usercenter/components/shared.tsx
T
wangjia 8c14913275
Deploy Site / deploy-site (push) Successful in 1m45s
Deploy Client / build-windows (push) Successful in 1m58s
Deploy Client / build-android (push) Successful in 2m10s
Deploy Client / build-macos (push) Successful in 4m2s
Deploy Client / build-ios (push) Successful in 3m40s
Deploy Client / release-deploy (push) Successful in 2m2s
feat(usercenter/i18n): 6 语(加 日/韩/俄/西)+ 默认英文
- lib/i18n.ts: Lang/Entry 扩 6 语;STRINGS 130 条补 ja/ko/ru/es;makeT 回退英文
- lib/api/errors.ts: ERROR_TEXT 14 条补 4 语;bilingual 改为 code 本地字典优先
  → 英文字典 → 后端 message → 通用兜底
- lib/theme.tsx: 默认语种 zh→en;localStorage 白名单扩 6 语;setAttribute('lang') 直用 lang
- components/shared.tsx: LangSeg 段控 → 原生 select 6 语下拉
- app/layout.tsx: 默认壳 html lang zh→en;title/desc 改英文
- next build 通过(5 页静态);tsc 干净;无红线词

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
2026-07-07 13:31:38 +08:00

54 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// shared.tsx — 公共样式常量与原子(承袭 ucapp.jsx 的 ucCard / ucInput / UCLang
import React from 'react';
import type { Lang } from '../lib/i18n';
export const card: React.CSSProperties = {
background: 'var(--surface)',
border: '1px solid var(--border)',
borderRadius: 'var(--radius-xl)',
boxShadow: 'var(--shadow-sm)',
};
export const input: React.CSSProperties = {
border: '1.5px solid var(--border-strong)',
borderRadius: 'var(--radius-md)',
padding: '12px 14px',
fontFamily: 'var(--font-sans)',
fontSize: 14.5,
color: 'var(--fg1)',
background: 'var(--surface)',
outline: 'none',
width: '100%',
boxSizing: 'border-box',
};
export function LangSeg({ lang, setLang }: { lang: Lang; setLang: (l: Lang) => void }) {
// 6 语言用原生下拉(段控横排会挤)。默认 en。
const langs: [Lang, string][] = [
['en', 'English'], ['zh', '中文'], ['ja', '日本語'],
['ko', '한국어'], ['ru', 'Русский'], ['es', 'Español'],
];
return (
<select
value={lang}
onChange={(e) => setLang(e.target.value as Lang)}
aria-label="Language"
style={{
border: '1px solid var(--border)',
cursor: 'pointer',
borderRadius: 999,
padding: '5px 9px',
fontFamily: 'var(--font-sans)',
fontSize: 12.5,
fontWeight: 700,
background: 'var(--bg-subtle)',
color: 'var(--fg2)',
}}
>
{langs.map(([v, l]) => (
<option key={v} value={v}>{l}</option>
))}
</select>
);
}