mirror of
http://112.124.100.131/ebiz-ai/ebiz-ai-knowledge-manage.git
synced 2025-12-09 19:06:49 +08:00
整理代码
This commit is contained in:
@@ -88,7 +88,6 @@ export function encrypt(data) {
|
||||
try {
|
||||
const plaintext = typeof data === 'string' ? data : JSON.stringify(data)
|
||||
var publicKeyHex = parseSM2PublicKey(derPublicKeyHex)
|
||||
var a = sessionStorage.getItem('derPublicKeyHex')
|
||||
publicKeyHex = publicKeyHex.startsWith('04')
|
||||
? publicKeyHex
|
||||
: '04' + publicKeyHex
|
||||
@@ -162,7 +161,7 @@ export function fetchPublicKey() {
|
||||
getPublicKeyHex()
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
sessionStorage.setItem('cachedRawPublicKey', res.content.content)
|
||||
sessionStorage.setItem('derPublicKeyHex', res.content.content)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -175,7 +174,7 @@ export function fetchPrivateKey() {
|
||||
getPrivateKeyHex()
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
sessionStorage.setItem('cachedPrivateKey', res.content.content)
|
||||
sessionStorage.setItem('privateKeyHex', res.content.content)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
@@ -4,41 +4,25 @@ import NProgress from 'nprogress' // progress bar
|
||||
import 'nprogress/nprogress.css' // progress bar style
|
||||
import { getToken, removeToken } from '@/assets/js/utils/auth' // get token from cookie
|
||||
import { Message } from 'element-ui'
|
||||
import { getPrivateKey, getPublicKey } from '@/assets/js/utils/encrypt'
|
||||
import { getPrivateKeyHex, getPublicKeyHex } from '@/api/safety'
|
||||
import {
|
||||
fetchPrivateKey,
|
||||
fetchPublicKey,
|
||||
getPrivateKey,
|
||||
getPublicKey
|
||||
} from '@/assets/js/utils/encrypt'
|
||||
NProgress.configure({ showSpinner: false }) // NProgress Configuration
|
||||
const whiteList = ['/login', '/authentication', '/404'] // no redirect whitelist
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (getPrivateKey() === '' || getPrivateKey() === null) {
|
||||
// fetchPrivateKey()
|
||||
getPrivateKeyHex()
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
sessionStorage.setItem('privateKeyHex', res.content.content)
|
||||
routerEach(to, from, next)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('系统安全异常,请联系管理员', err)
|
||||
})
|
||||
await fetchPrivateKey()
|
||||
}
|
||||
if (getPublicKey() === '' || getPublicKey() === null) {
|
||||
// fetchPublicKey()
|
||||
getPublicKeyHex()
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
sessionStorage.setItem('derPublicKeyHex', res.content.content)
|
||||
routerEach(to, from, next)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('系统安全异常,请联系管理员', err)
|
||||
})
|
||||
await fetchPublicKey()
|
||||
}
|
||||
routerEach(to, from, next)
|
||||
})
|
||||
function routerEach(to, from, next){
|
||||
function routerEach(to, from, next) {
|
||||
NProgress.start()
|
||||
if (getToken()) {
|
||||
/* has token*/
|
||||
|
||||
Reference in New Issue
Block a user