useRootSetting.ts 2.3 KB
Newer Older
V
vben 已提交
1 2 3 4 5
import type { ProjectConfig } from '/@/types/config';

import { computed, unref } from 'vue';

import { appStore } from '/@/store/modules/app';
V
vben 已提交
6
import { ContentEnum } from '/@/enums/appEnum';
V
vben 已提交
7 8 9 10 11 12

type RootSetting = Omit<
  ProjectConfig,
  'locale' | 'headerSetting' | 'menuSetting' | 'multiTabsSetting'
>;

V
vben 已提交
13 14 15
const getRootSetting = computed((): RootSetting => appStore.getProjectConfig);

const getPageLoading = computed(() => appStore.getPageLoading);
V
vben 已提交
16

V
vben 已提交
17
const getOpenKeepAlive = computed(() => unref(getRootSetting).openKeepAlive);
V
vben 已提交
18

V
vben 已提交
19
const getCanEmbedIFramePage = computed(() => unref(getRootSetting).canEmbedIFramePage);
V
vben 已提交
20

V
vben 已提交
21
const getPermissionMode = computed(() => unref(getRootSetting).permissionMode);
V
vben 已提交
22

V
vben 已提交
23
const getShowLogo = computed(() => unref(getRootSetting).showLogo);
V
vben 已提交
24

V
vben 已提交
25
const getContentMode = computed(() => unref(getRootSetting).contentMode);
V
vben 已提交
26

V
vben 已提交
27
const getUseOpenBackTop = computed(() => unref(getRootSetting).useOpenBackTop);
V
vben 已提交
28

V
vben 已提交
29
const getShowSettingButton = computed(() => unref(getRootSetting).showSettingButton);
V
vben 已提交
30

V
vben 已提交
31
const getUseErrorHandle = computed(() => unref(getRootSetting).useErrorHandle);
V
vben 已提交
32

V
vben 已提交
33
const getShowFooter = computed(() => unref(getRootSetting).showFooter);
V
vben 已提交
34

V
vben 已提交
35
const getShowBreadCrumb = computed(() => unref(getRootSetting).showBreadCrumb);
V
vben 已提交
36

V
vben 已提交
37
const getShowBreadCrumbIcon = computed(() => unref(getRootSetting).showBreadCrumbIcon);
V
vben 已提交
38

V
vben 已提交
39
const getFullContent = computed(() => unref(getRootSetting).fullContent);
V
vben 已提交
40

V
vben 已提交
41
const getColorWeak = computed(() => unref(getRootSetting).colorWeak);
V
vben 已提交
42

V
vben 已提交
43
const getGrayMode = computed(() => unref(getRootSetting).grayMode);
V
vben 已提交
44

V
vben 已提交
45 46
const getLockTime = computed(() => unref(getRootSetting).lockTime);

V
vben 已提交
47 48 49
const getLayoutContentMode = computed(() =>
  unref(getRootSetting).contentMode === ContentEnum.FULL ? ContentEnum.FULL : ContentEnum.FIXED
);
V
vben 已提交
50

V
vben 已提交
51 52 53
function setRootSetting(setting: Partial<RootSetting>) {
  appStore.commitProjectConfigState(setting);
}
V
vben 已提交
54

V
vben 已提交
55
export function useRootSetting() {
V
vben 已提交
56 57 58
  return {
    setRootSetting,

V
vben 已提交
59 60 61
    getFullContent,
    getColorWeak,
    getGrayMode,
V
vben 已提交
62
    getRootSetting,
V
vben 已提交
63 64
    getLayoutContentMode,
    getPageLoading,
V
vben 已提交
65 66 67 68 69 70 71
    getOpenKeepAlive,
    getCanEmbedIFramePage,
    getPermissionMode,
    getShowLogo,
    getUseErrorHandle,
    getShowBreadCrumb,
    getShowBreadCrumbIcon,
V
vben 已提交
72 73 74 75
    getUseOpenBackTop,
    getShowSettingButton,
    getShowFooter,
    getContentMode,
V
vben 已提交
76
    getLockTime,
V
vben 已提交
77 78
  };
}