mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
feat: 图片生成结果支持返回 MD 格式 (closes #84)
This commit is contained in:
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- **WebUI**
|
||||
- Gemini 和 ChatGPT 的临时对话模式开关(现可以在适配器设置中单独开关)
|
||||
|
||||
- **服务器**
|
||||
- 支持开启图片生成结果使用 Markdown 格式返回
|
||||
|
||||
## [3.6.6] - 2026-04-12
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
@@ -13,6 +13,8 @@ server:
|
||||
# "comment": (推荐) 发送 :keepalive 注释,不污染数据
|
||||
# "content": (备用) 发送空 delta,仅当客户端必须收到 JSON 包才重置超时时使用
|
||||
mode: "comment"
|
||||
# 图片生成结果返回 Markdown 格式
|
||||
imageMarkdown: false
|
||||
|
||||
backend:
|
||||
# ========================================
|
||||
|
||||
@@ -47,7 +47,8 @@ export function getServerConfig() {
|
||||
port: config.server?.port || 3000,
|
||||
authToken: config.server?.auth || '',
|
||||
keepaliveMode: config.server?.keepalive?.mode || 'comment',
|
||||
logLevel: config.logLevel || 'info'
|
||||
logLevel: config.logLevel || 'info',
|
||||
imageMarkdown: config.server?.imageMarkdown || false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ export function saveServerConfig(data) {
|
||||
config.server.keepalive.mode = data.keepaliveMode;
|
||||
}
|
||||
if (data.logLevel !== undefined) config.logLevel = data.logLevel;
|
||||
if (data.imageMarkdown !== undefined) config.server.imageMarkdown = data.imageMarkdown;
|
||||
|
||||
writeConfig(config);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ export function validateServerConfig(data) {
|
||||
}
|
||||
}
|
||||
|
||||
// Image Markdown 校验
|
||||
if (data.imageMarkdown !== undefined && typeof data.imageMarkdown !== 'boolean') {
|
||||
errors.push('imageMarkdown 必须是布尔值');
|
||||
}
|
||||
|
||||
return { valid: errors.length === 0, errors };
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -166,8 +166,13 @@ export function createQueueManager(queueConfig, callbacks) {
|
||||
let historyResponseText = ''; // 历史记录中存储的文本(不含 base64)
|
||||
|
||||
if (result.image) {
|
||||
// 直接返回 base64 数据,不加 Markdown 包装
|
||||
finalContent = result.image;
|
||||
// 判断是否开启 Markdown 格式
|
||||
const imageMarkdown = config?.server?.imageMarkdown || false;
|
||||
if (imageMarkdown) {
|
||||
finalContent = ``;
|
||||
} else {
|
||||
finalContent = result.image;
|
||||
}
|
||||
// 历史记录只存原始 URL,不存 base64
|
||||
historyResponseText = result.imageUrl || '';
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
[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}
|
||||
[data-v-64baeab9]::-webkit-scrollbar{width:6px;height:6px}[data-v-64baeab9]::-webkit-scrollbar-thumb{background:#ccc;border-radius:3px}[data-v-64baeab9]::-webkit-scrollbar-track{background:#f1f1f1}.sider-mask[data-v-64baeab9]{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}
|
||||
|
||||
Vendored
+97
-97
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
.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}}
|
||||
.log-container[data-v-bfed2dd2]{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-bfed2dd2]{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-bfed2dd2]:hover{background:#e6f7ff;white-space:normal;word-break:break-all}.log-meta[data-v-bfed2dd2]{display:flex;align-items:center;gap:4px;flex-shrink:0}.log-time[data-v-bfed2dd2]{color:#8c8c8c}.log-module[data-v-bfed2dd2]{color:#1890ff;margin-right:4px}.log-message[data-v-bfed2dd2]{color:#333;overflow:hidden;text-overflow:ellipsis}.level-erro .log-message[data-v-bfed2dd2]{color:#ff4d4f}.level-warn .log-message[data-v-bfed2dd2]{color:#faad14}.level-dbug .log-message[data-v-bfed2dd2]{color:#722ed1}.toolbar[data-v-bfed2dd2]{margin-bottom:16px}.toolbar-row[data-v-bfed2dd2]{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}.toolbar-row[data-v-bfed2dd2]:last-child{margin-bottom:0}@media(min-width:768px){.toolbar[data-v-bfed2dd2]{display:flex;justify-content:space-between;align-items:center;gap:12px}.toolbar-row[data-v-bfed2dd2]{margin-bottom:0}.toolbar-row[data-v-bfed2dd2]:last-child{flex:1;max-width:300px}}.stats-content[data-v-bfed2dd2]{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.stats-numbers[data-v-bfed2dd2]{display:flex;align-items:center;gap:20px}.stat-item[data-v-bfed2dd2]{display:flex;align-items:center;gap:6px;padding:4px 12px;background:#fafafa;border-radius:6px;transition:all .2s}.stat-item[data-v-bfed2dd2]:hover{background:#f0f0f0}.stat-item.success[data-v-bfed2dd2]{color:#52c41a}.stat-item.error[data-v-bfed2dd2]{color:#ff4d4f}.stat-item.neutral[data-v-bfed2dd2]{color:#8c8c8c}.stat-value[data-v-bfed2dd2]{font-size:18px;font-weight:600;font-family:SF Mono,Monaco,monospace}.stat-label[data-v-bfed2dd2]{font-size:12px;color:#8c8c8c}.stats-date-picker[data-v-bfed2dd2]{width:240px}@media(max-width:576px){.stats-content[data-v-bfed2dd2]{flex-direction:column;align-items:flex-start}.stats-content .ant-divider[data-v-bfed2dd2]{display:none}.stats-numbers[data-v-bfed2dd2]{margin-top:8px}}@media(max-width:768px){.stats-date-picker[data-v-bfed2dd2]{width:100%}.log-container[data-v-bfed2dd2]{padding:8px;font-size:11px}.log-line[data-v-bfed2dd2]{flex-direction:column;align-items:flex-start;gap:2px;white-space:normal;word-break:break-all;padding:6px 0}.log-line[data-v-bfed2dd2]:hover{white-space:normal}.log-meta[data-v-bfed2dd2]{flex-wrap:wrap}.log-time[data-v-bfed2dd2]{font-size:10px}.log-message[data-v-bfed2dd2]{white-space:normal;word-break:break-all;overflow:visible}}
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
.ant-input-number[data-v-66d7a617]{width:100%}
|
||||
.ant-input-number[data-v-5311fcbb]{width:100%}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
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};
|
||||
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};
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -12,7 +12,8 @@ const formData = reactive({
|
||||
keepaliveMode: 'comment',
|
||||
logLevel: 'info',
|
||||
queueBuffer: 2,
|
||||
imageLimit: 5
|
||||
imageLimit: 5,
|
||||
imageMarkdown: false
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -146,6 +147,18 @@ const handleSave = async () => {
|
||||
style="width: 100%" />
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<!-- 图片生成结果使用 Markdown -->
|
||||
<a-col :xs="24" :md="12">
|
||||
<div style="margin-bottom: 8px;">
|
||||
<div style="font-weight: 600; margin-bottom: 4px;">图片 Markdown 格式</div>
|
||||
<div style="font-size: 12px; color: #8c8c8c; margin-bottom: 8px;">
|
||||
开启后生图结果将使用 Markdown 语法返回图片内容<br>
|
||||
开启此项需要客户端支持渲染 Markdown
|
||||
</div>
|
||||
<a-switch v-model:checked="formData.imageMarkdown" />
|
||||
</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 保存按钮(右下角) -->
|
||||
|
||||
Reference in New Issue
Block a user