import { defineStore } from 'pinia'; import { AppState } from './types'; const useAppStore = defineStore('app', { state: (): AppState => ({ version: '1.0.0', domain: '', device: 'desktop', trackConfig: { pictureType: ['track'], outputDir: '', curOutputDir: '', outputDirIsDefault: true, trackColorType: 'DEFAULT', studentFileRule: 'CODE', }, }), getters: { appInfo(state: AppState): AppState { return { ...state }; }, }, actions: { resetInfo() { this.$reset(); }, setInfo(partial: Partial) { this.$patch(partial); }, toggleDevice(device: string) { this.device = device; }, }, persist: { storage: sessionStorage, }, }); export default useAppStore;