From 2dd409505461e4f7fc98c952a100aeec53897100 Mon Sep 17 00:00:00 2001 From: purocean Date: Wed, 5 Jan 2022 11:38:55 +0800 Subject: [PATCH] fix: fix memory leak --- src/renderer/utils/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/utils/index.ts b/src/renderer/utils/index.ts index 9ff0c6b8..47460512 100644 --- a/src/renderer/utils/index.ts +++ b/src/renderer/utils/index.ts @@ -78,10 +78,15 @@ export function objectInsertAfterKey (obj: {}, key: string, content: {}) { export function downloadContent (filename: string, content: Buffer | string, type = 'application/octet-stream') { const blob = new Blob([content], { type }) + const href = window.URL.createObjectURL(blob) const link = document.createElement('a') - link.href = window.URL.createObjectURL(blob) + link.href = href link.download = filename link.click() + + setTimeout(() => { + window.URL.revokeObjectURL(href) + }, 20000) } export function md5 (content: any) {