提交 498298ef 编写于 作者: H haoxr

refactor: 暗黑模式自定义样式统一

Former-commit-id: 83dc3250
上级 e4fd0f86
<template> <template>
<el-breadcrumb <el-breadcrumb class="h-[50px] flex items-center">
separator-class="el-icon-arrow-right"
class="h-[50px] flex items-center"
>
<transition-group name="breadcrumb"> <transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item, index) in breadcrumbs" :key="item.path"> <el-breadcrumb-item v-for="(item, index) in breadcrumbs" :key="item.path">
<span <span
v-if=" v-if="
item.redirect === 'noredirect' || index === breadcrumbs.length - 1 item.redirect === 'noredirect' || index === breadcrumbs.length - 1
" "
class="text-[#97a8be]" class="text-[var(--el-disabled-text-color)]"
>{{ translateRouteTitleI18n(item.meta.title) }}</span >{{ translateRouteTitleI18n(item.meta.title) }}</span
> >
<a v-else @click.prevent="handleLink(item)"> <a v-else @click.prevent="handleLink(item)">
...@@ -96,10 +93,11 @@ onBeforeMount(() => { ...@@ -96,10 +93,11 @@ onBeforeMount(() => {
font-size: 14px; font-size: 14px;
line-height: 50px; line-height: 50px;
margin-left: 8px; margin-left: 8px;
}
.no-redirect { // 覆盖 element-plus 的样式
color: #97a8be; .el-breadcrumb__inner,
cursor: text; .el-breadcrumb__inner a {
} font-weight: 400 !important;
} }
</style> </style>
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
class="px-[15px] hover:bg-gray-50 cursor-pointer h-[50px] leading-[50px] dark:hover:bg-[var(--el-fill-color-light)]" class="px-[15px] hover:bg-gray-50 cursor-pointer h-[50px] leading-[50px] dark:hover:bg-[var(--el-fill-color-light)]"
> >
<svg <svg
:class="{ 'is-active': isActive } " :class="{ 'is-active': isActive }"
class="hamburger" class="hamburger"
viewBox="0 0 1024 1024" viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
style="color:#FFF!important" style="color: #fff !important"
> >
<path <path
d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z" d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"
...@@ -37,7 +37,7 @@ function toggleClick() { ...@@ -37,7 +37,7 @@ function toggleClick() {
.hamburger { .hamburger {
width: 20px; width: 20px;
height: 20px; height: 20px;
vertical-align:-4px; vertical-align: -4px;
&.is-active { &.is-active {
transform: rotate(180deg); transform: rotate(180deg);
} }
......
...@@ -104,6 +104,7 @@ onBeforeUnmount(() => { ...@@ -104,6 +104,7 @@ onBeforeUnmount(() => {
} }
.right-panel { .right-panel {
background-color: var(--el-bg-color);
width: 100%; width: 100%;
max-width: 300px; max-width: 300px;
height: 100vh; height: 100vh;
...@@ -113,7 +114,6 @@ onBeforeUnmount(() => { ...@@ -113,7 +114,6 @@ onBeforeUnmount(() => {
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.05); box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.05);
transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1); transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
transform: translate(100%); transform: translate(100%);
background: #fff;
z-index: 199; z-index: 199;
.icon { .icon {
...@@ -125,7 +125,6 @@ onBeforeUnmount(() => { ...@@ -125,7 +125,6 @@ onBeforeUnmount(() => {
.show { .show {
transition: all 0.3s cubic-bezier(0.7, 0.3, 0.1, 1); transition: all 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
.right-panel-background { .right-panel-background {
z-index: 99; z-index: 99;
opacity: 1; opacity: 1;
...@@ -139,22 +138,18 @@ onBeforeUnmount(() => { ...@@ -139,22 +138,18 @@ onBeforeUnmount(() => {
} }
.right-panel__button { .right-panel__button {
background-color: var(--el-color-primary);
color: var(--el-color-white);
width: 48px; width: 48px;
height: 48px; height: 48px;
position: absolute;
left: -48px; left: -48px;
line-height: 48px;
position: absolute;
text-align: center; text-align: center;
font-size: 24px; font-size: 24px;
border-radius: 6px 0 0 6px !important; border-radius: 6px 0 0 6px;
z-index: 0; z-index: 0;
pointer-events: auto; pointer-events: auto;
cursor: pointer; cursor: pointer;
color: #fff;
line-height: 48px;
i {
font-size: 24px;
line-height: 48px;
}
} }
</style> </style>
...@@ -23,6 +23,7 @@ const tagsViewStore = useTagsViewStore(); ...@@ -23,6 +23,7 @@ const tagsViewStore = useTagsViewStore();
width: 100%; width: 100%;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
background-color: var(--el-bg-color-page);
} }
.fixed-header + .app-main { .fixed-header + .app-main {
......
...@@ -9,7 +9,7 @@ import { useDark, useToggle } from '@vueuse/core'; ...@@ -9,7 +9,7 @@ import { useDark, useToggle } from '@vueuse/core';
*/ */
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
const isDark = useDark(); const isDark = useDark();
const toggleDark = useToggle(isDark); const toggleDark = () => useToggle(isDark);
/** /**
* 切换布局 * 切换布局
...@@ -28,30 +28,32 @@ onMounted(() => { ...@@ -28,30 +28,32 @@ onMounted(() => {
<div class="settings-container"> <div class="settings-container">
<h3 class="text-base font-bold">项目配置</h3> <h3 class="text-base font-bold">项目配置</h3>
<el-divider /> <el-divider />
<div class="drawer-item"> <div class="py-[8px] flex justify-between">
<span>开启 Tags-View</span> <span class="text-xs">开启 Tags-View</span>
<el-switch v-model="settingsStore.tagsView" class="drawer-switch" /> <el-switch v-model="settingsStore.tagsView" />
</div> </div>
<div class="drawer-item"> <div class="py-[8px] flex justify-between">
<span>固定 Header</span> <span class="text-xs">固定 Header</span>
<el-switch v-model="settingsStore.fixedHeader" class="drawer-switch" /> <el-switch v-model="settingsStore.fixedHeader" />
</div> </div>
<div class="drawer-item"> <div class="py-[8px] flex justify-between">
<span>侧边栏 Logo</span> <span class="text-xs">侧边栏 Logo</span>
<el-switch v-model="settingsStore.sidebarLogo" class="drawer-switch" /> <el-switch v-model="settingsStore.sidebarLogo" />
</div> </div>
<el-divider>主题</el-divider> <el-divider>主题</el-divider>
<div class="flex justify-center" @click.stop> <div class="flex justify-center" @click.stop>
<el-switch <el-switch
v-model="isDark" v-model="isDark"
@change="toggleDark" @change="toggleDark"
inline-prompt inline-prompt
:active-icon="Sunny" :active-icon="Moon"
:inactive-icon="Moon" :inactive-icon="Sunny"
active-color="var(--el-fill-color-dark)"
inactive-color="var(--el-color-primary)"
/> />
</div> </div>
...@@ -101,25 +103,6 @@ onMounted(() => { ...@@ -101,25 +103,6 @@ onMounted(() => {
<style lang="scss" scoped> <style lang="scss" scoped>
.settings-container { .settings-container {
padding: 16px; padding: 16px;
font-size: 14px;
.drawer-title {
margin-bottom: 12px;
color: rgba(0, 0, 0, 0.85);
font-size: 14px;
line-height: 22px;
}
.drawer-item {
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
padding: 12px 0;
}
.drawer-switch {
float: right;
}
.layout { .layout {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
......
...@@ -17,7 +17,7 @@ const logo = ref<string>( ...@@ -17,7 +17,7 @@ const logo = ref<string>(
</script> </script>
<template> <template>
<transition class="bg-gray-800"> <transition class="bg-gray-800 dark:bg-[var(--el-bg-color-overlay)]">
<router-link <router-link
v-if="collapse" v-if="collapse"
key="collapse" key="collapse"
......
...@@ -8,7 +8,7 @@ import { useSettingsStore } from '@/store/modules/settings'; ...@@ -8,7 +8,7 @@ import { useSettingsStore } from '@/store/modules/settings';
import { usePermissionStore } from '@/store/modules/permission'; import { usePermissionStore } from '@/store/modules/permission';
import { useAppStore } from '@/store/modules/app'; import { useAppStore } from '@/store/modules/app';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import variables from '@/styles/ts-variables.module.scss' import variables from '@/styles/ts-variables.module.scss';
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
const permissionStore = usePermissionStore(); const permissionStore = usePermissionStore();
...@@ -16,25 +16,15 @@ const appStore = useAppStore(); ...@@ -16,25 +16,15 @@ const appStore = useAppStore();
const { sidebarLogo } = storeToRefs(settingsStore); const { sidebarLogo } = storeToRefs(settingsStore);
const route = useRoute(); const route = useRoute();
const isCollapse = computed(() => !appStore.sidebar.opened);
const activeMenu = computed<string>(() => {
const { meta, path } = route;
if (meta?.activeMenu) {
return meta.activeMenu;
}
return path;
});
</script> </script>
<template> <template>
<div :class="{ 'has-logo': sidebarLogo }"> <div :class="{ 'has-logo': sidebarLogo }">
<logo v-if="sidebarLogo" :collapse="isCollapse" /> <logo v-if="sidebarLogo" :collapse="!appStore.sidebar.opened" />
<el-scrollbar> <el-scrollbar>
<el-menu <el-menu
:default-active="activeMenu" :default-active="route.path"
:collapse="isCollapse" :collapse="!appStore.sidebar.opened"
:background-color="variables.menuBg" :background-color="variables.menuBg"
:text-color="variables.menuText" :text-color="variables.menuText"
:active-text-color="variables.menuActiveText" :active-text-color="variables.menuActiveText"
...@@ -47,7 +37,7 @@ const activeMenu = computed<string>(() => { ...@@ -47,7 +37,7 @@ const activeMenu = computed<string>(() => {
:item="route" :item="route"
:key="route.path" :key="route.path"
:base-path="route.path" :base-path="route.path"
:is-collapse="isCollapse" :is-collapse="!appStore.sidebar.opened"
/> />
</el-menu> </el-menu>
</el-scrollbar> </el-scrollbar>
......
:root {
// 这里可以设置你自定义的颜色变量
// 这个是element主要按钮:active的颜色,当主题更改后此变量的值也随之更改
--el-color-primary-dark: #0d84ff;
}
// 覆盖 element-plus 的样式
.el-breadcrumb__inner,
.el-breadcrumb__inner a {
font-weight: 400 !important;
}
// 选中行背景色值
.el-table__body tr.current-row td {
background-color: #e1f3d8b5 !important;
}
...@@ -20,4 +20,5 @@ svg { ...@@ -20,4 +20,5 @@ svg {
border-radius: var(--el-card-border-radius); border-radius: var(--el-card-border-radius);
border: 1px solid var(--el-border-color-light); border: 1px solid var(--el-border-color-light);
box-shadow: var(--el-box-shadow-light); box-shadow: var(--el-box-shadow-light);
} background-color: var(--el-bg-color-overlay);
\ No newline at end of file }
@import './element.scss';
@import './sidebar.scss'; @import './sidebar.scss';
@import './tailwind.scss'; @import './tailwind.scss';
@import './global.scss'; @import './global.scss';
......
...@@ -222,4 +222,4 @@ ...@@ -222,4 +222,4 @@
border-radius: 20px; border-radius: 20px;
} }
} }
} }
\ No newline at end of file
...@@ -116,7 +116,6 @@ import Team from './components/Team/index.vue'; ...@@ -116,7 +116,6 @@ import Team from './components/Team/index.vue';
<style lang="scss" scoped> <style lang="scss" scoped>
.dashboard-container { .dashboard-container {
padding: 24px; padding: 24px;
background-color:var(--el-bg-color-page);
position: relative; position: relative;
.github-corner { .github-corner {
...@@ -156,7 +155,6 @@ import Team from './components/Team/index.vue'; ...@@ -156,7 +155,6 @@ import Team from './components/Team/index.vue';
} }
} }
.card-panel { .card-panel {
height: 108px; height: 108px;
cursor: pointer; cursor: pointer;
...@@ -165,8 +163,8 @@ import Team from './components/Team/index.vue'; ...@@ -165,8 +163,8 @@ import Team from './components/Team/index.vue';
overflow: hidden; overflow: hidden;
color: var(--el-text-color-regular); color: var(--el-text-color-regular);
background: var(--el-bg-color-overlay); background: var(--el-bg-color-overlay);
box-shadow:var(--el-box-shadow-dark); box-shadow: var(--el-box-shadow-dark);
border-color:var(--el-border-color); border-color: var(--el-border-color);
.icon-message { .icon-message {
color: #36a3f7; color: #36a3f7;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册