index.ts 793 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { defineStore } from 'pinia';
  2. import { AppState } from './types';
  3. const useAppStore = defineStore('app', {
  4. state: (): AppState => ({
  5. version: '1.0.0',
  6. domain: '',
  7. device: 'desktop',
  8. trackConfig: {
  9. pictureType: ['track'],
  10. outputDir: '',
  11. curOutputDir: '',
  12. outputDirIsDefault: true,
  13. trackColorType: 'DEFAULT',
  14. studentFileRule: 'CODE',
  15. },
  16. }),
  17. getters: {
  18. appInfo(state: AppState): AppState {
  19. return { ...state };
  20. },
  21. },
  22. actions: {
  23. resetInfo() {
  24. this.$reset();
  25. },
  26. setInfo(partial: Partial<AppState>) {
  27. this.$patch(partial);
  28. },
  29. toggleDevice(device: string) {
  30. this.device = device;
  31. },
  32. },
  33. persist: {
  34. storage: sessionStorage,
  35. },
  36. });
  37. export default useAppStore;