feat: add login by code
This commit is contained in:
		| @@ -38,7 +38,7 @@ export class QueryLogin { | ||||
|   setQuery(query: Query) { | ||||
|     this.query = query; | ||||
|   } | ||||
|   async init() { | ||||
|   private async init() { | ||||
|     await this.cache.init(); | ||||
|     this.load = true; | ||||
|     this.onLoad?.(); | ||||
| @@ -60,6 +60,20 @@ export class QueryLogin { | ||||
|     } | ||||
|     return res; | ||||
|   } | ||||
|   /** | ||||
|    * 手机号登录 | ||||
|    * @param data | ||||
|    * @returns | ||||
|    */ | ||||
|   async loginByCode(data: { phone: string; code: string }) { | ||||
|     const res = await this.post<QueryLoginResult>({ path: 'sms', key: 'login', data }); | ||||
|     if (res.code === 200) { | ||||
|       const { accessToken, refreshToken } = res?.data || {}; | ||||
|       this.storage.setItem('token', accessToken || ''); | ||||
|       await this.beforeSetLoginUser({ accessToken, refreshToken }); | ||||
|     } | ||||
|     return res; | ||||
|   } | ||||
|   /** | ||||
|    * 登陆成功,需要获取用户信息进行缓存 | ||||
|    * @param param0 | ||||
| @@ -82,6 +96,11 @@ export class QueryLogin { | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   /** | ||||
|    * 刷新token | ||||
|    * @param refreshToken | ||||
|    * @returns | ||||
|    */ | ||||
|   async queryRefreshToken(refreshToken?: string) { | ||||
|     const _refreshToken = refreshToken || this.cache.getRefreshToken(); | ||||
|     let data = { refreshToken: _refreshToken }; | ||||
| @@ -212,6 +231,11 @@ export class QueryLogin { | ||||
|     this.cache.del(); | ||||
|     return this.post<Result>({ key: 'logout' }); | ||||
|   } | ||||
|   /** | ||||
|    * 检查用户名的组,这个用户是否存在 | ||||
|    * @param username | ||||
|    * @returns | ||||
|    */ | ||||
|   async hasUser(username: string) { | ||||
|     const that = this; | ||||
|     return this.post<Result>( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user