mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-12-21 15:00:28 +08:00
refactor: 将系统配置中的“整体风格”更名为“主题模式”,“导航模式”更名为“菜单布局”,以提升命名的专业性与清晰度 (#1247)
This commit is contained in:
@@ -37,7 +37,7 @@ const horizontalRef = ref();
|
||||
|
||||
const {
|
||||
dataTheme,
|
||||
overallStyle,
|
||||
themeMode,
|
||||
layoutTheme,
|
||||
themeColors,
|
||||
toggleClass,
|
||||
@@ -50,7 +50,7 @@ if (unref(layoutTheme)) {
|
||||
const layout = unref(layoutTheme).layout;
|
||||
const theme = unref(layoutTheme).theme;
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
setLayoutModel(layout);
|
||||
setMenuLayout(layout);
|
||||
}
|
||||
|
||||
/** 默认灵动模式 */
|
||||
@@ -195,24 +195,24 @@ const pClass = computed(() => {
|
||||
const themeOptions = computed<Array<OptionsType>>(() => {
|
||||
return [
|
||||
{
|
||||
label: t("panel.pureOverallStyleLight"),
|
||||
label: t("panel.pureThemeModeLight"),
|
||||
icon: DayIcon,
|
||||
theme: "light",
|
||||
tip: t("panel.pureOverallStyleLightTip"),
|
||||
tip: t("panel.pureThemeModeLightTip"),
|
||||
iconAttrs: { fill: isDark.value ? "#fff" : "#000" }
|
||||
},
|
||||
{
|
||||
label: t("panel.pureOverallStyleDark"),
|
||||
label: t("panel.pureThemeModeDark"),
|
||||
icon: DarkIcon,
|
||||
theme: "dark",
|
||||
tip: t("panel.pureOverallStyleDarkTip"),
|
||||
tip: t("panel.pureThemeModeDarkTip"),
|
||||
iconAttrs: { fill: isDark.value ? "#fff" : "#000" }
|
||||
},
|
||||
{
|
||||
label: t("panel.pureOverallStyleSystem"),
|
||||
label: t("panel.pureThemeModeSystem"),
|
||||
icon: SystemIcon,
|
||||
theme: "system",
|
||||
tip: t("panel.pureOverallStyleSystemTip"),
|
||||
tip: t("panel.pureThemeModeSystemTip"),
|
||||
iconAttrs: { fill: isDark.value ? "#fff" : "#000" }
|
||||
}
|
||||
];
|
||||
@@ -238,8 +238,8 @@ const markOptions = computed<Array<OptionsType>>(() => {
|
||||
];
|
||||
});
|
||||
|
||||
/** 设置导航模式 */
|
||||
function setLayoutModel(layout: string) {
|
||||
/** 设置菜单布局 */
|
||||
function setMenuLayout(layout: string) {
|
||||
layoutTheme.value.layout = layout;
|
||||
window.document.body.setAttribute("layout", layout);
|
||||
$storage.layout = {
|
||||
@@ -249,7 +249,7 @@ function setLayoutModel(layout: string) {
|
||||
sidebarStatus: $storage.layout?.sidebarStatus,
|
||||
epThemeColor: $storage.layout?.epThemeColor,
|
||||
themeColor: $storage.layout?.themeColor,
|
||||
overallStyle: $storage.layout?.overallStyle
|
||||
themeMode: $storage.layout?.themeMode
|
||||
};
|
||||
useAppStoreHook().setLayout(layout);
|
||||
}
|
||||
@@ -276,15 +276,15 @@ watch($storage, ({ layout }) => {
|
||||
|
||||
const mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
|
||||
/** 根据操作系统主题设置平台整体风格 */
|
||||
/** 根据操作系统主题设置平台主题模式 */
|
||||
function updateTheme() {
|
||||
if (overallStyle.value !== "system") return;
|
||||
if (themeMode.value !== "system") return;
|
||||
if (mediaQueryList.matches) {
|
||||
dataTheme.value = true;
|
||||
} else {
|
||||
dataTheme.value = false;
|
||||
}
|
||||
dataThemeChange(overallStyle.value);
|
||||
dataThemeChange(themeMode.value);
|
||||
}
|
||||
|
||||
function removeMatchMedia() {
|
||||
@@ -317,18 +317,18 @@ onUnmounted(() => removeMatchMedia);
|
||||
<template>
|
||||
<LayPanel>
|
||||
<div class="p-5">
|
||||
<p :class="pClass">{{ t("panel.pureOverallStyle") }}</p>
|
||||
<p :class="pClass">{{ t("panel.pureThemeMode") }}</p>
|
||||
<Segmented
|
||||
resize
|
||||
class="select-none"
|
||||
:modelValue="overallStyle === 'system' ? 2 : dataTheme ? 1 : 0"
|
||||
:modelValue="themeMode === 'system' ? 2 : dataTheme ? 1 : 0"
|
||||
:options="themeOptions"
|
||||
@change="
|
||||
theme => {
|
||||
theme.index === 1 && theme.index !== 2
|
||||
? (dataTheme = true)
|
||||
: (dataTheme = false);
|
||||
overallStyle = theme.option.theme;
|
||||
themeMode = theme.option.theme;
|
||||
dataThemeChange(theme.option.theme);
|
||||
theme.index === 2 && watchSystemThemeChange();
|
||||
}
|
||||
@@ -354,7 +354,7 @@ onUnmounted(() => removeMatchMedia);
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p :class="['mt-5!', pClass]">{{ t("panel.pureLayoutModel") }}</p>
|
||||
<p :class="['mt-5!', pClass]">{{ t("panel.pureMenuLayout") }}</p>
|
||||
<ul class="pure-theme">
|
||||
<li
|
||||
ref="verticalRef"
|
||||
@@ -363,7 +363,7 @@ onUnmounted(() => removeMatchMedia);
|
||||
zIndex: 41000
|
||||
}"
|
||||
:class="layoutTheme.layout === 'vertical' ? 'is-select' : ''"
|
||||
@click="setLayoutModel('vertical')"
|
||||
@click="setMenuLayout('vertical')"
|
||||
>
|
||||
<div />
|
||||
<div />
|
||||
@@ -376,7 +376,7 @@ onUnmounted(() => removeMatchMedia);
|
||||
zIndex: 41000
|
||||
}"
|
||||
:class="layoutTheme.layout === 'horizontal' ? 'is-select' : ''"
|
||||
@click="setLayoutModel('horizontal')"
|
||||
@click="setMenuLayout('horizontal')"
|
||||
>
|
||||
<div />
|
||||
<div />
|
||||
@@ -389,7 +389,7 @@ onUnmounted(() => removeMatchMedia);
|
||||
zIndex: 41000
|
||||
}"
|
||||
:class="layoutTheme.layout === 'mix' ? 'is-select' : ''"
|
||||
@click="setLayoutModel('mix')"
|
||||
@click="setMenuLayout('mix')"
|
||||
>
|
||||
<div />
|
||||
<div />
|
||||
|
||||
Reference in New Issue
Block a user