MCPcopy Create free account
hub / github.com/zxlie/FeHelper / tryDownload

Function tryDownload

apps/json-format/format-lib.js:478–500  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

476
477 // 尝试下载
478 function tryDownload() {
479 try {
480 let aLink = document.createElement('a');
481 aLink.download = 'FeHelper-' + dt + '.json';
482 aLink.href = URL.createObjectURL(blob);
483 aLink.style.display = 'none';
484
485 document.body.appendChild(aLink);
486 aLink.click();
487
488 setTimeout(() => {
489 if (document.body.contains(aLink)) {
490 document.body.removeChild(aLink);
491 }
492 URL.revokeObjectURL(aLink.href);
493 }, 100);
494
495 return true;
496 } catch (error) {
497 console.error('下载失败:', error);
498 return false;
499 }
500 }
501
502 // 下载按钮点击事件
503 button.click(function (e) {

Callers 1

_downloadSupportFunction · 0.85

Calls 1

setTimeoutFunction · 0.85

Tested by

no test coverage detected