mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 代码优化
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import type { App } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
|
||||
/** setup vue store plugin: pinia. - [安装vue状态管理插件:pinia] */
|
||||
export function setupStore(app: App) {
|
||||
const store = createPinia();
|
||||
app.use(store);
|
||||
|
@ -11,14 +11,14 @@ interface AuthState {
|
||||
/** 用户token */
|
||||
token: string;
|
||||
/** 登录的加载状态 */
|
||||
loginLoding: boolean;
|
||||
loginLoading: boolean;
|
||||
}
|
||||
|
||||
export const useAuthStore = defineStore('auth-store', {
|
||||
state: (): AuthState => ({
|
||||
userInfo: getUserInfo(),
|
||||
token: getToken(),
|
||||
loginLoding: false
|
||||
loginLoading: false
|
||||
}),
|
||||
getters: {
|
||||
/** 是否登录 */
|
||||
@ -81,12 +81,12 @@ export const useAuthStore = defineStore('auth-store', {
|
||||
* @param type - 登录方式: pwd - 密码登录; sms - 验证码登录
|
||||
*/
|
||||
async login(phone: string, pwdOrCode: string, type: 'pwd' | 'sms') {
|
||||
this.loginLoding = true;
|
||||
this.loginLoading = true;
|
||||
const { data } = await fetchLogin(phone, pwdOrCode, type);
|
||||
if (data) {
|
||||
await this.loginByToken(data);
|
||||
}
|
||||
this.loginLoding = false;
|
||||
this.loginLoading = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user