schangxiang@126.com
2024-11-28 1259cc80bb475c2d873d83af80636d3cc03e07c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
    <el-config-provider :size="getGlobalComponentSize" :locale="getGlobalI18n">
        <router-view v-show="setLockScreen" />
        <LockScreen v-if="themeConfig.isLockScreen" />
        <Setings ref="setingsRef" v-show="setLockScreen" />
        <CloseFull v-if="!themeConfig.isLockScreen" />
        <!-- <Upgrade v-if="needUpdate" /> -->
        <!-- <Sponsors /> -->
    </el-config-provider>
</template>
 
<script setup lang="ts" name="app">
import { defineAsyncComponent, computed, ref, onBeforeMount, onMounted, onUnmounted, nextTick, watch } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
import { useThemeConfig } from '/@/stores/themeConfig';
import other from '/@/utils/other';
import { Local, Session } from '/@/utils/storage';
import mittBus from '/@/utils/mitt';
import setIntroduction from '/@/utils/setIconfont';
// import checkUpdate from '/@/utils/auto-update';
 
// 引入组件
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
const Setings = defineAsyncComponent(() => import('/@/layout/navBars/topBar/setings.vue'));
const CloseFull = defineAsyncComponent(() => import('/@/layout/navBars/topBar/closeFull.vue'));
// const Upgrade = defineAsyncComponent(() => import('/@/layout/upgrade/index.vue'));
// const Sponsors = defineAsyncComponent(() => import('/@/layout/sponsors/index.vue'));
 
// 定义变量内容
const { messages, locale } = useI18n();
const setingsRef = ref();
const route = useRoute();
const stores = useTagsViewRoutes();
const storesThemeConfig = useThemeConfig();
const { themeConfig } = storeToRefs(storesThemeConfig);
const needUpdate = ref(false);
 
// 设置锁屏时组件显示隐藏
const setLockScreen = computed(() => {
    // 防止锁屏后,刷新出现不相关界面
    // https://gitee.com/lyt-top/vue-next-admin/issues/I6AF8P
    return themeConfig.value.isLockScreen ? themeConfig.value.lockScreenTime > 1 : themeConfig.value.lockScreenTime >= 0;
});
// // 获取版本号
// const getVersion = computed(() => {
//     let isVersion = false;
//     if (route.path !== '/login') {
//         // @ts-ignore
//         if ((Local.get('version') && Local.get('version') !== __NEXT_VERSION__) || !Local.get('version')) isVersion = true;
//     }
//     return isVersion;
// });
 
// checkUpdate(() => {
//     needUpdate.value = true;
// }, 60000);
 
// 获取全局组件大小
const getGlobalComponentSize = computed(() => {
    return other.globalComponentSize();
});
// 获取全局 i18n
const getGlobalI18n = computed(() => {
    return messages.value[locale.value];
});
// 设置初始化,防止刷新时恢复默认
onBeforeMount(() => {
    // 设置批量第三方 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'));
        }
    });
});
// 页面销毁时,关闭监听布局配置/i18n监听
onUnmounted(() => {
    mittBus.off('openSetingsDrawer', () => {});
});
// 监听路由的变化,设置网站标题
watch(
    () => route.path,
    () => {
        other.useTitle();
    },
    {
        deep: true,
    }
);
</script>
 
<style lang="scss">
.el-form--inline {
    .el-form-item {
        .el-select {
            width: 171px !important;
        }
        .el-select__wrapper {
            line-height: 22px !important;
        }
        .el-date-editor {
            --el-date-editor-width: 171px !important;
        }
        .el-input {
            width: 171px !important;
        }
    }
}
</style>