Zhufu 2024-07-19 15:03:23 +08:00
commit 80d2d85095
6 changed files with 125 additions and 24 deletions

View File

@ -44,7 +44,7 @@
const userStore = useUserStore();
const { title } = useGlobSetting();
const subjectLogoTitle = getAuthCache(SUBJECT_LOGO_TITLE);
const go = useGo();
const getAppLogoClass = computed(() => [

View File

@ -31,6 +31,7 @@ export const TABLE_SETTING_KEY = 'TABLE__SETTING__KEY__';
// 专题设置
export const SUBJECT_KEY = 'SUBJECT__';
export const SUBJECT_TITLE = 'SUBJECT_TITLE__';
export const SUBJECT_LOGO_TITLE = 'SUBJECT_LOGO_TITLE__';
export enum CacheTypeEnum {

View File

@ -4,7 +4,7 @@ import { defineStore } from 'pinia';
import { store } from '@/store';
import { RoleEnum } from '@/enums/roleEnum';
import { PageEnum } from '@/enums/pageEnum';
import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY, SUBJECT_KEY, SUBJECT_LOGO_TITLE } from '@/enums/cacheEnum';
import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY, SUBJECT_KEY, SUBJECT_TITLE, SUBJECT_LOGO_TITLE } from '@/enums/cacheEnum';
import { getAuthCache, setAuthCache } from '@/utils/auth';
import { GetUserInfoModel, LoginParams } from '@/api/sys/model/userModel';
import { doLogout, getUserInfo, loginApi } from '@/api/sys/user';
@ -25,6 +25,7 @@ interface UserState {
sessionTimeout?: boolean;
lastUpdateTime: number;
subject?: string;
subjectTitle?: string;
subjectLogoTitle?: string;
}
@ -42,6 +43,7 @@ export const useUserStore = defineStore({
// Last fetch time
lastUpdateTime: 0,
subject: '',
subjectTitle: '',
subjectLogoTitle: '',
}),
getters: {
@ -63,14 +65,18 @@ export const useUserStore = defineStore({
getSubject(state): string {
return state.subject || getAuthCache<string>(SUBJECT_KEY);
},
getSubjectTitle(state): string {
return state.subjectTitle || getAuthCache<string>(SUBJECT_TITLE);
},
getSubjectLogoTitle(state): string {
return state.subjectLogoTitle || getAuthCache<string>(SUBJECT_LOGO_TITLE);
},
},
actions: {
async setSubject(subject: string | undefined, logoTitle: string | undefined, link: string) {
async setSubject(subject: string | undefined, subjectTitle: string | undefined, logoTitle: string | undefined, link: string) {
this.subject = subject;
setAuthCache(SUBJECT_KEY, subject);
setAuthCache(SUBJECT_TITLE, subjectTitle);
setAuthCache(SUBJECT_LOGO_TITLE, logoTitle);
if (subject != undefined) {
const permissionStore = usePermissionStore();
@ -173,7 +179,7 @@ export const useUserStore = defineStore({
}
}
this.setToken(undefined);
this.setSubject(undefined, undefined, '');
this.setSubject(undefined, undefined, undefined, '');
this.setSessionTimeout(false);
this.setUserInfo(null);
goLogin && router.push(PageEnum.BASE_LOGIN);

View File

@ -6,6 +6,7 @@ import { createLocalStorage, createSessionStorage } from '@/utils/cache';
import { Memory } from './memory';
import {
SUBJECT_KEY,
SUBJECT_TITLE,
SUBJECT_LOGO_TITLE,
TOKEN_KEY,
USER_INFO_KEY,
@ -23,6 +24,7 @@ import { pick, omit } from 'lodash-es';
interface BasicStore {
[SUBJECT_KEY]: string | number | null | undefined;
[SUBJECT_TITLE]: string | number | null | undefined;
[SUBJECT_LOGO_TITLE]: string | number | null | undefined;
[TOKEN_KEY]: string | number | null | undefined;
[USER_INFO_KEY]: UserInfo;

View File

@ -3,8 +3,20 @@
<div class="subject_header">
<img class="subject_header_img" src="/subject/subject_header.png" />
<div class="subject_header_title">
<span>
<img src="/subject/subject_logo.png" />
<span
:style="{
fontSize: `${42 * bi}px`,
}"
>
<img
src="/subject/subject_logo.png"
:style="{
top: `${3 * bi}px`,
width: `${78 * bi}px`,
height: `${71 * bi}px`,
marginRight: `${10 * bi}px`,
}"
/>
{{ t('sys.subject.header_title') }}
</span>
</div>
@ -17,7 +29,15 @@
</div>
</div>
<div class="subject_box">
<div class="subject_box_btn" ref="contentArea">
<div
class="subject_box_btn"
ref="contentArea"
:style="{
top: `${50 * bi}px`,
left: `${100 * bi}px`,
height: `${688 * bi}px`,
}"
>
<div
v-for="(item, index) in list"
:key="item.id"
@ -25,46 +45,96 @@
class="subject_box_btn_div"
@click="getHome(item)"
:style="{
marginRight: `${20 * bi}px`,
marginBottom: `${20 * bi}px`,
height: `${325 * bi}px`,
width: `${225 * bi}px`,
'background-image': `url(${index % 2 == 0 ? '/subject/subject_btn_1.png' : '/subject/subject_btn_2.png'})`,
'background-size': 'cover',
'background-size': `${100}%`,
'background-repeat': 'no-repeat',
}"
>
<img class="subject_box_btn_div_url" :src="getImageUrl(item.imgUrl)" />
<img
class="subject_box_btn_div_url"
:src="getImageUrl(item.imgUrl)"
:style="{
left: `${11 * bi}px`,
width: `${191 * bi}px`,
height: `${191 * bi}px`,
}"
/>
<span
class="subject_box_btn_div_span"
:style="{ height: `${28 * spanWrap + 8}px` }"
v-html="renderedTitle(item.title)"
:style="{
fontSize: `${28 * bi}px`,
left: `${12 * bi}px`,
width: `${190 * bi}px`,
height: `${(28 * spanWrap + 8) * bi}px`,
}"
/>
<img
class="subject_box_btn_div_line"
src="/subject/subject_line.png"
:style="{
top: `${14 * getWrap(item.title) - 14 * (spanWrap - 1) - 8}px`,
top: `${(14 * getWrap(item.title) - 14 * (spanWrap - 1) - 8) * bi}px`,
left: `${42 * bi}px`,
width: `${128 * bi}px`,
height: `${7 * bi}px`,
}"
/>
<div
class="circle arc1"
:style="{
top: `${(-126 * 1 - 28 * spanWrap) * bi}px`,
left: `${108 * bi}px`,
width: `${126 * bi}px`,
height: `${126 * bi}px`,
}"
/>
<div
class="circle arc2"
:style="{
top: `${(-126 * 2 - 28 * spanWrap) * bi}px`,
left: `${108 * bi}px`,
width: `${126 * bi}px`,
height: `${126 * bi}px`,
}"
/>
<div
class="circle arc3"
:style="{
top: `${(-126 * 3 - 28 * spanWrap) * bi}px`,
left: `${108 * bi}px`,
width: `${126 * bi}px`,
height: `${126 * bi}px`,
}"
/>
<div
class="circle arc4"
:style="{
top: `${(-126 * 4 - 28 * spanWrap) * bi}px`,
left: `${108 * bi}px`,
width: `${126 * bi}px`,
height: `${126 * bi}px`,
}"
/>
<div class="circle arc1" :style="{ top: `${-126 * 1 - 28 * spanWrap}px` }" />
<div class="circle arc2" :style="{ top: `${-126 * 2 - 28 * spanWrap}px` }" />
<div class="circle arc3" :style="{ top: `${-126 * 3 - 28 * spanWrap}px` }" />
<div class="circle arc4" :style="{ top: `${-126 * 4 - 28 * spanWrap}px` }" />
</div>
</div>
<div class="subject_box_overflow">
<!-- <div class="subject_box_overflow">
<Icon
v-if="list.length > 14"
style="font-size: 31px"
class="subject_box_overflow_icon1"
icon="ant-design:up-outlined"
@click="scrollToElement('top')"
/>
<Icon
v-if="list.length > 14"
style="font-size: 31px"
class="subject_box_overflow_icon2"
icon="ant-design:down-outlined"
@click="scrollToElement('bottom')"
/>
</div>
</div> -->
</div>
<div class="subject_bottom">
<span>
@ -80,7 +150,7 @@
<script setup lang="ts">
import { useUserStore } from '@/store/modules/user';
import { getSpecialData } from '@/api/demo/system';
import { onMounted, ref, nextTick } from 'vue';
import { onMounted, onUnmounted, ref, nextTick, computed } from 'vue';
import { message } from 'ant-design-vue';
import Icon from '@/components/Icon/Icon.vue';
import { getAppEnvConfig } from '@/utils/env';
@ -159,7 +229,7 @@
if (!item.linkOrApi) {
item.linkOrApi = PageEnum.WELCOME_HOME;
}
userStore.setSubject(item.id, item.logoTitle, item.linkOrApi);
userStore.setSubject(item.id, item.title, item.logoTitle, item.linkOrApi);
}
}
//
@ -182,9 +252,29 @@
function handleLoginOut() {
userStore.confirmLoginOut();
}
//
const viewportWidth = ref(window.innerWidth);
const viewportHeight = ref(window.innerHeight);
const referenceWidth = 1920;
const referenceHeight = 1080;
const updateWindowSize = () => {
viewportWidth.value = window.innerWidth;
viewportHeight.value = window.innerHeight;
};
const bi = computed(() => {
return viewportWidth.value / referenceWidth;
});
onMounted(() => {
getData();
window.addEventListener('resize', updateWindowSize);
updateWindowSize(); //
});
onUnmounted(() => {
window.removeEventListener('resize', updateWindowSize);
});
</script>
<style lang="less" scoped>
@ -293,8 +383,8 @@
flex: 0 0 auto;
margin-right: 20px;
margin-bottom: 20px;
height: 320px;
width: 225px;
height: 325px;
transition: all 0.3s ease;
padding: 10px;

View File

@ -10,6 +10,8 @@
import { useI18n } from '@/hooks/web/useI18n';
import { useGo, useRedo } from '@/hooks/web/usePage';
import { PageEnum } from '@/enums/pageEnum';
import { SUBJECT_TITLE } from '@/enums/cacheEnum';
import { getAuthCache } from '@/utils/auth';
interface MapValue {
title: string;
@ -111,8 +113,8 @@
window.location.href.slice(window.location.href.indexOf('#') + 1) == PageEnum.WELCOME_HOME
) {
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_FOUND, {
title: '欢迎登',
subTitle: '欢迎登',
title: '欢迎登',
subTitle: '欢迎登录' + getAuthCache(SUBJECT_TITLE) + '专题模块',
icon: netWorkSvg,
});
}