dsh-zoo 1.3.0 → 1.3.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/desktop/main.js CHANGED
@@ -898,9 +898,9 @@ ipcMain.on('dsh-zoo:action', (event, payload) => {
898
898
  const id = shared.normalizeId(payload?.id)
899
899
  const action = typeof payload?.action === 'string' ? payload.action.trim().toLowerCase() : ''
900
900
  if (id === null || !shared.DESKTOP_ACTIONS.includes(action)) return
901
- const needsDevice = action === 'end-visit' || action === 'admit' || action === 'reject' || action === 'dismiss' ||
902
- // 票 54:看田与派它去偷都**必须有对象**——右键的是哪一户,就看/偷哪一户。
903
- action === 'farm-look' || action === 'farm-raid'
901
+ // 谁必须带对象只写一份(`shared.DEVICE_ACTIONS`):票 54 的两个农场动作曾经只加在这一行,
902
+ // 宿主那一侧的白名单没跟上,deviceId 到宿主就变成 null 了。
903
+ const needsDevice = shared.DEVICE_ACTIONS.includes(action)
904
904
  // `visit` 是「可能带对象」:从邻居面板点某一户就带 deviceId;没有就交给宿主随机挑一位
905
905
  // (HTTP 口的老行为)。needsDevice 的那几个动作则必须有对象,缺了直接拒绝。
906
906
  const deviceId = needsDevice || action === 'visit' ? shared.normalizeId(payload?.deviceId) : null
package/desktop/shared.js CHANGED
@@ -171,6 +171,16 @@
171
171
  * `farm-raid` 还可以带 `plots`(最多 50 个 pN);不带就让主人那边挑。
172
172
  */
173
173
  const FARM_LOOK_ACTIONS = ['farm-look', 'farm-raid']
174
+ /**
175
+ * **必须带对象**的动作:没有 `deviceId` 这条申请就没有意义,宁可整条拒掉。
176
+ *
177
+ * 只写一份、两边都用(`desktop/main.js` 的 IPC 窄口 + 这里的 helper 事件窄口)。
178
+ * 票 54 加 `farm-look` / `farm-raid` 时只改了 main.js 那一份,宿主这一份照旧只认
179
+ * 四个旧动作,于是 `deviceId` 在 helper → 宿主这一跳被削成 null:宿主回
180
+ * `bad-device-id`,桌面上就是「这位邻居已经不在桌面上了」——每一位邻居都这样。
181
+ * `visit` 不在这里:它是「可以带对象」,不带就由宿主随机挑一位。
182
+ */
183
+ const DEVICE_ACTIONS = ['end-visit', 'admit', 'reject', 'dismiss', ...FARM_LOOK_ACTIONS]
174
184
  // 只拼**动作名**数组:这里以前误把 `normalizeFarmLook` / `normalizeNeighborChips`
175
185
  // 两个函数也 concat 进来,还重复拼了一次 FARM_LOOK_ACTIONS。`.includes()` 看不出来,
176
186
  // 但白名单里混进函数是定时炸弹(序列化/遍历时就爆)。
@@ -2604,7 +2614,8 @@
2604
2614
  const action = typeof raw.action === 'string' ? raw.action.trim().toLowerCase() : ''
2605
2615
  if (!DESKTOP_ACTIONS.includes(action)) return { ok: false, error: 'bad-action' }
2606
2616
  if (id === null) return { ok: false, error: 'bad-id' }
2607
- const needsDevice = action === 'end-visit' || action === 'admit' || action === 'reject' || action === 'dismiss'
2617
+ // 谁必须有对象写在 DEVICE_ACTIONS 里:main.js 和这里共用同一份,免得再漂一次。
2618
+ const needsDevice = DEVICE_ACTIONS.includes(action)
2608
2619
  // `visit` 是「可能带对象」:邻居面板点某一户就带 deviceId;不带则由宿主随机挑。
2609
2620
  const deviceId = needsDevice || action === 'visit' ? normalizeId(raw.deviceId) : null
2610
2621
  if (needsDevice && deviceId === null) return { ok: false, error: 'bad-device-id' }
@@ -3109,6 +3120,7 @@
3109
3120
  FARM_MARKET_ACTIONS,
3110
3121
  FARM_LAND_ACTIONS,
3111
3122
  FARM_LOOK_ACTIONS,
3123
+ DEVICE_ACTIONS,
3112
3124
  normalizeFarmLook,
3113
3125
  normalizeNeighborChips,
3114
3126
  FARM_VISIT_ACTIONS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-zoo",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "局域网 DSH 宠物:互相看得见、互相串门、捎礼物,还能种地、偷菜、雇工和交易。 · LAN pets for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "index.js",