|
@@ -1,16 +1,16 @@
|
|
|
<template>
|
|
|
- <el-config-provider :size="getGlobalComponentSize" :locale="getGlobalI18n">
|
|
|
- <!-- v-show="themeConfig.lockScreenTime > 1" -->
|
|
|
- <router-view v-show="themeConfig.lockScreenTime > 1" />
|
|
|
- <LockScreen v-if="themeConfig.isLockScreen" />
|
|
|
- <Setings ref="setingsRef" v-show="themeConfig.lockScreenTime > 1" />
|
|
|
- <CloseFull v-if="!themeConfig.isLockScreen" />
|
|
|
-<!-- <Upgrade v-if="getVersion" />-->
|
|
|
- </el-config-provider>
|
|
|
+ <el-config-provider :locale="getGlobalI18n" :size="getGlobalComponentSize">
|
|
|
+ <!-- v-show="themeConfig.lockScreenTime > 1" -->
|
|
|
+ <router-view v-show="themeConfig.lockScreenTime > 1"/>
|
|
|
+ <LockScreen v-if="themeConfig.isLockScreen"/>
|
|
|
+ <Setings v-show="themeConfig.lockScreenTime > 1" ref="setingsRef"/>
|
|
|
+ <CloseFull v-if="!themeConfig.isLockScreen"/>
|
|
|
+ <!-- <Upgrade v-if="getVersion" />-->
|
|
|
+ </el-config-provider>
|
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts" name="app">
|
|
|
-import { defineAsyncComponent, computed, ref, onBeforeMount, onMounted, onUnmounted, nextTick, watch, onBeforeUnmount } from 'vue';
|
|
|
+<script lang="ts" name="app" setup>
|
|
|
+import { computed, defineAsyncComponent, nextTick, onBeforeMount, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
import { storeToRefs } from 'pinia';
|
|
@@ -20,6 +20,10 @@ import other from '/@/utils/other';
|
|
|
import { Local, Session } from '/@/utils/storage';
|
|
|
import mittBus from '/@/utils/mitt';
|
|
|
import setIntroduction from '/@/utils/setIconfont';
|
|
|
+import websocket from '/@/utils/websocket';
|
|
|
+import { ElNotification } from 'element-plus';
|
|
|
+// websocket相关代码
|
|
|
+import { messageCenterStore } from '/@/stores/messageCenter';
|
|
|
|
|
|
// 引入组件
|
|
|
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
|
@@ -34,93 +38,90 @@ const route = useRoute();
|
|
|
const stores = useTagsViewRoutes();
|
|
|
const storesThemeConfig = useThemeConfig();
|
|
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
|
|
-import websocket from '/@/utils/websocket';
|
|
|
-import { ElNotification } from 'element-plus';
|
|
|
// 获取版本号
|
|
|
const getVersion = computed(() => {
|
|
|
- let isVersion = false;
|
|
|
- if (route.path !== '/login') {
|
|
|
- // @ts-ignore
|
|
|
- if ((Local.get('version') && Local.get('version') !== __VERSION__) || !Local.get('version')) isVersion = true;
|
|
|
- }
|
|
|
- return isVersion;
|
|
|
+ let isVersion = false;
|
|
|
+ if (route.path !== '/login') {
|
|
|
+ // @ts-ignore
|
|
|
+ if ((Local.get('version') && Local.get('version') !== __VERSION__) || !Local.get('version')) isVersion = true;
|
|
|
+ }
|
|
|
+ return isVersion;
|
|
|
});
|
|
|
// 获取全局组件大小
|
|
|
const getGlobalComponentSize = computed(() => {
|
|
|
- return other.globalComponentSize();
|
|
|
+ return other.globalComponentSize();
|
|
|
});
|
|
|
// 获取全局 i18n
|
|
|
const getGlobalI18n = computed(() => {
|
|
|
- return messages.value[locale.value];
|
|
|
+ return messages.value[locale.value];
|
|
|
});
|
|
|
// 设置初始化,防止刷新时恢复默认
|
|
|
onBeforeMount(() => {
|
|
|
- // 设置批量第三方 icon 图标
|
|
|
- setIntroduction.cssCdn();
|
|
|
- // 设置批量第三方 js
|
|
|
- setIntroduction.jsCdn();
|
|
|
+ // 设置批量第三方 icon 图标
|
|
|
+ setIntroduction.cssCdn();
|
|
|
+ // 设置批量第三方 js
|
|
|
+ setIntroduction.jsCdn();
|
|
|
});
|
|
|
// 页面加载时
|
|
|
onMounted(() => {
|
|
|
- nextTick(() => {
|
|
|
- // 监听布局配'置弹窗点击打开
|
|
|
- mittBus.on('openSetingsDrawer', () => {
|
|
|
- setingsRef.value.openDrawer();
|
|
|
- });
|
|
|
- // 获取缓存中的布局配置
|
|
|
- if (Local.get('themeConfig')) {
|
|
|
- storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') });
|
|
|
- document.documentElement.style.cssText = Local.get('themeConfigStyle');
|
|
|
- }
|
|
|
- // 获取缓存中的全屏配置
|
|
|
- if (Session.get('isTagsViewCurrenFull')) {
|
|
|
- stores.setCurrenFullscreen(Session.get('isTagsViewCurrenFull'));
|
|
|
- }
|
|
|
- });
|
|
|
+ nextTick(() => {
|
|
|
+ // 监听布局配'置弹窗点击打开
|
|
|
+ mittBus.on('openSetingsDrawer', () => {
|
|
|
+ setingsRef.value.openDrawer();
|
|
|
+ });
|
|
|
+ // 获取缓存中的布局配置
|
|
|
+ if (Local.get('themeConfig')) {
|
|
|
+ storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') });
|
|
|
+ document.documentElement.style.cssText = Local.get('themeConfigStyle');
|
|
|
+ }
|
|
|
+ // 获取缓存中的全屏配置
|
|
|
+ if (Session.get('isTagsViewCurrenFull')) {
|
|
|
+ stores.setCurrenFullscreen(Session.get('isTagsViewCurrenFull'));
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
// 页面销毁时,关闭监听布局配置/i18n监听
|
|
|
onUnmounted(() => {
|
|
|
- mittBus.off('openSetingsDrawer', () => {});
|
|
|
+ mittBus.off('openSetingsDrawer', () => {
|
|
|
+ });
|
|
|
});
|
|
|
// 监听路由的变化,设置网站标题
|
|
|
watch(
|
|
|
- () => route.path,
|
|
|
- () => {
|
|
|
- other.useTitle();
|
|
|
- other.useFavicon();
|
|
|
- if (!websocket.websocket) {
|
|
|
- //websockt 模块
|
|
|
- try {
|
|
|
- websocket.init(wsReceive)
|
|
|
- } catch (e) {
|
|
|
- console.log('websocket错误');
|
|
|
+ () => route.path,
|
|
|
+ () => {
|
|
|
+ other.useTitle();
|
|
|
+ other.useFavicon();
|
|
|
+ if (!websocket.websocket) {
|
|
|
+ //websockt 模块
|
|
|
+ try {
|
|
|
+ websocket.init(wsReceive);
|
|
|
+ } catch (e) {
|
|
|
+ console.log('websocket错误');
|
|
|
+ }
|
|
|
}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true
|
|
|
}
|
|
|
- },
|
|
|
- {
|
|
|
- deep: true,
|
|
|
- }
|
|
|
);
|
|
|
|
|
|
-// websocket相关代码
|
|
|
-import { messageCenterStore } from '/@/stores/messageCenter';
|
|
|
const wsReceive = (message: any) => {
|
|
|
- const data = JSON.parse(message.data);
|
|
|
- const { unread } = data;
|
|
|
- const messageCenter = messageCenterStore();
|
|
|
- messageCenter.setUnread(unread);
|
|
|
- if (data.contentType === 'SYSTEM') {
|
|
|
- ElNotification({
|
|
|
- title: '系统消息',
|
|
|
- message: data.content,
|
|
|
- type: 'success',
|
|
|
- position: 'bottom-right',
|
|
|
- duration: 5000,
|
|
|
- });
|
|
|
- }
|
|
|
+ const data = JSON.parse(message.data);
|
|
|
+ const { unread } = data;
|
|
|
+ const messageCenter = messageCenterStore();
|
|
|
+ messageCenter.setUnread(unread);
|
|
|
+ if (data.contentType === 'SYSTEM') {
|
|
|
+ ElNotification({
|
|
|
+ title: '系统消息',
|
|
|
+ message: data.content,
|
|
|
+ type: 'success',
|
|
|
+ position: 'bottom-right',
|
|
|
+ duration: 5000
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
onBeforeUnmount(() => {
|
|
|
- // 关闭连接
|
|
|
- websocket.close();
|
|
|
+ // 关闭连接
|
|
|
+ websocket.close();
|
|
|
});
|
|
|
</script>
|