useRootSetting.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import type { ProjectConfig } from '/@/types/config';
  2. import { computed, unref } from 'vue';
  3. import { appStore } from '/@/store/modules/app';
  4. type RootSetting = Omit<
  5. ProjectConfig,
  6. 'locale' | 'headerSetting' | 'menuSetting' | 'multiTabsSetting'
  7. >;
  8. export function useRootSetting() {
  9. const getRootSetting = computed((): RootSetting => appStore.getProjectConfig);
  10. const getOpenPageLoading = computed(() => unref(getRootSetting).openPageLoading);
  11. const getOpenRouterTransition = computed(() => unref(getRootSetting).openRouterTransition);
  12. const getOpenKeepAlive = computed(() => unref(getRootSetting).openKeepAlive);
  13. const getRouterTransition = computed(() => unref(getRootSetting).routerTransition);
  14. const getCanEmbedIFramePage = computed(() => unref(getRootSetting).canEmbedIFramePage);
  15. const getPermissionMode = computed(() => unref(getRootSetting).permissionMode);
  16. const getShowLogo = computed(() => unref(getRootSetting).showLogo);
  17. const getUseErrorHandle = computed(() => unref(getRootSetting).useErrorHandle);
  18. const getShowBreadCrumb = computed(() => unref(getRootSetting).showBreadCrumb);
  19. const getShowBreadCrumbIcon = computed(() => unref(getRootSetting).showBreadCrumbIcon);
  20. function setRootSetting(setting: RootSetting) {
  21. appStore.commitProjectConfigState(setting);
  22. }
  23. return {
  24. setRootSetting,
  25. getRootSetting,
  26. getOpenPageLoading,
  27. getOpenRouterTransition,
  28. getOpenKeepAlive,
  29. getRouterTransition,
  30. getCanEmbedIFramePage,
  31. getPermissionMode,
  32. getShowLogo,
  33. getUseErrorHandle,
  34. getShowBreadCrumb,
  35. getShowBreadCrumbIcon,
  36. };
  37. }