| 1527 | } |
| 1528 | |
| 1529 | function createFailedTip(node, errorMsg, spinner) { |
| 1530 | // console.log(errorMsg); // 打印错误信息 |
| 1531 | // 取消转圈动画 |
| 1532 | spinner?.remove(); |
| 1533 | // 创建包装元素 |
| 1534 | const wrapper = document.createElement('span'); |
| 1535 | wrapper.classList.add('retry-error-wrapper'); |
| 1536 | |
| 1537 | // 创建重试按钮 |
| 1538 | const retryButton = document.createElement('span'); |
| 1539 | retryButton.innerText = '重试'; |
| 1540 | retryButton.classList.add('retry-error-button'); |
| 1541 | retryButton.addEventListener('click', function () { |
| 1542 | // 移除错误提示元素,重新翻译 |
| 1543 | wrapper.remove(); |
| 1544 | translate(node); |
| 1545 | }); |
| 1546 | |
| 1547 | // 创建错误提示元素 |
| 1548 | const errorTip = document.createElement('span'); |
| 1549 | errorTip.innerText = '错误原因'; |
| 1550 | errorTip.classList.add('retry-error-tip'); |
| 1551 | errorTip.addEventListener('click', function () { |
| 1552 | if (errorMsg.includes("auth failed")) { |
| 1553 | errorMsg = errorManager.authFailed |
| 1554 | } |
| 1555 | if (errorMsg.includes("quota") || errorMsg.includes("limit")) { |
| 1556 | window.alert(errorManager.quota); |
| 1557 | } |
| 1558 | window.alert(errorMsg || errorManager.unknownError); |
| 1559 | }); |
| 1560 | |
| 1561 | // 将 SVG 图标和文本添加到包装元素 |
| 1562 | wrapper.appendChild(icon.retryIcon); |
| 1563 | wrapper.appendChild(retryButton); |
| 1564 | wrapper.appendChild(icon.warnIcon); |
| 1565 | wrapper.appendChild(errorTip); |
| 1566 | |
| 1567 | node.appendChild(wrapper); |
| 1568 | } |
| 1569 | |
| 1570 | // 重试 svg |
| 1571 | function createRetrySvgIcon() { |