2019-12-04 13:45:37 +08:00
|
|
|
|
<template>
|
2020-02-19 15:16:38 +08:00
|
|
|
|
<div class="login" @click="langListShow = false">
|
2020-02-18 21:31:39 +08:00
|
|
|
|
<div class="model"></div>
|
|
|
|
|
|
<div class="logo"><img height="155" src="../../assets/img/logo-big.png"></div>
|
|
|
|
|
|
<div class='login-box'>
|
|
|
|
|
|
<div class="login-label"></div>
|
|
|
|
|
|
<div class="login-input">
|
2020-02-20 10:34:12 +08:00
|
|
|
|
<i class="nz-icon nz-icon-user"></i>
|
2020-04-15 12:48:30 +08:00
|
|
|
|
<input id="usernameInput" v-model="loginData.username" name="userName" autocomplete="on" :placeholder="$t('login.username')"></input>
|
2020-02-18 21:31:39 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-label"></div>
|
|
|
|
|
|
<div class="login-input">
|
2020-02-20 10:34:12 +08:00
|
|
|
|
<i class="nz-icon nz-icon-password"></i>
|
2021-03-25 09:46:59 +08:00
|
|
|
|
<input v-model="loginData.pin" type="password" name="password" autocomplete="on" :placeholder="$t('login.password')"></input>
|
2020-02-18 21:31:39 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-foot">
|
2021-04-16 21:10:31 +08:00
|
|
|
|
<button @click="login" class="login-btn" id="login" v-loading="loading" :class="{'nz-btn-disabled btn-disabled-cursor-not-allowed':!license.valid}">{{$t("login.login")}}</button>
|
2020-02-19 15:16:38 +08:00
|
|
|
|
<div class="login-foot-lang" @click.stop="langListShow = !langListShow">
|
|
|
|
|
|
<i v-if="lang == 'en'" class="nz-icon nz-icon-lang-en"></i>
|
|
|
|
|
|
<i v-else-if="lang == 'cn'" class="nz-icon nz-icon-lang-zh"></i>
|
|
|
|
|
|
<i class="nz-icon nz-icon-arrow-down"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-foot-lang-list" v-show="langListShow">
|
|
|
|
|
|
<i v-if="lang != 'en'" @click="changeLang('en')" class="nz-icon nz-icon-lang-en"></i>
|
|
|
|
|
|
<i v-if="lang != 'cn'" @click="changeLang('cn')" class="nz-icon nz-icon-lang-zh"></i>
|
2019-12-05 16:48:23 +08:00
|
|
|
|
</div>
|
2019-12-26 16:31:53 +08:00
|
|
|
|
</div>
|
2021-04-16 21:10:31 +08:00
|
|
|
|
<div class="login-license">
|
|
|
|
|
|
<div class="license-warn" v-if="license.warnInfo">{{license.warnInfo}}</div>
|
|
|
|
|
|
<div class="license-info" v-if="!license.valid">INSTALLATION ID:{{license.token}}</div>
|
|
|
|
|
|
<div class="license-upload" v-if="!license.valid">
|
|
|
|
|
|
<el-upload
|
|
|
|
|
|
ref="upload"
|
|
|
|
|
|
accept=".xml"
|
|
|
|
|
|
action=""
|
|
|
|
|
|
:file-list="uploadFileList"
|
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
|
:on-change="handleChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<button type="button" class="login-btn" ><span style="margin-right: 5px"><i class="nz-icon nz-icon-upload"></i></span>{{$t('login.upload')}}</button>
|
|
|
|
|
|
</el-upload>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-12-16 13:02:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-foot-buildOn">
|
2020-12-16 14:09:44 +08:00
|
|
|
|
<span><a target="_blank" rel="noopener noreferrer" href='https://prometheus.io'>Build on Prometheus</a></span>
|
2019-12-04 13:45:37 +08:00
|
|
|
|
</div>
|
2019-12-26 16:31:53 +08:00
|
|
|
|
</div>
|
2019-12-04 13:45:37 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
import { mapActions } from 'vuex'
|
2019-12-04 13:45:37 +08:00
|
|
|
|
export default {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
name: 'login',
|
|
|
|
|
|
data () {
|
2019-12-04 13:45:37 +08:00
|
|
|
|
return {
|
|
|
|
|
|
loginData: {
|
|
|
|
|
|
username: '',
|
2021-03-25 09:46:59 +08:00
|
|
|
|
pin: '',
|
2019-12-26 16:31:53 +08:00
|
|
|
|
remember: false
|
2019-12-04 13:45:37 +08:00
|
|
|
|
},
|
2021-04-16 21:10:31 +08:00
|
|
|
|
license: {
|
|
|
|
|
|
warnInfo: '',
|
|
|
|
|
|
token: '',
|
|
|
|
|
|
valid: false
|
|
|
|
|
|
},
|
|
|
|
|
|
uploadFileList: [],
|
|
|
|
|
|
uploadFile: { file: '', path: '', uuid: '' },
|
2020-12-08 21:53:37 +08:00
|
|
|
|
loading: false,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
lang: localStorage.getItem('nz-language') ? localStorage.getItem('nz-language') : 'en', // en/cn
|
|
|
|
|
|
langListShow: false
|
2019-12-04 13:45:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
...mapActions(['loginSuccess']),
|
|
|
|
|
|
login () {
|
2020-12-08 21:53:37 +08:00
|
|
|
|
if (this.loading) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return
|
2020-12-08 21:53:37 +08:00
|
|
|
|
}
|
2021-04-26 21:42:15 +08:00
|
|
|
|
// if (this.license.valid && this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) {
|
|
|
|
|
|
if (this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.loading = true
|
2020-12-04 20:53:58 +08:00
|
|
|
|
this.$post('sys/login', this.loginData).then(res => {
|
2020-02-19 15:16:38 +08:00
|
|
|
|
if (res.code == 200) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 登录成功,记录用户名、token和lang
|
|
|
|
|
|
sessionStorage.setItem('nz-username', this.loginData.username)
|
|
|
|
|
|
localStorage.setItem('nz-username', this.loginData.username)
|
|
|
|
|
|
localStorage.setItem('nz-language', this.lang)
|
|
|
|
|
|
this.$i18n.locale = this.lang
|
|
|
|
|
|
this.loginSuccess(res)
|
2020-02-19 15:16:38 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$message.error(res.msg)
|
2020-02-19 15:16:38 +08:00
|
|
|
|
}
|
2020-12-08 21:53:37 +08:00
|
|
|
|
}).finally(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.loading = false
|
|
|
|
|
|
})
|
2020-02-19 15:16:38 +08:00
|
|
|
|
}
|
2019-12-04 13:45:37 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
changeLang (lang) {
|
|
|
|
|
|
this.lang = lang
|
|
|
|
|
|
this.langListShow = false
|
|
|
|
|
|
this.$i18n.locale = this.lang
|
|
|
|
|
|
localStorage.setItem('nz-language', this.lang)
|
2020-02-19 15:16:38 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
validateLogin () {
|
2021-03-25 09:46:59 +08:00
|
|
|
|
if (!this.loginData.username || !this.loginData.pin) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$message.error('Empty username or password')
|
|
|
|
|
|
return false
|
2019-12-26 16:31:53 +08:00
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return true
|
2020-02-19 15:16:38 +08:00
|
|
|
|
}
|
2021-04-16 21:10:31 +08:00
|
|
|
|
},
|
|
|
|
|
|
licenseStat: function () {
|
|
|
|
|
|
this.$get('/sys/license/state').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.license.warnInfo = ''
|
|
|
|
|
|
this.license.valid = true
|
|
|
|
|
|
} else {
|
2021-04-21 18:24:25 +08:00
|
|
|
|
this.license.valid = false
|
2021-04-16 21:10:31 +08:00
|
|
|
|
this.license.warnInfo = response.msg
|
|
|
|
|
|
}
|
|
|
|
|
|
this.license.token = response.token
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
handleChange: function (file, fileList) {
|
|
|
|
|
|
if (fileList.length > 0) {
|
|
|
|
|
|
this.uploadFileList = [fileList[fileList.length - 1]]
|
|
|
|
|
|
}
|
|
|
|
|
|
this.uploadFile.file = this.uploadFileList[0]
|
|
|
|
|
|
this.upload()
|
|
|
|
|
|
},
|
|
|
|
|
|
upload () {
|
|
|
|
|
|
const form = new FormData()
|
|
|
|
|
|
form.append('file', this.uploadFile.file.raw)
|
|
|
|
|
|
this.$post('/sys/license/upload', form, { 'Content-Type': 'multipart/form-data' }).then(res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
this.licenseStat()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-02-19 15:16:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* 'loginData.username': function(n, o) {
|
2020-02-19 15:16:38 +08:00
|
|
|
|
let lang = localStorage.getItem('nz-language-' + n);
|
|
|
|
|
|
if (lang) {
|
2019-12-26 16:31:53 +08:00
|
|
|
|
this.lang = lang;
|
2020-03-12 18:04:04 +08:00
|
|
|
|
this.$i18n.locale = this.lang;
|
2020-02-19 15:16:38 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} */
|
2020-02-19 15:16:38 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
mounted () {
|
|
|
|
|
|
const _this = this
|
|
|
|
|
|
this.$i18n.locale = this.lang
|
|
|
|
|
|
document.onkeydown = function (e) {
|
|
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
|
|
_this.login()
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
document.getElementById('usernameInput').focus()
|
2021-04-16 21:10:31 +08:00
|
|
|
|
this.licenseStat()
|
2019-12-04 13:45:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2020-02-18 21:31:39 +08:00
|
|
|
|
<style scoped lang="scss">
|
2019-12-26 16:31:53 +08:00
|
|
|
|
.login {
|
|
|
|
|
|
background-image: url("../../assets/img/login-background.png");
|
2020-02-18 21:31:39 +08:00
|
|
|
|
background-size: cover;
|
|
|
|
|
|
position: relative;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
.model {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
width: 100%;
|
2020-02-18 21:31:39 +08:00
|
|
|
|
background-color: rgba(130, 130, 135, 0.4);
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
z-index: 1;
|
2019-12-05 16:48:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-18 21:31:39 +08:00
|
|
|
|
.logo {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 25%;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
z-index: 2;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
|
|
|
|
|
|
.login-box {
|
|
|
|
|
|
width: 460px;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
position: absolute;
|
2020-02-18 21:31:39 +08:00
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
z-index: 2;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
|
|
|
|
|
|
.login-box .login-input {
|
|
|
|
|
|
padding: 20px 0;
|
|
|
|
|
|
height: 60px;
|
2020-02-20 10:34:12 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
|
|
|
|
|
.login-box .login-input .nz-icon {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 18px;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
font-size: 20px;
|
2019-12-05 16:48:23 +08:00
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
.login-box .login-input input {
|
|
|
|
|
|
height: 100%;
|
2020-02-20 10:34:12 +08:00
|
|
|
|
width: calc(100% - 60px);
|
2020-02-18 21:31:39 +08:00
|
|
|
|
background-color: rgba(0, 0, 0, 0.55);
|
2020-02-20 10:34:12 +08:00
|
|
|
|
padding-left: 60px;
|
2020-02-18 21:31:39 +08:00
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
outline: none;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
border-radius: 4px;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
|
2019-12-26 16:31:53 +08:00
|
|
|
|
.login-foot {
|
2020-02-18 21:31:39 +08:00
|
|
|
|
padding-top: 45px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
2020-02-19 15:16:38 +08:00
|
|
|
|
position: relative;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
|
|
|
|
|
|
.login-btn {
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
|
background-image: $btn-normal-background-color;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
outline: none;
|
|
|
|
|
|
height: 44px;
|
|
|
|
|
|
width: 320px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
box-shadow: 0 2px 3px 2px rgba(0, 0, 0, 0.30);
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
|
2020-02-19 15:16:38 +08:00
|
|
|
|
.login-foot-lang {
|
2019-12-26 16:31:53 +08:00
|
|
|
|
position: relative;
|
2020-02-18 21:31:39 +08:00
|
|
|
|
cursor: pointer;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-20 10:34:12 +08:00
|
|
|
|
.login-foot-lang .nz-icon:not(.nz-icon-arrow-up):not(.nz-icon-arrow-down) {
|
|
|
|
|
|
font-size: 30px;
|
2020-02-18 21:31:39 +08:00
|
|
|
|
color: white;
|
|
|
|
|
|
margin-right: 30px;
|
2020-02-20 10:34:12 +08:00
|
|
|
|
line-height: 45px;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2020-02-19 15:16:38 +08:00
|
|
|
|
.login-foot-lang-list {
|
|
|
|
|
|
position: absolute;
|
2020-02-20 10:34:12 +08:00
|
|
|
|
height: 25px;
|
|
|
|
|
|
padding: 12px;
|
2020-02-19 15:16:38 +08:00
|
|
|
|
background-color: rgba(0, 0, 0, 0.55);
|
|
|
|
|
|
top: 107px;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.login-foot-lang-list .nz-icon {
|
2020-02-20 10:34:12 +08:00
|
|
|
|
font-size: 25px;
|
2020-02-19 15:16:38 +08:00
|
|
|
|
color: white;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2020-12-08 21:53:37 +08:00
|
|
|
|
.login-foot .el-loading-spinner {
|
|
|
|
|
|
width: 36px;
|
|
|
|
|
|
height: 36px;
|
|
|
|
|
|
}
|
2020-02-19 15:16:38 +08:00
|
|
|
|
.login-foot-lang-list::before {
|
|
|
|
|
|
content: " ";
|
|
|
|
|
|
width: 0px;
|
|
|
|
|
|
height: 0px;
|
|
|
|
|
|
border-width: 10px;
|
|
|
|
|
|
border-style: solid;
|
|
|
|
|
|
border-color: transparent transparent rgba(0, 0, 0, 0.55) transparent;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: -20px;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
}
|
2020-12-15 18:47:30 +08:00
|
|
|
|
.login-foot-buildOn{
|
2020-12-16 14:09:44 +08:00
|
|
|
|
position: absolute;
|
2020-12-16 17:09:02 +08:00
|
|
|
|
bottom: 20px;
|
2020-12-16 14:09:44 +08:00
|
|
|
|
z-index: 100;
|
2020-12-16 13:02:53 +08:00
|
|
|
|
left: calc(50% - 90px);
|
2020-12-15 18:47:30 +08:00
|
|
|
|
a{
|
2020-12-16 17:09:02 +08:00
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #eee;
|
|
|
|
|
|
text-shadow: 1px 1px 3px #333;
|
2020-12-15 18:47:30 +08:00
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-02-18 21:31:39 +08:00
|
|
|
|
.nz-icon-arrow-down, .nz-icon-arrow-up {
|
2019-12-26 16:31:53 +08:00
|
|
|
|
position: absolute;
|
2020-02-18 21:31:39 +08:00
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
transform: translateY(-50%);
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2021-04-16 21:10:31 +08:00
|
|
|
|
.login-license{
|
|
|
|
|
|
margin-top: 40px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
line-height: 30px;
|
|
|
|
|
|
.license-warn{
|
|
|
|
|
|
color: #EF7458;
|
|
|
|
|
|
}
|
|
|
|
|
|
.license-info{
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
.login-btn{
|
|
|
|
|
|
height: 30px;
|
|
|
|
|
|
width: 120px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.login-btn.nz-btn-disabled{
|
|
|
|
|
|
background-image: none;
|
|
|
|
|
|
color: #e5e5e5;
|
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
|
border-color: #e5e5e5 ;
|
|
|
|
|
|
cursor: default;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
<style>
|
|
|
|
|
|
.license-upload .el-upload-list{
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
2019-12-26 16:31:53 +08:00
|
|
|
|
</style>
|