refactor: refactor setting

This commit is contained in:
vben
2020-11-25 00:43:33 +08:00
parent 0692b4798c
commit 41d79008c5
20 changed files with 248 additions and 183 deletions

View File

@@ -5,9 +5,8 @@ export const createContext = <T>(
contextInjectKey: InjectionKey<T> = Symbol(),
_readonly = true
) => {
const state = reactive({
...context,
});
const state = reactive({ ...context });
const provideData = _readonly ? readonly(state) : state;
provide(contextInjectKey, provideData);
};

View File

@@ -12,16 +12,10 @@ type RootSetting = Omit<
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);
@@ -65,10 +59,7 @@ export function useRootSetting() {
getRootSetting,
getLayoutContentMode,
getPageLoading,
getOpenPageLoading,
getOpenRouterTransition,
getOpenKeepAlive,
getRouterTransition,
getCanEmbedIFramePage,
getPermissionMode,
getShowLogo,

View File

@@ -0,0 +1,33 @@
import type { TransitionSetting } from '/@/types/config';
import { computed, unref } from 'vue';
import { appStore } from '/@/store/modules/app';
export function useTransitionSetting() {
const getTransitionSetting = computed(() => appStore.getProjectConfig.transitionSetting);
const getEnableTransition = computed(() => unref(getTransitionSetting).enable);
const getOpenNProgress = computed(() => unref(getTransitionSetting)?.openNProgress);
const getOpenPageLoading = computed(() => {
return unref(getTransitionSetting)?.openPageLoading && unref(getEnableTransition);
});
const getBasicTransition = computed(() => unref(getTransitionSetting)?.basicTransition);
function setTransitionSetting(transitionSetting: Partial<TransitionSetting>) {
appStore.commitProjectConfigState({ transitionSetting });
}
return {
setTransitionSetting,
getTransitionSetting,
getEnableTransition,
getOpenNProgress,
getOpenPageLoading,
getBasicTransition,
};
}