-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fewbadboy
committed
Sep 7, 2024
1 parent
02fa965
commit 52e3cbf
Showing
15 changed files
with
239 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script setup lang="ts"> | ||
import { h, ref, watchEffect } from "vue"; | ||
import { useI18n } from "vue-i18n"; | ||
import { setI18NLanguage } from "@/i18n"; | ||
import { useGlobalStore } from "@/stores/global"; | ||
import { storeToRefs } from "pinia"; | ||
import enUS from "ant-design-vue/es/locale/en_US"; | ||
import zhCN from "ant-design-vue/es/locale/zh_CN"; | ||
import dayjs from "dayjs"; | ||
import { Avatar, Dropdown, Menu, MenuProps } from "ant-design-vue"; | ||
import { TranslationOutlined } from "@ant-design/icons-vue"; | ||
import { MenuInfo } from "ant-design-vue/es/menu/src/interface"; | ||
const global = useGlobalStore(); | ||
const { language } = storeToRefs(global); | ||
const { locale } = useI18n(); | ||
language.value = locale.value; | ||
watchEffect(() => { | ||
dayjs.locale(language.value === "en" ? enUS.locale : zhCN.locale); | ||
}); | ||
const items = ref<MenuProps["items"]>([ | ||
{ | ||
key: "en", | ||
icon: () => h(TranslationOutlined), | ||
label: "English", | ||
title: "English", | ||
}, | ||
{ | ||
key: "zh-CN", | ||
icon: () => h(TranslationOutlined), | ||
label: "中文", | ||
title: "中文", | ||
}, | ||
]); | ||
function handleOperate({ key }: MenuInfo) { | ||
language.value = key as string; | ||
setI18NLanguage(key as string); | ||
} | ||
</script> | ||
|
||
<template> | ||
<Dropdown> | ||
<div> | ||
<Avatar> | ||
<template #icon> | ||
<TranslationOutlined /> | ||
</template> | ||
</Avatar> | ||
</div> | ||
<template #overlay> | ||
<Menu :items="items" @click="handleOperate" /> | ||
</template> | ||
</Dropdown> | ||
</template> | ||
|
||
<style scoped lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const enMessage = { | ||
signIn: 'Sign In', | ||
dashboard: 'Dashboard', | ||
operate: { | ||
edit: 'Edit', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const zhMessage = { | ||
signIn: '登录', | ||
dashboard: '主页', | ||
operate: { | ||
edit: '编辑', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.