mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 16:46:19 +08:00
refactor: refactor setting
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
@@ -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,
|
||||
|
33
src/hooks/setting/useTransitionSetting.ts
Normal file
33
src/hooks/setting/useTransitionSetting.ts
Normal 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,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user