1
lzhe
2024-09-26 7d59e8e2c727dd49d9552a8febc2af47c5b95a69
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
<!--
 * @Date: 2024-03-23 09:49:06
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-03-26 21:41:35
 * @FilePath: /cps-web/src/App.vue
-->
<template>
    <el-config-provider :locale="locale" :size="config.size" :zIndex="config.zIndex" :button="config.button">
        <router-view></router-view>
    </el-config-provider>
</template>
 
<script>
import colorTool from '@/utils/color'
 
export default {
    name: 'App',
    data() {
        return {
            config: {
                size: "default",
                zIndex: 2000,
                button: {
                    autoInsertSpace: false
                }
            }
        }
    },
    computed: {
        locale() {
            return this.$i18n.messages[this.$i18n.locale].el
        },
    },
    created() {
        //设置主题颜色
        const app_color = this.$CONFIG.COLOR || this.$TOOL.data.get('APP_COLOR')
        if (app_color) {
            document.documentElement.style.setProperty('--el-color-primary', app_color);
            for (let i = 1; i <= 9; i++) {
                document.documentElement.style.setProperty(`--el-color-primary-light-${i}`, colorTool.lighten(app_color, i / 10));
            }
            for (let i = 1; i <= 9; i++) {
                document.documentElement.style.setProperty(`--el-color-primary-dark-${i}`, colorTool.darken(app_color, i / 10));
            }
        }
    },
    mounted() {
        const debounce = (fn, delay) => {
            let timer
            return (...args) => {
                if (timer) {
                    clearTimeout(timer)
                }
                timer = setTimeout(() => {
                    fn(...args)
                }, delay)
            }
        }
 
        const _ResizeObserver = window.ResizeObserver;
        window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
            constructor(callback) {
                callback = debounce(callback, 200);
                super(callback);
            }
        }
    }
}
</script>
 
<style lang="scss">
@import '@/style/style.scss';
</style>