9 changed files with 219 additions and 17 deletions
@ -0,0 +1,74 @@ |
|||
import { SM4 } from "gm-crypto-wasm"; |
|||
import * as CryptoJS from 'crypto-js' |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-12-07 10:26:51 |
|||
@ 备注: 将字符串转换成16进制 |
|||
*/ |
|||
const strToHexMethod = (str: string): string => { |
|||
return CryptoJS.enc.Utf8.parse(str).toString(CryptoJS.enc.Hex) |
|||
} |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-12-07 10:29:48 |
|||
@ 备注: 判断是不是12位16进制参数 |
|||
*/ |
|||
const isValidHex32 = (str: string): boolean => { |
|||
return /^[0-9a-fA-F]{32}$/.test(str) |
|||
} |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-12-07 10:28:33 |
|||
@ 备注: 初始化SM4密钥参数 |
|||
*/ |
|||
const appSystemKey = strToHexMethod(import.meta.env.VITE_APP_SYSTEM_KEY) |
|||
const sm4TokenKey = strToHexMethod(import.meta.env.VITE_APP_SM4_APP_KEY) |
|||
|
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2026-02-11 08:17:36 |
|||
@ 功能: SM4加密方法 |
|||
*/ |
|||
const sm4EncryptMethod = (data: string, customKey: string): string => { |
|||
let ivSetup = sm4TokenKey |
|||
if (customKey) { |
|||
ivSetup = strToHexMethod(customKey) |
|||
if (!isValidHex32(ivSetup)) { |
|||
ivSetup = sm4TokenKey |
|||
} |
|||
} |
|||
return SM4.encrypt(data, appSystemKey, { |
|||
iv: ivSetup, |
|||
mode: SM4.constants.CBC, |
|||
inputEncoding: 'utf8', |
|||
outputEncoding: 'hex', |
|||
padding: 1 |
|||
} as never) |
|||
} |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-12-07 10:31:22 |
|||
@ 备注: SM4解密方法 |
|||
*/ |
|||
const sm4DecryptMethod = (data: string, customKey: string): string => { |
|||
let ivSetup = sm4TokenKey |
|||
if (customKey) { |
|||
ivSetup = strToHexMethod(customKey) |
|||
if (!isValidHex32(ivSetup)) { |
|||
ivSetup = sm4TokenKey |
|||
} |
|||
} |
|||
// console.log('SM4解密方法----解密结构---data--->', data)
|
|||
// console.log('SM4解密方法----解密结构----customKey-->', customKey)
|
|||
// console.log('SM4解密方法----解密结构--ivSetup---->', ivSetup)
|
|||
// console.log('SM4解密方法----解密结构---sm4TokenKey--->', sm4TokenKey)
|
|||
// console.log('SM4解密方法----解密结构---appSystemKey--->', appSystemKey)
|
|||
return SM4.decrypt(data, appSystemKey, { |
|||
iv: ivSetup, |
|||
mode: SM4.constants.CBC, |
|||
inputEncoding: 'hex', |
|||
outputEncoding: 'utf8', |
|||
padding: 1 |
|||
} as never) |
|||
} |
|||
export { sm4EncryptMethod, sm4DecryptMethod } |
|||
@ -0,0 +1,97 @@ |
|||
<!-- |
|||
@ 作者: 秦东 |
|||
@ 时间: 2026-02-10 16:13:56 |
|||
@ 备注: App内容列表 |
|||
--> |
|||
<script lang='ts' setup> |
|||
import { gainAppPageInfo } from '@/api/DesignForm/requestapi'; |
|||
|
|||
const props = defineProps({ |
|||
pickAppMenu: { |
|||
type: Object, |
|||
default() { |
|||
return {}; |
|||
}, |
|||
}, |
|||
drawerWith: { |
|||
type: Number, |
|||
default: 0, |
|||
} |
|||
}); |
|||
const appFormTitle = ref(""); |
|||
|
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2026-02-10 16:21:21 |
|||
@ 功能: 初始化数据 |
|||
*/ |
|||
const initLoadData = () => { |
|||
if (props.pickAppMenu.type != 1) { |
|||
appFormTitle.value = props.pickAppMenu.label; |
|||
gainAppPageInfo({ id: props.pickAppMenu.id }).then((data:any) => { |
|||
console.log("初始化数据------>",data); |
|||
if (data.code == 200) { |
|||
appFormTitle.value = data.data.appName; |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-03 09:26:17 |
|||
@ 功能: 监听菜单数据变化 |
|||
*/ |
|||
watch( |
|||
() => props.pickAppMenu, |
|||
(val: any) => { |
|||
initLoadData(); |
|||
}, |
|||
{ |
|||
deep: true, |
|||
} |
|||
); |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2026-02-10 16:21:41 |
|||
@ 功能: 加载数据 |
|||
*/ |
|||
onMounted(() => { |
|||
initLoadData(); |
|||
}); |
|||
</script> |
|||
<template> |
|||
<div class="listContent"> |
|||
<div class="columnHeadBox">{{ appFormTitle }}</div> |
|||
</div> |
|||
<el-scrollbar class="scroBox"> |
|||
<el-card class="tispMsg" shadow="always"> |
|||
{{ props.pickAppMenu.type }} |
|||
</el-card> |
|||
</el-scrollbar> |
|||
</template> |
|||
<style lang='scss' scoped> |
|||
.listContent { |
|||
width: 100%; |
|||
} |
|||
.columnHeadBox{ |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
width: 100%; |
|||
height: 45px; |
|||
line-height: 45px; |
|||
text-align: center; |
|||
background-color: #ffffff; |
|||
font-size: 16px; |
|||
padding: 0 15px; |
|||
font-weight: 400; |
|||
} |
|||
.scroBox { |
|||
margin: 10px auto 0 auto; |
|||
padding: 0 10px; |
|||
height: calc(100vh - 95px); |
|||
.tispMsg { |
|||
margin: 0 auto 15px auto; |
|||
} |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue