dsh-live2dwaifu 2.0.0 → 2.1.0

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/README.md CHANGED
@@ -238,16 +238,7 @@ python tools/export-dsh-meme.py
238
238
 
239
239
  「本机」存 localStorage,只影响这一台浏览器;「服务端」存 `~/.dsh/dsh-live2d/config.json`,换浏览器也一样。
240
240
 
241
- ---|---|---|---|
242
- | 眼睛跟着鼠标 | 本机 | 开 | 关掉她就不看鼠标了 |
243
- | 点她有反应 | 本机 | 开 | 摸头害羞、戳身上瞪你 |
244
- | 自己播动作 | 本机 | 开 | 有动作文件的模型才会动 |
245
- | 出声 | 本机 | 开 | 电子音 |
246
- | 跟着聊天念 | 本机 | 开 | 助手每说一句她念一句 |
247
- | 没人理就自己开口 | 她那边 | 开 | 十几分钟没人说话她说一句 |
248
- | 给选项让他挑 | 她那边 | 开 | 气泡上方冒出可点的按钮 |
249
- | 记住之前说的 | 她那边 | 开 | 关掉就不带记忆、不压缩 |
250
- | 表情包(四档) | 她那边 | 不使用 | 测试功能,见上 |
241
+ 主动开口那根滑轴给的是基准时长,实际会在这个数前后浮动,不是准点报到;夜里 0 点到 7 点她不出声。想看效果不用等,⚙ 里有一句「让她现在说一句」,点一下马上说一句。
251
242
 
252
243
  ---
253
244
 
@@ -380,6 +371,25 @@ curl -X POST http://127.0.0.1:<端口>/dsh-live2d/api/push \
380
371
 
381
372
  版本号怎么走:动了功能和结构就抬第二位(1.2.0),只补洞和小修就抬第三位(1.2.1)。
382
373
 
374
+ ### 2.1.0
375
+
376
+ 「随机主动消息」这一块基本重做了。之前那版有两个毛病,都是真的。
377
+
378
+ - 修:**间隔根本不受设置管**。计时器只存在内存里,每次重启 DSH 归零,于是「闲置 1 小时才说一句」实际变成「重启后 1 小时说一句」。你重启三次,她就说三次,看着像 12 分钟、23 分钟一次。现在计时落到 `~/.dsh/dsh-live2d/auto.json`,锚点取聊天记录里最后一条的时间,重启不影响。
379
+ - 改:间隔改成浮动。设定值只当基准,每轮在 0.8~1.4 倍之间重新抽一次,不再准点报到。
380
+ - 加:夜里 0 点到 7 点不主动开口,白天再补。
381
+ - 修:**主动开口的样式是照着问答样例生成的**,所以每句都像在回答一个不存在的问题,结尾固定挂「你饿不饿」。现在换成开口样例(短句、不起头就是一句陈述),每轮随机指定一种开口方式:说手上的事、想起他一句、抱怨一句、只丢两三个字、说一件变化、提一件打算做的事。
382
+ - 加:主动开口会读自己最近六句,撞了就不说——同一个道具(粥、袖口、手凉)不会连着出现。两次都撞就这轮作罢,宁可不说。
383
+ - 加:主动开口也带情绪和配图(按表情包设置),并且会清掉上一次没点的选项按钮。
384
+ - 修:`guessMood` 用单字匹配,「了」被算进「无语」,导致「番茄藤绑好了」这类正常句子一律判成无语、连表情都选错。改成按词判断。
385
+ - 加:⚙ 里多一个「让她现在说一句」,不等时间,点了就看效果。
386
+ - 修:README 开关表里混进来一段旧表格残块。
387
+
388
+ ### 2.0.1
389
+
390
+ - 修:拖动时没限制边界,卡片能被推到屏幕外,标题栏抓不回来。现在拖动过程中就夹住,标题栏永远露在视口里。
391
+ - 加:双击标题栏回到右下角默认位置。
392
+
383
393
  ### 2.0.0
384
394
 
385
395
  - 修:`ISOLATION` 这个变量在 1.3.0 被误删,`/api/chat` 全部返回 500——那之后她其实一句都说不出来。这是这版最主要的问题。
@@ -57,6 +57,10 @@
57
57
  .opt-col input[type=range] { width: 100%; accent-color: #6aa9ff; }
58
58
  .opt-lab { font-size: 12px; color: #e2e8f1; margin-top: 2px; }
59
59
  .opt-note { font-size: 10.5px; line-height: 1.65; color: #6f7783; margin-top: 5px; }
60
+ .opt-btn { margin-top: 7px; padding: 6px 12px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 12px;
61
+ background: rgba(255,255,255,.07); color: #dfe4ec; border: 1px solid rgba(255,255,255,.12); transition: background .15s; }
62
+ .opt-btn:hover { background: rgba(255,255,255,.14); }
63
+ .opt-btn:disabled { opacity: .55; cursor: default; }
60
64
  #actions { display: flex; gap: 8px; flex: none; }
61
65
  #actions button { flex: 1; padding: 9px; border-radius: 10px; cursor: pointer; font: inherit;
62
66
  background: rgba(255,255,255,.07); color: #dfe4ec; border: 1px solid rgba(255,255,255,.1); transition: background .15s; }
package/assets/viewer.js CHANGED
@@ -44448,10 +44448,28 @@ void main(void)\r
44448
44448
  };
44449
44449
  const gapNote = document.createElement("div");
44450
44450
  gapNote.className = "opt-note";
44451
- gapNote.textContent = "\u591A\u4E45\u6CA1\u6709\u5BF9\u8BDD\u4E4B\u540E\uFF0C\u89D2\u8272\u4E3B\u52A8\u8BF4\u4E00\u53E5\u3002\u9009\u300C\u5173\u95ED\u300D\u5C31\u4E0D\u4F1A\u81EA\u5DF1\u5F00\u53E3\u3002";
44451
+ gapNote.textContent = "\u591A\u4E45\u6CA1\u6709\u5BF9\u8BDD\u4E4B\u540E\uFF0C\u89D2\u8272\u4E3B\u52A8\u8BF4\u4E00\u53E5\u3002\u5B9E\u9645\u4F1A\u6309\u8FD9\u4E2A\u6570\u4E0A\u4E0B\u6D6E\u52A8\uFF0C\u4E0D\u662F\u51C6\u70B9\uFF1B\u591C\u91CC 0 \u70B9\u5230 7 \u70B9\u4E0D\u5F00\u53E3\u3002\u9009\u300C\u5173\u95ED\u300D\u5C31\u4E0D\u4F1A\u81EA\u5DF1\u5F00\u53E3\u3002";
44452
+ const gapTry = document.createElement("button");
44453
+ gapTry.className = "opt-btn";
44454
+ gapTry.textContent = "\u8BA9\u5979\u73B0\u5728\u8BF4\u4E00\u53E5";
44455
+ gapTry.onclick = () => {
44456
+ gapTry.disabled = true;
44457
+ gapTry.textContent = "\u5728\u60F3\u2026";
44458
+ fetch(BASE + "/api/talk", { method: "POST" }).then((r2) => r2.json()).then((d2) => {
44459
+ gapTry.textContent = d2 && d2.ok ? "\u8BF4\u4E86" : "\u6CA1\u8BF4\u8BDD";
44460
+ }).catch(() => {
44461
+ gapTry.textContent = "\u6CA1\u8BF4\u8BDD";
44462
+ }).then(() => {
44463
+ setTimeout(() => {
44464
+ gapTry.disabled = false;
44465
+ gapTry.textContent = "\u8BA9\u5979\u73B0\u5728\u8BF4\u4E00\u53E5";
44466
+ }, 2400);
44467
+ });
44468
+ };
44452
44469
  gapWrap.appendChild(gapSlider);
44453
44470
  gapWrap.appendChild(gapLab);
44454
44471
  gapWrap.appendChild(gapNote);
44472
+ gapWrap.appendChild(gapTry);
44455
44473
  box.appendChild(gapWrap);
44456
44474
  const h3 = document.createElement("h3");
44457
44475
  h3.textContent = "\u8868\u60C5\u5305\uFF08\u6D4B\u8BD5\u529F\u80FD\uFF09";
package/lib/client.js CHANGED
@@ -122,13 +122,7 @@
122
122
  react.useEffect(() => localStorage.setItem('dsh-l2d-size', JSON.stringify(size)), [size]);
123
123
  react.useEffect(() => localStorage.setItem('dsh-l2d-pos', JSON.stringify(pos)), [pos]);
124
124
  react.useEffect(() => {
125
- setPos((p) => {
126
- const w = size.w;
127
- const h = open ? size.h : 38;
128
- const x = Math.max(-w + 90, Math.min(window.innerWidth - 90, p.x));
129
- const y = Math.max(-h + 50, Math.min(window.innerHeight - 50, p.y));
130
- return x === p.x && y === p.y ? p : { x, y };
131
- });
125
+ setPos((p) => clampPos(p, size.w, open ? size.h : 38));
132
126
  // eslint-disable-next-line react-hooks/exhaustive-deps
133
127
  }, []);
134
128
  react.useEffect(() => {
@@ -190,6 +184,18 @@
190
184
  .catch(() => setTitle('Live2D'));
191
185
  }, [nonce]);
192
186
 
187
+ // 卡片钉在右下角,位移后可能把标题栏拖出屏幕;这里保证标题栏始终露在视口里
188
+ const clampPos = (p, w, h) => {
189
+ const vw = window.innerWidth;
190
+ const vh = window.innerHeight;
191
+ const minX = 6 - (vw - 18 - w);
192
+ const minY = 6 - (vh - 18 - h);
193
+ return {
194
+ x: Math.round(Math.min(12, Math.max(minX, p.x))),
195
+ y: Math.round(Math.min(12, Math.max(minY, p.y))),
196
+ };
197
+ };
198
+
193
199
  // 拖动时盖一层全屏透明遮罩:既挡住 iframe 吃事件,也保证 pointermove 一定落在父窗口
194
200
  const beginDrag = (e, kind) => {
195
201
  if (e.button !== undefined && e.button !== 0) return;
@@ -219,7 +225,8 @@
219
225
  const hh = Math.max(200, Math.min(maxH, h0 + (sy - ev.clientY)));
220
226
  setSize({ w: Math.round(w), h: Math.round(hh) });
221
227
  } else {
222
- setPos({ x: Math.round(x0 + (ev.clientX - sx)), y: Math.round(y0 + (ev.clientY - sy)) });
228
+ const hNow = open ? h0 : 38;
229
+ setPos(clampPos({ x: x0 + (ev.clientX - sx), y: y0 + (ev.clientY - sy) }, w0, hNow));
223
230
  }
224
231
  };
225
232
 
@@ -295,7 +302,7 @@
295
302
  { className: 'dsh-l2d-card' + (open ? '' : ' collapsed'), style: cardStyle },
296
303
  h(
297
304
  'div',
298
- { className: 'dsh-l2d-head', onPointerDown: startMove },
305
+ { className: 'dsh-l2d-head', onPointerDown: startMove, onDoubleClick: () => setPos({ x: 0, y: 0 }) },
299
306
  h('span', { className: 'dsh-l2d-dot' }),
300
307
  h('span', { className: 'dsh-l2d-name' }, title),
301
308
  h(