feat: 项目初始化
This commit is contained in:
59
src/store/index.ts
Normal file
59
src/store/index.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
export const useRootUserStore = defineStore('rootUser', {
|
||||
state: () => ({
|
||||
rootUserId: Taro.getStorageSync('RootUserId') || null,
|
||||
userId: Taro.getStorageSync('UserId') || null,
|
||||
rootUserName: Taro.getStorageSync('RootUserName') || "鱼测云",
|
||||
loginStatus: Taro.getStorageSync('LoginStatus') || 0,
|
||||
unLogin: Taro.getStorageSync('UnLogin') || 1,
|
||||
noticeRead: Taro.getStorageSync('NoticeRead') || 0,
|
||||
}),
|
||||
getters: {
|
||||
getRootUserId(): string {
|
||||
return this.rootUserId;
|
||||
},
|
||||
getUserId(): string {
|
||||
return this.userId;
|
||||
},
|
||||
getRootUserName(): string {
|
||||
return this.rootUserName;
|
||||
},
|
||||
getLoginStatus(): string {
|
||||
return this.loginStatus;
|
||||
},
|
||||
getUnLogin(): string {
|
||||
return this.unLogin;
|
||||
},
|
||||
getNoticeRead(): string {
|
||||
return this.noticeRead;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
updateRootUserId(newId: string) {
|
||||
this.rootUserId = newId;
|
||||
Taro.setStorageSync('RootUserId', newId);
|
||||
},
|
||||
updateUserId(newId: string) {
|
||||
this.userId = newId;
|
||||
Taro.setStorageSync('UserId', newId);
|
||||
},
|
||||
updateRootUserName(name: string) {
|
||||
this.rootUserName = name;
|
||||
Taro.setStorageSync('RootUserName', name);
|
||||
},
|
||||
updateLoginStatus(status: number) {
|
||||
this.loginStatus = status;
|
||||
Taro.setStorageSync('LoginStatus', status);
|
||||
},
|
||||
updateUnLogin(status: number) {
|
||||
this.unLogin = status;
|
||||
Taro.setStorageSync('UnLogin', status);
|
||||
},
|
||||
updateNoticeRead(status: number) {
|
||||
this.noticeRead = status;
|
||||
Taro.setStorageSync('NoticeRead', status);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user