11<template >
22 <el-drawer v-model =" showSettings" :withHeader =" false" :lock-scroll =" false" direction =" rtl" size =" 300px" >
3+ <div class =" setting-drawer-title" >
4+ <h3 class =" drawer-title" >菜单导航设置</h3 >
5+ </div >
6+ <div class =" nav-wrap" >
7+ <el-tooltip content =" 左侧菜单" placement =" bottom" >
8+ <div class =" item left" @click =" handleNavType(1)" :class =" { activeItem: navType == 1 }" >
9+ <b ></b ><b ></b >
10+ </div >
11+ </el-tooltip >
12+
13+ <el-tooltip content =" 混合菜单" placement =" bottom" >
14+ <div class =" item mix" @click =" handleNavType(2)" :class =" { activeItem: navType == 2 }" >
15+ <b ></b ><b ></b >
16+ </div >
17+ </el-tooltip >
18+ <el-tooltip content =" 顶部菜单" placement =" bottom" >
19+ <div class =" item top" @click =" handleNavType(3)" :class =" { activeItem: navType == 3 }" >
20+ <b ></b ><b ></b >
21+ </div >
22+ </el-tooltip >
23+ </div >
324 <div class =" setting-drawer-title" >
425 <h3 class =" drawer-title" >主题风格设置</h3 >
526 </div >
3556
3657 <h3 class =" drawer-title" >系统布局配置</h3 >
3758
38- <div class =" drawer-item" >
39- <span >开启 TopNav</span >
40- <span class =" comp-style" >
41- <el-switch v-model =" settingsStore.topNav" @change =" topNavChange" class =" drawer-switch" />
42- </span >
43- </div >
44-
4559 <div class =" drawer-item" >
4660 <span >开启 Tags-Views</span >
4761 <span class =" comp-style" >
@@ -103,19 +117,12 @@ const appStore = useAppStore()
103117const settingsStore = useSettingsStore ()
104118const permissionStore = usePermissionStore ()
105119const showSettings = ref (false );
120+ const navType = ref (settingsStore .navType )
106121const theme = ref (settingsStore .theme );
107122const sideTheme = ref (settingsStore .sideTheme );
108123const storeSettings = computed (() => settingsStore);
109124const predefineColors = ref ([" #409EFF" , " #ff4500" , " #ff8c00" , " #ffd700" , " #90ee90" , " #00ced1" , " #1e90ff" , " #c71585" ]);
110125
111- /** 是否需要topnav */
112- function topNavChange (val ) {
113- if (! val) {
114- appStore .toggleSideBarHide (false );
115- permissionStore .setSidebarRouters (permissionStore .defaultRoutes );
116- }
117- }
118-
119126/** 是否需要dynamicTitle */
120127function dynamicTitleChange () {
121128 useSettingsStore ().setTitle (useSettingsStore ().title )
@@ -125,14 +132,40 @@ function themeChange(val) {
125132 settingsStore .theme = val;
126133 handleThemeStyle (val);
127134}
135+
128136function handleTheme (val ) {
129137 settingsStore .sideTheme = val;
130138 sideTheme .value = val;
131139}
140+
141+ function handleNavType (val ) {
142+ settingsStore .navType = val
143+ navType .value = val
144+ }
145+
146+ /** 菜单导航设置 */
147+ watch (() => navType, val => {
148+ if (val .value == 1 ) {
149+ appStore .sidebar .opened = true
150+ appStore .toggleSideBarHide (false )
151+ }
152+ if (val .value == 2 ) {
153+ appStore .sidebar .opened = true
154+ }
155+ if (val .value == 3 ) {
156+ appStore .sidebar .opened = false
157+ appStore .toggleSideBarHide (true )
158+ }
159+ if ([1 , 3 ].includes (val .value )) {
160+ permissionStore .setSidebarRouters (permissionStore .defaultRoutes )
161+ }
162+ }, { immediate: true , deep: true }
163+ )
164+
132165function saveSetting () {
133166 proxy .$modal .loading (" 正在保存到本地,请稍候..." );
134167 let layoutSetting = {
135- " topNav " : storeSettings .value .topNav ,
168+ " navType " : storeSettings .value .navType ,
136169 " tagsView" : storeSettings .value .tagsView ,
137170 " tagsIcon" : storeSettings .value .tagsIcon ,
138171 " fixedHeader" : storeSettings .value .fixedHeader ,
@@ -145,11 +178,13 @@ function saveSetting() {
145178 localStorage .setItem (" layout-setting" , JSON .stringify (layoutSetting));
146179 setTimeout (proxy .$modal .closeLoading (), 1000 )
147180}
181+
148182function resetSetting () {
149183 proxy .$modal .loading (" 正在清除设置缓存并刷新,请稍候..." );
150184 localStorage .removeItem (" layout-setting" )
151185 setTimeout (" window.location.reload()" , 1000 )
152186
D306
}
187+
153188function openSetting () {
154189 showSettings .value = true ;
155190}
@@ -214,4 +249,67 @@ defineExpose({
214249 margin : -3px 8px 0px 0px ;
215250 }
216251}
252+
253+ // 导航模式
254+ .nav-wrap {
255+ display : flex ;
256+ justify-content : flex-start ;
257+ align-items : center ;
258+ margin-top : 10px ;
259+ margin-bottom : 20px ;
260+
261+ .activeItem {
262+ border : 2px solid var (--el-color-primary ) !important ;
263+ }
264+
265+ .item {
266+ position : relative ;
267+ margin-right : 16px ;
268+ cursor : pointer ;
269+ width : 56px ;
270+ height : 48px ;
271+ border-radius : 4px ;
272+ background : #f0f2f5 ;
273+ border : 2px solid transparent ;
274+ }
275+
276+ .left {
277+ b :first-child {
278+ display : block ;
279+ height : 30% ;
280+ background : #fff ;
281+ }
282+ b :last-child {
283+ width : 30% ;
284+ background : #1b2a47 ;
285+ position : absolute ;
286+ height : 100% ;
287+ top : 0 ;
288+ border-radius : 4px 0 0 4px ;
289+ }
290+ }
291+ .mix {
292+ b :first-child {
293+ border-radius : 4px 4px 0 0 ;
294+ display : block ;
295+ height : 30% ;
296+ background : #1b2a47 ;
297+ }
298+ b :last-child {
299+ width : 30% ;
300+ background : #1b2a47 ;
301+ position : absolute ;
302+ height : 70% ;
303+ border-radius : 0 0 0 4px ;
304+ }
305+ }
306+ .top {
307+ b :first-child {
308+ display : block ;
309+ height : 30% ;
310+ background : #1b2a47 ;
311+ border-radius : 4px 4px 0 0 ;
312+ }
313+ }
314+ }
217315 </style >
0 commit comments