vben
2020-11-24 0692b4798c0f3391a2cb583e30dcca5345aba407
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import type { ProjectConfig } from '/@/types/config';
 
import { computed, unref } from 'vue';
 
import { appStore } from '/@/store/modules/app';
import { ContentEnum } from '/@/enums/appEnum';
 
type RootSetting = Omit<
  ProjectConfig,
  'locale' | 'headerSetting' | 'menuSetting' | 'multiTabsSetting'
>;
export function useRootSetting() {
  const getRootSetting = computed((): RootSetting => appStore.getProjectConfig);
 
  const getOpenPageLoading = computed(() => unref(getRootSetting).openPageLoading);
 
  const getPageLoading = computed(() => appStore.getPageLoading);
 
  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 getContentMode = computed(() => unref(getRootSetting).contentMode);
 
  const getUseOpenBackTop = computed(() => unref(getRootSetting).useOpenBackTop);
 
  const getShowSettingButton = computed(() => unref(getRootSetting).showSettingButton);
 
  const getUseErrorHandle = computed(() => unref(getRootSetting).useErrorHandle);
 
  const getShowFooter = computed(() => unref(getRootSetting).showFooter);
 
  const getShowBreadCrumb = computed(() => unref(getRootSetting).showBreadCrumb);
 
  const getShowBreadCrumbIcon = computed(() => unref(getRootSetting).showBreadCrumbIcon);
 
  const getFullContent = computed(() => unref(getRootSetting).fullContent);
 
  const getColorWeak = computed(() => unref(getRootSetting).colorWeak);
 
  const getGrayMode = computed(() => unref(getRootSetting).grayMode);
 
  const getLayoutContentMode = computed(() =>
    unref(getRootSetting).contentMode === ContentEnum.FULL ? ContentEnum.FULL : ContentEnum.FIXED
  );
 
  function setRootSetting(setting: RootSetting) {
    appStore.commitProjectConfigState(setting);
  }
 
  return {
    setRootSetting,
 
    getFullContent,
    getColorWeak,
    getGrayMode,
    getRootSetting,
    getLayoutContentMode,
    getPageLoading,
    getOpenPageLoading,
    getOpenRouterTransition,
    getOpenKeepAlive,
    getRouterTransition,
    getCanEmbedIFramePage,
    getPermissionMode,
    getShowLogo,
    getUseErrorHandle,
    getShowBreadCrumb,
    getShowBreadCrumbIcon,
    getUseOpenBackTop,
    getShowSettingButton,
    getShowFooter,
    getContentMode,
  };
}