(content)
| 311 | * @private |
| 312 | */ |
| 313 | let _downloadSupport = function (content) { |
| 314 | if (!_canRenderFormattedResult()) { |
| 315 | _clearOptionBar(); |
| 316 | return; |
| 317 | } |
| 318 | |
| 319 | // 下载链接 |
| 320 | let dt = (new Date()).format('yyyyMMddHHmmss'); |
| 321 | let blob = new Blob([content], {type: 'application/octet-stream'}); |
| 322 | |
| 323 | let button = $('<button class="xjf-btn xjf-btn-right">下载</button>').appendTo('#optionBar'); |
| 324 | |
| 325 | // 检查是否在沙盒化iframe中 |
| 326 | function isSandboxed() { |
| 327 | try { |
| 328 | return window !== window.top || window.parent !== window; |
| 329 | } catch (e) { |
| 330 | return true; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // 在沙盒模式下显示JSON内容 |
| 335 | function showJsonContentInSandbox() { |
| 336 | // 查找 #formattedJson 节点 |
| 337 | let formattedJsonDiv = document.getElementById('formattedJson'); |
| 338 | if (!formattedJsonDiv) { |
| 339 | console.error('未找到 #formattedJson 节点'); |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | // 清空 #formattedJson 的内容 |
| 344 | formattedJsonDiv.innerHTML = ''; |
| 345 | |
| 346 | // 创建下载提示和内容显示区域 |
| 347 | let downloadInfo = document.createElement('div'); |
| 348 | downloadInfo.style.cssText = ` |
| 349 | background: #e3f2fd; |
| 350 | border: 1px solid #2196f3; |
| 351 | border-radius: 4px; |
| 352 | padding: 15px; |
| 353 | margin-bottom: 15px; |
| 354 | font-family: Arial, sans-serif; |
| 355 | `; |
| 356 | downloadInfo.innerHTML = ` |
| 357 | <div style="color: #1976d2; font-weight: bold; margin-bottom: 8px;">沙盒模式 - JSON内容</div> |
| 358 | <div style="color: #666; font-size: 14px; margin-bottom: 10px;">由于浏览器安全限制,无法直接下载。请复制以下内容并保存为 .json 文件:</div> |
| 359 | <button onclick=" |
| 360 | let textarea = this.parentElement.nextElementSibling; |
| 361 | textarea.select(); |
| 362 | document.execCommand('copy'); |
| 363 | alert('已复制到剪贴板!'); |
| 364 | " style=" |
| 365 | background: #2196f3; |
| 366 | color: white; |
| 367 | border: none; |
| 368 | padding: 8px 16px; |
| 369 | border-radius: 4px; |
| 370 | cursor: pointer; |
no test coverage detected