Scert/frontend/src/views/Dashboard/DashboardNavigation.js
xuans a99a310f50 参考设置页拆分管理板块并优化单页布局
增加分组侧栏和按权限显示的用户入口,保留首页基本信息与现有弹窗;补齐证书导入绑定。新增板块切换及完整模板渲染回归,98项前端测试及生产构建通过。
2026-09-25 13:40:15 +08:00

32 lines
1.5 KiB
JavaScript

import { computed, ref } from "vue";
export const dashboardSections = [
{ id: "overview", label: "基本信息", group: "总览", hint: "查看用户、域名状态、证书到期时间和部署服务器" },
{ id: "activity", label: "运行概览", group: "总览", hint: "查看证书、任务与审计日志" },
{ id: "domains", label: "域名配置", group: "证书与部署", hint: "管理域名、申请证书和执行部署" },
{ id: "servers", label: "部署服务器", group: "证书与部署", hint: "配置部署目标及 SSH 认证方式" },
{ id: "keys", label: "SSH 私钥", group: "证书与部署", hint: "管理加密保存的 SSH 私钥" },
{ id: "users", label: "用户管理", group: "系统管理", hint: "管理登录账号、角色与使用状态" },
];
export function useDashboardNavigation(currentUser) {
const selectedSection = ref("overview");
const sections = computed(() => dashboardSections.filter(
(section) => section.id !== "users" || currentUser.value?.role === "super_admin",
));
const activeSection = computed(() => sections.value.some(
(section) => section.id === selectedSection.value,
) ? selectedSection.value : "overview");
const activeLabel = computed(() => sections.value.find(
(section) => section.id === activeSection.value,
)?.label || dashboardSections[0].label);
function selectSection(id) {
if (sections.value.some((section) => section.id === id)) {
selectedSection.value = id;
}
}
return { activeSection, activeLabel, sections, selectSection };
}