登录相关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: [] };
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@@ -86,67 +86,67 @@
|
||||
if (userName.value !== '' && password.value !== '') {
|
||||
errorShow.value = false;
|
||||
let data = JSON.stringify({ userName: userName.value, password: password.value });
|
||||
Cookies.set('nervsid', 'mockdata');
|
||||
router.replace({ name: 'root' });
|
||||
// Cookies.set('nervsid', 'mockdata');
|
||||
// router.replace({ name: 'root' });
|
||||
|
||||
// loading.value = true;
|
||||
// async function logins() {
|
||||
// try {
|
||||
// const res = await configStore.userLogin(JSON.parse(data));
|
||||
// if (res.success) {
|
||||
// if (res.data?.userToken) {
|
||||
// Cookies.set('nervsid', res.data?.userToken);
|
||||
// }
|
||||
// const info = await configStore.userInfo();
|
||||
// info.success
|
||||
// ? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
||||
// : '';
|
||||
// loading.value = false;
|
||||
// if (configStore.enablePermissions) {
|
||||
// const res = await configStore.userResource();
|
||||
// if (configStore.customApplication) {
|
||||
// await useAuthorization.initMenuResource();
|
||||
// }
|
||||
loading.value = true;
|
||||
async function logins() {
|
||||
try {
|
||||
const res = await configStore.userLogin(JSON.parse(data));
|
||||
if (res.success) {
|
||||
if (res.data?.userToken) {
|
||||
Cookies.set('nervsid', res.data?.userToken);
|
||||
}
|
||||
const info = await configStore.userInfo();
|
||||
info.success
|
||||
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
||||
: '';
|
||||
loading.value = false;
|
||||
if (configStore.enablePermissions) {
|
||||
const res = await configStore.userResource();
|
||||
if (configStore.customApplication) {
|
||||
await useAuthorization.initMenuResource();
|
||||
}
|
||||
|
||||
// initUrl.value = '';
|
||||
// const dealInitUrl = (item) => {
|
||||
// if (item.type === 'menus' && item.menus && item.menus?.length !== 0) {
|
||||
// dealInitUrl(item.menus[0]);
|
||||
// } else {
|
||||
// // if (item.type === 'noChildrenMenu') {
|
||||
// initUrl.value = configStore.resourceName
|
||||
// ? item.code.replace(configStore.resourceName, '')
|
||||
// : item.code;
|
||||
// // }
|
||||
// }
|
||||
// };
|
||||
// if (configStore.resourceName) {
|
||||
// const initResource = [];
|
||||
// res.data.forEach((item) => {
|
||||
// if (item.code.includes(configStore.resourceName)) {
|
||||
// initResource.push(item);
|
||||
// }
|
||||
// });
|
||||
// dealInitUrl(initResource[0]);
|
||||
// } else {
|
||||
// dealInitUrl(res.data[0]);
|
||||
// }
|
||||
// // dealInitUrl(res.data[0]);
|
||||
// useAuthorization.updateUserResource(res.data);
|
||||
// const initRouterList = useAuthorization.getInitRouterList;
|
||||
initUrl.value = '';
|
||||
const dealInitUrl = (item) => {
|
||||
if (item.type === 'menus' && item.menus && item.menus?.length !== 0) {
|
||||
dealInitUrl(item.menus[0]);
|
||||
} else {
|
||||
// if (item.type === 'noChildrenMenu') {
|
||||
initUrl.value = configStore.resourceName
|
||||
? item.code.replace(configStore.resourceName, '')
|
||||
: item.code;
|
||||
// }
|
||||
}
|
||||
};
|
||||
if (configStore.resourceName) {
|
||||
const initResource = [];
|
||||
res.data.forEach((item) => {
|
||||
if (item.code.includes(configStore.resourceName)) {
|
||||
initResource.push(item);
|
||||
}
|
||||
});
|
||||
dealInitUrl(initResource[0]);
|
||||
} else {
|
||||
dealInitUrl(res.data[0]);
|
||||
}
|
||||
// dealInitUrl(res.data[0]);
|
||||
useAuthorization.updateUserResource(res.data);
|
||||
const initRouterList = useAuthorization.getInitRouterList;
|
||||
|
||||
// router.push({
|
||||
// name: initRouterList.length === 0 ? 'error403' : initUrl.value,
|
||||
// });
|
||||
// } else {
|
||||
// router.replace({ name: 'root' });
|
||||
// }
|
||||
// }
|
||||
// } catch (err) {
|
||||
// loading.value = false;
|
||||
// }
|
||||
// }
|
||||
// logins();
|
||||
router.push({
|
||||
name: initRouterList.length === 0 ? 'error403' : initUrl.value,
|
||||
});
|
||||
} else {
|
||||
router.replace({ name: 'root' });
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
logins();
|
||||
}
|
||||
};
|
||||
const checkoutLogo = (): void => {
|
||||
|
@@ -1,22 +1,48 @@
|
||||
/** @format */
|
||||
import { dateUtil } from '/nerv-lib/util/date-util';
|
||||
import mockResource from './resource.json';
|
||||
console.log(mockResource.menus);
|
||||
|
||||
export const appConfig = {
|
||||
projectType: 'web',
|
||||
baseApi: '/api',
|
||||
enablePermissions: false,
|
||||
enablePermissions: true,
|
||||
// siderPosition: 'left',
|
||||
baseHeader: '/parkingManage',
|
||||
baseRouter: '/parkingManage/parkingLotManage',
|
||||
userCustomRouterGuard: (to, from, next, whiteNameList, authorizationStore, appConfig) => {
|
||||
console.log({ to, from, next, whiteNameList, authorizationStore, appConfig }, 'routeConfig');
|
||||
next();
|
||||
},
|
||||
// userCustomRouterGuard: (to, from, next, whiteNameList, authorizationStore, appConfig) => {
|
||||
// console.log({ to, from, next, whiteNameList, authorizationStore, appConfig }, 'routeConfig');
|
||||
// next();
|
||||
// },
|
||||
customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),
|
||||
timeout: 60 * 1000,
|
||||
userLoginApi: 'api/web/objs/Login',
|
||||
// userResourceApi: '/api/web/objs/User/Resource',
|
||||
// userInfoApi: 'api/web/objs/CurrentUser',
|
||||
userLoginApi: () => {
|
||||
return {
|
||||
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,
|
||||
// 修改密码配置
|
||||
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