2021-02-26 20:09:24 +08:00
|
|
|
import type { ProjectConfig } from '/#/config';
|
2020-11-23 23:24:13 +08:00
|
|
|
|
|
|
|
|
import { computed, unref } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { appStore } from '/@/store/modules/app';
|
2020-11-24 22:59:29 +08:00
|
|
|
import { ContentEnum } from '/@/enums/appEnum';
|
2020-11-23 23:24:13 +08:00
|
|
|
|
|
|
|
|
type RootSetting = Omit<
|
|
|
|
|
ProjectConfig,
|
|
|
|
|
'locale' | 'headerSetting' | 'menuSetting' | 'multiTabsSetting'
|
|
|
|
|
>;
|
|
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getRootSetting = computed((): RootSetting => appStore.getProjectConfig);
|
|
|
|
|
|
|
|
|
|
const getPageLoading = computed(() => appStore.getPageLoading);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getOpenKeepAlive = computed(() => unref(getRootSetting).openKeepAlive);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2021-02-18 21:02:56 +08:00
|
|
|
const getSettingButtonPosition = computed(() => unref(getRootSetting).settingButtonPosition);
|
|
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getCanEmbedIFramePage = computed(() => unref(getRootSetting).canEmbedIFramePage);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getPermissionMode = computed(() => unref(getRootSetting).permissionMode);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getShowLogo = computed(() => unref(getRootSetting).showLogo);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getContentMode = computed(() => unref(getRootSetting).contentMode);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getUseOpenBackTop = computed(() => unref(getRootSetting).useOpenBackTop);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getShowSettingButton = computed(() => unref(getRootSetting).showSettingButton);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getUseErrorHandle = computed(() => unref(getRootSetting).useErrorHandle);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getShowFooter = computed(() => unref(getRootSetting).showFooter);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getShowBreadCrumb = computed(() => unref(getRootSetting).showBreadCrumb);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2021-02-03 23:52:55 +08:00
|
|
|
const getThemeColor = computed(() => unref(getRootSetting).themeColor);
|
|
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getShowBreadCrumbIcon = computed(() => unref(getRootSetting).showBreadCrumbIcon);
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getFullContent = computed(() => unref(getRootSetting).fullContent);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getColorWeak = computed(() => unref(getRootSetting).colorWeak);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getGrayMode = computed(() => unref(getRootSetting).grayMode);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-09 22:11:34 +08:00
|
|
|
const getLockTime = computed(() => unref(getRootSetting).lockTime);
|
|
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
const getLayoutContentMode = computed(() =>
|
|
|
|
|
unref(getRootSetting).contentMode === ContentEnum.FULL ? ContentEnum.FULL : ContentEnum.FIXED
|
|
|
|
|
);
|
2020-11-24 22:59:29 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
function setRootSetting(setting: Partial<RootSetting>) {
|
|
|
|
|
appStore.commitProjectConfigState(setting);
|
|
|
|
|
}
|
2020-11-23 23:24:13 +08:00
|
|
|
|
2020-12-07 22:18:57 +08:00
|
|
|
export function useRootSetting() {
|
2020-11-23 23:24:13 +08:00
|
|
|
return {
|
|
|
|
|
setRootSetting,
|
|
|
|
|
|
2021-02-18 21:02:56 +08:00
|
|
|
getSettingButtonPosition,
|
2020-11-24 22:59:29 +08:00
|
|
|
getFullContent,
|
|
|
|
|
getColorWeak,
|
|
|
|
|
getGrayMode,
|
2020-11-23 23:24:13 +08:00
|
|
|
getRootSetting,
|
2020-11-24 22:59:29 +08:00
|
|
|
getLayoutContentMode,
|
|
|
|
|
getPageLoading,
|
2020-11-23 23:24:13 +08:00
|
|
|
getOpenKeepAlive,
|
|
|
|
|
getCanEmbedIFramePage,
|
|
|
|
|
getPermissionMode,
|
|
|
|
|
getShowLogo,
|
|
|
|
|
getUseErrorHandle,
|
|
|
|
|
getShowBreadCrumb,
|
|
|
|
|
getShowBreadCrumbIcon,
|
2020-11-24 22:59:29 +08:00
|
|
|
getUseOpenBackTop,
|
|
|
|
|
getShowSettingButton,
|
|
|
|
|
getShowFooter,
|
|
|
|
|
getContentMode,
|
2020-12-09 22:11:34 +08:00
|
|
|
getLockTime,
|
2021-02-03 23:52:55 +08:00
|
|
|
getThemeColor,
|
2020-11-23 23:24:13 +08:00
|
|
|
};
|
|
|
|
|
}
|