refactor: ♻️ 侧边栏配色方案命名优化调整
This commit is contained in:
@@ -18,15 +18,15 @@ export const enum ThemeEnum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 浅色主题下的侧边栏配色方案枚举
|
* 侧边栏配色方案枚举
|
||||||
*/
|
*/
|
||||||
export const enum SidebarLightThemeEnum {
|
export const enum SidebarColorEnum {
|
||||||
/**
|
/**
|
||||||
* 深蓝色
|
* 经典蓝
|
||||||
*/
|
*/
|
||||||
DARKBLUE = "light-darkBlue",
|
CLASSIC_BLUE = "classic-blue",
|
||||||
/**
|
/**
|
||||||
* 白色
|
* 极简白
|
||||||
*/
|
*/
|
||||||
WHITE = "light-white",
|
MINIMAL_WHITE = "minimal-white",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default {
|
|||||||
sidebarLogo: "Sidebar Logo",
|
sidebarLogo: "Sidebar Logo",
|
||||||
sidebarColorScheme: "Sidebar Color Scheme",
|
sidebarColorScheme: "Sidebar Color Scheme",
|
||||||
watermark: "Watermark",
|
watermark: "Watermark",
|
||||||
white: "white",
|
classicBlue: "Classic Blue",
|
||||||
darkBlue: "darkBlue",
|
minimalWhite: "Minimal White",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ export default {
|
|||||||
themeColor: "主题颜色",
|
themeColor: "主题颜色",
|
||||||
tagsView: "开启 Tags-View",
|
tagsView: "开启 Tags-View",
|
||||||
sidebarLogo: "侧边栏 Logo",
|
sidebarLogo: "侧边栏 Logo",
|
||||||
sidebarColorScheme: "侧边栏配色方案",
|
sidebarColorScheme: "侧边栏配色",
|
||||||
watermark: "开启水印",
|
watermark: "开启水印",
|
||||||
white: "白色",
|
classicBlue: "经典蓝",
|
||||||
darkBlue: "深蓝色",
|
minimalWhite: "极简白",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import { DeviceEnum } from "@/enums/DeviceEnum";
|
|||||||
import { useAppStore, useSettingsStore, useUserStore, useTagsViewStore } from "@/store";
|
import { useAppStore, useSettingsStore, useUserStore, useTagsViewStore } from "@/store";
|
||||||
|
|
||||||
import Notification from "./Notification.vue";
|
import Notification from "./Notification.vue";
|
||||||
import { SidebarLightThemeEnum, ThemeEnum } from "@/enums/ThemeEnum";
|
import { SidebarColorEnum, ThemeEnum } from "@/enums/ThemeEnum";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const settingStore = useSettingsStore();
|
const settingStore = useSettingsStore();
|
||||||
@@ -68,11 +68,16 @@ function handleProfileClick() {
|
|||||||
|
|
||||||
// 根据主题和侧边栏配色方案选择 navbar 右侧的样式类
|
// 根据主题和侧边栏配色方案选择 navbar 右侧的样式类
|
||||||
const navbarRightClass = computed(() => {
|
const navbarRightClass = computed(() => {
|
||||||
const isDarkTheme = settingStore.theme === ThemeEnum.DARK;
|
// 如果暗黑主题
|
||||||
const isDarkBlueSidebar = settingStore.sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE;
|
if (settingStore.theme === ThemeEnum.DARK) {
|
||||||
|
return "navbar__right--white";
|
||||||
|
}
|
||||||
|
|
||||||
// 如果是暗黑主题,或者是浅色主题中的深蓝色侧边栏配色
|
// 如果侧边栏是经典蓝
|
||||||
return isDarkTheme || isDarkBlueSidebar ? "navbar__right--darkBlue" : "navbar__right--white";
|
|
||||||
|
if (settingStore.sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE) {
|
||||||
|
return "navbar__right--white";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,14 +140,9 @@ function logout() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-top .navbar__right--darkBlue > *,
|
|
||||||
.layout-mix .navbar__right--darkBlue > * {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.layout-top .navbar__right--white > *,
|
.layout-top .navbar__right--white > *,
|
||||||
.layout-mix .navbar__right--white > * {
|
.layout-mix .navbar__right--white > * {
|
||||||
color: #000;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark .navbar__right > *:hover {
|
.dark .navbar__right > *:hover {
|
||||||
|
|||||||
@@ -30,8 +30,10 @@
|
|||||||
<div v-if="!isDark" class="py-1 flex-x-between">
|
<div v-if="!isDark" class="py-1 flex-x-between">
|
||||||
<span class="text-xs">{{ $t("settings.sidebarColorScheme") }}</span>
|
<span class="text-xs">{{ $t("settings.sidebarColorScheme") }}</span>
|
||||||
<el-radio-group v-model="settingsStore.sidebarColorScheme" @change="changeSidebarColorScheme">
|
<el-radio-group v-model="settingsStore.sidebarColorScheme" @change="changeSidebarColorScheme">
|
||||||
<el-radio :value="SidebarLightThemeEnum.WHITE">{{ $t("settings.white") }}</el-radio>
|
<el-radio :value="SidebarColorEnum.MINIMAL_WHITE">
|
||||||
<el-radio :value="SidebarLightThemeEnum.DARKBLUE">{{ $t("settings.darkBlue") }}</el-radio>
|
{{ $t("settings.minimalWhite") }}
|
||||||
|
</el-radio>
|
||||||
|
<el-radio :value="SidebarColorEnum.CLASSIC_BLUE">{{ $t("settings.classicBlue") }}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { LayoutEnum } from "@/enums/LayoutEnum";
|
import { LayoutEnum } from "@/enums/LayoutEnum";
|
||||||
import { ThemeEnum } from "@/enums/ThemeEnum";
|
import { ThemeEnum } from "@/enums/ThemeEnum";
|
||||||
import { SidebarLightThemeEnum } from "@/enums/ThemeEnum";
|
import { SidebarColorEnum } from "@/enums/ThemeEnum";
|
||||||
import { useSettingsStore, usePermissionStore, useAppStore } from "@/store";
|
import { useSettingsStore, usePermissionStore, useAppStore } from "@/store";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
:default-active="currentRoute.path"
|
:default-active="currentRoute.path"
|
||||||
:collapse="!appStore.sidebar.opened"
|
:collapse="!appStore.sidebar.opened"
|
||||||
:background-color="
|
:background-color="
|
||||||
theme === 'dark' || sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE
|
theme === 'dark' || sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE
|
||||||
? variables['menu-background']
|
? variables['menu-background']
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
:text-color="
|
:text-color="
|
||||||
theme === 'dark' || sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE
|
theme === 'dark' || sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE
|
||||||
? variables['menu-text']
|
? variables['menu-text']
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
:active-text-color="
|
:active-text-color="
|
||||||
theme === 'dark' || sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE
|
theme === 'dark' || sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE
|
||||||
? variables['menu-active-text']
|
? variables['menu-active-text']
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
@@ -42,7 +42,7 @@ import type { MenuInstance } from "element-plus";
|
|||||||
import type { RouteRecordRaw } from "vue-router";
|
import type { RouteRecordRaw } from "vue-router";
|
||||||
|
|
||||||
import { LayoutEnum } from "@/enums/LayoutEnum";
|
import { LayoutEnum } from "@/enums/LayoutEnum";
|
||||||
import { SidebarLightThemeEnum } from "@/enums/ThemeEnum";
|
import { SidebarColorEnum } from "@/enums/ThemeEnum";
|
||||||
import { useSettingsStore, useAppStore } from "@/store";
|
import { useSettingsStore, useAppStore } from "@/store";
|
||||||
import { isExternal } from "@/utils/index";
|
import { isExternal } from "@/utils/index";
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ html.dark {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html.light-darkBlue {
|
html.sidebar-color-blue {
|
||||||
.el-menu-item:hover {
|
.el-menu-item:hover {
|
||||||
background-color: $menu-hover;
|
background-color: $menu-hover;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
:default-active="activePath"
|
:default-active="activePath"
|
||||||
:background-color="
|
:background-color="
|
||||||
theme === 'dark' || sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE
|
theme === 'dark' || sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE
|
||||||
? variables['menu-background']
|
? variables['menu-background']
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
:text-color="
|
:text-color="
|
||||||
theme === 'dark' || sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE
|
theme === 'dark' || sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE
|
||||||
? variables['menu-text']
|
? variables['menu-text']
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
:active-text-color="
|
:active-text-color="
|
||||||
theme === 'dark' || sidebarColorScheme === SidebarLightThemeEnum.DARKBLUE
|
theme === 'dark' || sidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE
|
||||||
? variables['menu-active-text']
|
? variables['menu-active-text']
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
@@ -44,7 +44,7 @@ import { LocationQueryRaw, RouteRecordRaw } from "vue-router";
|
|||||||
import { usePermissionStore, useAppStore, useSettingsStore } from "@/store";
|
import { usePermissionStore, useAppStore, useSettingsStore } from "@/store";
|
||||||
import { translateRouteTitle } from "@/utils/i18n";
|
import { translateRouteTitle } from "@/utils/i18n";
|
||||||
import variables from "@/styles/variables.module.scss";
|
import variables from "@/styles/variables.module.scss";
|
||||||
import { SidebarLightThemeEnum } from "@/enums/ThemeEnum";
|
import { SidebarColorEnum } from "@/enums/ThemeEnum";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { SizeEnum } from "./enums/SizeEnum";
|
import { SizeEnum } from "./enums/SizeEnum";
|
||||||
import { LayoutEnum } from "./enums/LayoutEnum";
|
import { LayoutEnum } from "./enums/LayoutEnum";
|
||||||
import { ThemeEnum, SidebarLightThemeEnum } from "./enums/ThemeEnum";
|
import { ThemeEnum, SidebarColorEnum } from "./enums/ThemeEnum";
|
||||||
import { LanguageEnum } from "./enums/LanguageEnum";
|
import { LanguageEnum } from "./enums/LanguageEnum";
|
||||||
|
|
||||||
const { pkg } = __APP_INFO__;
|
const { pkg } = __APP_INFO__;
|
||||||
@@ -34,7 +34,7 @@ const defaultSettings: AppSettings = {
|
|||||||
// 水印内容
|
// 水印内容
|
||||||
watermarkContent: pkg.name,
|
watermarkContent: pkg.name,
|
||||||
// 侧边栏配色方案
|
// 侧边栏配色方案
|
||||||
sidebarColorScheme: SidebarLightThemeEnum.WHITE,
|
sidebarColorScheme: SidebarColorEnum.CLASSIC_BLUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultSettings;
|
export default defaultSettings;
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import defaultSettings from "@/settings";
|
import defaultSettings from "@/settings";
|
||||||
import { SidebarLightThemeEnum, ThemeEnum } from "@/enums/ThemeEnum";
|
import { SidebarColorEnum, ThemeEnum } from "@/enums/ThemeEnum";
|
||||||
import { LayoutEnum } from "@/enums/LayoutEnum";
|
import { LayoutEnum } from "@/enums/LayoutEnum";
|
||||||
import {
|
import { generateThemeColors, applyTheme, toggleDarkMode, toggleSidebarColor } from "@/utils/theme";
|
||||||
generateThemeColors,
|
|
||||||
applyTheme,
|
|
||||||
toggleDarkMode,
|
|
||||||
toggleLightModeSidebarColorScheme,
|
|
||||||
} from "@/utils/theme";
|
|
||||||
|
|
||||||
type SettingsValue = boolean | string;
|
type SettingsValue = boolean | string;
|
||||||
|
|
||||||
@@ -17,7 +12,7 @@ export const useSettingsStore = defineStore("setting", () => {
|
|||||||
const tagsView = useStorage<boolean>("tagsView", defaultSettings.tagsView);
|
const tagsView = useStorage<boolean>("tagsView", defaultSettings.tagsView);
|
||||||
// 侧边栏 Logo
|
// 侧边栏 Logo
|
||||||
const sidebarLogo = useStorage<boolean>("sidebarLogo", defaultSettings.sidebarLogo);
|
const sidebarLogo = useStorage<boolean>("sidebarLogo", defaultSettings.sidebarLogo);
|
||||||
// 浅色主题下的侧边栏配色方案 (白色/深蓝色)
|
// 侧边栏配色方案 (经典蓝/极简白)
|
||||||
const sidebarColorScheme = useStorage<string>(
|
const sidebarColorScheme = useStorage<string>(
|
||||||
"sidebarColorScheme",
|
"sidebarColorScheme",
|
||||||
defaultSettings.sidebarColorScheme
|
defaultSettings.sidebarColorScheme
|
||||||
@@ -49,7 +44,7 @@ export const useSettingsStore = defineStore("setting", () => {
|
|||||||
watch(
|
watch(
|
||||||
[sidebarColorScheme],
|
[sidebarColorScheme],
|
||||||
([newSidebarColorScheme]) => {
|
([newSidebarColorScheme]) => {
|
||||||
toggleLightModeSidebarColorScheme(newSidebarColorScheme === SidebarLightThemeEnum.DARKBLUE);
|
toggleSidebarColor(newSidebarColorScheme === SidebarColorEnum.CLASSIC_BLUE);
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 浅色主题-深蓝色侧边栏配色 */
|
/** 浅色主题-深蓝色侧边栏配色 */
|
||||||
html.light-darkBlue {
|
html.sidebar-color-blue {
|
||||||
--menu-background: #304156; // 菜单背景色
|
--menu-background: #304156; // 菜单背景色
|
||||||
--menu-text: #bfcbd9; // 菜单文字颜色
|
--menu-text: #bfcbd9; // 菜单文字颜色
|
||||||
--menu-active-text: var(--el-menu-active-color); // 菜单激活文字颜色
|
--menu-active-text: var(--el-menu-active-color); // 菜单激活文字颜色
|
||||||
|
|||||||
4
src/types/global.d.ts
vendored
4
src/types/global.d.ts
vendored
@@ -76,8 +76,8 @@ declare global {
|
|||||||
watermarkEnabled: boolean;
|
watermarkEnabled: boolean;
|
||||||
/** 水印内容 */
|
/** 水印内容 */
|
||||||
watermarkContent: string;
|
watermarkContent: string;
|
||||||
/** 侧边栏配色方案(light-white | light-darkBlue) */
|
/** 侧边栏配色方案 */
|
||||||
sidebarColorScheme: "light-white" | "light-darkBlue";
|
sidebarColorScheme: "classic-blue" | "minimal-white";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { SidebarLightThemeEnum } from "@/enums/ThemeEnum";
|
|
||||||
|
|
||||||
// 辅助函数:将十六进制颜色转换为 RGB
|
// 辅助函数:将十六进制颜色转换为 RGB
|
||||||
function hexToRgb(hex: string): [number, number, number] {
|
function hexToRgb(hex: string): [number, number, number] {
|
||||||
const bigint = parseInt(hex.slice(1), 16);
|
const bigint = parseInt(hex.slice(1), 16);
|
||||||
@@ -63,10 +61,10 @@ export function toggleDarkMode(isDark: boolean) {
|
|||||||
*
|
*
|
||||||
* @param isBlue 布尔值,表示是否开启深蓝色侧边栏颜色方案
|
* @param isBlue 布尔值,表示是否开启深蓝色侧边栏颜色方案
|
||||||
*/
|
*/
|
||||||
export function toggleLightModeSidebarColorScheme(isDarkBlueDark: boolean) {
|
export function toggleSidebarColor(isBuleSidebar: boolean) {
|
||||||
if (isDarkBlueDark) {
|
if (isBuleSidebar) {
|
||||||
document.documentElement.classList.add(SidebarLightThemeEnum.DARKBLUE);
|
document.documentElement.classList.add("sidebar-color-blue");
|
||||||
} else {
|
} else {
|
||||||
document.documentElement.classList.remove(SidebarLightThemeEnum.DARKBLUE);
|
document.documentElement.classList.remove("sidebar-color-blue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user