dsh-gufa-code 1.3.7 → 1.3.8
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/client.js +17 -112
- package/docs/KNOWN-PITFALLS.md +26 -19
- package/package.json +1 -1
- package/src/client/00-core.js +8 -6
- package/src/client/50-panels.js +6 -6
- package/src/client/59-dialog-layer.js +3 -1
- package/src/client/99-main.js +0 -10
- package/src/client/59-popup-layer.js +0 -86
package/client.js
CHANGED
|
@@ -1105,15 +1105,14 @@ html[data-gufa-float] #root [data-gufa-dock],
|
|
|
1105
1105
|
html[data-gufa-float] #root .gufa-overlay-root *,
|
|
1106
1106
|
html[data-gufa-float] #root [data-gufa-dock] *{visibility:visible!important}
|
|
1107
1107
|
/* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
|
|
1108
|
-
html[data-gufa-ide] .dsh-pet-root{z-index:
|
|
1109
|
-
/*
|
|
1110
|
-
html[data-gufa-popup] .gufa-overlay-root{z-index:2147483300!important}
|
|
1111
|
-
/* 外部弹窗(DSH 设置等)打开时:停靠会话与桌宠降到弹窗之下,保证弹窗完整可点可关 */
|
|
1108
|
+
html[data-gufa-ide] .dsh-pet-root{z-index:2147483050!important}
|
|
1109
|
+
/* 外部弹窗(DSH 设置等)打开时:停靠会话、古法 portal、桌宠全部降到官方弹窗之下 */
|
|
1112
1110
|
html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
|
|
1111
|
+
html[data-gufa-external-modal] #gufa-portal-root{z-index:1!important}
|
|
1113
1112
|
html[data-gufa-external-modal] .dsh-pet-root{z-index:2!important}
|
|
1114
1113
|
html[data-gufa-external-modal] div[data-dsh-pet-root]{z-index:2!important}
|
|
1115
1114
|
/* 桌宠(@linxin666/dsh-pet)在 IDE 模式提到覆盖层之上,避免被古法编程面板遮住 */
|
|
1116
|
-
html[data-gufa-ide] div[data-dsh-pet-root]{position:fixed;inset:0;z-index:
|
|
1115
|
+
html[data-gufa-ide] div[data-dsh-pet-root]{position:fixed;inset:0;z-index:2147483050;pointer-events:none}
|
|
1117
1116
|
html[data-gufa-ide] div[data-dsh-pet-root] *{pointer-events:auto}
|
|
1118
1117
|
.gufa-backdrop-page{position:absolute;inset:0;transition:background-color 200ms linear}
|
|
1119
1118
|
.gufa-backdrop-glow{position:absolute;inset:0;pointer-events:none;
|
|
@@ -1175,7 +1174,10 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1175
1174
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1176
1175
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1177
1176
|
/* 官方同款 body 级 portal 容器(弹窗渲染到这里,天然在停靠会话之上) */
|
|
1178
|
-
|
|
1177
|
+
/* 层级契约(见 docs/KNOWN-PITFALLS.md):
|
|
1178
|
+
1 = 古法覆盖层;2147483040 = 右侧停靠会话;2147483060 = 官方 DSH 菜单/弹窗;
|
|
1179
|
+
2147483100 = 古法 portal(所有弹窗/菜单);2147483200 = toast。 */
|
|
1180
|
+
#gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none}
|
|
1179
1181
|
#gufa-portal-root>*{pointer-events:auto}
|
|
1180
1182
|
/* 摸鱼模式:App 窗口选择器 */
|
|
1181
1183
|
.gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
|
|
@@ -6829,7 +6831,7 @@ G.Explorer = function Explorer(props) {
|
|
|
6829
6831
|
setMenu(null)
|
|
6830
6832
|
fn()
|
|
6831
6833
|
}
|
|
6832
|
-
return h(
|
|
6834
|
+
return G.portal(h(
|
|
6833
6835
|
'div',
|
|
6834
6836
|
{
|
|
6835
6837
|
className: 'gufa-menu',
|
|
@@ -6862,7 +6864,7 @@ G.Explorer = function Explorer(props) {
|
|
|
6862
6864
|
single
|
|
6863
6865
|
? h(G.MenuItem, { icon: 'trash', label: t('explorer.delete'), danger: true, onClick: closeAnd(() => props.onDelete?.(menu.path)) })
|
|
6864
6866
|
: null,
|
|
6865
|
-
)
|
|
6867
|
+
))
|
|
6866
6868
|
})(),
|
|
6867
6869
|
)
|
|
6868
6870
|
}
|
|
@@ -7252,7 +7254,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
7252
7254
|
),
|
|
7253
7255
|
headMenu === null
|
|
7254
7256
|
? null
|
|
7255
|
-
: h(
|
|
7257
|
+
: G.portal(h(
|
|
7256
7258
|
'div',
|
|
7257
7259
|
{
|
|
7258
7260
|
className: 'gufa-menu',
|
|
@@ -7291,10 +7293,10 @@ G.GitPanel = function GitPanel(props) {
|
|
|
7291
7293
|
label: t('graph.open'),
|
|
7292
7294
|
onClick: menuAction(() => props.onOpenGraph?.()),
|
|
7293
7295
|
}),
|
|
7294
|
-
),
|
|
7296
|
+
)),
|
|
7295
7297
|
rowMenu === null
|
|
7296
7298
|
? null
|
|
7297
|
-
: h(
|
|
7299
|
+
: G.portal(h(
|
|
7298
7300
|
'div',
|
|
7299
7301
|
{
|
|
7300
7302
|
className: 'gufa-menu',
|
|
@@ -7322,7 +7324,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
7322
7324
|
})
|
|
7323
7325
|
: null,
|
|
7324
7326
|
h(G.MenuItem, { icon: 'files', label: t('git.copyPath'), onClick: menuAction(() => copyText(rowMenu.change.path)) }),
|
|
7325
|
-
),
|
|
7327
|
+
)),
|
|
7326
7328
|
)
|
|
7327
7329
|
}
|
|
7328
7330
|
|
|
@@ -8118,7 +8120,9 @@ G.installDialogLayerWatch = function installDialogLayerWatch(ctx) {
|
|
|
8118
8120
|
const isExternalDialog = (el) => {
|
|
8119
8121
|
if (!(el instanceof Element) || typeof el.closest !== 'function') return false
|
|
8120
8122
|
if (el.getAttribute('role') !== 'dialog' || el.getAttribute('aria-modal') !== 'true') return false
|
|
8121
|
-
|
|
8123
|
+
if (el.closest('.gufa-root') !== null) return false
|
|
8124
|
+
if (el.closest('#gufa-portal-root') !== null) return false
|
|
8125
|
+
return true
|
|
8122
8126
|
}
|
|
8123
8127
|
|
|
8124
8128
|
const sync = () => {
|
|
@@ -8162,95 +8166,6 @@ G.installDialogLayerWatch = function installDialogLayerWatch(ctx) {
|
|
|
8162
8166
|
}
|
|
8163
8167
|
|
|
8164
8168
|
|
|
8165
|
-
/* ─────────────────────── 59-popup-layer.js ─────────────────────── */
|
|
8166
|
-
/**
|
|
8167
|
-
* 59-popup-layer:弹窗/菜单层级修正。
|
|
8168
|
-
*
|
|
8169
|
-
* 背景(踩坑记录,见 docs/KNOWN-PITFALLS.md):
|
|
8170
|
-
* 古法编程的界面都在 `.gufa-overlay-root`(z-index:1)这个层叠上下文里,而右侧停靠的
|
|
8171
|
-
* 官方会话根节点是 body 级 fixed、z-index 2147483040。任何在 root 内部弹出的
|
|
8172
|
-
* modal / menu / popover,如果只设自己的 z-index,都会被困在 root 的上下文里,
|
|
8173
|
-
* 被停靠会话盖住(表现为「弹窗被右侧聊天挡一半、点不到关闭」)。
|
|
8174
|
-
*
|
|
8175
|
-
* 修法:检测 root 内是否出现 popup,出现时给 html 加 `data-gufa-popup`,
|
|
8176
|
-
* 由 CSS 把整个 overlay root 临时抬到停靠会话之上。
|
|
8177
|
-
*/
|
|
8178
|
-
|
|
8179
|
-
G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
|
|
8180
|
-
if (typeof document === 'undefined') return () => {}
|
|
8181
|
-
const ATTR = 'data-gufa-popup'
|
|
8182
|
-
const SELECTOR = [
|
|
8183
|
-
'[role="menu"]',
|
|
8184
|
-
'[role="listbox"]',
|
|
8185
|
-
'[role="dialog"]',
|
|
8186
|
-
'.gufa-modal',
|
|
8187
|
-
'.gufa-float-backdrop',
|
|
8188
|
-
'.gufa-branch-dialog-backdrop',
|
|
8189
|
-
'.gufa-session-backdrop',
|
|
8190
|
-
'.gufa-shortcuts-backdrop',
|
|
8191
|
-
].join(',')
|
|
8192
|
-
|
|
8193
|
-
/* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
|
|
8194
|
-
在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
|
|
8195
|
-
它自己的层叠上下文。 */
|
|
8196
|
-
let liftedNodes = []
|
|
8197
|
-
const lift = (open) => {
|
|
8198
|
-
try {
|
|
8199
|
-
if (open) {
|
|
8200
|
-
if (liftedNodes.length > 0) return
|
|
8201
|
-
let node = document.querySelector('.gufa-overlay-root')
|
|
8202
|
-
if (node === null) return
|
|
8203
|
-
while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
|
|
8204
|
-
if (node.parentElement !== document.body) return
|
|
8205
|
-
const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
|
|
8206
|
-
node.style.zIndex = '2147483300'
|
|
8207
|
-
if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
|
|
8208
|
-
liftedNodes.push(saved)
|
|
8209
|
-
if (node.parentElement !== document.body) return
|
|
8210
|
-
} else {
|
|
8211
|
-
for (const saved of liftedNodes) {
|
|
8212
|
-
saved.node.style.zIndex = saved.zIndex
|
|
8213
|
-
saved.node.style.position = saved.position
|
|
8214
|
-
}
|
|
8215
|
-
liftedNodes = []
|
|
8216
|
-
}
|
|
8217
|
-
} catch {
|
|
8218
|
-
/* ignore */
|
|
8219
|
-
}
|
|
8220
|
-
}
|
|
8221
|
-
|
|
8222
|
-
const sync = () => {
|
|
8223
|
-
try {
|
|
8224
|
-
const root = document.querySelector('.gufa-root')
|
|
8225
|
-
const popup = root === null ? null : root.querySelector(SELECTOR)
|
|
8226
|
-
const open = popup !== null
|
|
8227
|
-
lift(open)
|
|
8228
|
-
if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
|
|
8229
|
-
if (open) document.documentElement.setAttribute(ATTR, '1')
|
|
8230
|
-
else document.documentElement.removeAttribute(ATTR)
|
|
8231
|
-
} catch {
|
|
8232
|
-
/* ignore */
|
|
8233
|
-
}
|
|
8234
|
-
}
|
|
8235
|
-
|
|
8236
|
-
let observer = null
|
|
8237
|
-
try {
|
|
8238
|
-
observer = new MutationObserver(sync)
|
|
8239
|
-
observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'data-state', 'aria-hidden'] })
|
|
8240
|
-
} catch {
|
|
8241
|
-
observer = null
|
|
8242
|
-
}
|
|
8243
|
-
sync()
|
|
8244
|
-
const timer = window.setInterval(sync, 400)
|
|
8245
|
-
return () => {
|
|
8246
|
-
if (observer !== null) observer.disconnect()
|
|
8247
|
-
window.clearInterval(timer)
|
|
8248
|
-
lift(false)
|
|
8249
|
-
document.documentElement.removeAttribute(ATTR)
|
|
8250
|
-
}
|
|
8251
|
-
}
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
8169
|
/* ─────────────────────── 60-dock.js ─────────────────────── */
|
|
8255
8170
|
/**
|
|
8256
8171
|
* 60-dock:把官方 DSH 会话面板「停靠」进古法编程右侧的 AI 栏。
|
|
@@ -12438,16 +12353,6 @@ const GUFA_PLUGIN = {
|
|
|
12438
12353
|
window.setTimeout(cleanStaleSidebarLayouts, 1500)
|
|
12439
12354
|
window.setTimeout(cleanStaleSidebarLayouts, 5000)
|
|
12440
12355
|
|
|
12441
|
-
// 弹窗/菜单打开时把覆盖层整体抬到右侧停靠会话之上(否则会被盖住)
|
|
12442
|
-
try {
|
|
12443
|
-
if (typeof G.installPopupLayerWatch === 'function') {
|
|
12444
|
-
const disposePopupWatch = G.installPopupLayerWatch(ctx)
|
|
12445
|
-
if (typeof disposePopupWatch === 'function') ctx.effect(() => disposePopupWatch, 'gufa-code: popup layer watch')
|
|
12446
|
-
}
|
|
12447
|
-
} catch (error) {
|
|
12448
|
-
console.error('[gufa-code] 安装弹窗层级监听失败', error)
|
|
12449
|
-
}
|
|
12450
|
-
|
|
12451
12356
|
// 外部弹窗(设置等)打开时降低停靠层,避免遮挡弹窗导致关不掉
|
|
12452
12357
|
try {
|
|
12453
12358
|
if (typeof G.installDialogLayerWatch === 'function') {
|
package/docs/KNOWN-PITFALLS.md
CHANGED
|
@@ -2,25 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
> 这份清单记录已经犯过、并且容易再犯的错误。加新功能前先扫一遍。
|
|
4
4
|
|
|
5
|
-
## 1.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
1.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
## 1. 弹窗/菜单层级:只有一个正确做法(反复踩过多次,最终定案)
|
|
6
|
+
|
|
7
|
+
**现象**:弹窗被右侧「古法 AI」聊天栏压住、只显示一半、关闭按钮点不到;或者反过来把官方设置/会话弹窗盖住。
|
|
8
|
+
|
|
9
|
+
**根因**:古法编程界面在 `.gufa-overlay-root`(z-index:1)这个层叠上下文里;右侧停靠的官方会话根节点是 body 级
|
|
10
|
+
`position:fixed; z-index:2147483040`。任何渲染在 root 内部的弹窗/菜单,z-index 写多大都出不了 root 的上下文,
|
|
11
|
+
必然被会话盖住。
|
|
12
|
+
|
|
13
|
+
**定案(不要再发明新写法)**:
|
|
14
|
+
|
|
15
|
+
1. 所有浮层(modal / 菜单 / 列表 / 确认框)一律用 `G.portal(node)` 渲染到 `#gufa-portal-root`(body 级,官方同款 portal 机制);
|
|
16
|
+
- 新增浮层时**必须**用 `G.portal(...)` 包裹,否则一定踩坑;
|
|
17
|
+
- 模块内联菜单(`50-panels.js` 的 `.gufa-menu`)已经全部 portal,坐标本来就是 client 坐标 + `position:fixed`。
|
|
18
|
+
2. 层级契约(见 `00-core.js` 注释,按顺序递增):
|
|
19
|
+
- `1`:`.gufa-overlay-root`(IDE 本体)
|
|
20
|
+
- `2147483040`:右侧停靠会话
|
|
21
|
+
- `2147483050`:桌宠
|
|
22
|
+
- `2147483060`:官方 DSH 菜单/弹窗(`html[data-gufa-ide] [role=...]` 规则)
|
|
23
|
+
- `2147483100`:`#gufa-portal-root`(古法所有弹窗/菜单)
|
|
24
|
+
- `2147483200`:toast
|
|
25
|
+
3. 官方弹窗打开时(`59-dialog-layer.js` 检测 body 级 `[role=dialog][aria-modal=true]`):
|
|
26
|
+
`html[data-gufa-external-modal]` 把停靠会话降到 2、`#gufa-portal-root` 降到 1,保证官方弹窗永远在最上面。
|
|
27
|
+
4. **禁止**:抬高 `.gufa-overlay-root` 或它的祖先来做层级修正(历史补丁,已删除,最容易造成“弹窗层级混乱”)。
|
|
28
|
+
|
|
29
|
+
**验收方式**:改完浮层后,在有右侧会话、且 IDE 里有打开文件的情况下,逐一点一遍:
|
|
30
|
+
资源管理器右键菜单 / Git 菜单 / 摸鱼列表 / 切换会话 / 工作区切换 / 设置弹窗,确认都能完整显示、能点、能关。
|
|
24
31
|
|
|
25
32
|
## 2. macOS 屏幕录制权限 + 悬浮层 helper
|
|
26
33
|
|
package/package.json
CHANGED
package/src/client/00-core.js
CHANGED
|
@@ -1097,15 +1097,14 @@ html[data-gufa-float] #root [data-gufa-dock],
|
|
|
1097
1097
|
html[data-gufa-float] #root .gufa-overlay-root *,
|
|
1098
1098
|
html[data-gufa-float] #root [data-gufa-dock] *{visibility:visible!important}
|
|
1099
1099
|
/* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
|
|
1100
|
-
html[data-gufa-ide] .dsh-pet-root{z-index:
|
|
1101
|
-
/*
|
|
1102
|
-
html[data-gufa-popup] .gufa-overlay-root{z-index:2147483300!important}
|
|
1103
|
-
/* 外部弹窗(DSH 设置等)打开时:停靠会话与桌宠降到弹窗之下,保证弹窗完整可点可关 */
|
|
1100
|
+
html[data-gufa-ide] .dsh-pet-root{z-index:2147483050!important}
|
|
1101
|
+
/* 外部弹窗(DSH 设置等)打开时:停靠会话、古法 portal、桌宠全部降到官方弹窗之下 */
|
|
1104
1102
|
html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
|
|
1103
|
+
html[data-gufa-external-modal] #gufa-portal-root{z-index:1!important}
|
|
1105
1104
|
html[data-gufa-external-modal] .dsh-pet-root{z-index:2!important}
|
|
1106
1105
|
html[data-gufa-external-modal] div[data-dsh-pet-root]{z-index:2!important}
|
|
1107
1106
|
/* 桌宠(@linxin666/dsh-pet)在 IDE 模式提到覆盖层之上,避免被古法编程面板遮住 */
|
|
1108
|
-
html[data-gufa-ide] div[data-dsh-pet-root]{position:fixed;inset:0;z-index:
|
|
1107
|
+
html[data-gufa-ide] div[data-dsh-pet-root]{position:fixed;inset:0;z-index:2147483050;pointer-events:none}
|
|
1109
1108
|
html[data-gufa-ide] div[data-dsh-pet-root] *{pointer-events:auto}
|
|
1110
1109
|
.gufa-backdrop-page{position:absolute;inset:0;transition:background-color 200ms linear}
|
|
1111
1110
|
.gufa-backdrop-glow{position:absolute;inset:0;pointer-events:none;
|
|
@@ -1167,7 +1166,10 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1167
1166
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1168
1167
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1169
1168
|
/* 官方同款 body 级 portal 容器(弹窗渲染到这里,天然在停靠会话之上) */
|
|
1170
|
-
|
|
1169
|
+
/* 层级契约(见 docs/KNOWN-PITFALLS.md):
|
|
1170
|
+
1 = 古法覆盖层;2147483040 = 右侧停靠会话;2147483060 = 官方 DSH 菜单/弹窗;
|
|
1171
|
+
2147483100 = 古法 portal(所有弹窗/菜单);2147483200 = toast。 */
|
|
1172
|
+
#gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none}
|
|
1171
1173
|
#gufa-portal-root>*{pointer-events:auto}
|
|
1172
1174
|
/* 摸鱼模式:App 窗口选择器 */
|
|
1173
1175
|
.gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
|
package/src/client/50-panels.js
CHANGED
|
@@ -409,7 +409,7 @@ G.Explorer = function Explorer(props) {
|
|
|
409
409
|
setMenu(null)
|
|
410
410
|
fn()
|
|
411
411
|
}
|
|
412
|
-
return h(
|
|
412
|
+
return G.portal(h(
|
|
413
413
|
'div',
|
|
414
414
|
{
|
|
415
415
|
className: 'gufa-menu',
|
|
@@ -442,7 +442,7 @@ G.Explorer = function Explorer(props) {
|
|
|
442
442
|
single
|
|
443
443
|
? h(G.MenuItem, { icon: 'trash', label: t('explorer.delete'), danger: true, onClick: closeAnd(() => props.onDelete?.(menu.path)) })
|
|
444
444
|
: null,
|
|
445
|
-
)
|
|
445
|
+
))
|
|
446
446
|
})(),
|
|
447
447
|
)
|
|
448
448
|
}
|
|
@@ -832,7 +832,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
832
832
|
),
|
|
833
833
|
headMenu === null
|
|
834
834
|
? null
|
|
835
|
-
: h(
|
|
835
|
+
: G.portal(h(
|
|
836
836
|
'div',
|
|
837
837
|
{
|
|
838
838
|
className: 'gufa-menu',
|
|
@@ -871,10 +871,10 @@ G.GitPanel = function GitPanel(props) {
|
|
|
871
871
|
label: t('graph.open'),
|
|
872
872
|
onClick: menuAction(() => props.onOpenGraph?.()),
|
|
873
873
|
}),
|
|
874
|
-
),
|
|
874
|
+
)),
|
|
875
875
|
rowMenu === null
|
|
876
876
|
? null
|
|
877
|
-
: h(
|
|
877
|
+
: G.portal(h(
|
|
878
878
|
'div',
|
|
879
879
|
{
|
|
880
880
|
className: 'gufa-menu',
|
|
@@ -902,7 +902,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
902
902
|
})
|
|
903
903
|
: null,
|
|
904
904
|
h(G.MenuItem, { icon: 'files', label: t('git.copyPath'), onClick: menuAction(() => copyText(rowMenu.change.path)) }),
|
|
905
|
-
),
|
|
905
|
+
)),
|
|
906
906
|
)
|
|
907
907
|
}
|
|
908
908
|
|
|
@@ -13,7 +13,9 @@ G.installDialogLayerWatch = function installDialogLayerWatch(ctx) {
|
|
|
13
13
|
const isExternalDialog = (el) => {
|
|
14
14
|
if (!(el instanceof Element) || typeof el.closest !== 'function') return false
|
|
15
15
|
if (el.getAttribute('role') !== 'dialog' || el.getAttribute('aria-modal') !== 'true') return false
|
|
16
|
-
|
|
16
|
+
if (el.closest('.gufa-root') !== null) return false
|
|
17
|
+
if (el.closest('#gufa-portal-root') !== null) return false
|
|
18
|
+
return true
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const sync = () => {
|
package/src/client/99-main.js
CHANGED
|
@@ -352,16 +352,6 @@ const GUFA_PLUGIN = {
|
|
|
352
352
|
window.setTimeout(cleanStaleSidebarLayouts, 1500)
|
|
353
353
|
window.setTimeout(cleanStaleSidebarLayouts, 5000)
|
|
354
354
|
|
|
355
|
-
// 弹窗/菜单打开时把覆盖层整体抬到右侧停靠会话之上(否则会被盖住)
|
|
356
|
-
try {
|
|
357
|
-
if (typeof G.installPopupLayerWatch === 'function') {
|
|
358
|
-
const disposePopupWatch = G.installPopupLayerWatch(ctx)
|
|
359
|
-
if (typeof disposePopupWatch === 'function') ctx.effect(() => disposePopupWatch, 'gufa-code: popup layer watch')
|
|
360
|
-
}
|
|
361
|
-
} catch (error) {
|
|
362
|
-
console.error('[gufa-code] 安装弹窗层级监听失败', error)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
355
|
// 外部弹窗(设置等)打开时降低停靠层,避免遮挡弹窗导致关不掉
|
|
366
356
|
try {
|
|
367
357
|
if (typeof G.installDialogLayerWatch === 'function') {
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 59-popup-layer:弹窗/菜单层级修正。
|
|
3
|
-
*
|
|
4
|
-
* 背景(踩坑记录,见 docs/KNOWN-PITFALLS.md):
|
|
5
|
-
* 古法编程的界面都在 `.gufa-overlay-root`(z-index:1)这个层叠上下文里,而右侧停靠的
|
|
6
|
-
* 官方会话根节点是 body 级 fixed、z-index 2147483040。任何在 root 内部弹出的
|
|
7
|
-
* modal / menu / popover,如果只设自己的 z-index,都会被困在 root 的上下文里,
|
|
8
|
-
* 被停靠会话盖住(表现为「弹窗被右侧聊天挡一半、点不到关闭」)。
|
|
9
|
-
*
|
|
10
|
-
* 修法:检测 root 内是否出现 popup,出现时给 html 加 `data-gufa-popup`,
|
|
11
|
-
* 由 CSS 把整个 overlay root 临时抬到停靠会话之上。
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
|
|
15
|
-
if (typeof document === 'undefined') return () => {}
|
|
16
|
-
const ATTR = 'data-gufa-popup'
|
|
17
|
-
const SELECTOR = [
|
|
18
|
-
'[role="menu"]',
|
|
19
|
-
'[role="listbox"]',
|
|
20
|
-
'[role="dialog"]',
|
|
21
|
-
'.gufa-modal',
|
|
22
|
-
'.gufa-float-backdrop',
|
|
23
|
-
'.gufa-branch-dialog-backdrop',
|
|
24
|
-
'.gufa-session-backdrop',
|
|
25
|
-
'.gufa-shortcuts-backdrop',
|
|
26
|
-
].join(',')
|
|
27
|
-
|
|
28
|
-
/* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
|
|
29
|
-
在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
|
|
30
|
-
它自己的层叠上下文。 */
|
|
31
|
-
let liftedNodes = []
|
|
32
|
-
const lift = (open) => {
|
|
33
|
-
try {
|
|
34
|
-
if (open) {
|
|
35
|
-
if (liftedNodes.length > 0) return
|
|
36
|
-
let node = document.querySelector('.gufa-overlay-root')
|
|
37
|
-
if (node === null) return
|
|
38
|
-
while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
|
|
39
|
-
if (node.parentElement !== document.body) return
|
|
40
|
-
const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
|
|
41
|
-
node.style.zIndex = '2147483300'
|
|
42
|
-
if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
|
|
43
|
-
liftedNodes.push(saved)
|
|
44
|
-
if (node.parentElement !== document.body) return
|
|
45
|
-
} else {
|
|
46
|
-
for (const saved of liftedNodes) {
|
|
47
|
-
saved.node.style.zIndex = saved.zIndex
|
|
48
|
-
saved.node.style.position = saved.position
|
|
49
|
-
}
|
|
50
|
-
liftedNodes = []
|
|
51
|
-
}
|
|
52
|
-
} catch {
|
|
53
|
-
/* ignore */
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const sync = () => {
|
|
58
|
-
try {
|
|
59
|
-
const root = document.querySelector('.gufa-root')
|
|
60
|
-
const popup = root === null ? null : root.querySelector(SELECTOR)
|
|
61
|
-
const open = popup !== null
|
|
62
|
-
lift(open)
|
|
63
|
-
if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
|
|
64
|
-
if (open) document.documentElement.setAttribute(ATTR, '1')
|
|
65
|
-
else document.documentElement.removeAttribute(ATTR)
|
|
66
|
-
} catch {
|
|
67
|
-
/* ignore */
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let observer = null
|
|
72
|
-
try {
|
|
73
|
-
observer = new MutationObserver(sync)
|
|
74
|
-
observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'data-state', 'aria-hidden'] })
|
|
75
|
-
} catch {
|
|
76
|
-
observer = null
|
|
77
|
-
}
|
|
78
|
-
sync()
|
|
79
|
-
const timer = window.setInterval(sync, 400)
|
|
80
|
-
return () => {
|
|
81
|
-
if (observer !== null) observer.disconnect()
|
|
82
|
-
window.clearInterval(timer)
|
|
83
|
-
lift(false)
|
|
84
|
-
document.documentElement.removeAttribute(ATTR)
|
|
85
|
-
}
|
|
86
|
-
}
|