useRootSetting.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import type { ProjectConfig } from '/@/types/config';
  2. import { computed, unref } from 'vue';
  3. import { appStore } from '/@/store/modules/app';
  4. import { ContentEnum } from '/@/enums/appEnum';
  5. type RootSetting = Omit<
  6. ProjectConfig,
  7. 'locale' | 'headerSetting' | 'menuSetting' | 'multiTabsSetting'
  8. >;
  9. const getRootSetting = computed((): RootSetting => appStore.getProjectConfig);
  10. const getPageLoading = computed(() => appStore.getPageLoading);
  11. const getOpenKeepAlive = computed(() => unref(getRootSetting).openKeepAlive);
  12. const getSettingButtonPosition = computed(() => unref(getRootSetting).settingButtonPosition);
  13. const getCanEmbedIFramePage = computed(() => unref(getRootSetting).canEmbedIFramePage);
  14. const getPermissionMode = computed(() => unref(getRootSetting).permissionMode);
  15. const getShowLogo = computed(() => unref(getRootSetting).showLogo);
  16. const getContentMode = computed(() => unref(getRootSetting).contentMode);
  17. const getUseOpenBackTop = computed(() => unref(getRootSetting).useOpenBackTop);
  18. const getShowSettingButton = computed(() => unref(getRootSetting).showSettingButton);
  19. const getUseErrorHandle = computed(() => unref(getRootSetting).useErrorHandle);
  20. const getShowFooter = computed(() => unref(getRootSetting).showFooter);
  21. const getShowBreadCrumb = computed(() => unref(getRootSetting).showBreadCrumb);
  22. const getThemeColor = computed(() => unref(getRootSetting).themeColor);
  23. const getShowBreadCrumbIcon = computed(() => unref(getRootSetting).showBreadCrumbIcon);
  24. const getFullContent = computed(() => unref(getRootSetting).fullContent);
  25. const getColorWeak = computed(() => unref(getRootSetting).colorWeak);
  26. const getGrayMode = computed(() => unref(getRootSetting).grayMode);
  27. const getLockTime = computed(() => unref(getRootSetting).lockTime);
  28. const getLayoutContentMode = computed(() =>
  29. unref(getRootSetting).contentMode === ContentEnum.FULL ? ContentEnum.FULL : ContentEnum.FIXED
  30. );
  31. function setRootSetting(setting: Partial<RootSetting>) {
  32. appStore.commitProjectConfigState(setting);
  33. }
  34. export function useRootSetting() {
  35. return {
  36. setRootSetting,
  37. getSettingButtonPosition,
  38. getFullContent,
  39. getColorWeak,
  40. getGrayMode,
  41. getRootSetting,
  42. getLayoutContentMode,
  43. getPageLoading,
  44. getOpenKeepAlive,
  45. getCanEmbedIFramePage,
  46. getPermissionMode,
  47. getShowLogo,
  48. getUseErrorHandle,
  49. getShowBreadCrumb,
  50. getShowBreadCrumbIcon,
  51. getUseOpenBackTop,
  52. getShowSettingButton,
  53. getShowFooter,
  54. getContentMode,
  55. getLockTime,
  56. getThemeColor,
  57. };
  58. }