From e0954a34e7e0e887b46d94faeb446d43e376a682 Mon Sep 17 00:00:00 2001 From: HoshinoKoji Date: Mon, 3 Mar 2025 19:40:41 +0800 Subject: [PATCH] Remove JSON download functionality from App.vue and implement it in parent.html --- public/parent.html | 7 +++++-- src/App.vue | 4 ---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/public/parent.html b/public/parent.html index 88601b4..6b8a6b8 100644 --- a/public/parent.html +++ b/public/parent.html @@ -48,7 +48,10 @@ }] }; window.addEventListener('message', (event) => { - console.log(event.data); + const elem = document.createElement('a'); + elem.href = 'data:text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(event.data)); + elem.download = 'results.json'; + elem.click(); }); window.onload = () => { const iframe = document.getElementById('iframe'); @@ -64,7 +67,7 @@ diff --git a/src/App.vue b/src/App.vue index ae6acde..6cadc54 100644 --- a/src/App.vue +++ b/src/App.vue @@ -162,10 +162,6 @@ export default { ended: new Date().getTime(), results }, window.origin); - const elem = document.createElement('a'); - elem.href = 'data:text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(results)); - elem.download = 'results.json'; - elem.click(); } } }