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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
<div class="home">
<a-layout class="home-page">
<a-layout-header class="header">
<div class="header-right">
<bell-outlined />
</div>
<div class="header-right">
<RadarChartOutlined /><span>{{ info.name }}</span>
</div>
<div class="header-right">
<DashOutlined />
</div>
</a-layout-header>
<a-layout>
<a-layout-sider width="200" style="background: #fff">
<a-menu
v-model:selectedKeys="selectedKeys"
theme="dark"
mode="inline"
>
{{router.options.routes[2].children}}
<a-menu-item
v-for="item in router.options.routes[2]"
:key="item.id"
@click="goNewPage(item)"
>
<div style="display: flex; align-items: center" >
<AlipaySquareFilled
v-if="item.id === 1"
style="font-size: 25px"
/>
<DatabaseFilled v-else style="font-size: 25px" />
<span class="nav-text" >{{ item.name }}</span>
</div>
</a-menu-item>
</a-menu>
</a-layout-sider>
<a-layout style="padding: 0 24px 24px">
<a-layout-content
:style="{
background: '#fff',
padding: '24px',
margin: 0,
minHeight: '280px',
}"
>
<router-view></router-view>
</a-layout-content>
</a-layout>
</a-layout>
</a-layout>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, onMounted } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import {
BellOutlined,
RadarChartOutlined,
DashOutlined,
AlipaySquareFilled,
DatabaseFilled,
} from "@ant-design/icons-vue";
import { getRouters } from "@/api/index";
import { onSetRouter} from "@/utils/userInfo"
interface FormUser {
name: String;
password: String;
}
const router = useRouter();
const store = useStore();
const selectedKeys = ref<string[]>(["1"])
const info = reactive<FormUser>(store.getters.getUserInfo);
const goNewPage = (e: any) => {
const { path } = e;
router.push({
path,
query:{
}
});
};
const setRoutet = (list: any) => {
store.commit("setRoutet", list);
};
onMounted(async() => {
const list: any = await getRouters();
setRoutet(list.data);
});
defineExpose({
selectedKeys,
openKeys: ref<string[]>(["sub1"]),
goNewPage,
setRoutet,
info,
store,
router
});
</script>
<style>
#components-layout-demo-top-side-2 .logo {
float: left;
width: 120px;
height: 31px;
margin: 16px 24px 16px 0;
background: rgba(255, 255, 255, 0.3);
}
.ant-row-rtl #components-layout-demo-top-side-2 .logo {
float: right;
margin: 16px 0 16px 24px;
}
.site-layout-background {
background: #fff;
}
.ant-menu-submenu-arrow {
display: none;
}
</style>
<style scoped>
.custom-icons-list :deep(.anticon) {
margin-right: 6px;
}
</style>
<style lang="less">
.home {
width: 100%;
.ant-layout {
height: 871px;
overflow-y: hidden;
padding: 0px !important;
background-color: white;
}
.ant-layout-sider-children {
background: rgb(235, 235, 235);
}
.ant-layout-has-sider {
overflow: hidden;
}
.home-page {
height: 100%;
overflow: hidden;
.header {
display: flex;
align-items: center;
justify-content: flex-end;
background-color: @primary-color;
.header-right {
margin-right: 40px;
}
}
}
}
</style>