|  | @@ -0,0 +1,82 @@
 | 
	
		
			
				|  |  | +import { defineStore } from 'pinia';
 | 
	
		
			
				|  |  | +import { store } from '@/store';
 | 
	
		
			
				|  |  | +import { storage } from '@/utils/storage';
 | 
	
		
			
				|  |  | +import { userLogin, getUserInfo } from '@/api/user';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +export const useCatchStore = defineStore('catch-store', {
 | 
	
		
			
				|  |  | +  state: () => ({
 | 
	
		
			
				|  |  | +    bookVersionList: [] as any[], // 其它类型
 | 
	
		
			
				|  |  | +    musicTypeList: [] as any[], // 乐谱分类
 | 
	
		
			
				|  |  | +    subjectList: [] as any[] // 声部列表
 | 
	
		
			
				|  |  | +  }),
 | 
	
		
			
				|  |  | +  getters: {
 | 
	
		
			
				|  |  | +    getBookVersion(): any[] {
 | 
	
		
			
				|  |  | +      return this.bookVersionList;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    getMusicType(): any[] {
 | 
	
		
			
				|  |  | +      return this.musicTypeList;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    getSubjects(): any[] {
 | 
	
		
			
				|  |  | +      return this.subjectList;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  actions: {
 | 
	
		
			
				|  |  | +    setBookVersion(books: any[]) {
 | 
	
		
			
				|  |  | +      this.bookVersionList = books;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    setMusicType(musics: any[]) {
 | 
	
		
			
				|  |  | +      this.musicTypeList = musics;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    setSubjects(subjects: any[]) {
 | 
	
		
			
				|  |  | +      this.subjectList = subjects;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    //
 | 
	
		
			
				|  |  | +    // 登录
 | 
	
		
			
				|  |  | +    // async login(userInfo: any) {
 | 
	
		
			
				|  |  | +    //   try {
 | 
	
		
			
				|  |  | +    //     const { data } = await userLogin(userInfo);
 | 
	
		
			
				|  |  | +    //     console.log(data, 'data');
 | 
	
		
			
				|  |  | +    //     const userToken = data.token_type + ' ' + data.access_token;
 | 
	
		
			
				|  |  | +    //     const ex = 7 * 24 * 60 * 60 * 1000;
 | 
	
		
			
				|  |  | +    //     storage.set(ACCESS_TOKEN, userToken, ex);
 | 
	
		
			
				|  |  | +    //     // storage.get(IM_TOKEN, data.imToken);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //     this.setToken(userToken);
 | 
	
		
			
				|  |  | +    //     // this.setImToken(data.imToken);
 | 
	
		
			
				|  |  | +    //     return Promise.resolve();
 | 
	
		
			
				|  |  | +    //   } catch (e) {
 | 
	
		
			
				|  |  | +    //     return Promise.reject(e);
 | 
	
		
			
				|  |  | +    //   }
 | 
	
		
			
				|  |  | +    // },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // // 获取用户信息
 | 
	
		
			
				|  |  | +    // async getInfo() {
 | 
	
		
			
				|  |  | +    //   return new Promise((resolve, reject) => {
 | 
	
		
			
				|  |  | +    //     getUserInfo()
 | 
	
		
			
				|  |  | +    //       .then((res: any) => {
 | 
	
		
			
				|  |  | +    //         const result = res.data;
 | 
	
		
			
				|  |  | +    //         this.setUserInfo(result);
 | 
	
		
			
				|  |  | +    //         this.setAvatar(result.account.avatar);
 | 
	
		
			
				|  |  | +    //         this.setUsername(result.nickname);
 | 
	
		
			
				|  |  | +    //         resolve(true);
 | 
	
		
			
				|  |  | +    //       })
 | 
	
		
			
				|  |  | +    //       .catch((error: any) => {
 | 
	
		
			
				|  |  | +    //         reject(error);
 | 
	
		
			
				|  |  | +    //       });
 | 
	
		
			
				|  |  | +    //   });
 | 
	
		
			
				|  |  | +    // },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // // 登出
 | 
	
		
			
				|  |  | +    // async logout() {
 | 
	
		
			
				|  |  | +    //   this.setUserInfo('');
 | 
	
		
			
				|  |  | +    //   storage.remove(ACCESS_TOKEN);
 | 
	
		
			
				|  |  | +    //   storage.remove(CURRENT_USER);
 | 
	
		
			
				|  |  | +    //   return Promise.resolve('');
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// Need to be used outside the setup
 | 
	
		
			
				|  |  | +export function useCatchStoreWidthOut() {
 | 
	
		
			
				|  |  | +  return useCatchStore(store);
 | 
	
		
			
				|  |  | +}
 |