MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / useHeaderMenus

Function useHeaderMenus

frontend/src/hooks/useHeaderMenus.ts:64–293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62 | SidebarAppDropdownEntry;
63
64export function useHeaderMenus() {
65 const { saveGlobalLayoutConfig, resetGlobalLayoutConfig } = useLayoutConfigStore();
66 const { containerState, changeDesignMode } = useLayoutContainerStore();
67 const { toPage } = useAppRouters();
68 const { setTheme } = useAppConfigStore();
69 const { state: appTools } = useAppToolsStore();
70 const { isAdmin, state: appState, isLogged } = useAppStateStore();
71 const { execute } = logoutUser();
72
73 const openNewCardDialog = (): void => {
74 containerState.showNewCardDialog = true;
75 };
76
77 const handleToPage = (url: string) => {
78 containerState.showPhoneMenu = false;
79 toPage({ path: url });
80 };
81
82 const onClickIcon = () => {
83 window.open("https://github.com/MCSManager/MCSManager", "_blank");
84 };
85
86 const menus = computed(() => {
87 return router
88 .getRoutes()
89 .filter((v) => {
90 if (v.path === "/" || !v.name) return false;
91 const metaInfo = v.meta as RouterMetaInfo;
92 if (metaInfo.condition && !metaInfo.condition()) {
93 return false;
94 }
95 if (containerState.isDesignMode) {
96 return metaInfo.onlyDisplayEditMode || metaInfo.mainMenu;
97 }
98 if (isAdmin.value) {
99 return metaInfo.mainMenu === true && metaInfo.onlyDisplayEditMode !== true;
100 }
101 return (
102 metaInfo.mainMenu === true &&
103 isLogged.value &&
104 Number(appState.userInfo?.permission) >= Number(metaInfo.permission)
105 );
106 })
107 .map((r) => ({
108 name: r.name,
109 path: r.path,
110 meta: r.meta,
111 customClass: r.meta.customClass ?? []
112 }));
113 });
114
115 const appMenus = computed(() => {
116 return [
117 {
118 iconText: "",
119 title: "GitHub",
120 icon: GithubFilled,
121 onlyPC: true,

Callers

nothing calls this directly

Calls 2

useAppRoutersFunction · 0.90
setThemeFunction · 0.85

Tested by

no test coverage detected