dsh-live2dwaifu 2.0.0 → 2.0.1
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 +5 -0
- package/lib/client.js +16 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -380,6 +380,11 @@ curl -X POST http://127.0.0.1:<端口>/dsh-live2d/api/push \
|
|
|
380
380
|
|
|
381
381
|
版本号怎么走:动了功能和结构就抬第二位(1.2.0),只补洞和小修就抬第三位(1.2.1)。
|
|
382
382
|
|
|
383
|
+
### 2.0.1
|
|
384
|
+
|
|
385
|
+
- 修:拖动时没限制边界,卡片能被推到屏幕外,标题栏抓不回来。现在拖动过程中就夹住,标题栏永远露在视口里。
|
|
386
|
+
- 加:双击标题栏回到右下角默认位置。
|
|
387
|
+
|
|
383
388
|
### 2.0.0
|
|
384
389
|
|
|
385
390
|
- 修:`ISOLATION` 这个变量在 1.3.0 被误删,`/api/chat` 全部返回 500——那之后她其实一句都说不出来。这是这版最主要的问题。
|
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
|
-
|
|
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(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-live2dwaifu",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "给 DSH 网页右下角请一个 Live2D 角色:会眨眼、会呼吸、视线跟着鼠标、点她有反应、说话时嘴动、心情变了眉毛跟着动。模型不用内置——谁装谁放自己的文件夹;支持自定义 .exp3.json 表情和 .motion3.json 动作,卡片能拖能缩,背景可换。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|