| | |
| | | setup() { |
| | | const { t } = useI18n(); |
| | | const userInfo = useUserInfo() |
| | | const { userInfos } = storeToRefs(userInfo); |
| | | const storesThemeConfig = useThemeConfig(); |
| | | const { themeConfig } = storeToRefs(storesThemeConfig); |
| | | const route = useRoute(); |
| | | const router = useRouter(); |
| | | const state = reactive({ |
| | |
| | | // 存储 token 到浏览器缓存 |
| | | let res = await useLoginApi().signIn(state.ruleForm) |
| | | if(res.data.code === '200'){ |
| | | Session.set('ifMenu',false) |
| | | Session.set('projectId','') |
| | | userInfo.setUserInfos(res.data.data) |
| | | Session.set('token', res.data.data.accessToken); |
| | | Session.set('sign',res.data.data.id) |
| | | await initFrontEndControlRoutes(); |
| | | Session.set('projectId',''); |
| | | Session.set('uid',res.data.data.uid); |
| | | await initBackEndControlRoutes(); |
| | | signInSuccess(); |
| | | }else{ |
| | | state.loading.signIn = false |
| | |
| | | // 登录成功,跳到转首页 |
| | | // 如果是复制粘贴的路径,非首页/登录页,那么登录成功后重定向到对应的路径中 |
| | | if (route.query?.redirect) { |
| | | router.push('/menu'); |
| | | router.push('/homeMenu'); |
| | | // router.push({ |
| | | // path: <string>route.query?.redirect, |
| | | // query: Object.keys(<string>route.query?.params).length > 0 ? JSON.parse(<string>route.query?.params) : '', |
| | | // }); |
| | | } else { |
| | | router.push('/login'); |
| | | router.push('/loginPage'); |
| | | } |
| | | state.loading.signIn = true; |
| | | const signInText = t('message.signInText'); |