@andy.ian/dsh-homing 2.5.0 → 2.5.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/lib/mobile-patch.mjs +13 -8
- package/package.json +1 -1
package/lib/mobile-patch.mjs
CHANGED
|
@@ -220,13 +220,15 @@ export const MOBILE_JS = String.raw`(() => {
|
|
|
220
220
|
* 手机上没有那台电脑的屏幕,点了只会收到「已在其它设备打开」——纯噪音。
|
|
221
221
|
* 这里把它(主按钮和小箭头都算)接到文件页 /files。
|
|
222
222
|
*
|
|
223
|
-
*
|
|
224
|
-
* 它们排在分体按钮前面。「找第一个 aria-haspopup 的父容器」会认成子智能体
|
|
225
|
-
* 那个容器,于是点分体按钮时判定不命中、补丁失效(手机端历史 bug)。
|
|
226
|
-
* 所以:
|
|
223
|
+
* 定位:
|
|
227
224
|
* 1. 优先用 DSH 的稳定标记 data-open-target="directory"(分体按钮容器);
|
|
228
|
-
* 2.
|
|
229
|
-
*
|
|
225
|
+
* 2. 老版本没有标记时退回结构判断,但条件必须够严:
|
|
226
|
+
* 同容器恰好两个按钮,一个是纯图标主按钮且**里面是 <img> 应用图标**
|
|
227
|
+
* (分体按钮的真实特征),另一个是 aria-haspopup="menu" 的小箭头,
|
|
228
|
+
* 且整个容器在页头左上角。
|
|
229
|
+
* 2026-11-23 线上回归:新版 DSH 页头把「git 图标 + ⋯ 菜单」放在同一个
|
|
230
|
+
* 容器里(恰好两个按钮、后者 aria-haspopup=menu、前者纯 svg 图标),
|
|
231
|
+
* 只判断 svg 会把「⋯」劫持到文件页 —— 所以主按钮必须真是 <img> 图标。
|
|
230
232
|
*/
|
|
231
233
|
const splitHost = (node) => {
|
|
232
234
|
if (node === null || node === undefined || typeof node.closest !== 'function') return null
|
|
@@ -247,10 +249,13 @@ export const MOBILE_JS = String.raw`(() => {
|
|
|
247
249
|
if (main === null || chevron === null) return null
|
|
248
250
|
if (chevron.getAttribute('aria-haspopup') !== 'menu') return null
|
|
249
251
|
if ((main.textContent || '').trim() !== '') return null
|
|
250
|
-
|
|
252
|
+
// 分体按钮的主按钮是应用图标(<img>);git / ⋯ 这类页头按钮是 <svg>,不能混为一谈
|
|
253
|
+
if (main.querySelector('img') === null) return null
|
|
251
254
|
const rect = chevron.getBoundingClientRect()
|
|
252
255
|
if (rect.width === 0 || rect.height === 0) return null
|
|
253
|
-
if (rect.top >
|
|
256
|
+
if (rect.top > 120) return null
|
|
257
|
+
const hostRect = host.getBoundingClientRect()
|
|
258
|
+
if (hostRect.left > 160) return null
|
|
254
259
|
return host
|
|
255
260
|
}
|
|
256
261
|
|