From c8d2bdef1496354bf9f92fb191758a628e04d23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=8D=9A=E6=96=87?= <1179111926@qq.com> Date: Mon, 26 Sep 2022 12:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Encrypt/List/Index/index.tsx | 31 +++++++++++++++++++++++--- src/pages/Simulation/index.tsx | 5 ++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/pages/Encrypt/List/Index/index.tsx b/src/pages/Encrypt/List/Index/index.tsx index 7d73901..f8e703d 100644 --- a/src/pages/Encrypt/List/Index/index.tsx +++ b/src/pages/Encrypt/List/Index/index.tsx @@ -79,9 +79,34 @@ const Page: FC = () => { message.warn('请输入算法类型'); return; } - downLoadLink( - `${url}/openi/secretKey/encryption?type=${type}&algorithm=${algorithm}&length=${length}&count=${file.length}`, - ); + let item = undefined; + for (let i = 0; i < file.length; i++) { + if (file[i].name === '数据文件.txt') { + item = file[i]; + break; + } + } + if (item) { + var reader = new FileReader(); + reader.readAsText(file[0], 'UTF-8'); + reader.onload = function (e: any) { + let val = e.target.result; + try { + val = JSON.parse(val); + if (val.count !== undefined) { + downLoadLink( + `${url}/openi/secretKey/encryption?type=${type}&algorithm=${algorithm}&length=${length}&count=${val.count}`, + ); + } else { + message.warn('数据文件内容格式错误,请重新导入!'); + } + } catch (s) { + message.warn('数据文件内容格式错误,请重新导入!'); + } + }; + } else { + message.warn('导入文件没有包含数据文件(数据文件.txt),请重新导入!'); + } }; const renderText = () => { diff --git a/src/pages/Simulation/index.tsx b/src/pages/Simulation/index.tsx index d543db2..ceb69ec 100644 --- a/src/pages/Simulation/index.tsx +++ b/src/pages/Simulation/index.tsx @@ -235,7 +235,10 @@ const Page = () => { }; const getData = (e: any) => { - if (e.origin === 'https://edu-xnfz.educoder.net') { + if ( + e.origin === 'https://edu-xnfz.educoder.net' || + e.origin === 'http://localhost:81' + ) { console.log(e.data, 22222); let newData: any = []; try {