dsh-gufa-code 1.1.7 → 1.1.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 +74 -0
- package/package.json +1 -1
- package/src/client/00-core.js +4 -0
- package/src/client/59-dialog-layer.js +57 -0
- package/src/client/99-main.js +10 -0
package/client.js
CHANGED
|
@@ -1029,6 +1029,10 @@ G.CSS = `
|
|
|
1029
1029
|
.gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
|
1030
1030
|
/* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
|
|
1031
1031
|
html[data-gufa-ide] .dsh-pet-root{z-index:2147483400!important}
|
|
1032
|
+
/* 外部弹窗(DSH 设置等)打开时:停靠会话与桌宠降到弹窗之下,保证弹窗完整可点可关 */
|
|
1033
|
+
html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
|
|
1034
|
+
html[data-gufa-external-modal] .dsh-pet-root{z-index:2!important}
|
|
1035
|
+
html[data-gufa-external-modal] div[data-dsh-pet-root]{z-index:2!important}
|
|
1032
1036
|
/* 桌宠(@linxin666/dsh-pet)在 IDE 模式提到覆盖层之上,避免被古法编程面板遮住 */
|
|
1033
1037
|
html[data-gufa-ide] div[data-dsh-pet-root]{position:fixed;inset:0;z-index:2147483400;pointer-events:none}
|
|
1034
1038
|
html[data-gufa-ide] div[data-dsh-pet-root] *{pointer-events:auto}
|
|
@@ -7994,6 +7998,66 @@ G.installChatFilePaste = function installChatFilePaste(ctx) {
|
|
|
7994
7998
|
}
|
|
7995
7999
|
|
|
7996
8000
|
|
|
8001
|
+
/* ─────────────────────── 59-dialog-layer.js ─────────────────────── */
|
|
8002
|
+
/**
|
|
8003
|
+
* 59-dialog-layer:外部门户弹窗(DSH 官方设置等)打开时,把古法编程的会话停靠层降到弹窗之下。
|
|
8004
|
+
*
|
|
8005
|
+
* 背景:官方 dialog 通过 createPortal 挂到 document.body(`role="dialog" aria-modal="true"`),
|
|
8006
|
+
* 而停靠的官方会话根节点被 inline 设了 z-index 2147483040,会盖住弹窗右侧、导致关闭按钮点不到。
|
|
8007
|
+
* 这里只观察「外部 dialog」,不是我们自己的弹窗(在 `.gufa-root` 内),开关 html 属性给 CSS 用。
|
|
8008
|
+
*/
|
|
8009
|
+
|
|
8010
|
+
G.installDialogLayerWatch = function installDialogLayerWatch(ctx) {
|
|
8011
|
+
if (typeof document === 'undefined') return () => {}
|
|
8012
|
+
const ATTR = 'data-gufa-external-modal'
|
|
8013
|
+
|
|
8014
|
+
const isExternalDialog = (el) => {
|
|
8015
|
+
if (!(el instanceof Element) || typeof el.closest !== 'function') return false
|
|
8016
|
+
if (el.getAttribute('role') !== 'dialog' || el.getAttribute('aria-modal') !== 'true') return false
|
|
8017
|
+
return el.closest('.gufa-root') === null
|
|
8018
|
+
}
|
|
8019
|
+
|
|
8020
|
+
const sync = () => {
|
|
8021
|
+
try {
|
|
8022
|
+
const dialogs = document.querySelectorAll('[role="dialog"][aria-modal="true"]')
|
|
8023
|
+
let open = false
|
|
8024
|
+
for (const dialog of dialogs) {
|
|
8025
|
+
if (isExternalDialog(dialog)) {
|
|
8026
|
+
open = true
|
|
8027
|
+
break
|
|
8028
|
+
}
|
|
8029
|
+
}
|
|
8030
|
+
if (document.documentElement.getAttribute(ATTR) === (open ? '1' : null)) return
|
|
8031
|
+
if (open) document.documentElement.setAttribute(ATTR, '1')
|
|
8032
|
+
else document.documentElement.removeAttribute(ATTR)
|
|
8033
|
+
} catch {
|
|
8034
|
+
/* ignore */
|
|
8035
|
+
}
|
|
8036
|
+
}
|
|
8037
|
+
|
|
8038
|
+
let observer = null
|
|
8039
|
+
try {
|
|
8040
|
+
observer = new MutationObserver(sync)
|
|
8041
|
+
observer.observe(document.documentElement, {
|
|
8042
|
+
childList: true,
|
|
8043
|
+
subtree: true,
|
|
8044
|
+
attributes: true,
|
|
8045
|
+
attributeFilter: ['role', 'aria-modal'],
|
|
8046
|
+
})
|
|
8047
|
+
} catch {
|
|
8048
|
+
observer = null
|
|
8049
|
+
}
|
|
8050
|
+
sync()
|
|
8051
|
+
/* 兜底:某些弹窗只是切换 display(不触发 mutation attributes),低频轮询成本很低 */
|
|
8052
|
+
const timer = window.setInterval(sync, 500)
|
|
8053
|
+
return () => {
|
|
8054
|
+
if (observer !== null) observer.disconnect()
|
|
8055
|
+
window.clearInterval(timer)
|
|
8056
|
+
document.documentElement.removeAttribute(ATTR)
|
|
8057
|
+
}
|
|
8058
|
+
}
|
|
8059
|
+
|
|
8060
|
+
|
|
7997
8061
|
/* ─────────────────────── 60-dock.js ─────────────────────── */
|
|
7998
8062
|
/**
|
|
7999
8063
|
* 60-dock:把官方 DSH 会话面板「停靠」进古法编程右侧的 AI 栏。
|
|
@@ -11822,6 +11886,16 @@ const GUFA_PLUGIN = {
|
|
|
11822
11886
|
window.setTimeout(cleanStaleSidebarLayouts, 1500)
|
|
11823
11887
|
window.setTimeout(cleanStaleSidebarLayouts, 5000)
|
|
11824
11888
|
|
|
11889
|
+
// 外部弹窗(设置等)打开时降低停靠层,避免遮挡弹窗导致关不掉
|
|
11890
|
+
try {
|
|
11891
|
+
if (typeof G.installDialogLayerWatch === 'function') {
|
|
11892
|
+
const disposeDialogWatch = G.installDialogLayerWatch(ctx)
|
|
11893
|
+
if (typeof disposeDialogWatch === 'function') ctx.effect(() => disposeDialogWatch, 'gufa-code: dialog layer watch')
|
|
11894
|
+
}
|
|
11895
|
+
} catch (error) {
|
|
11896
|
+
console.error('[gufa-code] 安装外部弹窗层级监听失败', error)
|
|
11897
|
+
}
|
|
11898
|
+
|
|
11825
11899
|
// 聊天框:粘贴系统文件 → 自动插入 @文件引用(内容匹配项目内文件后插入)
|
|
11826
11900
|
try {
|
|
11827
11901
|
if (typeof G.installChatFilePaste === 'function') {
|
package/package.json
CHANGED
package/src/client/00-core.js
CHANGED
|
@@ -1021,6 +1021,10 @@ G.CSS = `
|
|
|
1021
1021
|
.gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
|
1022
1022
|
/* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
|
|
1023
1023
|
html[data-gufa-ide] .dsh-pet-root{z-index:2147483400!important}
|
|
1024
|
+
/* 外部弹窗(DSH 设置等)打开时:停靠会话与桌宠降到弹窗之下,保证弹窗完整可点可关 */
|
|
1025
|
+
html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
|
|
1026
|
+
html[data-gufa-external-modal] .dsh-pet-root{z-index:2!important}
|
|
1027
|
+
html[data-gufa-external-modal] div[data-dsh-pet-root]{z-index:2!important}
|
|
1024
1028
|
/* 桌宠(@linxin666/dsh-pet)在 IDE 模式提到覆盖层之上,避免被古法编程面板遮住 */
|
|
1025
1029
|
html[data-gufa-ide] div[data-dsh-pet-root]{position:fixed;inset:0;z-index:2147483400;pointer-events:none}
|
|
1026
1030
|
html[data-gufa-ide] div[data-dsh-pet-root] *{pointer-events:auto}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 59-dialog-layer:外部门户弹窗(DSH 官方设置等)打开时,把古法编程的会话停靠层降到弹窗之下。
|
|
3
|
+
*
|
|
4
|
+
* 背景:官方 dialog 通过 createPortal 挂到 document.body(`role="dialog" aria-modal="true"`),
|
|
5
|
+
* 而停靠的官方会话根节点被 inline 设了 z-index 2147483040,会盖住弹窗右侧、导致关闭按钮点不到。
|
|
6
|
+
* 这里只观察「外部 dialog」,不是我们自己的弹窗(在 `.gufa-root` 内),开关 html 属性给 CSS 用。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
G.installDialogLayerWatch = function installDialogLayerWatch(ctx) {
|
|
10
|
+
if (typeof document === 'undefined') return () => {}
|
|
11
|
+
const ATTR = 'data-gufa-external-modal'
|
|
12
|
+
|
|
13
|
+
const isExternalDialog = (el) => {
|
|
14
|
+
if (!(el instanceof Element) || typeof el.closest !== 'function') return false
|
|
15
|
+
if (el.getAttribute('role') !== 'dialog' || el.getAttribute('aria-modal') !== 'true') return false
|
|
16
|
+
return el.closest('.gufa-root') === null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sync = () => {
|
|
20
|
+
try {
|
|
21
|
+
const dialogs = document.querySelectorAll('[role="dialog"][aria-modal="true"]')
|
|
22
|
+
let open = false
|
|
23
|
+
for (const dialog of dialogs) {
|
|
24
|
+
if (isExternalDialog(dialog)) {
|
|
25
|
+
open = true
|
|
26
|
+
break
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (document.documentElement.getAttribute(ATTR) === (open ? '1' : null)) return
|
|
30
|
+
if (open) document.documentElement.setAttribute(ATTR, '1')
|
|
31
|
+
else document.documentElement.removeAttribute(ATTR)
|
|
32
|
+
} catch {
|
|
33
|
+
/* ignore */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let observer = null
|
|
38
|
+
try {
|
|
39
|
+
observer = new MutationObserver(sync)
|
|
40
|
+
observer.observe(document.documentElement, {
|
|
41
|
+
childList: true,
|
|
42
|
+
subtree: true,
|
|
43
|
+
attributes: true,
|
|
44
|
+
attributeFilter: ['role', 'aria-modal'],
|
|
45
|
+
})
|
|
46
|
+
} catch {
|
|
47
|
+
observer = null
|
|
48
|
+
}
|
|
49
|
+
sync()
|
|
50
|
+
/* 兜底:某些弹窗只是切换 display(不触发 mutation attributes),低频轮询成本很低 */
|
|
51
|
+
const timer = window.setInterval(sync, 500)
|
|
52
|
+
return () => {
|
|
53
|
+
if (observer !== null) observer.disconnect()
|
|
54
|
+
window.clearInterval(timer)
|
|
55
|
+
document.documentElement.removeAttribute(ATTR)
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/client/99-main.js
CHANGED
|
@@ -256,6 +256,16 @@ const GUFA_PLUGIN = {
|
|
|
256
256
|
window.setTimeout(cleanStaleSidebarLayouts, 1500)
|
|
257
257
|
window.setTimeout(cleanStaleSidebarLayouts, 5000)
|
|
258
258
|
|
|
259
|
+
// 外部弹窗(设置等)打开时降低停靠层,避免遮挡弹窗导致关不掉
|
|
260
|
+
try {
|
|
261
|
+
if (typeof G.installDialogLayerWatch === 'function') {
|
|
262
|
+
const disposeDialogWatch = G.installDialogLayerWatch(ctx)
|
|
263
|
+
if (typeof disposeDialogWatch === 'function') ctx.effect(() => disposeDialogWatch, 'gufa-code: dialog layer watch')
|
|
264
|
+
}
|
|
265
|
+
} catch (error) {
|
|
266
|
+
console.error('[gufa-code] 安装外部弹窗层级监听失败', error)
|
|
267
|
+
}
|
|
268
|
+
|
|
259
269
|
// 聊天框:粘贴系统文件 → 自动插入 @文件引用(内容匹配项目内文件后插入)
|
|
260
270
|
try {
|
|
261
271
|
if (typeof G.installChatFilePaste === 'function') {
|