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