|
@@ -4,32 +4,59 @@
|
|
<h2>
|
|
<h2>
|
|
<a :href="mainURL"><img :src="logoPng" /></a>
|
|
<a :href="mainURL"><img :src="logoPng" /></a>
|
|
</h2>
|
|
</h2>
|
|
|
|
+ <div class="right_menu_container">
|
|
|
|
+ <a-dropdown placement="bottomRight">
|
|
|
|
+ <template #overlay>
|
|
|
|
+ <a-menu style="width: 100px" @click="handlerLangClick">
|
|
|
|
+ <a-menu-item
|
|
|
|
+ v-for="menu in langList"
|
|
|
|
+ :key="menu.key"
|
|
|
|
+ class="menu-item"
|
|
|
|
+ :class="{ [menu.key]: true }"
|
|
|
|
+ >
|
|
|
|
+ {{ menu.label }}
|
|
|
|
+ </a-menu-item>
|
|
|
|
+ </a-menu>
|
|
|
|
+ </template>
|
|
|
|
+ <div class="avatar">
|
|
|
|
+ <a-avatar :size="32">
|
|
|
|
+ <template #icon>
|
|
|
|
+ <img :src="userStore.current.avatar" />
|
|
|
|
+ </template>
|
|
|
|
+ </a-avatar>
|
|
|
|
+ <span>
|
|
|
|
+ {{ currentLang.label }}
|
|
|
|
+ <!-- <DownOutlined /> -->
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
|
|
+ </a-dropdown>
|
|
|
|
|
|
- <a-dropdown placement="bottomRight">
|
|
|
|
- <template #overlay>
|
|
|
|
- <a-menu style="width: 100px" @click="handlerMenuClick">
|
|
|
|
- <a-menu-item
|
|
|
|
- v-for="menu in menus"
|
|
|
|
- :key="menu.key"
|
|
|
|
- class="menu-item"
|
|
|
|
- :class="{ [menu.key]: true }"
|
|
|
|
- >
|
|
|
|
- {{ menu.label }}
|
|
|
|
- </a-menu-item>
|
|
|
|
- </a-menu>
|
|
|
|
- </template>
|
|
|
|
- <div class="avatar">
|
|
|
|
- <a-avatar :size="32">
|
|
|
|
- <template #icon>
|
|
|
|
- <img :src="userStore.current.avatar" />
|
|
|
|
- </template>
|
|
|
|
- </a-avatar>
|
|
|
|
- <span>
|
|
|
|
- {{ userStore.current.nickname }}
|
|
|
|
- <DownOutlined />
|
|
|
|
- </span>
|
|
|
|
- </div>
|
|
|
|
- </a-dropdown>
|
|
|
|
|
|
+ <a-dropdown placement="bottomRight">
|
|
|
|
+ <template #overlay>
|
|
|
|
+ <a-menu style="width: 100px" @click="handlerMenuClick">
|
|
|
|
+ <a-menu-item
|
|
|
|
+ v-for="menu in menus"
|
|
|
|
+ :key="menu.key"
|
|
|
|
+ class="menu-item"
|
|
|
|
+ :class="{ [menu.key]: true }"
|
|
|
|
+ >
|
|
|
|
+ {{ menu.label }}
|
|
|
|
+ </a-menu-item>
|
|
|
|
+ </a-menu>
|
|
|
|
+ </template>
|
|
|
|
+ <div class="avatar">
|
|
|
|
+ <a-avatar :size="32">
|
|
|
|
+ <template #icon>
|
|
|
|
+ <img :src="userStore.current.avatar" />
|
|
|
|
+ </template>
|
|
|
|
+ </a-avatar>
|
|
|
|
+ <span>
|
|
|
|
+ {{ userStore.current.nickname }}
|
|
|
|
+ <DownOutlined />
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
|
|
+ </a-dropdown>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</a-layout-header>
|
|
</a-layout-header>
|
|
</template>
|
|
</template>
|
|
@@ -40,11 +67,40 @@ import { useUserStore } from '@/store/modules/user'
|
|
import { postLogout } from '@/api'
|
|
import { postLogout } from '@/api'
|
|
import { mainURL } from '@/env'
|
|
import { mainURL } from '@/env'
|
|
import logoPng from '@/assets/images/logo.png'
|
|
import logoPng from '@/assets/images/logo.png'
|
|
|
|
+import { useLocaleStore } from '@/store/modules/locale'
|
|
|
|
+import { useI18n } from '@/hook/useI18n'
|
|
|
|
+import { useLocale } from '@/locales/useLocale'
|
|
|
|
+import { computed, unref, inject } from 'vue'
|
|
|
|
+import { LocaleType } from '#/config'
|
|
|
|
+import { showLoading } from '@/components/loading'
|
|
|
|
+
|
|
|
|
+const getImgSrc = inject('getImgSrc')
|
|
|
|
|
|
defineOptions({ name: 'LayoutHeader' })
|
|
defineOptions({ name: 'LayoutHeader' })
|
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
|
+
|
|
userStore.fetch()
|
|
userStore.fetch()
|
|
|
|
+const { localInfo, getLocale } = useLocaleStore()
|
|
|
|
+
|
|
|
|
+console.log('localInfo', localInfo)
|
|
|
|
+const { t } = useI18n()
|
|
|
|
+const currentLang = computed(() => {
|
|
|
|
+ return {
|
|
|
|
+ key: unref(getLocale),
|
|
|
|
+ label: t(`base.lang.${unref(getLocale)}`)
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+console.log('getImgSrc', getImgSrc)
|
|
|
|
+const langList = localInfo.availableLocales.map((item: string) => {
|
|
|
|
+ return {
|
|
|
|
+ key: item,
|
|
|
|
+ label: t(`base.lang.${item}`),
|
|
|
|
+ // icon: getImgSrc(unref(getLocale))
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+console.log('langList', langList)
|
|
|
|
|
|
const menus = [
|
|
const menus = [
|
|
{ label: '个人中心', key: 'user' },
|
|
{ label: '个人中心', key: 'user' },
|
|
@@ -58,6 +114,17 @@ const handlerMenuClick: MenuProps['onClick'] = async e => {
|
|
location.href = `${mainURL}/#/information`
|
|
location.href = `${mainURL}/#/information`
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+const handlerLangClick: MenuProps['onClick'] = async e => {
|
|
|
|
+ console.log(e.key)
|
|
|
|
+ showLoading()
|
|
|
|
+ const { changeLocale } = useLocale()
|
|
|
|
+ changeLocale(e.key as LocaleType)
|
|
|
|
+ // location.reload()
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ location.reload()
|
|
|
|
+ }, 100)
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
.menu-item {
|
|
.menu-item {
|
|
@@ -81,6 +148,10 @@ const handlerMenuClick: MenuProps['onClick'] = async e => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+.right_menu_container {
|
|
|
|
+ display: flex;
|
|
|
|
+ flex-direction: row;
|
|
|
|
+}
|
|
|
|
|
|
.content-layout {
|
|
.content-layout {
|
|
display: flex;
|
|
display: flex;
|