Files
ymb-site/src/layouts/components/LanguageFlag.jsx
T
Zhou Weidong ecfbd3b8b5 refactor: 企业级目录重构与播放/关于页体验升级
- 按 app / shared / entities / features 分层,路由懒加载并抽出布局组件
- 请求层改为可插拔拦截器,统一错误类型、超时取消与端点拆分
- 抽取播放器、骨架屏、网格等复用组件,点赞收藏接入统一交互反馈
- 关于页重做为无边框极光风格,补充 iOS / Google Play 下载入口
- 修复播放页滚轮切集吞事件、页面误滚动、后台持续播放与声音记忆问题
- 语言按本地偏好与 IP 识别,国旗改为内联 SVG
- 清理未使用的旧站点文件,补充 ESLint 配置
2026-11-12 12:32:29 +08:00

41 lines
1.7 KiB
React

// Author: fruit.com.cn
// 用内联 SVG 绘制国旗,避免 Windows 等系统不渲染 emoji 国旗
const STAR = 'M0,-1 L0.2245,-0.309 L0.951,-0.309 L0.363,0.118 L0.588,0.809 L0,0.382 L-0.588,0.809 L-0.363,0.118 L-0.951,-0.309 L-0.2245,-0.309 Z';
const FLAGS = {
id: (
<svg viewBox="0 0 3 2" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<rect width="3" height="2" fill="#fff" />
<rect width="3" height="1" fill="#ce1126" />
</svg>
),
en: (
<svg viewBox="0 0 3 2" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<rect width="3" height="2" fill="#fff" />
{[0, 2, 4, 6, 8, 10, 12].map((index) => (
<rect key={index} y={(index * 2) / 13} width="3" height={2 / 13} fill="#b22234" />
))}
<rect width="1.2" height={14 / 13} fill="#3c3b6e" />
{[0, 1, 2, 3, 4].map((row) => (
[0, 1, 2, 3, 4, 5].map((col) => (
<circle key={`${row}-${col}`} cx={0.1 + col * 0.2} cy={0.11 + row * 0.22} r={0.05} fill="#fff" />
))
))}
</svg>
),
zh: (
<svg viewBox="0 0 3 2" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
<rect width="3" height="2" fill="#de2910" />
<path d={STAR} transform="translate(0.5 0.5) scale(0.28)" fill="#ffde00" />
<path d={STAR} transform="translate(1 0.28) scale(0.1)" fill="#ffde00" />
<path d={STAR} transform="translate(1.18 0.5) scale(0.1)" fill="#ffde00" />
<path d={STAR} transform="translate(1.18 0.74) scale(0.1)" fill="#ffde00" />
<path d={STAR} transform="translate(1 0.96) scale(0.1)" fill="#ffde00" />
</svg>
),
};
export function LanguageFlag({ code }) {
return <span className="language-flag">{FLAGS[code] || FLAGS.id}</span>;
}