2021-06-07 18:35:16 +08:00
|
|
|
<template>
|
2021-06-30 15:30:55 +08:00
|
|
|
<div class="logins">
|
2021-06-30 11:30:13 +08:00
|
|
|
<div class="inside">
|
2022-05-10 14:59:18 +08:00
|
|
|
<div class="title">
|
2022-12-13 17:53:55 +08:00
|
|
|
<img src="../public/images/logo-title.svg" />
|
2021-06-30 11:30:13 +08:00
|
|
|
</div>
|
2021-06-30 17:50:19 +08:00
|
|
|
<el-form class="login__box">
|
2021-06-30 11:30:13 +08:00
|
|
|
<el-form-item>
|
|
|
|
|
<el-input
|
2022-12-13 17:53:55 +08:00
|
|
|
prefix-icon="cn-icon cn-icon-user2"
|
2021-08-13 09:39:02 +08:00
|
|
|
class="login--input login__input"
|
2021-06-30 11:30:13 +08:00
|
|
|
v-model="username"
|
|
|
|
|
></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-input
|
2021-08-13 09:39:02 +08:00
|
|
|
class="login--input"
|
2021-06-30 11:30:13 +08:00
|
|
|
prefix-icon="el-icon-lock"
|
|
|
|
|
type="password"
|
2021-08-13 09:39:02 +08:00
|
|
|
@keyup.enter="login"
|
2021-06-30 11:30:13 +08:00
|
|
|
v-model="pin"
|
|
|
|
|
></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button
|
2021-06-30 17:32:20 +08:00
|
|
|
v-loading="loading"
|
2021-06-30 15:30:55 +08:00
|
|
|
type="primary"
|
2021-12-14 16:42:45 +08:00
|
|
|
class="login--input login--button"
|
2021-08-13 09:39:02 +08:00
|
|
|
@click="login"
|
|
|
|
|
@keyup.enter="login"
|
2021-07-05 22:58:12 +08:00
|
|
|
style="font-size: 16px;"
|
|
|
|
|
>Login</el-button
|
2021-06-30 11:30:13 +08:00
|
|
|
>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
2021-06-11 10:00:22 +08:00
|
|
|
</div>
|
2021-06-07 18:35:16 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-06-11 10:00:22 +08:00
|
|
|
import { mapActions } from 'vuex'
|
2022-04-08 09:28:55 +08:00
|
|
|
import { post, get } from '@/utils/http'
|
2022-04-13 10:14:36 +08:00
|
|
|
import { useRouter } from 'vue-router'
|
2022-04-14 15:52:07 +08:00
|
|
|
import { storageKey } from '@/utils/constants'
|
|
|
|
|
import { api } from '@/utils/api'
|
2022-04-19 13:11:26 +08:00
|
|
|
import dayjs from 'dayjs'
|
2022-07-12 19:06:31 +08:00
|
|
|
import _ from 'lodash'
|
2022-04-19 13:11:26 +08:00
|
|
|
import utc from 'dayjs/plugin/utc'
|
|
|
|
|
dayjs.extend(utc)
|
2022-04-14 15:52:07 +08:00
|
|
|
|
2021-06-07 18:35:16 +08:00
|
|
|
export default {
|
2021-06-11 10:00:22 +08:00
|
|
|
name: 'Login',
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
2021-06-30 17:39:36 +08:00
|
|
|
loading: false,
|
2021-08-11 22:14:23 +08:00
|
|
|
username: '',
|
|
|
|
|
pin: ''
|
2021-06-11 10:00:22 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions(['loginSuccess']),
|
|
|
|
|
login () {
|
2021-08-11 22:14:23 +08:00
|
|
|
if (!this.username || !this.pin) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2021-08-26 19:56:04 +08:00
|
|
|
if (!this.blockOperation.query) {
|
|
|
|
|
this.blockOperation.query = true
|
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.loading = true
|
2022-04-14 17:22:48 +08:00
|
|
|
post(api.login, { username: this.username, pin: this.pin }).then(
|
2021-06-30 11:30:13 +08:00
|
|
|
res => {
|
2021-08-26 17:14:51 +08:00
|
|
|
if (res.code === 200) {
|
2022-07-12 19:06:31 +08:00
|
|
|
if (!_.isEmpty(res.data.lang)) {
|
2022-04-14 15:52:07 +08:00
|
|
|
localStorage.setItem(storageKey.language, res.data.lang)
|
2022-04-08 09:28:55 +08:00
|
|
|
}
|
2022-07-12 19:06:31 +08:00
|
|
|
if (!_.isEmpty(res.data.theme)) {
|
2022-04-14 15:52:07 +08:00
|
|
|
localStorage.setItem(storageKey.theme, res.data.theme)
|
2022-04-08 09:28:55 +08:00
|
|
|
}
|
2022-05-24 09:32:33 +08:00
|
|
|
res.loginSuccessPath = this.$route.query.redirect
|
2021-07-01 15:39:48 +08:00
|
|
|
this.loginSuccess(res)
|
2022-04-14 15:52:07 +08:00
|
|
|
localStorage.setItem(storageKey.username, this.username)
|
2022-08-10 15:05:56 +08:00
|
|
|
localStorage.setItem(storageKey.userId, res.data.userId)
|
2022-07-12 19:06:31 +08:00
|
|
|
localStorage.setItem(storageKey.token, res.data.token)
|
2021-08-26 17:14:51 +08:00
|
|
|
} else if (res.code === 518005) {
|
2021-08-29 22:19:26 +08:00
|
|
|
this.$message.error(this.$t('Incorrect username or password'))
|
2021-08-27 16:45:03 +08:00
|
|
|
this.loading = false
|
|
|
|
|
this.blockOperation.query = false
|
2021-08-24 17:36:27 +08:00
|
|
|
} else {
|
2021-08-29 22:19:26 +08:00
|
|
|
this.$message.error('Unknown error')
|
2021-08-27 16:45:03 +08:00
|
|
|
this.loading = false
|
|
|
|
|
this.blockOperation.query = false
|
2021-07-01 15:39:48 +08:00
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
}
|
2021-08-26 18:33:49 +08:00
|
|
|
).catch(e => {
|
2022-04-19 13:11:26 +08:00
|
|
|
console.error(e)
|
2021-08-26 17:14:51 +08:00
|
|
|
this.loading = false
|
|
|
|
|
this.blockOperation.query = false
|
2021-08-26 18:33:49 +08:00
|
|
|
this.$message.error(this.$t('tip.unknownError'))
|
2021-08-26 17:14:51 +08:00
|
|
|
})
|
2022-04-08 09:28:55 +08:00
|
|
|
},
|
2022-04-19 13:11:26 +08:00
|
|
|
queryAppearance () {
|
2022-04-14 15:52:07 +08:00
|
|
|
get(api.appearance).then(res => {
|
2022-04-08 09:28:55 +08:00
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.appearanceOut(res.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
appearanceOut (data) {
|
2022-07-12 19:06:31 +08:00
|
|
|
if (_.isEmpty(localStorage.getItem(storageKey.language))) {
|
2022-04-19 13:11:26 +08:00
|
|
|
localStorage.setItem(storageKey.language, data.lang || 'zh')
|
2022-04-08 09:28:55 +08:00
|
|
|
}
|
2022-07-12 19:06:31 +08:00
|
|
|
if (_.isEmpty(localStorage.getItem(storageKey.theme))) {
|
2022-04-19 13:11:26 +08:00
|
|
|
localStorage.setItem(storageKey.theme, data.theme || 'light')
|
2022-04-08 09:28:55 +08:00
|
|
|
}
|
2022-07-19 16:24:12 +08:00
|
|
|
localStorage.setItem(storageKey.s3Enable, data.s3_enable)
|
2022-04-19 13:11:26 +08:00
|
|
|
localStorage.setItem(storageKey.sysTimezone, data.timezone)
|
|
|
|
|
window.$dayJs.tz.setDefault(data.timezone)
|
|
|
|
|
localStorage.setItem(storageKey.timezoneOffset, window.$dayJs.tz().utcOffset() / 60)
|
|
|
|
|
localStorage.setItem(storageKey.timezoneLocalOffset, dayjs().utcOffset() / 60)
|
|
|
|
|
localStorage.setItem(storageKey.dateFormat, data.dateFormat)
|
|
|
|
|
localStorage.setItem(storageKey.sysName, data.system_name)
|
|
|
|
|
localStorage.setItem(storageKey.sysLogo, data.system_logo)
|
2021-06-11 10:00:22 +08:00
|
|
|
}
|
2022-04-08 09:28:55 +08:00
|
|
|
},
|
|
|
|
|
mounted () {
|
2022-04-19 13:11:26 +08:00
|
|
|
this.queryAppearance()
|
2022-04-13 10:14:36 +08:00
|
|
|
},
|
|
|
|
|
setup (props) {
|
|
|
|
|
const { currentRoute } = useRouter()
|
|
|
|
|
return {
|
|
|
|
|
loginSuccessPath: currentRoute.value.query.redirect
|
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
}
|
2021-06-07 18:35:16 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2022-12-13 17:53:55 +08:00
|
|
|
<style scoped>
|
|
|
|
|
.logins {
|
2021-06-30 15:45:45 +08:00
|
|
|
background-color: #000C18;
|
2021-06-30 15:30:55 +08:00
|
|
|
background-size: auto;
|
|
|
|
|
background-repeat: round;
|
2021-06-30 11:30:13 +08:00
|
|
|
background-image: url('../public/images/bg.png');
|
|
|
|
|
display: flex;
|
2022-12-13 17:53:55 +08:00
|
|
|
height: 100%;
|
2021-06-30 11:30:13 +08:00
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-13 17:53:55 +08:00
|
|
|
>>>.el-input__inner {
|
|
|
|
|
background-color: #0B325C !important;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 0px;
|
|
|
|
|
border-bottom: 1px solid #295688;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 14px;
|
|
|
|
|
}
|
|
|
|
|
>>>.el-input__inner:hover {
|
|
|
|
|
border-color: #295688;
|
|
|
|
|
}
|
|
|
|
|
>>>.el-input__inner:focus {
|
|
|
|
|
border-color: #295688;
|
|
|
|
|
}
|
|
|
|
|
.el-button--primary:hover, .el-button--primary:focus, .el-button--primary:active {
|
|
|
|
|
background: #21B4ED;
|
|
|
|
|
border-color: #21B4ED;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
}
|
|
|
|
|
>>>.el-loading-mask {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
}
|
|
|
|
|
>>>input {
|
|
|
|
|
-webkit-text-fill-color: rgba(231,234,237, .8) !important;
|
|
|
|
|
transition: background-color 500000000000000000s ease-in-out 0s !important;
|
|
|
|
|
caret-color: #fff ;
|
|
|
|
|
}
|
2021-06-30 11:30:13 +08:00
|
|
|
.inside {
|
2022-12-13 17:53:55 +08:00
|
|
|
width: 414px;
|
|
|
|
|
height: 524px;
|
|
|
|
|
background: #0B325C;
|
|
|
|
|
border: 1px solid rgba(103,179,245,0.65);
|
|
|
|
|
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.38);
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
.inside {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: space-between;
|
2021-06-30 11:30:13 +08:00
|
|
|
}
|
|
|
|
|
.inside > div {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2021-06-07 18:35:16 +08:00
|
|
|
|
2021-06-30 11:30:13 +08:00
|
|
|
.title {
|
2022-12-13 17:53:55 +08:00
|
|
|
margin-top: 65px;
|
2022-05-10 14:59:18 +08:00
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
.title > img {
|
2022-12-13 17:53:55 +08:00
|
|
|
height: 135px;
|
|
|
|
|
}
|
|
|
|
|
.login__box {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
>>>.el-form-item {
|
|
|
|
|
width: 334px;
|
|
|
|
|
margin-bottom: 25px;
|
|
|
|
|
}
|
|
|
|
|
>>>.el-input__prefix {
|
|
|
|
|
color: #6DBBFF;
|
|
|
|
|
}
|
|
|
|
|
>>>.el-input__prefix i {
|
|
|
|
|
width: 17px;
|
|
|
|
|
font-size: 17px;
|
|
|
|
|
}
|
|
|
|
|
.login__box .el-form-item:nth-of-type(3) {
|
|
|
|
|
margin-top: 25px;
|
|
|
|
|
margin-bottom: 65px;
|
|
|
|
|
}
|
2021-12-14 16:42:45 +08:00
|
|
|
.login--button {
|
2022-12-13 17:53:55 +08:00
|
|
|
background: #21B4ED;
|
2021-06-30 11:30:13 +08:00
|
|
|
border-radius: 4px;
|
2021-07-05 17:40:43 +08:00
|
|
|
border: 0;
|
2021-06-30 11:30:13 +08:00
|
|
|
font-weight: 400;
|
2022-12-13 17:53:55 +08:00
|
|
|
font-size: 16px;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
width: 334px;
|
|
|
|
|
height: 52px;
|
2021-06-30 11:30:13 +08:00
|
|
|
}
|
2021-06-07 18:35:16 +08:00
|
|
|
</style>
|