diff --git a/apps/ossheroes/src/components/Navbar.astro b/apps/ossheroes/src/components/Navbar.astro index c2cd70837..16663b235 100644 --- a/apps/ossheroes/src/components/Navbar.astro +++ b/apps/ossheroes/src/components/Navbar.astro @@ -1,5 +1,6 @@ --- -import { LOCALES, localePath, localeUrl, t, type Locale } from '@opensource-win/ui'; +import { localePath, localeUrl, t, type Locale } from '@opensource-win/ui'; +import LangSwitcher from '@opensource-win/ui/LangSwitcher.astro'; import { HEROES_BASE as BASE, SITE_URL } from '../lib/site'; import { getPastYears } from '../lib/ranking'; @@ -15,8 +16,6 @@ const pastYears = getPastYears(); /** 当前语言的榜单首页路径(锚点链接拼接用) */ const home = localePath(locale, `${BASE}/`); const mainSite = localeUrl(SITE_URL, locale, '/'); - -const LANG_LABELS: Record = { en: 'EN', 'zh-CN': '简', 'zh-TW': '繁' }; --- {/* 导航 */} @@ -56,21 +55,9 @@ const LANG_LABELS: Record = { en: 'EN', 'zh-CN': '简', 'zh-TW': - {/* 语言切换:跳转到当前页面对应的其他语言 URL,并记录 localStorage('osw-language') */} - diff --git a/apps/ossheroes/src/styles/global.css b/apps/ossheroes/src/styles/global.css index e31814787..c7838731e 100644 --- a/apps/ossheroes/src/styles/global.css +++ b/apps/ossheroes/src/styles/global.css @@ -642,33 +642,6 @@ a.user-item:hover .nickname { line-height: 1.8; } -/* 导航语言切换:单按钮显示目标语言,与官网首页 #lang-toggle 同款观感 */ -.lang-switch { - padding: 0.5rem; -} -.lang-btn { - display: inline-flex; - align-items: center; - gap: 0.5rem; - background: none; - border: none; - border-radius: 0; - color: var(--osw-muted); - font-family: var(--osw-font); - font-size: 14px; - padding: 0; - cursor: pointer; - white-space: nowrap; - transition: color 0.2s; -} -.lang-btn:hover, -.lang-btn:focus { - color: var(--osw-primary); -} -.lang-btn svg { - width: 1rem; - height: 1rem; -} /* 详情页顶部终端风页面头部:grid 背景 + 径向辉光 + 扫描线 + 描边大字,零图片素材 */ .detail-hero { diff --git a/apps/www/src/components/Home.astro b/apps/www/src/components/Home.astro index df10052e2..42c9bd42e 100644 --- a/apps/www/src/components/Home.astro +++ b/apps/www/src/components/Home.astro @@ -8,7 +8,8 @@ import Typewriter from "./Typewriter.tsx"; import SeoHead from "@opensource-win/ui/SeoHead.astro"; import FooterCredit from "@opensource-win/ui/FooterCredit.astro"; import LangRedirect from "@opensource-win/ui/LangRedirect.astro"; -import { LOCALES, localePath, localeUrl, t, toZhTwDeep, type Locale } from "@opensource-win/ui"; +import LangSwitcher from "@opensource-win/ui/LangSwitcher.astro"; +import { localeUrl, t, toZhTwDeep, type Locale } from "@opensource-win/ui"; import "../styles/global.css"; import heroImg from "../assets/hero_network.jpg"; @@ -40,13 +41,6 @@ const heroesUrl = localeUrl(SITE, locale, "/heroes/"); const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}&hashtags=OpenSourceWin`; const xUrl = locale === "en" ? "https://x.com/sunnyygao" : "https://x.com/gaoyangio"; -const LANG_LABELS: Record = { en: "EN", "zh-CN": "简", "zh-TW": "繁" }; -const langLinks = LOCALES.map((item) => ({ - locale: item, - href: localePath(item, "/"), - label: LANG_LABELS[item], -})); - /** Escape a string for safe interpolation into generated attribute HTML. */ function escapeHtml(value: string): string { return value @@ -177,25 +171,8 @@ const jsonLd = {
- {/* 语言切换:跳转到当前页面对应的其他语言 URL,并记录 localStorage('osw-language') */} -
- {langLinks.map((item, i) => ( - <> - {i > 0 && } - {item.label} - - ))} -
+ {/* 语言切换:图标按钮 + 下拉(跳对应语言 URL 并写 localStorage,见共享组件) */} + + + + +