"use client"; import React from "react"; interface LangSwitchProps { basePath?: string; locale?: string; } export function LangSwitch({ basePath = "", locale = "zh-CN" }: LangSwitchProps) { const onSwitch = () => { const current = window.location.pathname; const parts = current.split("/").filter(Boolean); const currentLocale = parts[0] === "en" ? "en" : parts[0] === "zh-CN" ? "zh-CN" : null; const nextLocale = currentLocale === "en" ? "zh-CN" : "en"; if (currentLocale) { parts[0] = nextLocale; } else { parts.unshift(nextLocale); } const nextPath = "/" + parts.join("/"); window.location.assign(nextPath); }; const buttonText = locale === "en" ? "CN" : "EN"; return ( ); }