Commit 88cb5497c5ae090d6d6ea4c981ae4aaebf0399cc

Authored by xingyu4j
1 parent 33fbe43f

perf: 登录显示loading

yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue
... ... @@ -147,7 +147,8 @@ import {
147 147 ElCol,
148 148 ElLink,
149 149 ElRow,
150   - ElDivider
  150 + ElDivider,
  151 + ElLoading
151 152 } from 'element-plus'
152 153 import { reactive, ref, unref, onMounted, computed, watch } from 'vue'
153 154 import * as LoginApi from '@/api/login'
... ... @@ -247,6 +248,11 @@ const handleLogin = async (params) => {
247 248 if (!res) {
248 249 return
249 250 }
  251 + ElLoading.service({
  252 + lock: true,
  253 + text: '正在加载系统中...',
  254 + background: 'rgba(0, 0, 0, 0.7)'
  255 + })
250 256 if (loginData.loginForm.rememberMe) {
251 257 Cookies.set('username', loginData.loginForm.username, { expires: 30 })
252 258 Cookies.set('password', encrypt(loginData.loginForm.password), { expires: 30 })
... ... @@ -265,6 +271,11 @@ const handleLogin = async (params) => {
265 271 push({ path: redirect.value || permissionStore.addRouters[0].path })
266 272 } catch {
267 273 loginLoading.value = false
  274 + } finally {
  275 + setTimeout(() => {
  276 + const loadingInstance = ElLoading.service()
  277 + loadingInstance.close()
  278 + }, 400)
268 279 }
269 280 }
270 281  
... ...