新增lang参数
This commit is contained in:
parent
71f4a91c3c
commit
2a8e85faa6
@ -9,8 +9,21 @@ const messages = {
|
||||
"ja-JP": jaJP,
|
||||
};
|
||||
|
||||
const supportedLocales = Object.keys(messages);
|
||||
|
||||
const getInitialLocale = () => {
|
||||
if (typeof window !== "undefined") {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const lang = params.get("lang");
|
||||
if (lang && supportedLocales.includes(lang)) {
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
return "zh-CN";
|
||||
};
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'zh-CN',
|
||||
locale: getInitialLocale(),
|
||||
fallbackLocale: "zh-CN",
|
||||
messages,
|
||||
legacy: false,
|
||||
|
||||
@ -196,6 +196,9 @@ const { locale, t } = useI18n();
|
||||
|
||||
const handleLangMenuClick = ({ key }: { key: string }) => {
|
||||
locale.value = key;
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set("lang", key);
|
||||
window.history.replaceState({}, "", url.href);
|
||||
};
|
||||
|
||||
const isPhone = ref(false);
|
||||
@ -247,7 +250,12 @@ const requestCamera = () => {
|
||||
const shareUrl = async () => {
|
||||
if (myId.value) {
|
||||
const url =
|
||||
window.location.origin + window.location.pathname + "?sign=" + myId.value;
|
||||
window.location.origin +
|
||||
window.location.pathname +
|
||||
"?sign=" +
|
||||
myId.value +
|
||||
"&lang=" +
|
||||
locale.value;
|
||||
await copyToClipboard(url);
|
||||
notification.success({
|
||||
message: t("index.linkCopied"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user