Skip to content

Commit 8bf9635

Browse files
committed
fix(dashboard): dashboard 分类
1 parent b7fe2c7 commit 8bf9635

File tree

7 files changed

+70
-11
lines changed

7 files changed

+70
-11
lines changed

src/assets/style/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@import 'base.less'
1+
@import 'base.less';

src/components/nav-menu/src/nav-menu.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: wenlan
55
* @Date: 2022-01-27 22:29:28
66
* @LastEditors: wenlan
7-
* @LastEditTime: 2022-02-06 21:02:44
7+
* @LastEditTime: 2022-02-06 21:01:12
88
-->
99
<script setup lang="ts">
1010
import { PermissionModule } from '@/store/premission/index'
@@ -16,7 +16,8 @@ const route = useRoute()
1616
const routes = computed(() => {
1717
return PermissionModule.routes
1818
})
19-
computed
19+
console.log('route', route)
20+
//computed
2021
const activeMenu = computed(() => {
2122
const { meta, name } = route
2223
// if set path, the sidebar will highlight the path you set

src/router/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: wenlan
55
* @Date: 2022-01-15 16:55:13
66
* @LastEditors: wenlan
7-
* @LastEditTime: 2022-02-05 13:11:41
7+
* @LastEditTime: 2022-02-07 16:04:51
88
*/
99
import { createRouter, createWebHashHistory } from 'vue-router'
1010
import type { RouteRecordRaw } from 'vue-router'
@@ -168,4 +168,6 @@ export function resetRouter() {
168168
;(router as any).matcher = (newRouter as any).matcher // reset router
169169
}
170170

171+
console.log('路由', router.getRoutes())
172+
171173
export default router

src/views/main/Main.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* @Author: wenlan
55
* @Date: 2022-01-23 17:12:21
66
* @LastEditors: wenlan
7-
* @LastEditTime: 2022-02-06 21:04:01
7+
* @LastEditTime: 2022-02-07 14:35:33
88
-->
99
<script setup lang="ts">
10-
import { markRaw, ref } from 'vue'
10+
import { ref } from 'vue'
1111
import NavHeader from '@/components/nav-header'
1212
import NavMenu from '@/components/nav-menu'
1313
import { useRoute } from 'vue-router'
14-
const route = markRaw(useRoute())
1514
let ISCollapse = ref<boolean>(false)
15+
const route = useRoute()
1616
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1717
const handleCollapse = (isCollapse: boolean) => {
1818
console.log(isCollapse)
@@ -31,14 +31,33 @@ const handleCollapse = (isCollapse: boolean) => {
3131
<nav-header @change-collapse="handleCollapse"></nav-header>
3232
</el-header>
3333
<el-main class="page-content">
34-
<router-view :key="route.path"> </router-view>
34+
<router-view v-slot="{ Component }">
35+
<transition name="why" appear>
36+
<div :key="(route.name as string)">
37+
<component :is="Component"></component>
38+
</div>
39+
</transition>
40+
</router-view>
3541
</el-main>
3642
</el-container>
3743
</el-container>
3844
</div>
3945
</template>
4046

4147
<style scoped lang="less">
48+
.why-active {
49+
color: red;
50+
}
51+
52+
.why-enter-from,
53+
.why-leave-to {
54+
opacity: 0;
55+
}
56+
57+
.why-enter-active,
58+
.why-leave-active {
59+
transition: opacity 1s ease;
60+
}
4261
.main {
4362
position: fixed;
4463
top: 0;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
* @Descripttion:
3+
* @version:
4+
* @Author: wenlan
5+
* @Date: 2022-02-07 16:24:32
6+
* @LastEditors: wenlan
7+
* @LastEditTime: 2022-02-07 16:25:47
8+
-->
9+
<script setup lang="ts"></script>
10+
11+
<template><h1>admin</h1></template>
12+
13+
<style scoped></style>

src/views/main/dashboard/dashboard.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44
* @Author: wenlan
55
* @Date: 2022-02-03 10:50:45
66
* @LastEditors: wenlan
7-
* @LastEditTime: 2022-02-03 10:50:48
7+
* @LastEditTime: 2022-02-07 16:42:49
88
-->
9-
<script setup lang="ts"></script>
9+
<script setup lang="ts">
10+
import { LoginModule } from '@/store/login/index'
11+
import { computed } from 'vue'
12+
import AdminDashboard from './admin/index.vue'
13+
import EditorDashboard from './editor/index.vue'
14+
let currentRole = computed(() => {
15+
return LoginModule.roles.includes('admin') ? AdminDashboard : EditorDashboard
16+
})
17+
</script>
1018

1119
<template>
12-
<h1>首页</h1>
20+
<div class="dashboard-container">
21+
<component :is="currentRole" />
22+
</div>
1323
</template>
1424

1525
<style scoped></style>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--
2+
* @Descripttion:
3+
* @version:
4+
* @Author: wenlan
5+
* @Date: 2022-02-07 16:24:41
6+
* @LastEditors: wenlan
7+
* @LastEditTime: 2022-02-07 16:25:52
8+
-->
9+
<script setup lang="ts"></script>
10+
<template>
11+
<h1>Editor</h1>
12+
</template>
13+
14+
<style scoped></style>

0 commit comments

Comments
 (0)