加密算法异常,使用新的加密和解密算法

This commit is contained in:
zhaoyz 2024-04-23 14:59:13 +08:00
parent 298074da1f
commit e674cf8cd8
7 changed files with 503 additions and 432 deletions

View File

@ -12,7 +12,7 @@
"dependencies": { "dependencies": {
"@stomp/stompjs": "^7.0.0", "@stomp/stompjs": "^7.0.0",
"axios": "^1.3.3", "axios": "^1.3.3",
"crypto-js": "4.2.0", "crypto-js": "^4.2.0",
"echarts": "^5.4.1", "echarts": "^5.4.1",
"element-plus": "2.3.1", "element-plus": "2.3.1",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",

View File

@ -1,13 +1,18 @@
import {createRouter, createWebHistory} from 'vue-router' import {createRouter, createWebHistory} from 'vue-router'
import {useLoginStore} from '@/stores/user-info-store' import {useLoginStore} from '@/stores/user-info-store'
import { ElMessage, ElMessageBox } from 'element-plus' import {ElMessage} from 'element-plus'
import {constantRoute} from './routes' import {constantRoute} from './routes'
import {decrypt, decryption, encrypt, encryption, isBase64} from "@/utils/other";
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes: constantRoute, routes: constantRoute,
stringifyQuery: stringifyQuery,
parseQuery: parseQuery,
}) })
const kk = "raxipnenttlewe";
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const loginInfo = useLoginStore().getlogin() const loginInfo = useLoginStore().getlogin()
// const isLogin = loginInfo.isLogin // const isLogin = loginInfo.isLogin
@ -73,10 +78,23 @@ router.beforeEach((to, from, next) => {
return return
} }
/*if (!isLogin) next('/login') // /*if (!isLogin) next('/login') //
else */if(!isViewRoute()) { else */
if (!isViewRoute()) {
ElMessage.error('无权访问!') ElMessage.error('无权访问!')
next(from.fullPath) next(from.fullPath)
} else next() } else next()
}); });
function stringifyQuery(query: any) {
return btoa(encrypt(JSON.stringify(query), kk));
}
function parseQuery(query: any) {
if (isBase64(query)) {
return JSON.parse(decrypt(atob(query), kk));
} else {
return query;
}
}
export default router export default router

View File

@ -7,7 +7,7 @@ import * as CryptoJS from 'crypto-js';
export function encryption(src: string, keyWord: string) { export function encryption(src: string, keyWord: string) {
const key = CryptoJS.enc.Utf8.parse(keyWord); const key = CryptoJS.enc.Utf8.parse(keyWord);
// 加密 // 加密
let encrypted = CryptoJS.AES.encrypt(src, key, { const encrypted = CryptoJS.AES.encrypt(src, key, {
iv: key, iv: key,
mode: CryptoJS.mode.CBC, mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7, padding: CryptoJS.pad.Pkcs7,
@ -17,13 +17,14 @@ export function encryption(src: string, keyWord: string) {
/** /**
* *
* @param {*} params
* @returns * @returns
* @param src
* @param keyWord
*/ */
export function decryption(src: string, keyWord: string) { export function decryption(src: string, keyWord: string) {
const key = CryptoJS.enc.Utf8.parse(keyWord); const key = keyWord;
// 解密逻辑 // 解密逻辑
let decryptd = CryptoJS.AES.decrypt(src, key, { const decryptd = CryptoJS.AES.decrypt(src, key, {
iv: key, iv: key,
mode: CryptoJS.mode.CBC, mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7, padding: CryptoJS.pad.Pkcs7,
@ -31,3 +32,20 @@ export function decryption(src: string, keyWord: string) {
return decryptd.toString(CryptoJS.enc.Utf8); return decryptd.toString(CryptoJS.enc.Utf8);
} }
export function encrypt(src: string, key: string) {
return CryptoJS.AES.encrypt(src, key).toString()
}
export function decrypt(src: string, key: string) {
return CryptoJS.AES.decrypt(src, key).toString(CryptoJS.enc.Utf8)
}
export function isBase64(s: string) {
if (s == "" || s.trim() == "") return false;
try {
return window.btoa(window.atob(s)) == s;
} catch (e) {
return false;
}
}

View File

@ -158,6 +158,7 @@ function initData() {
function getData() { function getData() {
remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date); remoteWsStore.unsubscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date);
remoteWsStore.subscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, (res: any) => { remoteWsStore.subscribeVital(remoteItem.value.patient, remoteItem.value.patientId, remoteItem.value.date, (res: any) => {
if (res && res.data) {
const data = JSON.parse(res.data); const data = JSON.parse(res.data);
if (data.vitalSignsList && data.vitalSignsList.length > 0) { if (data.vitalSignsList && data.vitalSignsList.length > 0) {
Object.assign(patientInfo.value, data.vitalSignsList[0]); Object.assign(patientInfo.value, data.vitalSignsList[0]);
@ -166,6 +167,7 @@ function getData() {
setLog(patientInfo.value) setLog(patientInfo.value)
emit('addLogAfter') emit('addLogAfter')
} }
}
}) })
} }
@ -210,18 +212,21 @@ const breakRemote = () => {
font-weight: 600; font-weight: 600;
color: white; color: white;
background: $main-color; background: $main-color;
.break-btn { .break-btn {
position: absolute; position: absolute;
top: 4px; top: 4px;
right: 20px; right: 20px;
} }
} }
.content { .content {
width: 100%; width: 100%;
height: calc(100% - 40px); height: calc(100% - 40px);
padding: 20px 50px; padding: 20px 50px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.common-box { .common-box {
width: 30%; width: 30%;
height: 100%; height: 100%;
@ -230,6 +235,7 @@ const breakRemote = () => {
justify-content: space-evenly; justify-content: space-evenly;
align-items: center; align-items: center;
} }
.left-box { .left-box {
@extend .common-box; @extend .common-box;
@ -237,23 +243,29 @@ const breakRemote = () => {
background: $main-color; background: $main-color;
} }
} }
.center-box { .center-box {
@extend .common-box; @extend .common-box;
img { img {
max-width: 100%; max-width: 100%;
max-height: 100%; max-height: 100%;
} }
} }
.right-box { .right-box {
@extend .common-box; @extend .common-box;
.label { .label {
background: $main-color; background: $main-color;
} }
} }
.row-item { .row-item {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.label { .label {
flex-shrink: 0; flex-shrink: 0;
width: 100%; width: 100%;
@ -265,16 +277,20 @@ const breakRemote = () => {
border-radius: 5px; border-radius: 5px;
} }
} }
.info-box, .row-item .value { .info-box, .row-item .value {
display: none; display: none;
} }
&.is-total { &.is-total {
.info-box, .row-item .value { .info-box, .row-item .value {
display: block; display: block;
} }
.label { .label {
width: calc(50% - 10px); width: calc(50% - 10px);
} }
.value { .value {
width: 50%; width: 50%;
height: 40px; height: 40px;
@ -287,31 +303,38 @@ const breakRemote = () => {
font-size: 22px; font-size: 22px;
line-height: 40px; line-height: 40px;
font-weight: 600; font-weight: 600;
.unit { .unit {
font-size: 16px; font-size: 16px;
font-family: 400; font-family: 400;
} }
} }
.right-box .value { .right-box .value {
color: $main-color; color: $main-color;
border-color: $main-color; border-color: $main-color;
} }
.row-item.alarm { .row-item.alarm {
.label { .label {
background: red !important; background: red !important;
} }
.value { .value {
color: red !important; color: red !important;
border-color: red !important; border-color: red !important;
} }
} }
.info-box { .info-box {
width: 100%; width: 100%;
.row-item { .row-item {
padding: 10px 0; padding: 10px 0;
height: 40px; height: 40px;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
.label { .label {
width: 70px; width: 70px;
height: 20px; height: 20px;
@ -322,6 +345,7 @@ const breakRemote = () => {
font-weight: 600; font-weight: 600;
text-align: left; text-align: left;
} }
.input-value { .input-value {
width: 100%; width: 100%;
height: 21px; height: 21px;
@ -330,6 +354,7 @@ const breakRemote = () => {
color: $main-color; color: $main-color;
border-bottom: 1px solid $border2-color; border-bottom: 1px solid $border2-color;
} }
.tag-value { .tag-value {
margin-left: 30px; margin-left: 30px;
padding: 0 20px; padding: 0 20px;
@ -340,9 +365,11 @@ const breakRemote = () => {
font-weight: 600; font-weight: 600;
background: $border2-color; background: $border2-color;
border-radius: 8px; border-radius: 8px;
&.normal { &.normal {
background: $main-color; background: $main-color;
} }
&.alarm { &.alarm {
background: red; background: red;
} }
@ -350,24 +377,30 @@ const breakRemote = () => {
} }
} }
} }
&.mini { &.mini {
padding: 20px; padding: 20px;
.left-box { .left-box {
width: 240px; width: 240px;
} }
.center-box { .center-box {
width: calc(100% - 250px); width: calc(100% - 250px);
} }
&.is-total { &.is-total {
.left-box { .left-box {
.info-box { .info-box {
display: block; display: block;
flex-shrink: 0; flex-shrink: 0;
} }
.row-item.yellow { .row-item.yellow {
.label { .label {
background: $main-color; background: $main-color;
} }
.value { .value {
color: $main-color; color: $main-color;
border-color: $main-color; border-color: $main-color;

View File

@ -481,7 +481,7 @@ const viewPatientInfo = () => {
}, 0) }, 0)
} }
const backRemote = () => { const backRemote = () => {
router.back() router.back();
} }
const playPause = () => { const playPause = () => {
if (liveVideo.value.paused) { if (liveVideo.value.paused) {

View File

@ -46,11 +46,14 @@ onMounted(() => {
function initRemoteTask() { function initRemoteTask() {
remoteTask.value = remoteWsStore.initRemoteTask() remoteTask.value = remoteWsStore.initRemoteTask()
remotePartRef.value.showData(remoteWsStore.currentTaskIndex);
} }
const viewThumbnail = () => { const viewThumbnail = () => {
router.push({ router.push({
path: '/remote-manage/remote-thumbnail' path: '/remote-manage/remote-thumbnail',
query: {
}
}) })
} }
// //

View File

@ -39,12 +39,11 @@ const remoteTask = ref([] as any);
const remoteWsStore = useRemoteWsStore(); const remoteWsStore = useRemoteWsStore();
onMounted(() => { onMounted(() => {
console.log("remoteThumbnail", remoteWsStore.remoteTasks)
remoteTask.value = remoteWsStore.remoteTasks; remoteTask.value = remoteWsStore.remoteTasks;
}) })
const openRemote = (params: any) => { const openRemote = (params: any) => {
router.push('/remote-manage/remote-manage') router.push('/remote-manage/remote-manage');
} }
const addLogAfter = (index: number) => { const addLogAfter = (index: number) => {
messageItemPartRef.value[index].scrollToBottom() messageItemPartRef.value[index].scrollToBottom()