@@ -18,6 +18,7 @@ interface UserState {
1818 exp : number
1919 time : number
2020 weight : number
21+ origin : number
2122 platformInfo : any | null
2223 [ key : string ] : string | number | any | null
2324}
@@ -34,6 +35,7 @@ export const UserStore = defineStore('user', {
3435 exp : 0 ,
3536 time : 0 ,
3637 weight : 0 ,
38+ origin : 0 ,
3739 platformInfo : null ,
3840 }
3941 } ,
@@ -68,6 +70,9 @@ export const UserStore = defineStore('user', {
6870 getWeight ( ) : number {
6971 return this . weight
7072 } ,
73+ getOrigin ( ) : number {
74+ return this . origin
75+ } ,
7176 isSpaceAdmin ( ) : boolean {
7277 return this . uid === '1' || ! ! this . weight
7378 } ,
@@ -106,12 +111,22 @@ export const UserStore = defineStore('user', {
106111 const res : any = await AuthApi . info ( )
107112 const res_data = res || { }
108113
109- const keys = [ 'uid' , 'account' , 'name' , 'oid' , 'language' , 'exp' , 'time' , 'weight' ] as const
114+ const keys = [
115+ 'uid' ,
116+ 'account' ,
117+ 'name' ,
118+ 'oid' ,
119+ 'language' ,
120+ 'exp' ,
121+ 'time' ,
122+ 'weight' ,
123+ 'origin' ,
124+ ] as const
110125
111126 keys . forEach ( ( key ) => {
112127 const dkey = key === 'uid' ? 'id' : key
113128 const value = res_data [ dkey ]
114- if ( key === 'exp' || key === 'time' || key === 'weight' ) {
129+ if ( key === 'exp' || key === 'time' || key === 'weight' || key === 'origin' ) {
115130 this [ key ] = Number ( value )
116131 } else {
117132 this [ key ] = String ( value )
@@ -168,6 +183,10 @@ export const UserStore = defineStore('user', {
168183 wsCache . set ( 'user.weight' , weight )
169184 this . weight = weight
170185 } ,
186+ setOrigin ( origin : number ) {
187+ wsCache . set ( 'user.origin' , origin )
188+ this . origin = origin
189+ } ,
171190 setPlatformInfo ( info : any | null ) {
172191 wsCache . set ( 'user.platformInfo' , info )
173192 this . platformInfo = info
@@ -183,6 +202,7 @@ export const UserStore = defineStore('user', {
183202 'exp' ,
184203 'time' ,
185204 'weight' ,
205+ 'origin' ,
186206 'platformInfo' ,
187207 ]
188208 keys . forEach ( ( key ) => wsCache . delete ( 'user.' + key ) )
0 commit comments