vue-element-equipment-pty/src/App.vue
2025-04-03 16:54:02 +08:00

86 lines
2.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>