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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<template>
  <div class="menubutton" :style="{ width: props.width, height: props.height }" :onclick="onClick">
    <div style="margin-top: 10px;">
      <svg-icon width="30" height="30" :color="props.color" :name="props.item.icon"/>
    </div>
    <div style="margin-top: 10px;">
      <p style="width: 100%; overflow: hidden;">{{ props.item.text }}</p>
    </div>
  </div>
</template>
 
<script>
import {getCurrentInstance, onBeforeUnmount, onMounted, reactive, toRefs} from "vue";
import {useBasicInfoStore} from "@/store/basicInfo";
import * as elementplus from "element-plus";
 
export default {
  name: "MenuButton",
  components: {},
  props: {
    item: null,
    height: "100px",
    width: "100px",
    color: "",
    click: null
  },
  setup(props) {
    let {proxy} = getCurrentInstance();
    const store = useBasicInfoStore();
    const state = reactive({
      staticDomain: WGURL.staticDomain,
    });
 
    onMounted(() => {
      Init();
    });
    onBeforeUnmount(() => {
 
    });
 
    const Init = () => {
 
    };
 
    const onClick = () => {
      if (!props.click) {
        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":
            store.iframe_url = props.item.link;
            store.iframe_dialogVisible = true;
            store.iframe_title = props.item.text;
            store.iframe_loading = true;
            // window.open(props.item.link);
            break;
        }
      } else {
        props.click(props.item);
      }
    };
    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,
          path: target.link
        });
      }
    };
    return {
      ...toRefs(state), props, onClick
    }
  },
}
</script>
 
<style scoped>
.menubutton {
  border: 1px solid;
  border-image: linear-gradient(45deg, rgba(255, 255, 255, 0) 0%, var(--el-color-primary-light-6) 20%, rgba(255, 255, 255, 0) 99%) 2 2 2 2;
  float: left;
  text-align: center;
  padding: 5px;
  font-size: 12px;
  cursor: pointer;
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE10+/Edge */
  user-select: none; /* Standard syntax */
}
 
.menubutton:hover {
  background-color: var(--el-color-primary-light-6);
  color: white;
}
 
.menubutton:active {
  background-color: var(--el-color-primary-light-6);
  color: white;
}
</style>