sys.ts 846 B

1234567891011121314151617181920212223
  1. import { ref, computed } from "vue";
  2. export const appEl = ref<HTMLElement>(null);
  3. export const showToolbox = ref(true);
  4. export const showToolbar = ref(false);
  5. // 当前系统的模式 分可读可写 预览编辑
  6. // 具体操作方式参考 https://juejin.cn/post/7000335920972955684
  7. export const modeFlags = {
  8. EDIT: 0b10,
  9. // 已经保存,是最新的
  10. SAVED: 0b100,
  11. // 可写模式,用户已登陆
  12. LOGIN: 0b1000,
  13. } as const;
  14. export type ModeFlag = typeof modeFlags[keyof typeof modeFlags];
  15. export const mode = ref<number>(modeFlags.SAVED | modeFlags.LOGIN);
  16. export const isEdit = computed(() => !!(mode.value & modeFlags.EDIT));
  17. export const isLogin = computed(() => !!(mode.value & modeFlags.LOGIN));
  18. export const isSave = computed(() => !(mode.value & modeFlags.SAVED));
  19. export const docDomain = `http://showdoc.4dage.com/`;