| 85 | |
| 86 | // 根据错误信息返回错误提示 |
| 87 | function getErrorMessage(errMsg: string): string { |
| 88 | if (errMsg.includes("auth failed") || errMsg.includes("API key")) { |
| 89 | return "Token 似乎有点问题,请前往设置页面重新配置后再试。"; |
| 90 | } else if (errMsg.includes("quota") || errMsg.includes("limit")) { |
| 91 | const service = options.services.find((s: { value: string; label: string }) => s.value === config.service); |
| 92 | return "你的请求频率过高,被【" + (service?.label || config.service) + "】拒绝了,请稍后再试吧~"; |
| 93 | } else if (errMsg.includes("network error")) { |
| 94 | return "网络连接好像不稳定,请检查网络后再试。"; |
| 95 | } else if (errMsg.includes("model")) { |
| 96 | return "模型配置可能有误,请前往设置页面进行检查和调整。"; |
| 97 | } else if (errMsg.includes("timeout")) { |
| 98 | return "请求超时啦,请稍后再试一次。"; |
| 99 | } else { |
| 100 | return errMsg || "出现了未知错误,请前往开源社区联系开发者吧~"; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // 创建图标元素 |
| 105 | function createIconElement(iconContent: string): HTMLElement { |