2019-12-04 13:45:37 +08:00
|
|
|
|
<template>
|
2021-11-24 15:55:18 +08:00
|
|
|
|
<div class="login" id="login-bgimg">
|
2020-02-18 21:31:39 +08:00
|
|
|
|
<div class="model"></div>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<div class="login-main">
|
|
|
|
|
|
<div class="logo"><img src="../../assets/img/logo-big.png"></div>
|
|
|
|
|
|
<div class='login-box'>
|
|
|
|
|
|
<div class="login-label"></div>
|
|
|
|
|
|
<div class="login-input" v-if="!verifyShow">
|
|
|
|
|
|
<i class="nz-icon nz-icon-user"></i>
|
2021-11-02 18:34:01 +08:00
|
|
|
|
<input id="usernameInput" v-model="loginData.username" autocomplete="on" name="userName" placeholder="Username" @keydown.enter="login"></input>
|
2020-02-19 15:16:38 +08:00
|
|
|
|
</div>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<div class="login-label"></div>
|
|
|
|
|
|
<div class="login-input" v-if="!verifyShow">
|
|
|
|
|
|
<i class="nz-icon nz-icon-password"></i>
|
2021-11-02 18:34:01 +08:00
|
|
|
|
<input v-model="loginData.pin" autocomplete="on" name="password" placeholder="Password" type="password" @keydown.enter="login"></input>
|
2019-12-05 16:48:23 +08:00
|
|
|
|
</div>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<div class="login-label" v-if="verifyShow">{{$t('login.verifyTitle')}}</div>
|
|
|
|
|
|
<div class="login-input" v-if="verifyShow">
|
|
|
|
|
|
<i class="nz-icon nz-icon-yanzhengma"></i>
|
2021-08-13 14:43:39 +08:00
|
|
|
|
<input v-model="loginData.authCode" name="newPassword" autocomplete="off" :placeholder="$t('login.verifyPlaceholder')" @keydown.enter="verify"></input>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-label-foot" v-if="verifyShow">
|
|
|
|
|
|
{{$t('login.verifyContent')}}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-foot">
|
2021-11-02 18:34:01 +08:00
|
|
|
|
<button v-if="!verifyShow" id="login" v-loading="loading" :class="{'nz-btn-disabled': !license.valid}" class="login-btn" @click="login">Login</button>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<button v-if="verifyShow" id="verify" v-loading="loading" :class="{'nz-btn-disabled': !license.valid}" class="login-btn" @click="verify">{{$t("login.verify")}}</button>
|
|
|
|
|
|
</div>
|
2021-12-22 19:54:51 +08:00
|
|
|
|
<div class="license-warn" v-if="license.warnInfo">{{license.warnInfo}}</div>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<div class="login-license">
|
2021-12-13 17:15:32 +08:00
|
|
|
|
<!-- <div v-if="!license.valid" class="license-info">INSTALLATION ID: {{license.token}}</div>-->
|
|
|
|
|
|
<div v-if="!license.valid" class="license-upload">
|
|
|
|
|
|
<!-- <button type="button" class="login-btn" @click="downloadMib"><span style="margin-right: 5px"><i class="nz-icon nz-icon-download1"></i></span>{{$t('license.dowLicense')}}</button>-->
|
2022-01-04 10:23:24 +08:00
|
|
|
|
<button type="button" class="login-btn download-btn" @click="downloadLogin"><span style="margin-right: 5px"><i class="nz-icon nz-icon-download1"></i></span>{{$t('login.download')}}</button>
|
2021-12-13 17:15:32 +08:00
|
|
|
|
</div>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<div class="license-upload" v-if="!license.valid">
|
|
|
|
|
|
<el-upload
|
|
|
|
|
|
ref="upload"
|
|
|
|
|
|
accept=".xml"
|
|
|
|
|
|
action=""
|
|
|
|
|
|
:file-list="uploadFileList"
|
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
|
:on-change="handleChange"
|
2021-04-16 21:10:31 +08:00
|
|
|
|
>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
<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>
|
2021-04-16 21:10:31 +08:00
|
|
|
|
</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>
|
2022-03-08 11:22:26 +08:00
|
|
|
|
<el-dialog id="viewGraphDialog" :visible.sync="authBindShow" :title="$t('login.verifyDialogTitle')" :modal-append-to-body='false'
|
2021-08-12 09:38:23 +08:00
|
|
|
|
:show-close="true" width="620px" class="nz-dialog" >
|
|
|
|
|
|
|
|
|
|
|
|
<div v-loading="dialogLoading">
|
|
|
|
|
|
<div class="login-dialog-title">
|
|
|
|
|
|
1 Download your preferred authenticator app to your phone (any will work). If you don't
|
|
|
|
|
|
have a preferred app, we recommend using <span @click="jumpDlw" class="verify-link">Google Authenticator.</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-dialog-title">
|
|
|
|
|
|
2 Use your app to take a photo of the QR code.
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="qrCode-box">
|
|
|
|
|
|
<div id="qrCode" ref="qrCodeDiv" class="qrCode-content"></div>
|
|
|
|
|
|
<div class="qrCode-text">
|
|
|
|
|
|
<div>Type this code down if you can't take a photo.</div>
|
|
|
|
|
|
<div class="qrCode-authKey">{{authKey}}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="login-dialog-title">
|
|
|
|
|
|
3. Enter the 6-digit code provided by your app and then verify.
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="enter-code">Enter Code</div>
|
2021-08-19 17:00:57 +08:00
|
|
|
|
<el-input v-model="bindAuthCode" size="small" style="width: 50%" @keydown.enter="bindCode"></el-input>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div slot="footer" class="footer">
|
|
|
|
|
|
<button id="asset-edit-cancel" @click="closeDialog" class="footer__btn footer__btn--light">
|
|
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button id="asset-edit-save" :class="{'footer__btn--disabled': prevent_opt.save}" :disabled="prevent_opt.save" class="footer__btn" @click="bindCode">
|
|
|
|
|
|
<span style="text-transform:capitalize">{{$t('login.verify')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-dialog>
|
2022-03-08 11:22:26 +08:00
|
|
|
|
<el-dialog id="viewGraphDialog" :visible.sync="fileShow" :title="$t('login.verifyDialogTitle')" :modal-append-to-body='false'
|
2021-08-12 09:38:23 +08:00
|
|
|
|
:show-close="true" width="620px" class="nz-dialog" >
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class="login-dialog-title">
|
|
|
|
|
|
Should you ever lose your phone or access to your one time password secret, each of these recovery codes can be used one time each to regain access to your account.
|
|
|
|
|
|
Please save them in a safe place, or you will lose access to your account.
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="login-dialog-title2">
|
|
|
|
|
|
<div class="login-dialog-recover">
|
2021-08-19 17:00:57 +08:00
|
|
|
|
<div v-for="(item, index) in recoveryCode" :key="index" style="color: #999999;">
|
2021-08-12 17:13:11 +08:00
|
|
|
|
<span class="circle"></span>
|
2021-08-12 09:38:23 +08:00
|
|
|
|
{{item}}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span class="copy-value-content"> <i class="nz-icon nz-icon-override" @click="copyValue"></i></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div slot="footer" class="footer">
|
|
|
|
|
|
<button id="asset-edit-download" :class="{'footer__btn--disabled': prevent_opt.save}" :disabled="prevent_opt.save" class="footer__btn" @click="downloadTxt">
|
|
|
|
|
|
<span style="text-transform:capitalize">{{$t('overall.download')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-dialog>
|
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'
|
2021-08-12 09:38:23 +08:00
|
|
|
|
import QRCode from 'qrcodejs2'
|
2021-08-19 12:51:49 +08:00
|
|
|
|
import bus from '@/libs/bus.js'
|
2021-11-04 09:29:01 +08:00
|
|
|
|
import { get } from '@/http'
|
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: '',
|
2021-08-12 09:38:23 +08:00
|
|
|
|
remember: false,
|
|
|
|
|
|
authCode: ''
|
2019-12-04 13:45:37 +08:00
|
|
|
|
},
|
2021-04-16 21:10:31 +08:00
|
|
|
|
license: {
|
|
|
|
|
|
warnInfo: '',
|
|
|
|
|
|
token: '',
|
2021-11-11 17:01:04 +08:00
|
|
|
|
valid: true
|
2021-04-16 21:10:31 +08:00
|
|
|
|
},
|
|
|
|
|
|
uploadFileList: [],
|
|
|
|
|
|
uploadFile: { file: '', path: '', uuid: '' },
|
2020-12-08 21:53:37 +08:00
|
|
|
|
loading: false,
|
2021-10-13 09:17:51 +08:00
|
|
|
|
lang: 'en', // en/cn
|
2021-08-12 09:38:23 +08:00
|
|
|
|
verifyShow: false,
|
2021-12-02 10:44:21 +08:00
|
|
|
|
theme: 1,
|
2021-08-12 09:38:23 +08:00
|
|
|
|
authBindShow: false,
|
|
|
|
|
|
authToken: '',
|
|
|
|
|
|
QRCode: '',
|
|
|
|
|
|
bindAuthCode: '',
|
2021-08-13 13:47:12 +08:00
|
|
|
|
authKey: '',
|
2021-08-12 09:38:23 +08:00
|
|
|
|
dialogLoading: false,
|
|
|
|
|
|
fileShow: false,
|
|
|
|
|
|
fileContent: '',
|
2021-11-24 15:55:18 +08:00
|
|
|
|
recoveryCode: [],
|
|
|
|
|
|
bgImg: '' // 背景图
|
2019-12-04 13:45:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
...mapActions(['loginSuccess']),
|
|
|
|
|
|
login () {
|
2021-12-20 18:02:48 +08:00
|
|
|
|
if (this.loading || !this.license.valid) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.loading = true
|
2021-08-13 13:47:12 +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
|
2021-08-13 13:47:12 +08:00
|
|
|
|
this.authToken = res.data.authToken
|
2021-11-24 15:55:18 +08:00
|
|
|
|
this.lang = res.data.user.lang || localStorage.getItem('nz-language')
|
2021-10-13 09:17:51 +08:00
|
|
|
|
this.$i18n.locale = this.lang
|
2021-12-02 10:44:21 +08:00
|
|
|
|
this.theme = res.data.user.theme
|
2021-11-04 09:29:01 +08:00
|
|
|
|
// 获取可选语言
|
2021-11-04 12:13:36 +08:00
|
|
|
|
get('/sys/dict/all?type=lang').then(response => {
|
2021-11-04 09:29:01 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
const langList = response.data.map(lang => ({ name: lang.name, value: lang.value }))
|
|
|
|
|
|
this.$store.commit('setLangList', langList)
|
|
|
|
|
|
localStorage.setItem('nz-language-list', JSON.stringify(langList))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-11-26 18:47:00 +08:00
|
|
|
|
localStorage.setItem('nz-token', res.data.authToken)
|
2021-08-12 09:38:23 +08:00
|
|
|
|
if (res.data.authFlag === 1) {
|
|
|
|
|
|
if (res.data.authBind === 0) {
|
|
|
|
|
|
this.verifyShow = true
|
|
|
|
|
|
} else if (res.data.authBind === 1) {
|
|
|
|
|
|
this.authBindShow = true
|
|
|
|
|
|
this.dialogLoading = true
|
2021-08-13 13:47:12 +08:00
|
|
|
|
this.$post('/mfa/genkey', { authToken: this.authToken }).then(res => {
|
|
|
|
|
|
this.dialogLoading = false
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.authToken = res.data.authToken
|
|
|
|
|
|
this.authKey = res.data.authKey
|
|
|
|
|
|
this.bindQRCode(res.data.otpauth)
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.authBindShow = false
|
|
|
|
|
|
this.$message.error(res.message)
|
|
|
|
|
|
}
|
2021-08-12 09:38:23 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2021-11-26 18:47:00 +08:00
|
|
|
|
localStorage.setItem('nz-username', this.loginData.username)
|
2021-08-12 09:38:23 +08:00
|
|
|
|
localStorage.setItem('nz-username', this.loginData.username)
|
|
|
|
|
|
localStorage.setItem('nz-prometheus-federation-enabled', res.data.prometheusFederationEnabled)
|
|
|
|
|
|
localStorage.setItem('nz-language', 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-08-12 09:38:23 +08:00
|
|
|
|
verify () {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
authToken: this.authToken,
|
|
|
|
|
|
authCode: this.loginData.authCode
|
|
|
|
|
|
}
|
2021-08-13 13:47:12 +08:00
|
|
|
|
this.$post('/mfa/verify', params).then(res => {
|
2021-08-12 15:52:48 +08:00
|
|
|
|
if (res.code === 200) {
|
2021-11-26 18:47:00 +08:00
|
|
|
|
localStorage.setItem('nz-username', this.loginData.username)
|
2021-08-12 15:52:48 +08:00
|
|
|
|
localStorage.setItem('nz-username', this.loginData.username)
|
|
|
|
|
|
localStorage.setItem('nz-prometheus-federation-enabled', res.data.prometheusFederationEnabled)
|
2021-10-14 13:40:13 +08:00
|
|
|
|
localStorage.setItem('nz-language', this.lang)
|
2021-11-15 11:18:07 +08:00
|
|
|
|
res.data.user = {
|
2021-12-02 10:44:21 +08:00
|
|
|
|
lang: this.lang,
|
|
|
|
|
|
theme: this.theme
|
2021-11-15 11:18:07 +08:00
|
|
|
|
}
|
2021-08-12 15:52:48 +08:00
|
|
|
|
this.loginSuccess(res)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.authToken = res.data.authToken
|
2021-08-13 14:29:17 +08:00
|
|
|
|
this.$message.error(res.msg)
|
2021-08-12 15:52:48 +08:00
|
|
|
|
}
|
2021-08-12 09:38:23 +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
|
|
|
|
},
|
2021-05-12 11:43:43 +08:00
|
|
|
|
licenseStat () {
|
2021-12-15 17:29:55 +08:00
|
|
|
|
this.$get('/sys/license/status').then(response => {
|
2021-05-12 11:43:43 +08:00
|
|
|
|
if (response.code && response.code === 200) {
|
2021-04-16 21:10:31 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-05-12 11:43:43 +08:00
|
|
|
|
handleChange (file, fileList) {
|
2021-04-16 21:10:31 +08:00
|
|
|
|
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)
|
2021-12-10 18:12:37 +08:00
|
|
|
|
this.$post('/sys/license/upload', form).then(res => {
|
2021-04-16 21:10:31 +08:00
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
this.licenseStat()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-08-12 09:38:23 +08:00
|
|
|
|
},
|
2021-12-13 17:15:32 +08:00
|
|
|
|
downloadLogin () {
|
|
|
|
|
|
this.$get('/sys/license/token').then(res => {
|
|
|
|
|
|
const fileName = 'Login' + '-' + this.getTimeString() + '.xml'
|
|
|
|
|
|
if (window.navigator.msSaveOrOpenBlob) {
|
|
|
|
|
|
// 兼容ie11
|
|
|
|
|
|
const blobObject = new Blob([res])
|
|
|
|
|
|
window.navigator.msSaveOrOpenBlob(blobObject, fileName)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const url = URL.createObjectURL(new Blob([res]))
|
|
|
|
|
|
const a = document.createElement('a')
|
|
|
|
|
|
document.body.appendChild(a) // 此处增加了将创建的添加到body当中
|
|
|
|
|
|
a.href = url
|
|
|
|
|
|
a.download = fileName
|
|
|
|
|
|
a.target = '_blank'
|
|
|
|
|
|
a.click()
|
|
|
|
|
|
a.remove() // 将a标签移除
|
|
|
|
|
|
}
|
|
|
|
|
|
}, error => {
|
|
|
|
|
|
const $self = this
|
|
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
|
reader.onload = function (event) {
|
|
|
|
|
|
const responseText = reader.result
|
|
|
|
|
|
const exception = JSON.parse(responseText)
|
|
|
|
|
|
if (exception.message) {
|
|
|
|
|
|
$self.$message.error(exception.message)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
reader.readAsText(error.response.data)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getTimeString () {
|
|
|
|
|
|
const split = '-'
|
|
|
|
|
|
const date = new Date()
|
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
|
const month = this.formatNum(date.getMonth() + 1)
|
|
|
|
|
|
const day = this.formatNum(date.getDate())
|
|
|
|
|
|
const hours = this.formatNum(date.getHours())
|
|
|
|
|
|
const minutes = this.formatNum(date.getMinutes())
|
|
|
|
|
|
const seconds = this.formatNum(date.getSeconds())
|
|
|
|
|
|
return year + split + month + split + day + ' ' + hours + split + minutes + split + seconds
|
|
|
|
|
|
},
|
|
|
|
|
|
formatNum (num) {
|
|
|
|
|
|
return num > 9 ? num : '0' + num
|
|
|
|
|
|
},
|
2021-08-12 09:38:23 +08:00
|
|
|
|
bindQRCode: function (text) {
|
|
|
|
|
|
text = text || 'https://www.baidu.com'
|
|
|
|
|
|
if (!this.QRCode) {
|
|
|
|
|
|
this.QRCode = new QRCode(this.$refs.qrCodeDiv, {
|
|
|
|
|
|
text: text,
|
|
|
|
|
|
width: 124,
|
|
|
|
|
|
height: 124,
|
|
|
|
|
|
colorDark: '#333333', // 二维码颜色
|
|
|
|
|
|
colorLight: '#ffffff', // 二维码背景色
|
|
|
|
|
|
correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.QRCode.makeCode(text)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
closeDialog () {
|
|
|
|
|
|
this.authBindShow = false
|
|
|
|
|
|
this.bindAuthCode = ''
|
|
|
|
|
|
},
|
|
|
|
|
|
bindCode () {
|
|
|
|
|
|
this.prevent_opt.save = true
|
2021-08-13 13:47:12 +08:00
|
|
|
|
this.$post('/mfa/bind', { authToken: this.authToken, authCode: this.bindAuthCode }).then(res => {
|
2021-08-12 15:52:48 +08:00
|
|
|
|
this.prevent_opt.save = false
|
2021-08-12 09:38:23 +08:00
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.authBindShow = false
|
|
|
|
|
|
this.bindAuthCode = ''
|
2021-08-12 17:13:11 +08:00
|
|
|
|
this.recoveryCode = res.data.recoveryCode
|
2021-08-12 09:38:23 +08:00
|
|
|
|
this.fileContent = this.recoveryCode.join(' \n ')
|
|
|
|
|
|
this.fileShow = true
|
|
|
|
|
|
} else {
|
2021-08-13 13:47:12 +08:00
|
|
|
|
this.authToken = res.data.authToken
|
2021-08-12 09:38:23 +08:00
|
|
|
|
this.$message.error(this.$t('login.bindFail'))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
jumpDlw () {
|
|
|
|
|
|
window.open('https://google-authenticator.en.softonic.com/android')
|
|
|
|
|
|
},
|
|
|
|
|
|
downloadTxt () {
|
|
|
|
|
|
const element = document.createElement('a')
|
2021-12-17 09:47:50 +08:00
|
|
|
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.fileContent))
|
2021-08-13 14:29:17 +08:00
|
|
|
|
element.setAttribute('download', 'Nezha recovery codes')
|
2021-08-12 09:38:23 +08:00
|
|
|
|
element.style.display = 'none'
|
|
|
|
|
|
element.click()
|
|
|
|
|
|
},
|
|
|
|
|
|
copyValue () {
|
|
|
|
|
|
const domUrl = document.createElement('input')
|
|
|
|
|
|
domUrl.value = this.fileContent
|
|
|
|
|
|
domUrl.id = 'creatDom'
|
|
|
|
|
|
document.body.appendChild(domUrl)
|
|
|
|
|
|
domUrl.select() // 选择对象
|
|
|
|
|
|
document.execCommand('Copy') // 执行浏览器复制命令
|
|
|
|
|
|
const creatDom = document.getElementById('creatDom')
|
|
|
|
|
|
creatDom.parentNode.removeChild(creatDom)
|
|
|
|
|
|
this.$message.success(this.$t('overall.copySuccess'))
|
2021-08-19 12:51:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
initEvent () {
|
|
|
|
|
|
bus.$on('profile-dialog', () => {
|
|
|
|
|
|
this.authBindShow = true
|
|
|
|
|
|
})
|
2020-02-19 15:16:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
mounted () {
|
|
|
|
|
|
this.$i18n.locale = this.lang
|
|
|
|
|
|
document.getElementById('usernameInput').focus()
|
2021-04-16 21:10:31 +08:00
|
|
|
|
this.licenseStat()
|
2021-08-19 12:51:49 +08:00
|
|
|
|
this.initEvent()
|
2021-11-24 15:55:18 +08:00
|
|
|
|
this.bgImg = localStorage.getItem('nz-sys-bgImg')
|
|
|
|
|
|
if (this.bgImg) {
|
|
|
|
|
|
document.getElementById('login-bgimg').style['background-image'] = `url(${this.bgImg})`
|
|
|
|
|
|
}
|
2019-12-04 13:45:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2021-11-01 17:23:01 +08:00
|
|
|
|
<style scoped>
|
2019-12-26 16:31:53 +08:00
|
|
|
|
.login {
|
2021-05-12 11:43:43 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
position: relative;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
background-image: url("../../assets/img/login-background.png");
|
2020-02-18 21:31:39 +08:00
|
|
|
|
background-size: cover;
|
2019-12-26 16:31:53 +08:00
|
|
|
|
}
|
2021-04-16 21:10:31 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<style>
|
|
|
|
|
|
.license-upload .el-upload-list{
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
2019-12-26 16:31:53 +08:00
|
|
|
|
</style>
|