86 lines
2.0 KiB
Vue
86 lines
2.0 KiB
Vue
<template>
|
||
<div id="app">
|
||
<Loading v-show="isDot" />
|
||
<router-view v-show="!isDot" />
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import Loading from '@/components/loading'
|
||
import { queryInfo, getKeyInfo } from '@/api/user.js'
|
||
import { getNetLang } from '@/api/index.js'
|
||
export default {
|
||
name: 'App',
|
||
components: {
|
||
Loading
|
||
},
|
||
data() {
|
||
return {
|
||
isDot: true
|
||
}
|
||
},
|
||
created() {
|
||
getNetLang({}).then(res => {
|
||
if (res?.lang) {
|
||
this.$i18n.locale = res.lang
|
||
this.$store.dispatch('app/setLanguage', res.lang)
|
||
}
|
||
})
|
||
setTimeout(() => {
|
||
this.isDot = false
|
||
}, 1500)
|
||
this.getQueryInfo()
|
||
this.getKeyInfo()
|
||
var token = this.getUrlKey('token')
|
||
console.log(token, '----------->')
|
||
if (token) {
|
||
this.$store.dispatch('user/setUrlToken', token).then(() => {
|
||
this.$router.push('/')
|
||
})
|
||
} else {
|
||
this.$router.push('/login')
|
||
return
|
||
}
|
||
},
|
||
methods: {
|
||
getKeyInfo() {
|
||
getKeyInfo({}).then(res => {
|
||
const reslut = {
|
||
rsaPublicKey: res.rsaPublicKey || '', // RSA公钥(2048位)
|
||
aesKey: res.aesKey || '' // AES密钥(256位)
|
||
}
|
||
this.$store.commit('user/SET_KEY', reslut)
|
||
}).catch(() => {
|
||
const reslut = {
|
||
rsaPublicKey: '', // RSA公钥(2048位)
|
||
aesKey: '' // AES密钥(256位)
|
||
}
|
||
this.$store.commit('user/SET_KEY', reslut)
|
||
})
|
||
},
|
||
getQueryInfo() {
|
||
queryInfo({}).then(res => {
|
||
this.$store.commit('user/SET_INITSTATE', res.userHasBeenInit || true)
|
||
}).catch(() => {
|
||
this.$store.commit('user/SET_INITSTATE', true)
|
||
})
|
||
},
|
||
getUrlKey(name) {
|
||
return (
|
||
decodeURIComponent(
|
||
(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(
|
||
decodeURIComponent(location.href)
|
||
// eslint-disable-next-line no-sparse-arrays
|
||
) || [, ''])[1].replace(/\+/g, '%20')
|
||
) || null
|
||
)
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<style>
|
||
body {
|
||
font-family: 'Adobe-MyriadPro-Regular';
|
||
}
|
||
</style>
|