登录相关mock
This commit is contained in:
@@ -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: [] };
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user