You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { computed } from "vue";
|
|
import { routerArrays } from "../types";
|
|
import { useGlobal } from "@pureadmin/utils";
|
|
import { useMultiTagsStore } from "@/store/modules/multiTags";
|
|
|
|
export function useLayout() {
|
|
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
|
|
|
|
const initStorage = () => {
|
|
/** 路由 */
|
|
if (
|
|
useMultiTagsStore().multiTagsCache &&
|
|
(!$storage.tags || $storage.tags.length === 0)
|
|
) {
|
|
$storage.tags = routerArrays;
|
|
}
|
|
/** 导航 */
|
|
if (!$storage.layout) {
|
|
$storage.layout = {
|
|
layout: $config?.Layout ?? "vertical",
|
|
theme: $config?.Theme ?? "default",
|
|
darkMode: $config?.DarkMode ?? false,
|
|
sidebarStatus: $config?.SidebarStatus ?? true,
|
|
epThemeColor: $config?.EpThemeColor ?? "#2e80fa"
|
|
};
|
|
}
|
|
/** 灰色模式、色弱模式、隐藏标签页 */
|
|
if (!$storage.configure) {
|
|
$storage.configure = {
|
|
grey: $config?.Grey ?? false,
|
|
weak: $config?.Weak ?? false,
|
|
hideTabs: $config?.HideTabs ?? false,
|
|
showLogo: $config?.ShowLogo ?? true,
|
|
showModel: $config?.ShowModel ?? "smart",
|
|
multiTagsCache: $config?.MultiTagsCache ?? false
|
|
};
|
|
}
|
|
};
|
|
|
|
/** 清空缓存后从serverConfig.json读取默认配置并赋值到storage中 */
|
|
const layout = computed(() => {
|
|
return $storage?.layout.layout;
|
|
});
|
|
|
|
const layoutTheme = computed(() => {
|
|
return $storage.layout;
|
|
});
|
|
|
|
return {
|
|
layout,
|
|
layoutTheme,
|
|
initStorage
|
|
};
|
|
}
|