| | |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item class="login-animation3"> |
| | | <!-- <el-form-item class="login-animation3"> |
| | | <el-col :span="15"> |
| | | <el-input |
| | | text |
| | |
| | | <el-col :span="8"> |
| | | <el-button class="login-content-code" v-waves>1234</el-button> |
| | | </el-col> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <el-form-item class="login-animation4"> |
| | | <el-button type="primary" class="login-content-submit" round v-waves @click="onSignIn" :loading="state.loading.signIn"> |
| | | <span>{{ $t('message.account.accountBtnText') }}</span> |
| | |
| | | import { Session } from '/@/utils/storage'; |
| | | import { formatAxis } from '/@/utils/formatTime'; |
| | | import { NextLoading } from '/@/utils/loading'; |
| | | import { signIn } from '/@/api/login'; |
| | | import { error } from 'console'; |
| | | |
| | | // 定义变量内容 |
| | | const { t } = useI18n(); |
| | |
| | | }); |
| | | // 登录 |
| | | const onSignIn = async () => { |
| | | state.loading.signIn = true; |
| | | // 存储 token 到浏览器缓存 |
| | | Session.set('token', Math.random().toString(36).substr(0)); |
| | | // 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据) |
| | | Cookies.set('userName', state.ruleForm.userName); |
| | | if (!themeConfig.value.isRequestRoutes) { |
| | | // 前端控制路由,2、请注意执行顺序 |
| | | const isNoPower = await initFrontEndControlRoutes(); |
| | | signInSuccess(isNoPower); |
| | | } else { |
| | | // 模拟后端控制路由,isRequestRoutes 为 true,则开启后端控制路由 |
| | | // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" |
| | | const isNoPower = await initBackEndControlRoutes(); |
| | | // 执行完 initBackEndControlRoutes,再执行 signInSuccess |
| | | signInSuccess(isNoPower); |
| | | try{ |
| | | state.loading.signIn = true; |
| | | const signInRes = await signIn(`user_no=${state.ruleForm.userName}&user_password=${state.ruleForm.password}`) |
| | | if(signInRes.data){ |
| | | // 存储 token 到浏览器缓存 |
| | | Session.set('token', signInRes.data); |
| | | // 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据) |
| | | Cookies.set('userName', state.ruleForm.userName); |
| | | // 前端控制路由,2、请注意执行顺序 |
| | | const isNoPower = await initFrontEndControlRoutes(); |
| | | signInSuccess(isNoPower); |
| | | |
| | | } |
| | | }catch(err){ |
| | | console.log(err) |
| | | state.loading.signIn = false |
| | | } |
| | | |
| | | |
| | | // 存储 token 到浏览器缓存 |
| | | // Session.set('token', '999'); |
| | | // 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据) |
| | | // Cookies.set('userName', state.ruleForm.userName); |
| | | // if (!themeConfig.value.isRequestRoutes) { |
| | | // // 前端控制路由,2、请注意执行顺序 |
| | | // const isNoPower = await initFrontEndControlRoutes(); |
| | | // signInSuccess(isNoPower); |
| | | // } else { |
| | | // // 模拟后端控制路由,isRequestRoutes 为 true,则开启后端控制路由 |
| | | // // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" |
| | | // const isNoPower = await initBackEndControlRoutes(); |
| | | // // 执行完 initBackEndControlRoutes,再执行 signInSuccess |
| | | // signInSuccess(isNoPower); |
| | | // } |
| | | }; |
| | | // 登录成功后的跳转 |
| | | const signInSuccess = (isNoPower: boolean | undefined) => { |