base64加密
This commit is contained in:
parent
b6215d68dc
commit
331a457727
@ -72,7 +72,7 @@ export const processImageApi = {
|
||||
enableWatermark:1,
|
||||
}
|
||||
},
|
||||
processImg: async (params: any) => {
|
||||
processImg: async (params: string) => {
|
||||
try {
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
|
27
src/utils/base64.ts
Normal file
27
src/utils/base64.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 将字符串转换为 base64 编码
|
||||
* @param {string} str 需要编码的字符串
|
||||
* @returns {string} base64 编码后的字符串
|
||||
*/
|
||||
export const encodeBase64 = (str) => {
|
||||
try {
|
||||
return btoa(unescape(encodeURIComponent(str)));
|
||||
} catch (error) {
|
||||
console.error('Base64 编码失败:', error);
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 将 base64 编码的字符串解码
|
||||
* @param {string} str base64 编码的字符串
|
||||
* @returns {string} 解码后的原始字符串
|
||||
*/
|
||||
export const decodeBase64 = (str) => {
|
||||
try {
|
||||
return decodeURIComponent(escape(atob(str)));
|
||||
} catch (error) {
|
||||
console.error('Base64 解码失败:', error);
|
||||
return '';
|
||||
}
|
||||
};
|
@ -581,12 +581,9 @@ import { WarningApi, WarningVO } from '@/api/system/warning'
|
||||
import ECGCopmareDialog from '@/views/ECG/ECGCompare.vue'
|
||||
import ECGApplyforRepair from '@/views/ECG/ECGModify/ECGApplyforRepair.vue'
|
||||
import useClipboard from 'vue-clipboard3' //复制组件
|
||||
import ECGSB from '@/views/ECG/ECGSB.vue'
|
||||
import { ElLoading } from 'element-plus'
|
||||
import { log } from 'console'
|
||||
import { processImageApi } from '@/api/processImage'
|
||||
import jsPDF from 'jspdf'
|
||||
import VuePdfEmbed from 'vue-pdf-embed'
|
||||
import {encodeBase64} from "@/utils/base64"
|
||||
|
||||
const { toClipboard } = useClipboard()
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
@ -738,7 +735,9 @@ async function process() {
|
||||
data.watermarkText = data.step + queryParams.value.doctorDiagResult
|
||||
// console.log(data)
|
||||
data.imagePath = processImageApi.urlToAddress(data.imagePath)
|
||||
const processResponse = await processImageApi.processImg(data)
|
||||
let str = JSON.stringify(data)
|
||||
let str64 = encodeBase64(str)
|
||||
const processResponse = await processImageApi.processImg(str64)
|
||||
console.log("processResponse",processResponse)
|
||||
|
||||
// 1. 解析外层 JSON 的 data 字符串
|
||||
|
Loading…
Reference in New Issue
Block a user