/* * @Author: wei.li * @Date: 2022-08-30 10:31:26 * @LastEditors: wei.li * @LastEditTime: 2024-07-02 14:31:54 * @Description: file content */ import { computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { routerArrays } from '../types'; import { useGlobal } from '@utogether/utils'; import { useMultiTagsStore } from '../../store/modules/multiTags'; export function useLayout() { const { $storage, $config } = useGlobal(); const initStorage = () => { /** 路由 */ if (useMultiTagsStore().multiTagsCache && (!$storage.tags || $storage.tags.length === 0)) { $storage.tags = routerArrays; } /** 国际化 */ if (!$storage?.locale) { // $storage.locale = { locale: $config?.Locale ?? 'zh' }; useI18n().locale.value = $config?.Locale ?? 'zh'; } /** 导航 */ if ($storage && !$storage?.layout) { $storage.layout = { layout: $config?.Layout ?? 'vertical', theme: $config?.Theme ?? 'default', darkMode: $config?.DarkMode ?? false, sidebarStatus: $config?.SidebarStatus ?? true, epThemeColor: $config?.EpThemeColor ?? '#409EFF', overallStyle: $config?.OverallStyle ?? 'light' }; } /** 灰色模式、色弱模式、隐藏标签页 */ if ($storage && !$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 }; }