mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-18 05:43:42 +08:00
feat: expand device networking and management
This commit is contained in:
@@ -22,6 +22,8 @@ import { cx } from "../../lib/utils";
|
||||
import { BrandLogo } from "./BrandLogo";
|
||||
import { VersionBadge } from "./VersionBadge";
|
||||
import { listPlugins, type InstalledPlugin } from "../../extensions";
|
||||
import { api } from "../../api";
|
||||
import type { SystemInfo } from "../../types";
|
||||
|
||||
const NAV = [
|
||||
{ to: "/", label: "仪表盘", icon: BoardRegular, end: true },
|
||||
@@ -43,11 +45,24 @@ export function AuthenticatedShell({
|
||||
const [isMobile, setIsMobile] = useState(false);
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
const [plugins, setPlugins] = useState<InstalledPlugin[]>([]);
|
||||
const [developer, setDeveloper] = useState(false);
|
||||
const { logout, user } = useAuth();
|
||||
const { t, lang } = useI18n();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
const load = () => api<SystemInfo>("/system/info").then((info) => {
|
||||
if (active) setDeveloper(!!info.developer);
|
||||
}).catch(() => {
|
||||
if (active) setDeveloper(false);
|
||||
});
|
||||
void load();
|
||||
const timer = window.setInterval(load, 10_000);
|
||||
return () => { active = false; window.clearInterval(timer); };
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia("(max-width: 767px)");
|
||||
const update = () => {
|
||||
@@ -99,15 +114,17 @@ export function AuthenticatedShell({
|
||||
const navItems: Array<(typeof NAV)[number] | { to: string; label: string; icon: typeof GlobeRegular; pluginLabelZH?: string }> = [];
|
||||
for (const item of NAV) {
|
||||
navItems.push(item);
|
||||
if (item.to === "/sms") {
|
||||
for (const extension of sidebarPlugins.filter((entry) => !entry.contribution.after || entry.contribution.after === "sms")) {
|
||||
navItems.push({
|
||||
to: `/extensions/${encodeURIComponent(extension.plugin.id)}/${encodeURIComponent(extension.contribution.id)}`,
|
||||
label: extension.contribution.label,
|
||||
pluginLabelZH: extension.contribution.labelZh,
|
||||
icon: GlobeRegular,
|
||||
});
|
||||
}
|
||||
if (developer && item.to === "/proxy") {
|
||||
navItems.push({ to: "/export-proxy", label: "导出代理", icon: GlobeRegular });
|
||||
}
|
||||
const itemKey = item.to.replace(/^\//, "") || "dashboard";
|
||||
for (const extension of sidebarPlugins.filter((entry) => (entry.contribution.after || "sms") === itemKey)) {
|
||||
navItems.push({
|
||||
to: `/extensions/${encodeURIComponent(extension.plugin.id)}/${encodeURIComponent(extension.contribution.id)}`,
|
||||
label: extension.contribution.label,
|
||||
pluginLabelZH: extension.contribution.labelZh,
|
||||
icon: GlobeRegular,
|
||||
});
|
||||
}
|
||||
}
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user