feat: 添加设置入口并统一背景样式
新增设置菜单入口,将其放在侧边栏底部系统信息区下方 统一背景绘制到 html 元素上,避免元素高度差导致的留白 临时下架背景选项 bg-3,调整侧边栏布局与样式 新增中英文的设置翻译文本,优化系统信息区的间距
This commit is contained in:
+51
-37
@@ -3,51 +3,48 @@
|
||||
<aside class="glass-panel flex w-56 shrink-0 flex-col overflow-hidden">
|
||||
<!-- 菜单区 -->
|
||||
<div class="flex-1 overflow-y-auto p-2">
|
||||
<a-menu
|
||||
class="aside-menu"
|
||||
mode="inline"
|
||||
:selected-keys="selectedKeys"
|
||||
:items="menuItems"
|
||||
@click="onMenuClick"
|
||||
/>
|
||||
<a-menu class="aside-menu" mode="inline" :selected-keys="selectedKeys" :items="menuItems" @click="onMenuClick" />
|
||||
</div>
|
||||
|
||||
<!-- 底部系统信息区(与菜单之间有间隔) -->
|
||||
<div class="system-panel mt-2 border-t p-3">
|
||||
<!-- CPU -->
|
||||
<div class="mb-2">
|
||||
<div class="mb-1 flex items-center justify-between text-xs">
|
||||
<span class="opacity-70">{{ t("system.cpu") }}</span>
|
||||
<span class="font-medium tabular-nums">{{ cpu }}%</span>
|
||||
<div class="system-panel mt-2 border-t px-2 pb-2 pt-3">
|
||||
<div class="px-1">
|
||||
<!-- CPU -->
|
||||
<div class="mb-2">
|
||||
<div class="mb-1 flex items-center justify-between text-xs">
|
||||
<span class="opacity-70">{{ t("system.cpu") }}</span>
|
||||
<span class="font-medium tabular-nums">{{ cpu }}%</span>
|
||||
</div>
|
||||
<a-progress :percent="cpu" :show-info="false" :stroke-color="barColor(cpu)" size="small" />
|
||||
</div>
|
||||
|
||||
<!-- 内存 -->
|
||||
<div class="mb-3">
|
||||
<div class="mb-1 flex items-center justify-between text-xs">
|
||||
<span class="opacity-70">{{ t("system.memory") }}</span>
|
||||
<span class="font-medium tabular-nums">{{ memory }}%</span>
|
||||
</div>
|
||||
<a-progress :percent="memory" :show-info="false" :stroke-color="barColor(memory)" size="small" />
|
||||
</div>
|
||||
|
||||
<!-- 运行状态 -->
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<span class="h-2 w-2 shrink-0 rounded-full" :class="statusDotClass" />
|
||||
<span class="opacity-70">{{ t("system.status") }}</span>
|
||||
<span class="font-medium">{{ statusText }}</span>
|
||||
</div>
|
||||
<a-progress
|
||||
:percent="cpu"
|
||||
:show-info="false"
|
||||
:stroke-color="barColor(cpu)"
|
||||
size="small"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 内存 -->
|
||||
<div class="mb-3">
|
||||
<div class="mb-1 flex items-center justify-between text-xs">
|
||||
<span class="opacity-70">{{ t("system.memory") }}</span>
|
||||
<span class="font-medium tabular-nums">{{ memory }}%</span>
|
||||
</div>
|
||||
<a-progress
|
||||
:percent="memory"
|
||||
:show-info="false"
|
||||
:stroke-color="barColor(memory)"
|
||||
size="small"
|
||||
<!-- 设置入口(位于运行状态下方) -->
|
||||
<div class="system-divider mt-3 border-t pt-2">
|
||||
<a-menu
|
||||
class="aside-menu"
|
||||
mode="inline"
|
||||
:selected-keys="settingSelectedKeys"
|
||||
:items="settingItems"
|
||||
@click="onMenuClick"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 运行状态 -->
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<span class="h-2 w-2 shrink-0 rounded-full" :class="statusDotClass" />
|
||||
<span class="opacity-70">{{ t("system.status") }}</span>
|
||||
<span class="font-medium">{{ statusText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -59,6 +56,7 @@ import {
|
||||
CloudServerOutlined,
|
||||
DashboardOutlined,
|
||||
DownloadOutlined,
|
||||
SettingOutlined,
|
||||
} from "@ant-design/icons-vue"
|
||||
import { useI18n } from "vue-i18n"
|
||||
import type { MenuProps } from "ant-design-vue"
|
||||
@@ -74,6 +72,9 @@ const { cpu, memory } = useSystemStats()
|
||||
|
||||
const selectedKeys = computed(() => [route.path])
|
||||
|
||||
/** 设置项在运行状态下方独立渲染,子路由(如 /setting/appearance)同样高亮 */
|
||||
const settingSelectedKeys = computed(() => (route.path.startsWith("/setting") ? ["/setting"] : []))
|
||||
|
||||
const menuItems = computed<MenuProps["items"]>(() => [
|
||||
{ key: "/dashboard", icon: () => h(DashboardOutlined), label: t("menu.dashboard") },
|
||||
{ key: "/servers", icon: () => h(CloudServerOutlined), label: t("menu.servers") },
|
||||
@@ -81,6 +82,10 @@ const menuItems = computed<MenuProps["items"]>(() => [
|
||||
{ key: "/download", icon: () => h(DownloadOutlined), label: t("menu.download") },
|
||||
])
|
||||
|
||||
const settingItems = computed<MenuProps["items"]>(() => [
|
||||
{ key: "/setting", icon: () => h(SettingOutlined), label: t("menu.setting") },
|
||||
])
|
||||
|
||||
const onMenuClick: MenuProps["onClick"] = ({ key }) => {
|
||||
router.push(String(key))
|
||||
}
|
||||
@@ -124,6 +129,15 @@ const statusText = computed(() => {
|
||||
border-color: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
/* 系统信息与设置入口之间的分隔线 */
|
||||
.system-divider {
|
||||
border-color: rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.dark .system-divider {
|
||||
border-color: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
/* 让 Antd 菜单透明化,融入磨砂玻璃面板 */
|
||||
.aside-menu {
|
||||
background: transparent;
|
||||
|
||||
Reference in New Issue
Block a user