|
@@ -1,5 +1,5 @@
|
|
import type { UserInfo, LoginInfo } from '/#/store';
|
|
import type { UserInfo, LoginInfo } from '/#/store';
|
|
-import type { ErrorMessageMode } from '/#/axios';
|
|
|
|
|
|
+import type { ErrorMessageMode, SuccessMessageMode } from '/#/axios';
|
|
import { defineStore } from 'pinia';
|
|
import { defineStore } from 'pinia';
|
|
import { store } from '/@/store';
|
|
import { store } from '/@/store';
|
|
import { PageEnum } from '/@/enums/pageEnum';
|
|
import { PageEnum } from '/@/enums/pageEnum';
|
|
@@ -141,11 +141,12 @@ export const useUserStore = defineStore({
|
|
params: LoginParams & {
|
|
params: LoginParams & {
|
|
goHome?: boolean;
|
|
goHome?: boolean;
|
|
mode?: ErrorMessageMode;
|
|
mode?: ErrorMessageMode;
|
|
|
|
+ successMode?: SuccessMessageMode;
|
|
}
|
|
}
|
|
): Promise<GetUserInfoModel | null> {
|
|
): Promise<GetUserInfoModel | null> {
|
|
try {
|
|
try {
|
|
- const { goHome = true, mode, ...loginParams } = params;
|
|
|
|
- const data = await loginApi(loginParams, mode);
|
|
|
|
|
|
+ const { goHome = true, mode, successMode, ...loginParams } = params;
|
|
|
|
+ const data = await loginApi(loginParams, mode, successMode);
|
|
const { token, userInfo } = data;
|
|
const { token, userInfo } = data;
|
|
// save token
|
|
// save token
|
|
this.setToken(token);
|
|
this.setToken(token);
|
|
@@ -369,6 +370,7 @@ export const useUserStore = defineStore({
|
|
params: Partial<LoginParams> & {
|
|
params: Partial<LoginParams> & {
|
|
goHome?: boolean;
|
|
goHome?: boolean;
|
|
mode?: ErrorMessageMode;
|
|
mode?: ErrorMessageMode;
|
|
|
|
+ successMode?: SuccessMessageMode;
|
|
} = {}
|
|
} = {}
|
|
) {
|
|
) {
|
|
try {
|
|
try {
|
|
@@ -376,6 +378,7 @@ export const useUserStore = defineStore({
|
|
username: MOCK_LOGIN_UESRNAME,
|
|
username: MOCK_LOGIN_UESRNAME,
|
|
password: MOCK_LOGIN_PASSWORD,
|
|
password: MOCK_LOGIN_PASSWORD,
|
|
checkKey: new Date().getTime(),
|
|
checkKey: new Date().getTime(),
|
|
|
|
+ successMode: 'none' as SuccessMessageMode,
|
|
...params,
|
|
...params,
|
|
};
|
|
};
|
|
return this.login(loginParams);
|
|
return this.login(loginParams);
|
|
@@ -388,6 +391,7 @@ export const useUserStore = defineStore({
|
|
params: Partial<LoginParams> & {
|
|
params: Partial<LoginParams> & {
|
|
goHome?: boolean;
|
|
goHome?: boolean;
|
|
mode?: ErrorMessageMode;
|
|
mode?: ErrorMessageMode;
|
|
|
|
+ successMode?: SuccessMessageMode;
|
|
} = {}
|
|
} = {}
|
|
) {
|
|
) {
|
|
await this.logout();
|
|
await this.logout();
|
|
@@ -402,10 +406,11 @@ export const useUserStore = defineStore({
|
|
params: AutoLoginParams & {
|
|
params: AutoLoginParams & {
|
|
goHome?: boolean;
|
|
goHome?: boolean;
|
|
mode?: ErrorMessageMode;
|
|
mode?: ErrorMessageMode;
|
|
|
|
+ successMode?: SuccessMessageMode;
|
|
}
|
|
}
|
|
) {
|
|
) {
|
|
- const { goHome = true, mode, ...loginParams } = params;
|
|
|
|
- const data = await autoLoginApi(loginParams, mode);
|
|
|
|
|
|
+ const { goHome = true, mode, successMode = 'none', ...loginParams } = params;
|
|
|
|
+ const data = await autoLoginApi(loginParams, mode, successMode);
|
|
const { token, userInfo } = data;
|
|
const { token, userInfo } = data;
|
|
// save token
|
|
// save token
|
|
this.setToken(token);
|
|
this.setToken(token);
|