useRootSetting.ts 1.6 KB
Newer Older
V
vben 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
import type { ProjectConfig } from '/@/types/config';

import { computed, unref } from 'vue';

import { appStore } from '/@/store/modules/app';

type RootSetting = Omit<
  ProjectConfig,
  'locale' | 'headerSetting' | 'menuSetting' | 'multiTabsSetting'
>;
export function useRootSetting() {
  const getRootSetting = computed((): RootSetting => appStore.getProjectConfig);

  const getOpenPageLoading = computed(() => unref(getRootSetting).openPageLoading);

  const getOpenRouterTransition = computed(() => unref(getRootSetting).openRouterTransition);

  const getOpenKeepAlive = computed(() => unref(getRootSetting).openKeepAlive);

  const getRouterTransition = computed(() => unref(getRootSetting).routerTransition);

  const getCanEmbedIFramePage = computed(() => unref(getRootSetting).canEmbedIFramePage);

  const getPermissionMode = computed(() => unref(getRootSetting).permissionMode);

  const getShowLogo = computed(() => unref(getRootSetting).showLogo);

  const getUseErrorHandle = computed(() => unref(getRootSetting).useErrorHandle);

  const getShowBreadCrumb = computed(() => unref(getRootSetting).showBreadCrumb);

  const getShowBreadCrumbIcon = computed(() => unref(getRootSetting).showBreadCrumbIcon);

  function setRootSetting(setting: RootSetting) {
    appStore.commitProjectConfigState(setting);
  }

  return {
    setRootSetting,

    getRootSetting,
    getOpenPageLoading,
    getOpenRouterTransition,
    getOpenKeepAlive,
    getRouterTransition,
    getCanEmbedIFramePage,
    getPermissionMode,
    getShowLogo,
    getUseErrorHandle,
    getShowBreadCrumb,
    getShowBreadCrumbIcon,
  };
}