dsh-live2dwaifu 1.0.1 → 1.0.2
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 +4 -2
- package/lib/client.js +51 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,9 @@ dsh plugin --profile desktop add dsh-live2dwaifu
|
|
|
35
35
|
|
|
36
36
|
### 位置和大小
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
按住**标题栏**能拖到屏幕任何地方。
|
|
39
|
+
**改大小**:卡片左上角那个小斜纹,往左上拖变大、往右下拖变小——卡片本身钉在屏幕右下角,所以动的是它的左上角(宽 200–720,高 220–视口高−80)。
|
|
40
|
+
位置、大小、背景、开合状态都记在本机,下次打开还是这样。
|
|
39
41
|
|
|
40
42
|
拖到一半跑到屏幕外了?关掉重开一次就回到默认位置。
|
|
41
43
|
|
|
@@ -272,7 +274,7 @@ curl -X POST http://127.0.0.1:<端口>/dsh-live2d/api/push \
|
|
|
272
274
|
先重启。还不来,看 profile 的 `package.json`:`dsh.profile.bundles` 和 `dependencies` 里都得有 `dsh-live2dwaifu`。手动拷进 `node_modules` 的不会自动登记。
|
|
273
275
|
|
|
274
276
|
**她只有半张脸 / 位置偏上**
|
|
275
|
-
|
|
277
|
+
模型画布比例跟卡片不一样。卡片是竖的,太宽或太扁的模型会被裁两边。拖左上角那个小斜纹改形状试试。
|
|
276
278
|
|
|
277
279
|
**导入了却不认得**
|
|
278
280
|
`.model3.json` 的层级选错了。选它隔壁那一层。
|
package/lib/client.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
transition:box-shadow .2s ease}
|
|
19
19
|
.dsh-l2d-card:hover{box-shadow:0 22px 58px rgba(0,0,0,.58)}
|
|
20
20
|
.dsh-l2d-card.collapsed{width:150px!important;height:38px!important}
|
|
21
|
-
.dsh-l2d-head{display:flex;align-items:center;gap:7px;padding:9px 11px;color:#a8b1bf;font-size:11px;
|
|
21
|
+
.dsh-l2d-head{display:flex;align-items:center;gap:7px;padding:9px 11px 9px 24px;color:#a8b1bf;font-size:11px;
|
|
22
22
|
letter-spacing:.4px;border-bottom:1px solid rgba(255,255,255,.06);user-select:none;flex:none;cursor:move;
|
|
23
23
|
background:linear-gradient(180deg,rgba(255,255,255,.045),rgba(255,255,255,0))}
|
|
24
24
|
.dsh-l2d-dot{width:7px;height:7px;border-radius:50%;background:#6aa9ff;flex:none;
|
|
@@ -43,10 +43,12 @@
|
|
|
43
43
|
transition:filter .15s ease}
|
|
44
44
|
.dsh-l2d-send:hover{filter:brightness(1.14)}
|
|
45
45
|
.dsh-l2d-send:active{filter:brightness(.96)}
|
|
46
|
-
.dsh-l2d-grip{position:absolute;
|
|
47
|
-
transition:opacity .15s ease;
|
|
48
|
-
background:repeating-linear-gradient(135deg,transparent 0 2px,rgba(255,255,255,.
|
|
49
|
-
.dsh-l2d-grip:hover{opacity:1}
|
|
46
|
+
.dsh-l2d-grip{position:absolute;left:0;top:0;width:20px;height:20px;cursor:nwse-resize;opacity:.4;
|
|
47
|
+
transition:opacity .15s ease,background .15s ease;border-radius:16px 0 8px 0;z-index:2;
|
|
48
|
+
background:repeating-linear-gradient(135deg,transparent 0 2px,rgba(255,255,255,.45) 2px 3px) no-repeat left top/10px 10px}
|
|
49
|
+
.dsh-l2d-grip:hover{opacity:1;background-color:rgba(255,255,255,.08)}
|
|
50
|
+
.dsh-l2d-card.resizing{cursor:nwse-resize;box-shadow:0 0 0 1px rgba(106,169,255,.45),0 22px 58px rgba(0,0,0,.6)}
|
|
51
|
+
.dsh-l2d-card.moving{cursor:move;box-shadow:0 0 0 1px rgba(106,169,255,.35),0 22px 58px rgba(0,0,0,.6)}
|
|
50
52
|
`;
|
|
51
53
|
|
|
52
54
|
function ensureCss() {
|
|
@@ -149,42 +151,67 @@
|
|
|
149
151
|
.catch(() => setTitle('Live2D'));
|
|
150
152
|
}, [nonce]);
|
|
151
153
|
|
|
154
|
+
// 拖动时把 iframe 的指针事件关掉,否则光标一进 iframe 父窗口就收不到事件,手感像粘住
|
|
155
|
+
const lockPointer = (on, cls, cardEl) => {
|
|
156
|
+
const f = ref.current;
|
|
157
|
+
if (f) f.style.pointerEvents = on ? 'none' : '';
|
|
158
|
+
if (cardEl && cardEl.classList) {
|
|
159
|
+
cardEl.classList.toggle('resizing', on && cls === 'resizing');
|
|
160
|
+
cardEl.classList.toggle('moving', on && cls === 'moving');
|
|
161
|
+
}
|
|
162
|
+
document.body.style.userSelect = on ? 'none' : '';
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const bindDrag = (move, cls, cardEl) => {
|
|
166
|
+
const up = () => {
|
|
167
|
+
window.removeEventListener('pointermove', move);
|
|
168
|
+
window.removeEventListener('pointerup', up);
|
|
169
|
+
window.removeEventListener('pointercancel', up);
|
|
170
|
+
lockPointer(false, cls, cardEl);
|
|
171
|
+
};
|
|
172
|
+
window.addEventListener('pointermove', move);
|
|
173
|
+
window.addEventListener('pointerup', up);
|
|
174
|
+
window.addEventListener('pointercancel', up);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// 卡片钉在右下角,所以只有左上角会动:往左上拖变大,往右下拖变小
|
|
152
178
|
const startDrag = (e) => {
|
|
153
179
|
e.preventDefault();
|
|
180
|
+
e.stopPropagation();
|
|
181
|
+
const cardEl = e.currentTarget.closest('.dsh-l2d-card');
|
|
154
182
|
const sx = e.clientX;
|
|
155
183
|
const sy = e.clientY;
|
|
156
184
|
const w0 = size.w;
|
|
157
185
|
const h0 = size.h;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const
|
|
186
|
+
lockPointer(true, 'resizing', cardEl);
|
|
187
|
+
bindDrag((ev) => {
|
|
188
|
+
const maxW = Math.min(720, Math.max(240, window.innerWidth - 60));
|
|
189
|
+
const maxH = Math.max(240, window.innerHeight - 80);
|
|
190
|
+
const w = Math.max(200, Math.min(maxW, w0 + (sx - ev.clientX)));
|
|
191
|
+
const hh = Math.max(220, Math.min(maxH, h0 + (sy - ev.clientY)));
|
|
161
192
|
setSize({ w: Math.round(w), h: Math.round(hh) });
|
|
162
|
-
};
|
|
163
|
-
const up = () => {
|
|
164
|
-
window.removeEventListener('pointermove', move);
|
|
165
|
-
window.removeEventListener('pointerup', up);
|
|
166
|
-
};
|
|
167
|
-
window.addEventListener('pointermove', move);
|
|
168
|
-
window.addEventListener('pointerup', up);
|
|
193
|
+
}, 'resizing', cardEl);
|
|
169
194
|
};
|
|
170
195
|
|
|
171
196
|
const startMove = (e) => {
|
|
172
197
|
if (e.button !== undefined && e.button !== 0) return;
|
|
198
|
+
const cardEl = e.currentTarget.closest('.dsh-l2d-card');
|
|
173
199
|
const sx = e.clientX;
|
|
174
200
|
const sy = e.clientY;
|
|
175
201
|
const x0 = pos.x;
|
|
176
202
|
const y0 = pos.y;
|
|
177
|
-
const
|
|
203
|
+
const w = size.w;
|
|
204
|
+
const hh = open ? size.h : 38;
|
|
205
|
+
lockPointer(true, 'moving', cardEl);
|
|
206
|
+
bindDrag((ev) => {
|
|
178
207
|
const nx = x0 + (ev.clientX - sx);
|
|
179
208
|
const ny = y0 + (ev.clientY - sy);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
186
|
-
window.addEventListener('pointermove', move);
|
|
187
|
-
window.addEventListener('pointerup', up);
|
|
209
|
+
// 至少留八十像素在视口里,别拖丢
|
|
210
|
+
setPos({
|
|
211
|
+
x: Math.round(Math.min(window.innerWidth - 80, Math.max(-w + 80, nx))),
|
|
212
|
+
y: Math.round(Math.min(window.innerHeight - 44, Math.max(-hh + 44, ny))),
|
|
213
|
+
});
|
|
214
|
+
}, 'moving', cardEl);
|
|
188
215
|
};
|
|
189
216
|
const noDrag = (e) => e.stopPropagation();
|
|
190
217
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-live2dwaifu",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "给 DSH 网页右下角请一个 Live2D 角色:会眨眼、会呼吸、视线跟着鼠标、点她有反应、说话时嘴动、心情变了眉毛跟着动。模型不用内置——谁装谁放自己的文件夹;支持自定义 .exp3.json 表情和 .motion3.json 动作,卡片能拖能缩,背景可换。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|