Skip to content

Commit 4e45daf

Browse files
committed
feat: 新增页签图标显示开关功能
1 parent 04422ff commit 4e45daf

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

ruoyi-fastapi-frontend/src/layout/components/Settings/index.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
<el-switch v-model="tagsView" class="drawer-switch" />
5050
</div>
5151

52+
<div class="drawer-item">
53+
<span>显示页签图标</span>
54+
<el-switch v-model="tagsIcon" :disabled="!tagsView" class="drawer-switch" />
55+
</div>
56+
5257
<div class="drawer-item">
5358
<span>固定 Header</span>
5459
<el-switch v-model="fixedHeader" class="drawer-switch" />
@@ -124,6 +129,17 @@ export default {
124129
})
125130
}
126131
},
132+
tagsIcon: {
133+
get() {
134+
return this.$store.state.settings.tagsIcon
135+
},
136+
set(val) {
137+
this.$store.dispatch('settings/changeSetting', {
138+
key: 'tagsIcon',
139+
value: val
140+
})
141+
}
142+
},
127143
sidebarLogo: {
128144
get() {
129145
return this.$store.state.settings.sidebarLogo
@@ -176,6 +192,7 @@ export default {
176192
`{
177193
"topNav":${this.topNav},
178194
"tagsView":${this.tagsView},
195+
"tagsIcon":${this.tagsIcon},
179196
"fixedHeader":${this.fixedHeader},
180197
"sidebarLogo":${this.sidebarLogo},
181198
"dynamicTitle":${this.dynamicTitle},

ruoyi-fastapi-frontend/src/layout/components/TagsView/index.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
v-for="tag in visitedViews"
66
ref="tag"
77
:key="tag.path"
8-
:class="isActive(tag)?'active':''"
8+
:class="{ 'active': isActive(tag), 'has-icon': tagsIcon }"
99
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
1010
tag="span"
1111
class="tags-view-item"
1212
:style="activeStyle(tag)"
1313
@click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
1414
@contextmenu.prevent.native="openMenu(tag,$event)"
1515
>
16+
<svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" />
1617
{{ tag.title }}
1718
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
1819
</router-link>
@@ -52,6 +53,9 @@ export default {
5253
},
5354
theme() {
5455
return this.$store.state.settings.theme;
56+
},
57+
tagsIcon() {
58+
return this.$store.state.settings.tagsIcon
5559
}
5660
},
5761
watch: {
@@ -277,6 +281,11 @@ export default {
277281
}
278282
}
279283
}
284+
285+
.tags-view-item.active.has-icon::before {
286+
content: none !important;
287+
}
288+
280289
.contextmenu {
281290
margin: 0;
282291
background: #fff;

ruoyi-fastapi-frontend/src/settings.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
sideTheme: 'theme-dark',
1111

1212
/**
13-
* 是否系统布局配置
13+
* 系统布局配置
1414
*/
1515
showSettings: true,
1616

@@ -24,6 +24,11 @@ module.exports = {
2424
*/
2525
tagsView: true,
2626

27+
/**
28+
* 显示页签图标
29+
*/
30+
tagsIcon: false,
31+
2732
/**
2833
* 是否固定头部
2934
*/
@@ -37,13 +42,5 @@ module.exports = {
3742
/**
3843
* 是否显示动态标题
3944
*/
40-
dynamicTitle: false,
41-
42-
/**
43-
* @type {string | array} 'production' | ['production', 'development']
44-
* @description Need show err logs component.
45-
* The default is only used in the production env
46-
* If you want to also use it in dev, you can pass ['production', 'development']
47-
*/
48-
errorLog: 'production'
45+
dynamicTitle: false
4946
}

ruoyi-fastapi-frontend/src/store/modules/settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import defaultSettings from '@/settings'
22
import { useDynamicTitle } from '@/utils/dynamicTitle'
33

4-
const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings
4+
const { sideTheme, showSettings, topNav, tagsView, tagsIcon, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings
55

66
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
77
const state = {
@@ -11,6 +11,7 @@ const state = {
1111
showSettings: showSettings,
1212
topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,
1313
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
14+
tagsIcon: storageSetting.tagsIcon === undefined ? tagsIcon : storageSetting.tagsIcon,
1415
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
1516
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
1617
dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle

0 commit comments

Comments
 (0)