@shun-js/aibaiban-server 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shun-js/aibaiban-server",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "aibaiban.com server",
5
5
  "keywords": [
6
6
  "ai aibaiban"
@@ -45,5 +45,5 @@
45
45
  "access": "public",
46
46
  "registry": "https://registry.npmjs.org/"
47
47
  },
48
- "gitHead": "ffee7a3b1c2fed4ab5eeff1694aad7a69edbfa2a"
48
+ "gitHead": "ad8ddf1d9a446652b6027d64755ceca13994ccbd"
49
49
  }
@@ -356,11 +356,15 @@ exports.drawAgent = async (req, res) => {
356
356
  const imageUrl = imageResult.data?.[0]?.url;
357
357
 
358
358
  if (imageUrl) {
359
+ // 下载图片转 base64(火山引擎 TOS URL 不支持浏览器跨域 fetch)
360
+ const imgResponse = await fetch(imageUrl);
361
+ const imgBuffer = Buffer.from(await imgResponse.arrayBuffer());
362
+ const contentType = imgResponse.headers.get('content-type') || 'image/jpeg';
363
+ const dataURL = `data:${contentType};base64,${imgBuffer.toString('base64')}`;
364
+
359
365
  const duration = Date.now() - startTime;
360
366
  req.logger.info(methodName, 'image generated', `${duration}ms`);
361
- res.streaming(
362
- `data: ${JSON.stringify({ type: 'image', url: imageUrl, prompt: decision.prompt, duration })}\n\n`,
363
- );
367
+ res.streaming(`data: ${JSON.stringify({ type: 'image', dataURL, duration })}\n\n`);
364
368
  } else {
365
369
  req.logger.error(methodName, 'image generation failed', JSON.stringify(imageResult));
366
370
  res.streaming(`data: ${JSON.stringify({ type: 'message', content: '图片生成失败,请稍后重试。' })}\n\n`);
package/views/index.html CHANGED
@@ -105,7 +105,7 @@
105
105
  <script
106
106
  type="module"
107
107
  crossorigin
108
- src="https://static-small.vincentqiao.com/aibaiban/static/index-Dk6vTJo1.js"
108
+ src="https://static-small.vincentqiao.com/aibaiban/static/index-CSOQjpSt.js"
109
109
  ></script>
110
110
  <link
111
111
  rel="modulepreload"
@@ -130,7 +130,7 @@
130
130
  <link
131
131
  rel="modulepreload"
132
132
  crossorigin
133
- href="https://static-small.vincentqiao.com/aibaiban/static/chunks/excalidraw-XjoTMqq7.js"
133
+ href="https://static-small.vincentqiao.com/aibaiban/static/chunks/excalidraw-uW8o6EnV.js"
134
134
  />
135
135
  <link
136
136
  rel="stylesheet"