mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-04-26 09:17:52 +08:00
新增标签页样式chrome风格
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
<h3 class="drawer-title">系统布局配置</h3>
|
<h3 class="drawer-title">系统布局配置</h3>
|
||||||
|
|
||||||
<div class="drawer-item">
|
<div class="drawer-item">
|
||||||
<span>开启 Tags-Views</span>
|
<span>开启页签</span>
|
||||||
<el-switch v-model="tagsView" class="drawer-switch" />
|
<el-switch v-model="tagsView" class="drawer-switch" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -75,6 +75,14 @@
|
|||||||
<el-switch v-model="tagsIcon" :disabled="!tagsView" class="drawer-switch" />
|
<el-switch v-model="tagsIcon" :disabled="!tagsView" class="drawer-switch" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="drawer-item">
|
||||||
|
<span>标签页样式</span>
|
||||||
|
<el-radio-group v-model="tagsViewStyle" :disabled="!tagsView" size="mini" class="drawer-switch">
|
||||||
|
<el-radio-button label="card">卡片</el-radio-button>
|
||||||
|
<el-radio-button label="chrome">谷歌</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="drawer-item">
|
<div class="drawer-item">
|
||||||
<span>固定 Header</span>
|
<span>固定 Header</span>
|
||||||
<el-switch v-model="fixedHeader" class="drawer-switch" />
|
<el-switch v-model="fixedHeader" class="drawer-switch" />
|
||||||
@@ -163,6 +171,17 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
tagsViewStyle: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.settings.tagsViewStyle
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.dispatch('settings/changeSetting', {
|
||||||
|
key: 'tagsViewStyle',
|
||||||
|
value: val
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
sidebarLogo: {
|
sidebarLogo: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state.settings.sidebarLogo
|
return this.$store.state.settings.sidebarLogo
|
||||||
@@ -256,6 +275,7 @@ export default {
|
|||||||
"navType":${this.navType},
|
"navType":${this.navType},
|
||||||
"tagsView":${this.tagsView},
|
"tagsView":${this.tagsView},
|
||||||
"tagsIcon":${this.tagsIcon},
|
"tagsIcon":${this.tagsIcon},
|
||||||
|
"tagsViewStyle":"${this.tagsViewStyle}",
|
||||||
"tagsViewPersist":${this.tagsViewPersist},
|
"tagsViewPersist":${this.tagsViewPersist},
|
||||||
"fixedHeader":${this.fixedHeader},
|
"fixedHeader":${this.fixedHeader},
|
||||||
"sidebarLogo":${this.sidebarLogo},
|
"sidebarLogo":${this.sidebarLogo},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="tags-view-container" class="tags-view-container">
|
<div id="tags-view-container" class="tags-view-container" :class="{ 'tags-view-container--chrome': tagsViewStyle === 'chrome' }" :style="chromeVars">
|
||||||
<!-- 左切换箭头 -->
|
<!-- 左切换箭头 -->
|
||||||
<span class="tags-nav-btn tags-nav-btn--left" :class="{ disabled: !canScrollLeft }" @click="scrollLeft">
|
<span class="tags-nav-btn tags-nav-btn--left" :class="{ disabled: !canScrollLeft }" @click="scrollLeft">
|
||||||
<i class="el-icon-arrow-left" />
|
<i class="el-icon-arrow-left" />
|
||||||
@@ -15,11 +15,11 @@
|
|||||||
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
||||||
tag="span"
|
tag="span"
|
||||||
class="tags-view-item"
|
class="tags-view-item"
|
||||||
:style="activeStyle(tag)"
|
:style="tagActiveStyle(tag)"
|
||||||
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
||||||
@contextmenu.prevent.native="openMenu(tag, $event)"
|
@contextmenu.prevent.native="openMenu(tag, $event)"
|
||||||
>
|
>
|
||||||
<svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" />
|
<svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" style="margin-right: 3px;" />
|
||||||
{{ tag.title }}
|
{{ tag.title }}
|
||||||
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
|
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
|
||||||
</router-link>
|
</router-link>
|
||||||
@@ -97,8 +97,20 @@ export default {
|
|||||||
tagsIcon() {
|
tagsIcon() {
|
||||||
return this.$store.state.settings.tagsIcon
|
return this.$store.state.settings.tagsIcon
|
||||||
},
|
},
|
||||||
|
tagsViewStyle() {
|
||||||
|
return this.$store.state.settings.tagsViewStyle
|
||||||
|
},
|
||||||
selectedDropdownTag() {
|
selectedDropdownTag() {
|
||||||
return this.visitedViews.find(v => this.isActive(v)) || {}
|
return this.visitedViews.find(v => this.isActive(v)) || {}
|
||||||
|
},
|
||||||
|
chromeVars() {
|
||||||
|
if (this.tagsViewStyle !== 'chrome') return {}
|
||||||
|
const primary = this.theme || '#409EFF'
|
||||||
|
return {
|
||||||
|
'--chrome-tab-active-bg': this.mixHexWithWhite(primary, 0.15),
|
||||||
|
'--chrome-tab-text-active': primary,
|
||||||
|
'--chrome-wing-r': '14px'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -136,11 +148,21 @@ export default {
|
|||||||
this.toggleFullscreen()
|
this.toggleFullscreen()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mixHexWithWhite(hex, ratio) {
|
||||||
|
const clean = hex.replace('#', '')
|
||||||
|
const r = parseInt(clean.substring(0, 2), 16)
|
||||||
|
const g = parseInt(clean.substring(2, 4), 16)
|
||||||
|
const b = parseInt(clean.substring(4, 6), 16)
|
||||||
|
const mr = Math.round(r * ratio + 255 * (1 - ratio))
|
||||||
|
const mg = Math.round(g * ratio + 255 * (1 - ratio))
|
||||||
|
const mb = Math.round(b * ratio + 255 * (1 - ratio))
|
||||||
|
return `rgb(${mr}, ${mg}, ${mb})`
|
||||||
|
},
|
||||||
isActive(route) {
|
isActive(route) {
|
||||||
return route.path === this.$route.path
|
return route.path === this.$route.path
|
||||||
},
|
},
|
||||||
activeStyle(tag) {
|
tagActiveStyle(tag) {
|
||||||
if (!this.isActive(tag)) return {}
|
if (!this.isActive(tag) || this.tagsViewStyle !== 'card') return {}
|
||||||
return {
|
return {
|
||||||
"background-color": this.theme,
|
"background-color": this.theme,
|
||||||
"border-color": this.theme
|
"border-color": this.theme
|
||||||
@@ -367,13 +389,16 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
$tags-bar-height: 34px;
|
||||||
|
|
||||||
.tags-view-container {
|
.tags-view-container {
|
||||||
height: 34px;
|
height: $tags-bar-height;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
border-bottom: 1px solid #d8dce5;
|
border-bottom: 1px solid #d8dce5;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
$btn-width: 28px;
|
$btn-width: 28px;
|
||||||
$btn-color: #71717a;
|
$btn-color: #71717a;
|
||||||
@@ -388,7 +413,7 @@ export default {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: $btn-width;
|
width: $btn-width;
|
||||||
height: 34px;
|
height: $tags-bar-height;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: $btn-color;
|
color: $btn-color;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -405,18 +430,14 @@ export default {
|
|||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--left {
|
&--left { border-right: $divider; }
|
||||||
border-right: $divider;
|
&--right { border-left: $divider; }
|
||||||
}
|
|
||||||
|
|
||||||
&--right {
|
|
||||||
border-left: $divider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags-view-wrapper {
|
.tags-view-wrapper {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
.tags-view-item {
|
.tags-view-item {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -432,13 +453,11 @@ export default {
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
&:first-of-type {
|
&:first-of-type { margin-left: 6px; }
|
||||||
margin-left: 6px;
|
&:last-of-type { margin-right: 15px; }
|
||||||
}
|
}
|
||||||
&:last-of-type {
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
}
|
||||||
&.active {
|
&:not(.tags-view-container--chrome) .tags-view-wrapper .tags-view-item.active {
|
||||||
background-color: #42b983;
|
background-color: #42b983;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-color: #42b983;
|
border-color: #42b983;
|
||||||
@@ -453,10 +472,8 @@ export default {
|
|||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tags-view-item.active.has-icon::before {
|
&:not(.tags-view-container--chrome) .tags-view-wrapper .tags-view-item.active.has-icon::before {
|
||||||
content: none !important;
|
content: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +488,7 @@ export default {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: $btn-width;
|
width: $btn-width;
|
||||||
height: 34px;
|
height: $tags-bar-height;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: $btn-color;
|
color: $btn-color;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -511,11 +528,174 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.tags-view-container--chrome {
|
||||||
|
--chrome-strip-bg: #ffffff;
|
||||||
|
--chrome-strip-border: #e4e7ed;
|
||||||
|
--chrome-tab-text: #606266;
|
||||||
|
|
||||||
|
overflow: visible;
|
||||||
|
background: var(--chrome-strip-bg);
|
||||||
|
border-bottom: 1px solid var(--chrome-strip-border);
|
||||||
|
align-items: flex-end;
|
||||||
|
|
||||||
|
.tags-nav-btn {
|
||||||
|
align-self: stretch;
|
||||||
|
height: auto;
|
||||||
|
min-height: $tags-bar-height;
|
||||||
|
border-color: var(--chrome-strip-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-action-btn {
|
||||||
|
border-color: var(--chrome-strip-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-view-wrapper {
|
||||||
|
.tags-view-item {
|
||||||
|
display: inline-flex !important;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
height: 30px;
|
||||||
|
min-height: 30px;
|
||||||
|
margin: 0 0 -1px;
|
||||||
|
padding: 0 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.2;
|
||||||
|
border: none !important;
|
||||||
|
border-radius: 0;
|
||||||
|
background: transparent !important;
|
||||||
|
color: var(--chrome-tab-text) !important;
|
||||||
|
padding-top: 0 !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
transition: background 0.12s ease, color 0.12s ease, border-radius 0.12s ease;
|
||||||
|
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
content: '' !important;
|
||||||
|
display: block !important;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: var(--chrome-wing-r);
|
||||||
|
height: var(--chrome-wing-r);
|
||||||
|
margin: 0 !important;
|
||||||
|
pointer-events: none;
|
||||||
|
background: transparent !important;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
transition: box-shadow 0.12s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
left: calc(-1 * var(--chrome-wing-r));
|
||||||
|
border-bottom-right-radius: var(--chrome-wing-r) !important;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
right: calc(-1 * var(--chrome-wing-r));
|
||||||
|
border-bottom-left-radius: var(--chrome-wing-r) !important;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:first-of-type { margin-left: 6px; }
|
||||||
|
&:last-of-type { margin-right: 10px; }
|
||||||
|
|
||||||
|
&:not(.active) + .tags-view-item:not(.active) {
|
||||||
|
border-left: 1px solid #e4e7ed;
|
||||||
|
padding-left: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover:not(.active) {
|
||||||
|
background: #f5f7fa !important;
|
||||||
|
border-radius: 6px 6px 0 0;
|
||||||
|
color: #303133 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
height: 31px;
|
||||||
|
min-height: 31px;
|
||||||
|
padding: 0 14px;
|
||||||
|
color: var(--chrome-tab-text-active) !important;
|
||||||
|
font-weight: 500;
|
||||||
|
background: var(--chrome-tab-active-bg) !important;
|
||||||
|
border: none !important;
|
||||||
|
border-radius: var(--chrome-wing-r) var(--chrome-wing-r) 0 0;
|
||||||
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
box-shadow: calc(var(--chrome-wing-r) * 0.5) calc(var(--chrome-wing-r) * 0.5) 0 calc(var(--chrome-wing-r) * 0.5) var(--chrome-tab-active-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
box-shadow: calc(var(--chrome-wing-r) * -0.5) calc(var(--chrome-wing-r) * 0.5) 0 calc(var(--chrome-wing-r) * 0.5) var(--chrome-tab-active-bg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.el-icon-close {
|
||||||
|
margin-left: 3px;
|
||||||
|
&:before {
|
||||||
|
vertical-align: -2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.tags-view-wrapper {
|
.tags-view-wrapper {
|
||||||
|
.el-scrollbar {
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-scrollbar__wrap {
|
||||||
|
height: 34px !important;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-view-container:hover & {
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
|
border-radius: 3px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-scrollbar__bar {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s;
|
||||||
|
|
||||||
|
.tags-view-container:hover & {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.tags-view-item {
|
.tags-view-item {
|
||||||
.el-icon-close {
|
.el-icon-close {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
tagsIcon: false,
|
tagsIcon: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签页样式:card 卡片(默认)、chrome 谷歌浏览器风格
|
||||||
|
*/
|
||||||
|
tagsViewStyle: 'card',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否固定头部
|
* 是否固定头部
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import defaultSettings from '@/settings'
|
import defaultSettings from '@/settings'
|
||||||
import { useDynamicTitle } from '@/utils/dynamicTitle'
|
import { useDynamicTitle } from '@/utils/dynamicTitle'
|
||||||
|
|
||||||
const { sideTheme, showSettings, navType, tagsView, tagsViewPersist, tagsIcon, fixedHeader, sidebarLogo, dynamicTitle, footerVisible, footerContent } = defaultSettings
|
const { sideTheme, showSettings, navType, tagsView, tagsViewPersist, tagsIcon, tagsViewStyle, fixedHeader, sidebarLogo, dynamicTitle, footerVisible, footerContent } = defaultSettings
|
||||||
|
|
||||||
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
|
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
|
||||||
const state = {
|
const state = {
|
||||||
@@ -13,6 +13,7 @@ const state = {
|
|||||||
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
|
tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
|
||||||
tagsViewPersist: storageSetting.tagsViewPersist === undefined ? tagsViewPersist : storageSetting.tagsViewPersist,
|
tagsViewPersist: storageSetting.tagsViewPersist === undefined ? tagsViewPersist : storageSetting.tagsViewPersist,
|
||||||
tagsIcon: storageSetting.tagsIcon === undefined ? tagsIcon : storageSetting.tagsIcon,
|
tagsIcon: storageSetting.tagsIcon === undefined ? tagsIcon : storageSetting.tagsIcon,
|
||||||
|
tagsViewStyle: storageSetting.tagsViewStyle === undefined ? tagsViewStyle : storageSetting.tagsViewStyle,
|
||||||
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
|
fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
|
||||||
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
|
sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
|
||||||
dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle,
|
dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle,
|
||||||
|
|||||||
Reference in New Issue
Block a user