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