feat: 管理后台改为浅色蓝主色并平铺导航
This commit is contained in:
+21
-6
@@ -3,11 +3,11 @@ import { NConfigProvider, NDialogProvider, NMessageProvider, dateZhCN, zhCN } fr
|
||||
import { RouterView } from "vue-router";
|
||||
import { useAppTheme } from "./theme";
|
||||
|
||||
const { theme } = useAppTheme();
|
||||
const { theme, themeOverrides } = useAppTheme();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-config-provider :locale="zhCN" :date-locale="dateZhCN" :theme="theme" size="small">
|
||||
<n-config-provider :locale="zhCN" :date-locale="dateZhCN" :theme="theme" :theme-overrides="themeOverrides" size="small">
|
||||
<n-message-provider>
|
||||
<n-dialog-provider>
|
||||
<RouterView />
|
||||
@@ -23,12 +23,27 @@ body,
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
html {
|
||||
color-scheme: light;
|
||||
}
|
||||
body {
|
||||
background: #f7f8fa;
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
background: #f6f8fa;
|
||||
color: #1f2328;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
::selection {
|
||||
background: #0969da;
|
||||
color: #fff;
|
||||
}
|
||||
html.dark {
|
||||
color-scheme: dark;
|
||||
}
|
||||
html.dark body {
|
||||
background: #101014;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
background: #0d1117;
|
||||
color: #e6edf3;
|
||||
}
|
||||
html.dark ::selection {
|
||||
background: #4493f8;
|
||||
color: #0d1117;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<svg class="brand-mark" viewBox="0 0 32 32" aria-hidden="true">
|
||||
<rect width="32" height="32" rx="8" fill="#18a058" />
|
||||
<rect width="32" height="32" rx="8" fill="#0969da" />
|
||||
<circle cx="7.4" cy="16" r="2.6" fill="#fff" />
|
||||
<circle cx="24.6" cy="16" r="2.6" fill="#fff" />
|
||||
<path fill="#fff" d="M11.2 14.6H16.6V12.4L21.4 16 16.6 19.6V17.4H11.2z" />
|
||||
|
||||
@@ -4,7 +4,6 @@ import { RouterView, useRoute, useRouter } from "vue-router";
|
||||
import { NAvatar, NButton, NDropdown, NIcon, NLayout, NLayoutContent, NLayoutSider, NMenu, NTooltip } from "naive-ui";
|
||||
import type { MenuOption } from "naive-ui";
|
||||
import {
|
||||
ChatbubblesOutline,
|
||||
DesktopOutline,
|
||||
GridOutline,
|
||||
KeyOutline,
|
||||
@@ -32,15 +31,8 @@ function renderIcon(icon: Component) {
|
||||
|
||||
const menuOptions: MenuOption[] = [
|
||||
{ label: "概览", key: "/overview", icon: renderIcon(GridOutline) },
|
||||
{
|
||||
label: "通讯",
|
||||
key: "comms",
|
||||
icon: renderIcon(ChatbubblesOutline),
|
||||
children: [
|
||||
{ label: "设备端", key: "/endpoints", icon: renderIcon(PhonePortraitOutline) },
|
||||
{ label: "群组", key: "/groups", icon: renderIcon(PeopleOutline) },
|
||||
],
|
||||
},
|
||||
{ label: "设备端", key: "/endpoints", icon: renderIcon(PhonePortraitOutline) },
|
||||
{ label: "群组", key: "/groups", icon: renderIcon(PeopleOutline) },
|
||||
{ label: "投递记录", key: "/messages", icon: renderIcon(PaperPlaneOutline) },
|
||||
{ label: "API 令牌", key: "/tokens", icon: renderIcon(KeyOutline) },
|
||||
{ label: "设置", key: "/settings", icon: renderIcon(SettingsOutline) },
|
||||
@@ -118,7 +110,7 @@ async function onLogout() {
|
||||
</template>
|
||||
</n-button>
|
||||
</n-dropdown>
|
||||
<n-avatar round :size="28" color="#18a058">{{ initial }}</n-avatar>
|
||||
<n-avatar round :size="28" color="#0969da">{{ initial }}</n-avatar>
|
||||
<span v-if="!collapsed" class="name">{{ auth.username }}</span>
|
||||
<n-tooltip placement="right">
|
||||
<template #trigger>
|
||||
|
||||
+40
-2
@@ -1,10 +1,47 @@
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { darkTheme, useOsTheme, type GlobalTheme } from "naive-ui";
|
||||
import { darkTheme, type GlobalTheme, type GlobalThemeOverrides, useOsTheme } from "naive-ui";
|
||||
|
||||
export type ThemeChoice = "auto" | "light" | "dark";
|
||||
|
||||
const KEY = "nixmsg-theme";
|
||||
|
||||
const lightOverrides: GlobalThemeOverrides = {
|
||||
common: {
|
||||
primaryColor: "#0969da",
|
||||
primaryColorHover: "#0860c4",
|
||||
primaryColorPressed: "#0550ae",
|
||||
primaryColorSuppl: "#0969da",
|
||||
borderRadius: "6px",
|
||||
fontFamily: '"Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
bodyColor: "#f6f8fa",
|
||||
cardColor: "#ffffff",
|
||||
borderColor: "#d0d7de",
|
||||
textColorBase: "#1f2328",
|
||||
textColor2: "#1f2328",
|
||||
textColor3: "#59636e",
|
||||
},
|
||||
Card: { borderRadius: "8px" },
|
||||
Button: { fontWeight: "560" },
|
||||
DataTable: { thColor: "#f6f8fa", borderColor: "#d0d7de" },
|
||||
};
|
||||
|
||||
const darkOverrides: GlobalThemeOverrides = {
|
||||
common: {
|
||||
primaryColor: "#4493f8",
|
||||
primaryColorHover: "#6cb0ff",
|
||||
primaryColorPressed: "#316dca",
|
||||
primaryColorSuppl: "#4493f8",
|
||||
borderRadius: "6px",
|
||||
fontFamily: '"Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
bodyColor: "#0d1117",
|
||||
cardColor: "#161b22",
|
||||
borderColor: "#30363d",
|
||||
},
|
||||
Card: { borderRadius: "8px" },
|
||||
Button: { fontWeight: "560" },
|
||||
DataTable: { thColor: "#161b22", borderColor: "#30363d" },
|
||||
};
|
||||
|
||||
function readChoice(): ThemeChoice {
|
||||
const raw = localStorage.getItem(KEY);
|
||||
if (raw === "light" || raw === "dark" || raw === "auto") return raw;
|
||||
@@ -17,6 +54,7 @@ export function useAppTheme() {
|
||||
const os = useOsTheme();
|
||||
const isDark = computed(() => (choice.value === "auto" ? os.value === "dark" : choice.value === "dark"));
|
||||
const theme = computed<GlobalTheme | null>(() => (isDark.value ? darkTheme : null));
|
||||
const themeOverrides = computed(() => (isDark.value ? darkOverrides : lightOverrides));
|
||||
|
||||
function setChoice(next: ThemeChoice) {
|
||||
choice.value = next;
|
||||
@@ -31,5 +69,5 @@ export function useAppTheme() {
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
return { choice, isDark, theme, setChoice };
|
||||
return { choice, isDark, theme, themeOverrides, setChoice };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user