refactor:顶部栏语言切换
This commit is contained in:
parent
4b26bdddd4
commit
dd7bdf5489
@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
|
||||
@ -102,6 +102,7 @@ export const languageList = {
|
||||
'zh-TW': '繁體中文(台灣)',
|
||||
'zh-HK': '繁體中文(香港)',
|
||||
};
|
||||
|
||||
const itemize = { en: [], 'zh-CN': [], 'zh-TW': [], 'zh-HK': [], de: [], es: [], fi: [], fr: [], it: [], ja: [], ko: [], no: [], pl: [], pt: [], ru: [] };
|
||||
const modules: Record<string, any> = import.meta.glob('./**/*.ts', { eager: true });
|
||||
|
||||
@ -148,4 +149,32 @@ export const i18n = createI18n({
|
||||
fallbackLocale: "zh-CN",
|
||||
messages,
|
||||
globalInjection: true,
|
||||
});
|
||||
});
|
||||
|
||||
//iso 3166-1 国家代码
|
||||
export const iso_3166_1_CountryList = {
|
||||
'de': 'de',
|
||||
'en': 'us',
|
||||
'es': 'es',
|
||||
'fi': 'fi',
|
||||
'fr': 'fr',
|
||||
'it': 'it',
|
||||
'ja': 'jp',
|
||||
'ko': 'kr',
|
||||
'no': 'no',
|
||||
'pl': 'pl',
|
||||
'pt': 'pt',
|
||||
'ru': 'ru',
|
||||
'zh-CN': 'cn',
|
||||
'zh-TW': 'tw',
|
||||
'zh-HK': 'hk',
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取国家代码
|
||||
* @param locale 语言
|
||||
* @returns 国家代码
|
||||
*/
|
||||
export const getCountryCode = (locale: string) => {
|
||||
return iso_3166_1_CountryList[locale as keyof typeof iso_3166_1_CountryList];
|
||||
}
|
||||
|
||||
@ -14,13 +14,20 @@
|
||||
</el-dropdown>
|
||||
<el-dropdown :show-timeout="70" :hide-timeout="50" trigger="click" @command="onLanguageChange">
|
||||
<div class="layout-navbars-breadcrumb-user-icon">
|
||||
<i class="iconfont" :class="state.disabledI18n === 'en' ? 'icon-fuhao-yingwen' : 'icon-fuhao-zhongwen'" :title="$t('message.user.title1')"></i>
|
||||
<FlagIcon :code="currentCountryCode" square :size="16" :title="$t('message.user.title1')"/>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="zh-CN" :disabled="state.disabledI18n === 'zh-CN'">简体中文</el-dropdown-item>
|
||||
<el-dropdown-item command="en" :disabled="state.disabledI18n === 'en'">English</el-dropdown-item>
|
||||
<el-dropdown-item command="zh-TW" :disabled="state.disabledI18n === 'zh-TW'">繁體中文</el-dropdown-item>
|
||||
<el-dropdown-item v-for="(value,key) in languageList" :key="key" :command="key" :disabled="state.disabledI18n === key">
|
||||
<div class="flex items-center">
|
||||
<div class="mr-2">
|
||||
<FlagIcon :code="getCountryCode(key)" :size="24" />
|
||||
</div>
|
||||
<div style="margin-left:10px;">
|
||||
{{value}}
|
||||
</div>
|
||||
</div>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
@ -48,21 +55,23 @@
|
||||
<i class="iconfont" :title="state.isScreenfull ? $t('message.user.title6') : $t('message.user.title5')" :class="!state.isScreenfull ? 'icon-fullscreen' : 'icon-tuichuquanping'"></i>
|
||||
</div>
|
||||
<div class="layout-navbars-breadcrumb-user-icon mr10" @click="onOnlineUserClick">
|
||||
<el-icon title="在线用户">
|
||||
<el-icon :title="$t('message.list.onlineUser')">
|
||||
<ele-User />
|
||||
</el-icon>
|
||||
</div>
|
||||
|
||||
<el-dropdown :show-timeout="70" :hide-timeout="50" size="large" @command="onHandleCommandClick">
|
||||
<span class="layout-navbars-breadcrumb-user-link">
|
||||
<el-tooltip effect="dark" placement="left">
|
||||
<template #content>
|
||||
账号:{{ userInfos.account }}<br />
|
||||
姓名:{{ userInfos.realName }}<br />
|
||||
电话:{{ userInfos.phone }}<br />
|
||||
邮箱:{{ userInfos.email }}<br />
|
||||
部门:{{ userInfos.orgName }}<br />
|
||||
职位:{{ userInfos.posName }}<br />
|
||||
{{$t('message.list.account')}}:{{ userInfos.account }}<br />
|
||||
{{$t('message.list.realName')}}:{{ userInfos.realName }}<br />
|
||||
{{$t('message.list.phone')}}:{{ userInfos.phone }}<br />
|
||||
{{$t('message.list.email')}}:{{ userInfos.email }}<br />
|
||||
{{$t('message.list.orgName')}}:{{ userInfos.orgName }}<br />
|
||||
{{$t('message.list.positionText')}}:{{ userInfos.posName }}<br />
|
||||
</template>
|
||||
|
||||
<img :src="userInfos.avatar" class="layout-navbars-breadcrumb-user-link-photo mr5" />
|
||||
</el-tooltip>
|
||||
{{ userInfos.realName == '' ? userInfos.account : userInfos.realName }}
|
||||
@ -107,6 +116,8 @@ import { Avatar, CircleCloseFilled, Loading, Lock } from '@element-plus/icons-vu
|
||||
|
||||
import { clearAccessTokens, getAPI } from '/@/utils/axios-utils';
|
||||
import { SysAuthApi, SysNoticeApi, SysUpgradeApi, SysUserApi } from '/@/api-services/api';
|
||||
import { languageList, getCountryCode } from '/@/i18n';
|
||||
import FlagIcon from 'vue3-flag-icons'
|
||||
|
||||
// 引入组件
|
||||
const UserNews = defineAsyncComponent(() => import('/@/layout/navBars/topBar/userNews.vue'));
|
||||
@ -125,10 +136,11 @@ const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||
const searchRef = ref();
|
||||
const onlineUserRef = ref();
|
||||
const changePasswordRef = ref();
|
||||
const upgradeInfoRef = ref()
|
||||
const upgradeInfoRef = ref();
|
||||
const currentCountryCode = ref(getCountryCode(themeConfig.value.globalI18n));
|
||||
const state = reactive({
|
||||
isScreenfull: false,
|
||||
disabledI18n: 'zh-CN',
|
||||
disabledI18n: 'zh-cn',
|
||||
disabledSize: 'large',
|
||||
noticeList: [] as any, // 站内信列表
|
||||
});
|
||||
@ -228,9 +240,11 @@ const onLanguageChange = (lang: string) => {
|
||||
Local.remove('themeConfig');
|
||||
themeConfig.value.globalI18n = lang;
|
||||
Local.set('themeConfig', themeConfig.value);
|
||||
currentCountryCode.value = getCountryCode(lang);
|
||||
locale.value = lang;
|
||||
other.useTitle();
|
||||
initI18nOrSize('globalI18n', 'disabledI18n');
|
||||
window.location.reload();
|
||||
};
|
||||
// 初始化组件大小/i18n
|
||||
const initI18nOrSize = (value: string, attr: string) => {
|
||||
|
||||
@ -29,6 +29,7 @@ import sysDict from "/@/components/sysDict/sysDict.vue";
|
||||
|
||||
// 关闭自动打印
|
||||
import { disAutoConnect } from 'vue-plugin-hiprint';
|
||||
import 'vue3-flag-icons/styles'
|
||||
|
||||
disAutoConnect();
|
||||
|
||||
|
||||
@ -61,12 +61,6 @@
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<div class="font12 mt30 login-animation4 login-msg">{{ $t('message.mobile.msgText') }}</div>
|
||||
<div>
|
||||
<FlagIcon code="gr" />
|
||||
<FlagIcon code="gb" :size="25" square />
|
||||
<FlagIcon code="us" size="32" circle />
|
||||
<FlagIcon code="fr" title="A flag icon" />
|
||||
</div>
|
||||
<!-- <el-button type="primary" round v-waves @click="weixinSignIn" :loading="state.loading.signIn"></el-button> -->
|
||||
</el-form>
|
||||
</el-tooltip>
|
||||
@ -96,7 +90,6 @@ import { storeToRefs } from 'pinia';
|
||||
|
||||
import { accessTokenKey, clearTokens, feature, getAPI } from '/@/utils/axios-utils';
|
||||
import { SysAuthApi } from '/@/api-services/api';
|
||||
import FlagIcon from 'vue3-flag-icons'
|
||||
|
||||
// 旋转图片滑块组件
|
||||
// import verifyImg from '/@/assets/logo-mini.svg';
|
||||
|
||||
@ -103,16 +103,19 @@ onMounted(async () => {
|
||||
.login-container {
|
||||
height: 100%;
|
||||
background-color: rgba(53, 62, 84);
|
||||
|
||||
.login-left {
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
float: left;
|
||||
justify-content: center;
|
||||
|
||||
.login-carousel {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.login-left-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -121,19 +124,23 @@ onMounted(async () => {
|
||||
left: 30px;
|
||||
z-index: 1;
|
||||
animation: logoAnimation 0.3s ease;
|
||||
|
||||
img {
|
||||
// width: 100px;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
.login-left-logo-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
span {
|
||||
margin-left: 20px;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: var(--next-color-white);
|
||||
}
|
||||
|
||||
.login-left-logo-text-msg {
|
||||
padding-top: 5px;
|
||||
font-size: 14px;
|
||||
@ -141,6 +148,7 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-icon-group-icon {
|
||||
width: 85%;
|
||||
height: 85%;
|
||||
@ -150,6 +158,7 @@ onMounted(async () => {
|
||||
transform: translateY(-50%) translate3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.login-right {
|
||||
width: 50%;
|
||||
float: right;
|
||||
@ -159,6 +168,7 @@ onMounted(async () => {
|
||||
background-position: 50% calc(50% - 15px);
|
||||
background-attachment: fixed;
|
||||
background-repeat: no-repeat;
|
||||
|
||||
.login-right-warp {
|
||||
border: 1px solid var(--el-color-primary-light-3);
|
||||
border-radius: 3px;
|
||||
@ -166,12 +176,14 @@ onMounted(async () => {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background-color: var(--el-color-white);
|
||||
|
||||
.login-right-warp-one,
|
||||
.login-right-warp-two {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: inherit;
|
||||
height: inherit;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
@ -179,6 +191,7 @@ onMounted(async () => {
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.login-right-warp-one {
|
||||
&::before {
|
||||
filter: hue-rotate(0deg);
|
||||
@ -189,6 +202,7 @@ onMounted(async () => {
|
||||
background: linear-gradient(90deg, transparent, var(--el-color-primary));
|
||||
animation: loginLeft 3s linear infinite;
|
||||
}
|
||||
|
||||
&::after {
|
||||
filter: hue-rotate(0deg);
|
||||
top: -100%;
|
||||
@ -200,6 +214,7 @@ onMounted(async () => {
|
||||
animation-delay: 0.7s;
|
||||
}
|
||||
}
|
||||
|
||||
.login-right-warp-two {
|
||||
&::before {
|
||||
filter: hue-rotate(0deg);
|
||||
@ -211,6 +226,7 @@ onMounted(async () => {
|
||||
animation: loginRight 3s linear infinite;
|
||||
animation-delay: 1.4s;
|
||||
}
|
||||
|
||||
&::after {
|
||||
filter: hue-rotate(0deg);
|
||||
bottom: -100%;
|
||||
@ -222,11 +238,13 @@ onMounted(async () => {
|
||||
animation-delay: 2.1s;
|
||||
}
|
||||
}
|
||||
|
||||
.login-right-warp-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
background-color: var(--el-color-white);
|
||||
|
||||
.login-right-warp-main-title {
|
||||
height: 130px;
|
||||
line-height: 130px;
|
||||
@ -238,9 +256,11 @@ onMounted(async () => {
|
||||
animation-delay: 0.3s;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.login-right-warp-main-form {
|
||||
flex: 1;
|
||||
padding: 0 50px 50px;
|
||||
|
||||
.login-content-main-scan {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@ -251,6 +271,7 @@ onMounted(async () => {
|
||||
cursor: pointer;
|
||||
transition: all ease 0.3s;
|
||||
color: var(--el-color-primary);
|
||||
|
||||
&-delta {
|
||||
position: absolute;
|
||||
width: 35px;
|
||||
@ -261,11 +282,13 @@ onMounted(async () => {
|
||||
background: var(--el-color-white);
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
transition: all ease 0.3s;
|
||||
color: var(--el-color-primary) !important;
|
||||
}
|
||||
|
||||
i {
|
||||
width: 47px;
|
||||
height: 50px;
|
||||
@ -279,6 +302,7 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 在这里可以添加一个伪元素来覆盖原内容,实现磨砂效果 */
|
||||
.login-right-warp::before {
|
||||
content: '';
|
||||
@ -288,17 +312,19 @@ onMounted(async () => {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
filter: blur(4px); /* 调整模糊半径以改变磨砂效果强度 */
|
||||
filter: blur(4px);
|
||||
/* 调整模糊半径以改变磨砂效果强度 */
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* 保持原有内容可见,放置在伪元素下方 */
|
||||
.login-right-warp > * {
|
||||
.login-right-warp>* {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copyright,
|
||||
.icp {
|
||||
position: absolute;
|
||||
@ -306,39 +332,48 @@ onMounted(async () => {
|
||||
transform: translateX(-50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1200px) {
|
||||
.login-right-warp {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.copyright,
|
||||
.icp {
|
||||
left: 75%;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.icp {
|
||||
.el-link {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1200px) {
|
||||
|
||||
.copyright,
|
||||
.icp {
|
||||
left: 50%;
|
||||
color: var(--el-color-white);
|
||||
}
|
||||
|
||||
.icp {
|
||||
.el-link {
|
||||
color: var(--el-color-white);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 580px) {
|
||||
|
||||
.copyright,
|
||||
.icp {
|
||||
left: 50%;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.icp {
|
||||
.el-link {
|
||||
color: var(--el-text-color-secondary);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user