qiyunfeng-create
3 天以前 f2433a2fb08c167b45a9fc26f2fa178a76ab807b
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<template>
  <page>
    <div class="contentBox">
      <div class="breadcrumbBox">
        <span>位置:</span>
        <el-breadcrumb :separator-icon="ArrowRight">
          <el-breadcrumb-item>个人中心</el-breadcrumb-item>
          <el-breadcrumb-item>{{ label }}</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <el-divider />
      <div class="personalPage clear">
        <div class="leftList fl">
          <ul class="menu">
            <li
              v-for="item in listMenu"
              :key="item.key"
              @click="goRouter(item)"
              :class="`/${item.path}` === path ? 'activeItem hover' : 'menuItem hover'"
            >
              <span
                :style="{
                  fill: `/${item.path}` === path ? '#fff' : '#000',
                }"
                v-html="item.icon"
              >
              </span>
              <span>{{ item.label }}</span>
            </li>
          </ul>
        </div>
        <div class="rightContent">
          <div>
            <!-- 让主体做子路由的显示 -->
            <router-view />
          </div>
        </div>
      </div>
    </div>
  </page>
</template>
 
<script setup lang="ts">
import { ArrowRight } from '@element-plus/icons-vue'
import { menu } from './config.ts'
import { useRouter, onBeforeRouteUpdate } from 'vue-router'
import { ref, onMounted } from 'vue'
const router = useRouter()
const routerVal = router.currentRoute.value
const path = ref(routerVal.path)
const label = ref('')
const listMenu: any = ref([])
onBeforeRouteUpdate(async (to, from) => {
  path.value = to.fullPath
})
onMounted(() => {
  menu.forEach((item) => {
    if ('/' + item.path === path.value) {
      label.value = item.label
    }
  })
  // const userCache: any = localStorage.getItem('jesk-userInfo')
  // const userInfo = JSON.parse(userCache)
  // if(!userInfo){
  //   router.push({
  //     path:'/'
  //   })
  //   return false;
  // }
  // if (userInfo.role == 'Teacher') {
  //   const data: any = menu.filter((item) => item.path != 'class')
  //   listMenu.value = data
  // } else {
  const data: any = menu.filter((item) => item.path != 'course')
  listMenu.value = data
  // }
})
const goRouter = (item: any) => {
  // if (!localStorage.getItem('jsek-token') || localStorage.getItem('jsek-token') == null) {
  //   router.push({
  //     path: '/home',
  //     query: {
  //       showLogin: '1'
  //     }
  //   })
  // } else {
  label.value = item.label
  router.push({ path: item.path })
  // }
}
</script>
<style lang="less" scoped>
.breadcrumbBox {
  display: flex;
  padding: 20px;
}
 
.personalPage {
  padding: 20px 10px;
  display: flex;
 
  .leftList {
    width: 275px;
    border-radius: 10px 10px 10px 10px;
    background: #e1ebe3;
    height: max-content;
    .menu {
      li {
        height: 50px;
        padding: 10px 40px;
        font-size: 16px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid #ffffff;
 
        img {
          width: 19px;
          height: 24px;
        }
 
        span {
          margin-left: 10px;
        }
      }
 
      .activeItem {
        background: linear-gradient(90deg, #019e58 0%, #144941 100%);
        background-size: 100% 100%;
        color: #fff;
        svg {
          fill: #fff;
        }
      }
    }
  }
 
  .rightContent {
    flex: 1;
    overflow: auto;
    margin-left: 15px;
    background-color: #fff;
  }
}
</style>