登录相关mock

This commit is contained in:
xuziqiang
2024-05-20 16:42:40 +08:00
parent 7cb6d585b4
commit e6c8c78308
4 changed files with 4428 additions and 80 deletions

View File

@@ -1,5 +1,7 @@
import { defineStore } from 'pinia';
import { http } from '/nerv-lib/saas';
import { useApi, HttpRequestConfig } from '/nerv-lib/use/use-api';
interface AppConfig {
projectType: string;
baseApi: string;
@@ -36,6 +38,10 @@ interface resourceInfoModul {
api: string;
dealReosurceList?: Function;
}
const { httpRequest } = useApi();
const requestConfig: HttpRequestConfig = { method: 'POST' };
export const appConfigStore = defineStore({
id: 'appConfig',
state(): AppConfig {
@@ -102,32 +108,39 @@ export const appConfigStore = defineStore({
},
userLogin(data: loginData) {
if (this.userLoginApi) {
return http.post(this.userLoginApi, data, {
transformRequest: [
(mode, headers) => {
if (headers.qsToken) {
delete headers.qsToken;
}
return JSON.stringify(mode);
},
],
});
return httpRequest({ api: this.userLoginApi, params: data, pathParams: {}, requestConfig });
// return http.post(this.userLoginApi, data, {
// transformRequest: [
// (mode, headers) => {
// if (headers.qsToken) {
// delete headers.qsToken;
// }
// return JSON.stringify(mode);
// },
// ],
// });
} else {
return null;
}
},
userInfo() {
if (this.userInfoApi) {
return http.get(this.userInfoApi);
return httpRequest({ api: this.userInfoApi, params: {}, pathParams: {}, requestConfig });
} else {
return null;
return { data: {} };
}
},
userResource() {
if (this.userResourceApi) {
return http.get(this.userResourceApi);
return httpRequest({
api: this.userResourceApi,
params: {},
pathParams: {},
requestConfig,
});
} else {
return null;
return { data: [] };
}
},
},