Merge pull request #38 from solar2ain/fix/download-retries

fix: 修复 retries=0 时不下载的问题
This commit is contained in:
FoxHui
2026-03-29 02:28:35 +08:00
committed by GitHub
Unverified
17 changed files with 132 additions and 121 deletions
+7
View File
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [3.6.1] - 2025-03-28
### ✨ Added
- 图片下载重试机制(指数退避)
- 请求历史记录(SQLite 存储)
- WebUI 请求模型页面
## [3.6.0] - 2026-03-26
### 🐛 Fixed
+7 -5
View File
@@ -27,16 +27,18 @@ function isRetryableError(message) {
*/
export async function useContextDownload(url, page, options = {}) {
const { timeout = 120000, retries = 3, retryDelay = 1000 } = options;
// 至少执行一次尝试(retries=0 表示不重试,但仍需下载一次)
const maxAttempts = Math.max(1, retries);
for (let attempt = 1; attempt <= retries; attempt++) {
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
const response = await page.request.get(url, { timeout });
if (!response.ok()) {
const status = response.status();
// 5xx 错误可重试
if (status >= 500 && attempt < retries) {
logger.warn('下载', `HTTP ${status},重试 ${attempt}/${retries}...`);
if (status >= 500 && attempt < maxAttempts) {
logger.warn('下载', `HTTP ${status},重试 ${attempt}/${maxAttempts}...`);
await new Promise(r => setTimeout(r, retryDelay * attempt));
continue;
}
@@ -50,8 +52,8 @@ export async function useContextDownload(url, page, options = {}) {
return { image: `data:${mimeType};base64,${base64}`, imageUrl: url };
} catch (e) {
if (isRetryableError(e.message) && attempt < retries) {
logger.warn('下载', `${e.message},重试 ${attempt}/${retries}...`);
if (isRetryableError(e.message) && attempt < maxAttempts) {
logger.warn('下载', `${e.message},重试 ${attempt}/${maxAttempts}...`);
await new Promise(r => setTimeout(r, retryDelay * attempt));
continue;
}
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
[data-v-5ef25f71]::-webkit-scrollbar{width:6px;height:6px}[data-v-5ef25f71]::-webkit-scrollbar-thumb{background:#ccc;border-radius:3px}[data-v-5ef25f71]::-webkit-scrollbar-track{background:#f1f1f1}html,body{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,*:before,*:after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}@-ms-viewport{width:device-width}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[title],abbr[data-original-title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=text],input[type=password],input[type=number],textarea{-webkit-appearance:none}ol,ul,dl{margin-top:0;margin-bottom:1em}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}pre,code,kbd,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}a,area,button,[role=button],input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}input,button,select,optgroup,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{padding:0;border-style:none}input[type=radio],input[type=checkbox]{box-sizing:border-box;padding:0}input[type=date],input[type=time],input[type=datetime-local],input[type=month]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}
[data-v-b293cd32]::-webkit-scrollbar{width:6px;height:6px}[data-v-b293cd32]::-webkit-scrollbar-thumb{background:#ccc;border-radius:3px}[data-v-b293cd32]::-webkit-scrollbar-track{background:#f1f1f1}.sider-mask[data-v-b293cd32]{position:fixed;inset:64px 0 0;background:#00000073;z-index:199}html,body{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,*:before,*:after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}@-ms-viewport{width:device-width}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[title],abbr[data-original-title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=text],input[type=password],input[type=number],textarea{-webkit-appearance:none}ol,ul,dl{margin-top:0;margin-bottom:1em}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}pre,code,kbd,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}a,area,button,[role=button],input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}input,button,select,optgroup,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{padding:0;border-style:none}input[type=radio],input[type=checkbox]{box-sizing:border-box;padding:0}input[type=date],input[type=time],input[type=datetime-local],input[type=month]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}
+103 -103
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
.log-container[data-v-f89c259b]{max-height:600px;overflow-y:auto;font-family:Consolas,Monaco,monospace;font-size:12px;background:#fafafa;border-radius:4px;padding:12px}.log-line[data-v-f89c259b]{padding:4px 0;border-bottom:1px solid #f0f0f0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.log-line[data-v-f89c259b]:hover{background:#e6f7ff;white-space:normal;word-break:break-all}.log-time[data-v-f89c259b]{color:#8c8c8c}.log-module[data-v-f89c259b]{color:#1890ff;margin-right:8px}.log-message[data-v-f89c259b]{color:#333}.level-erro .log-message[data-v-f89c259b]{color:#ff4d4f}.level-warn .log-message[data-v-f89c259b]{color:#faad14}.level-dbug .log-message[data-v-f89c259b]{color:#722ed1}.toolbar[data-v-f89c259b]{margin-bottom:16px}.toolbar-row[data-v-f89c259b]{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}.toolbar-row[data-v-f89c259b]:last-child{margin-bottom:0}@media(min-width:768px){.toolbar[data-v-f89c259b]{display:flex;justify-content:space-between;align-items:center;gap:12px}.toolbar-row[data-v-f89c259b]{margin-bottom:0}.toolbar-row[data-v-f89c259b]:last-child{flex:1;max-width:300px}}.stats-content[data-v-f89c259b]{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.stats-numbers[data-v-f89c259b]{display:flex;align-items:center;gap:20px}.stat-item[data-v-f89c259b]{display:flex;align-items:center;gap:6px;padding:4px 12px;background:#fafafa;border-radius:6px;transition:all .2s}.stat-item[data-v-f89c259b]:hover{background:#f0f0f0}.stat-item.success[data-v-f89c259b]{color:#52c41a}.stat-item.error[data-v-f89c259b]{color:#ff4d4f}.stat-item.neutral[data-v-f89c259b]{color:#8c8c8c}.stat-value[data-v-f89c259b]{font-size:18px;font-weight:600;font-family:SF Mono,Monaco,monospace}.stat-label[data-v-f89c259b]{font-size:12px;color:#8c8c8c}@media(max-width:576px){.stats-content[data-v-f89c259b]{flex-direction:column;align-items:flex-start}.stats-content .ant-divider[data-v-f89c259b]{display:none}.stats-numbers[data-v-f89c259b]{margin-top:8px}}
.log-container[data-v-708825db]{max-height:600px;overflow-y:auto;overflow-x:auto;font-family:Consolas,Monaco,monospace;font-size:12px;background:#fafafa;border-radius:4px;padding:12px}.log-line[data-v-708825db]{padding:4px 0;border-bottom:1px solid #f0f0f0;display:flex;align-items:baseline;gap:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.log-line[data-v-708825db]:hover{background:#e6f7ff;white-space:normal;word-break:break-all}.log-meta[data-v-708825db]{display:flex;align-items:center;gap:4px;flex-shrink:0}.log-time[data-v-708825db]{color:#8c8c8c}.log-module[data-v-708825db]{color:#1890ff;margin-right:4px}.log-message[data-v-708825db]{color:#333;overflow:hidden;text-overflow:ellipsis}.level-erro .log-message[data-v-708825db]{color:#ff4d4f}.level-warn .log-message[data-v-708825db]{color:#faad14}.level-dbug .log-message[data-v-708825db]{color:#722ed1}.toolbar[data-v-708825db]{margin-bottom:16px}.toolbar-row[data-v-708825db]{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}.toolbar-row[data-v-708825db]:last-child{margin-bottom:0}@media(min-width:768px){.toolbar[data-v-708825db]{display:flex;justify-content:space-between;align-items:center;gap:12px}.toolbar-row[data-v-708825db]{margin-bottom:0}.toolbar-row[data-v-708825db]:last-child{flex:1;max-width:300px}}.stats-content[data-v-708825db]{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.stats-numbers[data-v-708825db]{display:flex;align-items:center;gap:20px}.stat-item[data-v-708825db]{display:flex;align-items:center;gap:6px;padding:4px 12px;background:#fafafa;border-radius:6px;transition:all .2s}.stat-item[data-v-708825db]:hover{background:#f0f0f0}.stat-item.success[data-v-708825db]{color:#52c41a}.stat-item.error[data-v-708825db]{color:#ff4d4f}.stat-item.neutral[data-v-708825db]{color:#8c8c8c}.stat-value[data-v-708825db]{font-size:18px;font-weight:600;font-family:SF Mono,Monaco,monospace}.stat-label[data-v-708825db]{font-size:12px;color:#8c8c8c}.stats-date-picker[data-v-708825db]{width:240px}@media(max-width:576px){.stats-content[data-v-708825db]{flex-direction:column;align-items:flex-start}.stats-content .ant-divider[data-v-708825db]{display:none}.stats-numbers[data-v-708825db]{margin-top:8px}}@media(max-width:768px){.stats-date-picker[data-v-708825db]{width:100%}.log-container[data-v-708825db]{padding:8px;font-size:11px}.log-line[data-v-708825db]{flex-direction:column;align-items:flex-start;gap:2px;white-space:normal;word-break:break-all;padding:6px 0}.log-line[data-v-708825db]:hover{white-space:normal}.log-meta[data-v-708825db]{flex-wrap:wrap}.log-time[data-v-708825db]{font-size:10px}.log-message[data-v-708825db]{white-space:normal;word-break:break-all;overflow:visible}}
+2 -2
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
.ant-input-number[data-v-e88c66ad]{width:100%}
.ant-input-number[data-v-66d7a617]{width:100%}
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
import{y as i,k as a,m as r}from"./index.js";const u=i("system",{state:()=>({status:"",version:"1.0.0",systemVersion:"",uptime:0,cpuUsage:0,memoryUsage:{total:0,used:0,free:0},safeMode:{enabled:!1,reason:null},stats:{totalRequests:0,successRate:0,activeWorkers:0,totalWorkers:0,avgResponseTime:0,success:0,failed:0}}),actions:{async fetchStatus(){const t=a();try{const e=await fetch("/admin/status",{headers:t.getHeaders()});if(e.ok){const s=await e.json();this.$patch(s)}}catch(e){console.error("Failed to fetch system status:",e)}},async fetchStats(){const t=a();try{const e=await fetch("/admin/stats",{headers:t.getHeaders()});if(e.ok){const s=await e.json();this.stats=s}}catch(e){console.error("Failed to fetch stats:",e)}},async restartService(t={}){const e=a(),{loginMode:s,workerName:n}=t;try{const o=await(await fetch("/admin/restart",{method:"POST",headers:{...e.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({loginMode:s,workerName:n})})).json();return o.success?(r.success(o.message||"服务重启中..."),!0):(r.error("重启失败"),!1)}catch{return r.error("重启请求失败"),!1}},async stopService(){const t=a();try{const s=await(await fetch("/admin/stop",{method:"POST",headers:t.getHeaders()})).json();return s.success?(r.success(s.message||"服务停止中..."),!0):(r.error("停止失败"),!1)}catch{return r.error("停止请求失败"),!1}}}});export{u};
import{y as i,j as a,m as r}from"./index.js";const u=i("system",{state:()=>({status:"",version:"1.0.0",systemVersion:"",uptime:0,cpuUsage:0,memoryUsage:{total:0,used:0,free:0},safeMode:{enabled:!1,reason:null},stats:{totalRequests:0,successRate:0,activeWorkers:0,totalWorkers:0,avgResponseTime:0,success:0,failed:0}}),actions:{async fetchStatus(){const t=a();try{const e=await fetch("/admin/status",{headers:t.getHeaders()});if(e.ok){const s=await e.json();this.$patch(s)}}catch(e){console.error("Failed to fetch system status:",e)}},async fetchStats(){const t=a();try{const e=await fetch("/admin/stats",{headers:t.getHeaders()});if(e.ok){const s=await e.json();this.stats=s}}catch(e){console.error("Failed to fetch stats:",e)}},async restartService(t={}){const e=a(),{loginMode:s,workerName:n}=t;try{const o=await(await fetch("/admin/restart",{method:"POST",headers:{...e.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({loginMode:s,workerName:n})})).json();return o.success?(r.success(o.message||"服务重启中..."),!0):(r.error("重启失败"),!1)}catch{return r.error("重启请求失败"),!1}},async stopService(){const t=a();try{const s=await(await fetch("/admin/stop",{method:"POST",headers:t.getHeaders()})).json();return s.success?(r.success(s.message||"服务停止中..."),!0):(r.error("停止失败"),!1)}catch{return r.error("停止请求失败"),!1}}}});export{u};
+1 -1
View File
File diff suppressed because one or more lines are too long