This commit is contained in:
fengchuanhn@gmail.com
2026-05-17 12:54:04 +08:00
parent e6c8c18be0
commit f1fce871bb
28 changed files with 2566 additions and 235 deletions

View File

@@ -1,8 +1,10 @@
<script setup>
import { computed } from "vue";
import { useRoute } from "vue-router";
import { useAuthStore } from "../stores/auth";
const route = useRoute();
const auth = useAuthStore();
const baseMenuItems = [
{ name: "home", label: "首页", to: "/", icon: "home" },
@@ -17,13 +19,24 @@ const baseMenuItems = [
];
const menuItems = computed(() => {
if (import.meta.env.DEV) {
return [...baseMenuItems, { name: "debug", label: "调试", to: "/debug", icon: "debug" }];
const items = [...baseMenuItems];
if (auth.isAdmin) {
items.push({ name: "admin", label: "管理", to: "/admin", icon: "admin" });
}
return baseMenuItems;
if (auth.isAgent) {
items.push({ name: "agent", label: "代理", to: "/agent", icon: "agent" });
}
if (import.meta.env.DEV) {
items.push({ name: "debug", label: "调试", to: "/debug", icon: "debug" });
}
return items;
});
const activeName = computed(() => route.name);
const activeName = computed(() => {
if (route.path.startsWith("/admin")) return "admin";
if (route.path.startsWith("/agent")) return "agent";
return route.name;
});
</script>
<template>
@@ -72,6 +85,14 @@ const activeName = computed(() => route.name);
<circle cx="12" cy="12" r="9" />
<path d="M9.5 9a2.5 2.5 0 1 1 4.2 1.8c-.8.7-1.2 1.2-1.2 2.2M12 17h.01" stroke-linecap="round" />
</svg>
<svg v-else-if="item.icon === 'admin'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M12 3l8 4v6c0 5-3.5 8-8 8s-8-3-8-8V7l8-4z" stroke-linejoin="round" />
<path d="M9 12l2 2 4-4" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<svg v-else-if="item.icon === 'agent'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="12" cy="8" r="3" />
<path d="M5 20c0-3.5 3-6 7-6s7 2.5 7 6" stroke-linecap="round" />
</svg>
<svg v-else-if="item.icon === 'debug'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M12 6v2M12 16v2M6 12h2M16 12h2" stroke-linecap="round" />
<circle cx="12" cy="12" r="4" />