登录相关mock
This commit is contained in:
@@ -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 => {
|
||||
|
Reference in New Issue
Block a user