登录相关mock
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { http } from '/nerv-lib/saas';
|
import { http } from '/nerv-lib/saas';
|
||||||
|
import { useApi, HttpRequestConfig } from '/nerv-lib/use/use-api';
|
||||||
|
|
||||||
interface AppConfig {
|
interface AppConfig {
|
||||||
projectType: string;
|
projectType: string;
|
||||||
baseApi: string;
|
baseApi: string;
|
||||||
@@ -36,6 +38,10 @@ interface resourceInfoModul {
|
|||||||
api: string;
|
api: string;
|
||||||
dealReosurceList?: Function;
|
dealReosurceList?: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { httpRequest } = useApi();
|
||||||
|
const requestConfig: HttpRequestConfig = { method: 'POST' };
|
||||||
|
|
||||||
export const appConfigStore = defineStore({
|
export const appConfigStore = defineStore({
|
||||||
id: 'appConfig',
|
id: 'appConfig',
|
||||||
state(): AppConfig {
|
state(): AppConfig {
|
||||||
@@ -102,32 +108,39 @@ export const appConfigStore = defineStore({
|
|||||||
},
|
},
|
||||||
userLogin(data: loginData) {
|
userLogin(data: loginData) {
|
||||||
if (this.userLoginApi) {
|
if (this.userLoginApi) {
|
||||||
return http.post(this.userLoginApi, data, {
|
return httpRequest({ api: this.userLoginApi, params: data, pathParams: {}, requestConfig });
|
||||||
transformRequest: [
|
|
||||||
(mode, headers) => {
|
// return http.post(this.userLoginApi, data, {
|
||||||
if (headers.qsToken) {
|
// transformRequest: [
|
||||||
delete headers.qsToken;
|
// (mode, headers) => {
|
||||||
}
|
// if (headers.qsToken) {
|
||||||
return JSON.stringify(mode);
|
// delete headers.qsToken;
|
||||||
},
|
// }
|
||||||
],
|
// return JSON.stringify(mode);
|
||||||
});
|
// },
|
||||||
|
// ],
|
||||||
|
// });
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
userInfo() {
|
userInfo() {
|
||||||
if (this.userInfoApi) {
|
if (this.userInfoApi) {
|
||||||
return http.get(this.userInfoApi);
|
return httpRequest({ api: this.userInfoApi, params: {}, pathParams: {}, requestConfig });
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return { data: {} };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
userResource() {
|
userResource() {
|
||||||
if (this.userResourceApi) {
|
if (this.userResourceApi) {
|
||||||
return http.get(this.userResourceApi);
|
return httpRequest({
|
||||||
|
api: this.userResourceApi,
|
||||||
|
params: {},
|
||||||
|
pathParams: {},
|
||||||
|
requestConfig,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return { data: [] };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -86,67 +86,67 @@
|
|||||||
if (userName.value !== '' && password.value !== '') {
|
if (userName.value !== '' && password.value !== '') {
|
||||||
errorShow.value = false;
|
errorShow.value = false;
|
||||||
let data = JSON.stringify({ userName: userName.value, password: password.value });
|
let data = JSON.stringify({ userName: userName.value, password: password.value });
|
||||||
Cookies.set('nervsid', 'mockdata');
|
// Cookies.set('nervsid', 'mockdata');
|
||||||
router.replace({ name: 'root' });
|
// router.replace({ name: 'root' });
|
||||||
|
|
||||||
// loading.value = true;
|
loading.value = true;
|
||||||
// async function logins() {
|
async function logins() {
|
||||||
// try {
|
try {
|
||||||
// const res = await configStore.userLogin(JSON.parse(data));
|
const res = await configStore.userLogin(JSON.parse(data));
|
||||||
// if (res.success) {
|
if (res.success) {
|
||||||
// if (res.data?.userToken) {
|
if (res.data?.userToken) {
|
||||||
// Cookies.set('nervsid', res.data?.userToken);
|
Cookies.set('nervsid', res.data?.userToken);
|
||||||
// }
|
}
|
||||||
// const info = await configStore.userInfo();
|
const info = await configStore.userInfo();
|
||||||
// info.success
|
info.success
|
||||||
// ? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
||||||
// : '';
|
: '';
|
||||||
// loading.value = false;
|
loading.value = false;
|
||||||
// if (configStore.enablePermissions) {
|
if (configStore.enablePermissions) {
|
||||||
// const res = await configStore.userResource();
|
const res = await configStore.userResource();
|
||||||
// if (configStore.customApplication) {
|
if (configStore.customApplication) {
|
||||||
// await useAuthorization.initMenuResource();
|
await useAuthorization.initMenuResource();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// initUrl.value = '';
|
initUrl.value = '';
|
||||||
// const dealInitUrl = (item) => {
|
const dealInitUrl = (item) => {
|
||||||
// if (item.type === 'menus' && item.menus && item.menus?.length !== 0) {
|
if (item.type === 'menus' && item.menus && item.menus?.length !== 0) {
|
||||||
// dealInitUrl(item.menus[0]);
|
dealInitUrl(item.menus[0]);
|
||||||
// } else {
|
} else {
|
||||||
// // if (item.type === 'noChildrenMenu') {
|
// if (item.type === 'noChildrenMenu') {
|
||||||
// initUrl.value = configStore.resourceName
|
initUrl.value = configStore.resourceName
|
||||||
// ? item.code.replace(configStore.resourceName, '')
|
? item.code.replace(configStore.resourceName, '')
|
||||||
// : item.code;
|
: item.code;
|
||||||
// // }
|
// }
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// if (configStore.resourceName) {
|
if (configStore.resourceName) {
|
||||||
// const initResource = [];
|
const initResource = [];
|
||||||
// res.data.forEach((item) => {
|
res.data.forEach((item) => {
|
||||||
// if (item.code.includes(configStore.resourceName)) {
|
if (item.code.includes(configStore.resourceName)) {
|
||||||
// initResource.push(item);
|
initResource.push(item);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// dealInitUrl(initResource[0]);
|
dealInitUrl(initResource[0]);
|
||||||
// } else {
|
} else {
|
||||||
// dealInitUrl(res.data[0]);
|
dealInitUrl(res.data[0]);
|
||||||
// }
|
}
|
||||||
// // dealInitUrl(res.data[0]);
|
// dealInitUrl(res.data[0]);
|
||||||
// useAuthorization.updateUserResource(res.data);
|
useAuthorization.updateUserResource(res.data);
|
||||||
// const initRouterList = useAuthorization.getInitRouterList;
|
const initRouterList = useAuthorization.getInitRouterList;
|
||||||
|
|
||||||
// router.push({
|
router.push({
|
||||||
// name: initRouterList.length === 0 ? 'error403' : initUrl.value,
|
name: initRouterList.length === 0 ? 'error403' : initUrl.value,
|
||||||
// });
|
});
|
||||||
// } else {
|
} else {
|
||||||
// router.replace({ name: 'root' });
|
router.replace({ name: 'root' });
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } catch (err) {
|
} catch (err) {
|
||||||
// loading.value = false;
|
loading.value = false;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// logins();
|
logins();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const checkoutLogo = (): void => {
|
const checkoutLogo = (): void => {
|
||||||
|
@@ -1,22 +1,48 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
import { dateUtil } from '/nerv-lib/util/date-util';
|
import { dateUtil } from '/nerv-lib/util/date-util';
|
||||||
|
import mockResource from './resource.json';
|
||||||
|
console.log(mockResource.menus);
|
||||||
|
|
||||||
export const appConfig = {
|
export const appConfig = {
|
||||||
projectType: 'web',
|
projectType: 'web',
|
||||||
baseApi: '/api',
|
baseApi: '/api',
|
||||||
enablePermissions: false,
|
enablePermissions: true,
|
||||||
// siderPosition: 'left',
|
// siderPosition: 'left',
|
||||||
baseHeader: '/parkingManage',
|
baseHeader: '/parkingManage',
|
||||||
baseRouter: '/parkingManage/parkingLotManage',
|
baseRouter: '/parkingManage/parkingLotManage',
|
||||||
userCustomRouterGuard: (to, from, next, whiteNameList, authorizationStore, appConfig) => {
|
// userCustomRouterGuard: (to, from, next, whiteNameList, authorizationStore, appConfig) => {
|
||||||
console.log({ to, from, next, whiteNameList, authorizationStore, appConfig }, 'routeConfig');
|
// console.log({ to, from, next, whiteNameList, authorizationStore, appConfig }, 'routeConfig');
|
||||||
next();
|
// next();
|
||||||
},
|
// },
|
||||||
customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),
|
customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),
|
||||||
timeout: 60 * 1000,
|
timeout: 60 * 1000,
|
||||||
userLoginApi: 'api/web/objs/Login',
|
userLoginApi: () => {
|
||||||
// userResourceApi: '/api/web/objs/User/Resource',
|
return {
|
||||||
// userInfoApi: 'api/web/objs/CurrentUser',
|
code: 200,
|
||||||
|
success: true,
|
||||||
|
data: { userToken: 123123123 },
|
||||||
|
};
|
||||||
|
},
|
||||||
|
userResourceApi: () => {
|
||||||
|
return { data: mockResource.menus };
|
||||||
|
},
|
||||||
|
userInfoApi: () => {
|
||||||
|
return {
|
||||||
|
code: 200,
|
||||||
|
success: true,
|
||||||
|
data: {
|
||||||
|
accountCode: '1305107806187376793',
|
||||||
|
accountName: 'adm*n',
|
||||||
|
accountType: 'admin',
|
||||||
|
accountStatus: 1,
|
||||||
|
accountRealName: 'admin',
|
||||||
|
organizationCode: 'dingcloud',
|
||||||
|
authConfigList: [],
|
||||||
|
organizeResCode: [],
|
||||||
|
leadDepartmentUuidList: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
useHistoryTag: false,
|
useHistoryTag: false,
|
||||||
// 修改密码配置
|
// 修改密码配置
|
||||||
updatePassWordInfo: {
|
updatePassWordInfo: {
|
||||||
|
4309
nervui-smart-parking/src/config/resource.json
Normal file
4309
nervui-smart-parking/src/config/resource.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user