feat: 图标支持根据语言上传对应图标

This commit is contained in:
TsMask
2023-12-04 16:54:49 +08:00
parent c16a1675f0
commit 96d6cfcfa2
7 changed files with 188 additions and 147 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { message } from 'ant-design-vue/lib';
import { reactive, onMounted, computed } from 'vue';
import { reactive, onMounted, computed, ref } from 'vue';
import useUserStore from '@/store/modules/user';
import useAppStore from '@/store/modules/app';
import { getCaptchaImage } from '@/api/login';
@@ -9,7 +9,8 @@ import useI18n from '@/hooks/useI18n';
import { toRaw } from 'vue';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { sessionGet } from '@/utils/cache-session-utils';
const { t, changeLocale, optionsLocale } = useI18n();
import { parseUrlPath } from '@/plugins/file-static-url';
const { t, changeLocale, optionsLocale, currentLocale } = useI18n();
const appStore = useAppStore();
const router = useRouter();
const route = useRoute();
@@ -87,9 +88,25 @@ function fnGetCaptcha() {
});
}
// LOGO地址
const logoUrl = computed(() => {
let url =
appStore.logoType === 'brand'
? parseUrlPath(appStore.filePathBrand)
: parseUrlPath(appStore.filePathIcon);
if (url.indexOf('{language}') === -1) {
return url;
}
// 语言参数替换
const local = currentLocale.value;
const lang = local.split('_')[0];
return url.replace('{language}', lang);
});
// 判断是否有背景地址
const calcBG = computed(() => {
const bgURL = appStore.getLoginBackground;
const bgURL = parseUrlPath(appStore.loginBackground);
if (bgURL && bgURL !== '#') {
return {
backgroundImage: `url(${bgURL})`,
@@ -137,19 +154,11 @@ function fnChangeLocale(e: any) {
<header class="header">
<template v-if="appStore.logoType === 'icon'">
<img
:src="appStore.getLOGOIcon"
class="logo-icon"
:alt="appStore.appName"
/>
<img :src="logoUrl" class="logo-icon" :alt="appStore.appName" />
<span class="title">{{ appStore.appName }}</span>
</template>
<template v-if="appStore.logoType === 'brand'">
<img
:src="appStore.getLOGOBrand"
class="logo-brand"
:alt="appStore.appName"
/>
<img :src="logoUrl" class="logo-brand" :alt="appStore.appName" />
</template>
</header>