管理平台
{{theme === 'dark' ? '深色' : '浅色'}}
当前用户:{{$root.userInfo.userName}} 登出
$colors-light: (
bg-header: linear-gradient(45deg, #abc7da 0%, #1f8fd9 100%),
bg-main-content: #ffffff,
bg-block: #ffffff,
bg-table-header: #ffffff,
bg-li: linear-gradient(45deg, #ffffff 0%, #d2e3ed 100%),
text-title: #353535,
text-menu: #404040,
text-logout: #ffffff,
text-li: #353535,
shadow-color: rgba(74, 144, 226, 0.8),
shadow-block: rgba(0, 58, 129, 0.4),
);
$colors-dark: (
bg-header: linear-gradient(-135deg, #003659 0%, #2b6993 100%),
bg-main-content: #061b38,
bg-block: linear-gradient(-180deg, rgba(19, 20, 41, 0.47) 79%, rgba(25, 68, 90, 0.32) 100%),
bg-li: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(210, 227, 237, 0.2) 100%),
bg-table-header: linear-gradient(45deg, #224969 0%, #08244c 100%),
text-title: #ffffff,
text-menu: #ffffff,
text-logout: #1f8fd9,
text-li: #ffffff,
shadow-color: rgba(74, 144, 226, 0.14),
shadow-block: rgba(0, 58, 129, 0.05),
);
这两个Maps里面存储了页面主体切换时要使用的色值,比如说字体颜色、按钮颜色或者列表背景色等等。。。然后在common.scss里定义了几个混合指令@mixin,
@mixin bg-color($key) {
background: map-get($colors-light, $key);
[data-theme="dark"] & {
background: map-get($colors-dark, $key);
}
}
@mixin text-color($key) {
color: map-get($colors-light, $key);
[data-theme="dark"] & {
color: map-get($colors-dark, $key);
}
}
@mixin border($width, $color: 1px) {
border: $width solid $color;
}
@mixin shadow($shadows...) {
box-shadow: $shadows;
}
@mixin box-shadow($size, $key) {
box-shadow: $size map-get($colors-light, $key);
[data-theme="dark"] & {
box-shadow: $size map-get($colors-dark, $key);
}
}
管理平台
{{theme === 'dark' ? '深色' : '浅色'}}
当前用户:{{$root.userInfo.userName}} 登出
这个自定义属性data-theme,对应@mixin里面的[data-theme=“dark”],默认theme是‘light’。
最后,home.scss里可以写一些页面的页面的样式属性了,当然别忘了引入common.scss,(@import “~@/views/common.scss”),通过@include去调用mixin,获得不同主题所需要的色值。
@import "~@/views/common.scss";
.home {
min-height: 100%;
display: flex;
flex-direction: column;
.main {
overflow-y: auto;
}
}
.content-wrapper {
@include bg-color(bg-main-content);
}
.v-header {
@include bg-color(bg-header);
border-bottom-color: transparent;
z-index: 2;
transition: 0.3s;
color: white;
.title-wrapper {
height: 80px;
.title {
@include text-color(text-title);
font-size: 30px;
font-weight: bold;
}
}
.menu-box {
.menu {
@include text-color(text-menu);
display: inline-block;
width: 60px;
height: 25px;
line-height: 25px;
text-decoration: none;
border: 1px solid #1f8fd9;
cursor: pointer;
&:first-child {
border-radius: 2px 0 0 2px;
border-right: none;
}
&:last-child {
border-radius: 0 2px 2px 0;
border-left: none;
}
}
.router-link-active {
background: #1f8fd9;
color: #ffffff;
}
}
.operation-box {
.logout {
@include text-color(text-logout);
}
}
}