suerprisePlus
2024-09-24 0d50fe17a7086791275bc21d70adc79c5497c9d2
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
<template>
    <div class="tabsBox">
        <div @click="setPageToStop('Top')"><el-button class="tabsTitle" type="text">On This Page</el-button></div>
        <div class="tabsContent">
            <ul>
                <li :class="{ 'tabsLi': activeName === res.name }" @click="handleClick(res.name)"
                    v-for="(res, index) in tabsOption">
                    {{ res.name }}
                </li>
            </ul>
        </div>
    </div>
</template>
 
<script  setup lang="ts">
import { ref, onMounted, nextTick ,watch} from 'vue';
import useStore from '../../store/defineStore.ts';
import type { TabsPaneContext } from 'element-plus'
const tabPosition = ref('right')
const activeName = ref(null)
const store = useStore()
const handleClick = (res) => {
 
    if (res) {
        setPageToStop(res);
        activeName.value = res;
    }
}
const setPageToStop = (res) => {
    store.$patch((state) => {
        state.setListFlag = res;
 
    })
};
const tabsOption = ref([]);
 
const setTabsStart = () => {
    const std = [];
    for (var i in listMenu) {
        std.push({
            name: listMenu[i].name
        })
    }
    if (std.length <= 0) return
    tabsOption.value = std;
    activeName.value = std[0].name
}
onMounted(() => {
    setTabsStart();
 
})
 
watch(() => store.$state.setListIndex, (newValue, oldValue) => {
    if (newValue) {
     
        activeName.value = tabsOption.value[newValue.val].name;
        nextTick(() => {
            store.$state.setListIndex = null;
        })
    }
 
})
</script>
 
<style lang="scss" scoped>
.tabsBox {
    width: 20%;
    height: 99%;
    padding-top: 1%;
 
    .tabsTitle {
        font-size: 14px;
 
        line-height: 20px;
        padding-left: 20px;
        font-weight: bold;
 
        color: black
    }
 
    .tabsContent {
 
        padding-left: 20px;
        cursor: pointer;
 
        ul {
            margin: 0px;
            list-style: none;
            padding-left: 0px;
 
            li {
                line-height: 35px;
                font-size: 14px;
                padding-left: 10px;
            }
 
            li:hover {
                color: #409eff;
            }
        }
 
        .tabsLi {
            border-left: 2px solid #409eff;
            color: #409eff;
        }
 
 
    }
 
 
}
</style>