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