Skip to content

Commit 2402ea3

Browse files
committed
fix: 修复语言切换功能
- 使用 window.location.href 直接导航 - 确保语言切换可靠工作 - 添加 hover 效果和过渡动画 - 修复按钮样式
1 parent c39d1de commit 2402ea3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

platform/src/components/LanguageSwitcher.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ export default function LanguageSwitcher() {
1212
const otherLocale = locale === 'en' ? 'zh' : 'en'
1313

1414
const switchLocale = () => {
15-
// Use push instead of replace for more reliable navigation
16-
router.push(pathname, { locale: otherLocale })
15+
// 强制刷新页面切换语言
16+
const newPath = `/${otherLocale}${pathname}`
17+
window.location.href = newPath
1718
}
1819

1920
return (
2021
<button
2122
onClick={switchLocale}
22-
className="px-3 py-1.5 rounded-m3-sm bg-surface-container border border-outline-variant text-onsurface-variant hover:text-onsurface hover:border-primary/50 transition-colors text-[14px] font-medium cursor-pointer"
23+
className="px-3 py-1.5 rounded-lg bg-surface-container border border-outline-variant text-on-surface-variant hover:text-on-surface hover:border-primary/50 transition-all duration-200 text-sm font-medium cursor-pointer hover:scale-105"
2324
aria-label={`Switch to ${otherLocale === 'en' ? 'English' : '中文'}`}
25+
type="button"
2426
>
2527
{t(otherLocale)}
2628
</button>

0 commit comments

Comments
 (0)