- 根因:public/index.html head 内同步引用 pv.sohu.com/cityjson, 浏览器需阻塞等待该外部脚本加载完成(该服务已不稳定,经常长时间挂起), 是登录页打开慢的主因 - ip 参数整链路为死代码:login.vue 取 returnCitySN["cip"] → store handleLogin 透传 → api login() 中根本未使用; 后端也无一处消费 ip 参数(smart-campus 脚手架遗留) - 删除 index.html 脚本引用与 login.vue / store 中的 ip 取值透传
This commit is contained in:
@@ -5,8 +5,6 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
<!--获取当前ip的js依赖-->
|
|
||||||
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
|
|
||||||
<title>freedom</title>
|
<title>freedom</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
+29
-31
@@ -34,41 +34,39 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LoginForm from '_c/login-form'
|
import LoginForm from '_c/login-form'
|
||||||
import {mapActions} from 'vuex'
|
import { mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
LoginForm
|
LoginForm
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions([
|
...mapActions([
|
||||||
'handleLogin',
|
'handleLogin',
|
||||||
'getUserInfo'
|
'getUserInfo'
|
||||||
]),
|
]),
|
||||||
handleSubmit({username, password}) {
|
handleSubmit ({ username, password }) {
|
||||||
// returnCitySN 由 index.html 引用的第三方脚本定义,可能加载失败,需兜底
|
this.$refs.loginForm.loading = true
|
||||||
var ip = (typeof returnCitySN !== 'undefined' && returnCitySN) ? returnCitySN["cip"] : ''
|
this.handleLogin({ username, password }).then(res => {
|
||||||
this.$refs.loginForm.loading = true
|
setTimeout(() => {
|
||||||
this.handleLogin({username, password, ip}).then(res => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.loginForm.loading = false
|
|
||||||
this.$router.push({
|
|
||||||
name: this.$config.homeName
|
|
||||||
})
|
|
||||||
}, 400)
|
|
||||||
}).catch(err => {
|
|
||||||
// 登录失败 / 后端不可用 / 请求超时统一在此提示,并复位按钮 loading
|
|
||||||
this.$refs.loginForm.loading = false
|
this.$refs.loginForm.loading = false
|
||||||
let msg = (err && err.message) ? err.message : ''
|
this.$router.push({
|
||||||
if (!msg || msg.indexOf('Network Error') > -1 || msg.indexOf('timeout') > -1 || msg.indexOf('ECONNABORTED') > -1) {
|
name: this.$config.homeName
|
||||||
msg = '网络异常或服务不可用,请稍后重试'
|
})
|
||||||
}
|
}, 400)
|
||||||
this.$Message.error(msg)
|
}).catch(err => {
|
||||||
})
|
// 登录失败 / 后端不可用 / 请求超时统一在此提示,并复位按钮 loading
|
||||||
}
|
this.$refs.loginForm.loading = false
|
||||||
|
let msg = (err && err.message) ? err.message : ''
|
||||||
|
if (!msg || msg.indexOf('Network Error') > -1 || msg.indexOf('timeout') > -1 || msg.indexOf('ECONNABORTED') > -1) {
|
||||||
|
msg = '网络异常或服务不可用,请稍后重试'
|
||||||
|
}
|
||||||
|
this.$Message.error(msg)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user