xuruiqian
2025-02-25 e85ab165147c37b571ea67ce6f6ae9ae55a96070
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
<template>
    <div class="appmenubutton" :style="{ width: props.width, height: props.height }" :onclick="onClick">
        <div style="margin-top: 20px;">
            <svg-icon width="30" height="30" :color="props.color" :name="props.item.icon"/>
        </div>
        <div style="margin-top: 10px;">
            <span style="font-family: FangSong bold; font-size: 14px; margin-left: 5px; overflow: hidden">{{ props.item.text }}</span>
        </div>
    </div>
</template>
 
<script>
    import {getCurrentInstance, onBeforeUnmount, onMounted, reactive, toRefs, shallowRef, ref} from "vue";
    import {useBasicInfoStore} from "../../store/basicInfo";
    import * as elementplus from "element-plus";
 
    export default {
        name: "AppMenuButton",
        components: {},
        props: {
            item: null,
            height: "100px",
            width: "100px",
            color: ""
        },
        setup(props) {
            let {proxy} = getCurrentInstance();
            const store = useBasicInfoStore();
            const state = reactive({
                staticDomain: WGURL.staticDomain,
            });
 
            onMounted(() => {
                Init();
            });
            onBeforeUnmount(() => {
 
            });
 
            const Init = () => {
 
            };
 
            const onClick = () => {
                switch (props.item.type) {
                    case "menu":
                        if (store.tags.length > store.tagUpperLimit) {
                            elementplus.ElMessageBox.alert(
                                `${proxy.$t('message.TagQuantityReachedUpperLimit')}`,
                                '',
                                {
                                    confirmButtonText: 'OK',
                                    type: 'warning',
                                }
                            );
 
                            return;
                        }
 
                        addTag(props.item);
                        proxy.$router.replace(props.item.link);
                        break;
                    case "link":
                        window.open(props.item.link);
                        break;
                }
            };
            const addTag = (target) => {
                let stags = store.tags.filter(tab => tab.name === target.name);
 
                if (stags === [] || stags.length <= 0) {
                    store.tags.push({
                        name: target.name,
                        languagekey: target.languagekey,
                        closable: true,
                        icon: target.icon
                    });
                }
            };
            return {
                ...toRefs(state), props, onClick
            }
        },
    }
</script>
 
<style scoped>
    .appmenubutton {
        border: 1px solid #ccc;
        float: left;
        text-align: center;
        padding: 5px;
    }
 
    .appmenubutton:hover {
        background-color: var(--el-color-primary-light-6);
        color: white;
    }
 
    .appmenubutton:active {
        background-color: var(--el-color-primary-light-6);
        color: white;
    }
</style>