dsh-gufa-code 1.3.10 → 1.3.49
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 +19 -11
- package/client.js +670 -97
- package/desktop/float/GufaFloat.m +283 -29
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/KNOWN-PITFALLS.md +61 -0
- package/docs/MODES.md +42 -0
- package/host/dev.js +125 -6
- package/package.json +1 -1
- package/scripts/build-client.mjs +5 -1
- package/scripts/build-float-macos.sh +43 -14
- package/src/client/00-core.js +121 -12
- package/src/client/30-terminal.js +51 -8
- package/src/client/55-backdrop.js +28 -4
- package/src/client/85-shortcuts.js +22 -16
- package/src/client/90-app.js +320 -44
- package/src/client/99-main.js +128 -13
package/client.js
CHANGED
|
@@ -15,6 +15,8 @@ const GUFA_NS = 'gufa-code'
|
|
|
15
15
|
/** 全局命名空间:所有零件通过 G.xxx 共享能力与组件。 */
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
|
+
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
+
G.BUILD = '1.3.49'
|
|
18
20
|
G.PANEL_ID = 'gufa-code'
|
|
19
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
20
22
|
G.pendingEntryWorkspace = null
|
|
@@ -47,6 +49,16 @@ G.portal = (function createPortalHelper() {
|
|
|
47
49
|
G.hooks = { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect }
|
|
48
50
|
|
|
49
51
|
/* ── 悬浮层状态:helper 通过 URL 参数 ?gufa-state=<base64url(JSON)> 传主窗口快照 ── */
|
|
52
|
+
/** 三种界面状态:classic(无标记)/ gufa(data-gufa-ide)/ moyu(data-gufa-float)。
|
|
53
|
+
* 判断一律用 DOM 标记,不要用 localStorage 或状态对象,避免主窗口被摸鱼状态污染。 */
|
|
54
|
+
G.isFloatMode = function isFloatMode() {
|
|
55
|
+
try {
|
|
56
|
+
return typeof document !== 'undefined' && document.documentElement.hasAttribute('data-gufa-float')
|
|
57
|
+
} catch {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
G.floatState = (function readFloatState() {
|
|
51
63
|
if (typeof window === 'undefined' || typeof document === 'undefined') return null
|
|
52
64
|
try {
|
|
@@ -1074,24 +1086,101 @@ G.errorText = (error) => {
|
|
|
1074
1086
|
G.CSS = `
|
|
1075
1087
|
.gufa-overlay-root{position:fixed;inset:0;z-index:1;display:flex;box-sizing:border-box;background:var(--gufa-solid-bg, var(--dsw-alias-bg-base));pointer-events:auto;overflow:hidden}
|
|
1076
1088
|
.gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
|
1077
|
-
/*
|
|
1089
|
+
/* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
|
|
1090
|
+
html[data-gufa-float]{--gufa-float-alpha:0.55}
|
|
1078
1091
|
html[data-gufa-float] body{background:transparent!important}
|
|
1079
1092
|
html[data-gufa-float] .gufa-overlay-root,
|
|
1080
1093
|
html[data-gufa-float] .gufa-root{
|
|
1081
|
-
--gufa-solid-bg:rgba(13,15,19,
|
|
1082
|
-
--gufa-solid-layer:rgba(20,22,27,
|
|
1083
|
-
--gufa-solid-layer2:rgba(26,28,34,
|
|
1084
|
-
--gufa-solid-overlay:rgba(30,33,40,0.
|
|
1094
|
+
--gufa-solid-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;--gufa-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;
|
|
1095
|
+
--gufa-solid-layer:rgba(20,22,27,var(--gufa-float-alpha))!important;--gufa-layer:rgba(20,22,27,var(--gufa-float-alpha))!important;
|
|
1096
|
+
--gufa-solid-layer2:rgba(26,28,34,var(--gufa-float-alpha))!important;--gufa-layer2:rgba(26,28,34,var(--gufa-float-alpha))!important;
|
|
1097
|
+
--gufa-solid-overlay:rgba(30,33,40,calc(var(--gufa-float-alpha) + 0.17))!important;
|
|
1098
|
+
--gufa-solid-sidebar:rgba(18,20,24,var(--gufa-float-alpha))!important;
|
|
1099
|
+
/* 官方组件用 --dsw-alias-*:在覆盖层内也统一成同一个透明度,100% 时完全遮住底层 */
|
|
1100
|
+
--dsw-alias-bg-base:rgba(13,15,19,var(--gufa-float-alpha))!important;
|
|
1101
|
+
--dsw-alias-bg-layer-1:rgba(20,22,27,var(--gufa-float-alpha))!important;
|
|
1102
|
+
--dsw-alias-bg-layer-2:rgba(26,28,34,var(--gufa-float-alpha))!important;
|
|
1103
|
+
--dsw-alias-bg-overlay:rgba(30,33,40,calc(var(--gufa-float-alpha) + 0.17))!important;
|
|
1104
|
+
}
|
|
1105
|
+
/* 顶部 22px 拖动条区域也跟随透明度,否则 100% 时仍能透出被吸附 App(实测 1.3.27 的破绽) */
|
|
1106
|
+
html[data-gufa-float] .gufa-overlay-root::before{
|
|
1107
|
+
content:'';position:fixed;top:0;left:0;right:0;height:22px;pointer-events:none;
|
|
1108
|
+
background:rgba(13,15,19,var(--gufa-float-alpha));z-index:1;
|
|
1085
1109
|
}
|
|
1086
1110
|
html[data-gufa-float] .gufa-overlay-root{background:transparent!important;padding-top:22px;box-sizing:border-box}
|
|
1087
|
-
|
|
1088
|
-
|
|
1111
|
+
/* 摸鱼:整窗只保留「覆盖层根节点」这一层半透明底,其余面板/会话/终端全部透明,
|
|
1112
|
+
保证编辑器、会话框、终端框看到的透明度完全一致(都等于滑块的 alpha)。 */
|
|
1113
|
+
html[data-gufa-float] .gufa-overlay-root{background:rgba(13,15,19,var(--gufa-float-alpha))!important}
|
|
1114
|
+
html[data-gufa-float] .gufa-root,
|
|
1115
|
+
html[data-gufa-float] .gufa-shell,
|
|
1116
|
+
html[data-gufa-float] .gufa-main,
|
|
1117
|
+
html[data-gufa-float] .gufa-main-row,
|
|
1118
|
+
html[data-gufa-float] .gufa-sidepanel,
|
|
1119
|
+
html[data-gufa-float] .gufa-editor-area,
|
|
1120
|
+
html[data-gufa-float] .gufa-chatpane,
|
|
1121
|
+
html[data-gufa-float] .gufa-termpane,
|
|
1122
|
+
html[data-gufa-float] .gufa-termhead,
|
|
1123
|
+
html[data-gufa-float] .gufa-termbody,
|
|
1124
|
+
html[data-gufa-float] .gufa-termview,
|
|
1125
|
+
html[data-gufa-float] .gufa-titlebar,
|
|
1126
|
+
html[data-gufa-float] .gufa-activity,
|
|
1127
|
+
html[data-gufa-float] .gufa-tabs,
|
|
1128
|
+
html[data-gufa-float] .gufa-statusbar,
|
|
1129
|
+
html[data-gufa-float] [data-gufa-dock],
|
|
1130
|
+
html[data-gufa-float] [data-gufa-dock] > *{background:transparent!important}
|
|
1131
|
+
/* 官方会话停靠层(toolbar/host)自带底色,摸鱼里一并透明,避免会话框叠两层 */
|
|
1132
|
+
html[data-gufa-float] .gufa-dock-toolbar,
|
|
1133
|
+
html[data-gufa-float] .gufa-dock-host,
|
|
1134
|
+
html[data-gufa-float] .gufa-chatdock{background:transparent!important}
|
|
1135
|
+
/* 官方会话/组件在摸鱼里也用透明 token,避免和覆盖层底叠成两层 */
|
|
1136
|
+
html[data-gufa-float] .gufa-root,
|
|
1137
|
+
html[data-gufa-float] .gufa-overlay-root,
|
|
1089
1138
|
html[data-gufa-float] [data-gufa-dock]{
|
|
1090
|
-
--dsw-alias-bg-base:
|
|
1091
|
-
--dsw-alias-bg-layer-1:
|
|
1092
|
-
--dsw-alias-bg-layer-2:
|
|
1093
|
-
--dsw-alias-bg-overlay:
|
|
1094
|
-
|
|
1139
|
+
--dsw-alias-bg-base:transparent!important;
|
|
1140
|
+
--dsw-alias-bg-layer-1:transparent!important;
|
|
1141
|
+
--dsw-alias-bg-layer-2:transparent!important;
|
|
1142
|
+
--dsw-alias-bg-overlay:transparent!important;
|
|
1143
|
+
}
|
|
1144
|
+
/* 终端面板:古法编程(带皮肤背景)时和编辑器区域一样透出背景;摸鱼时跟随滑块 */
|
|
1145
|
+
.gufa-termpane{background:var(--gufa-bg)}
|
|
1146
|
+
.gufa-termhead{background:var(--gufa-layer)}
|
|
1147
|
+
.gufa-termbody,
|
|
1148
|
+
.gufa-termview{background:transparent!important}
|
|
1149
|
+
.gufa-root[data-backdrop="on"] .gufa-termpane{background:color-mix(in srgb, var(--gufa-bg) 46%, transparent)}
|
|
1150
|
+
.gufa-root[data-backdrop="on"] .gufa-termhead{background:color-mix(in srgb, var(--gufa-layer) 64%, transparent)}
|
|
1151
|
+
html[data-gufa-float] .gufa-termpane{background:transparent!important}
|
|
1152
|
+
html[data-gufa-float] .gufa-termhead{background:transparent!important}
|
|
1153
|
+
/* xterm 自带的黑色底(xterm.css 默认 .xterm-viewport{background:#000})必须清掉,
|
|
1154
|
+
否则古法编程和摸鱼里的终端内容区永远是黑的(外层透明也没用) */
|
|
1155
|
+
.gufa-termview .xterm,
|
|
1156
|
+
.gufa-termview .xterm .xterm-viewport,
|
|
1157
|
+
.gufa-termview .xterm .xterm-screen{background-color:transparent!important;background-image:none!important}
|
|
1158
|
+
/* 摸鱼模式不显示皮肤(梁圣)背景:包括古法自己的复刻层和第三方皮肤插件在 body/html 上画的层 */
|
|
1159
|
+
html[data-gufa-float],
|
|
1160
|
+
html[data-gufa-float] body,
|
|
1161
|
+
html[data-gufa-float] #root{background-image:none!important;background-color:transparent!important}
|
|
1162
|
+
/* 皮肤插件可能用 html::before/::after 画背景层,摸鱼里一并清掉 */
|
|
1163
|
+
html[data-gufa-float]::before,
|
|
1164
|
+
html[data-gufa-float]::after{display:none!important;content:none!important;background:none!important}
|
|
1165
|
+
html[data-gufa-float] .liang-skin-backdrop,
|
|
1166
|
+
html[data-gufa-float] .liang-ambient,
|
|
1167
|
+
html[data-gufa-float] .liang-skin-portrait,
|
|
1168
|
+
html[data-gufa-float] .liang-skin-root,
|
|
1169
|
+
html[data-gufa-float] #root>[class*="skin"],
|
|
1170
|
+
html[data-gufa-float] #root>[class*="backdrop"]{display:none!important}
|
|
1171
|
+
/* 摸鱼模式不显示皮肤(梁圣)背景 */
|
|
1172
|
+
html[data-gufa-float] .gufa-backdrop,
|
|
1173
|
+
html[data-gufa-float] .gufa-backdrop-page,
|
|
1174
|
+
html[data-gufa-float] .gufa-backdrop-glow,
|
|
1175
|
+
html[data-gufa-float] .gufa-backdrop-portrait{display:none!important}
|
|
1176
|
+
/* 悬浮模式:右侧停靠的官方会话根节点不再自己画底(整窗只有覆盖层那一层),
|
|
1177
|
+
否则会和覆盖层叠成两层,会话框看起来明显更黑更实 */
|
|
1178
|
+
html[data-gufa-float] [data-gufa-dock]{
|
|
1179
|
+
--dsw-alias-bg-base:transparent!important;
|
|
1180
|
+
--dsw-alias-bg-layer-1:transparent!important;
|
|
1181
|
+
--dsw-alias-bg-layer-2:transparent!important;
|
|
1182
|
+
--dsw-alias-bg-overlay:transparent!important;
|
|
1183
|
+
background:transparent!important;
|
|
1095
1184
|
}
|
|
1096
1185
|
html[data-gufa-float] [data-gufa-dock] [data-conversation-scroll],
|
|
1097
1186
|
html[data-gufa-float] [data-gufa-dock] [data-conversation-content]{background:transparent!important}
|
|
@@ -1414,9 +1503,29 @@ html[data-windows-titlebar] .gufa-overlay-root{padding-top:var(--dsh-windows-tit
|
|
|
1414
1503
|
html[data-platform=darwin] .gufa-titlebar{height:48px;padding-left:86px}
|
|
1415
1504
|
html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-left:16px}
|
|
1416
1505
|
.gufa-titlebar button,.gufa-titlebar input,.gufa-titlebar .gufa-project,.gufa-titlebar-action{-webkit-app-region:no-drag}
|
|
1506
|
+
/* 摸鱼入口按钮:带框的两个字 */
|
|
1507
|
+
.gufa-moyu-btn{display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 12px;border-radius:8px;
|
|
1508
|
+
border:1px solid var(--gufa-border-strong);background:color-mix(in srgb, var(--gufa-accent) 14%, transparent);
|
|
1509
|
+
color:var(--gufa-text);font-size:12px;font-weight:600;letter-spacing:1px;cursor:pointer;white-space:nowrap}
|
|
1510
|
+
.gufa-moyu-btn:hover{background:color-mix(in srgb, var(--gufa-accent) 24%, transparent);border-color:var(--gufa-accent)}
|
|
1511
|
+
.gufa-moyu-btn:disabled{opacity:.55;cursor:default}
|
|
1512
|
+
/* 退出摸鱼按钮(原「返回经典模式」位置) */
|
|
1513
|
+
.gufa-moyu-exit{display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 14px;border-radius:8px;
|
|
1514
|
+
border:1px solid color-mix(in srgb, var(--gufa-accent) 60%, transparent);
|
|
1515
|
+
background:color-mix(in srgb, var(--gufa-accent) 20%, transparent);color:var(--gufa-text);
|
|
1516
|
+
font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap}
|
|
1517
|
+
.gufa-moyu-exit:hover{background:color-mix(in srgb, var(--gufa-accent) 34%, transparent)}
|
|
1518
|
+
.gufa-moyu-exit:disabled{opacity:.55;cursor:default}
|
|
1519
|
+
/* 摸鱼界面透明度滑块 */
|
|
1520
|
+
.gufa-moyu-alpha{display:inline-flex;align-items:center;gap:8px;height:26px;padding:0 10px;border-radius:8px;
|
|
1521
|
+
border:1px solid var(--gufa-border);background:color-mix(in srgb, var(--gufa-layer2) 70%, transparent);font-size:11.5px;color:var(--gufa-text-dim)}
|
|
1522
|
+
.gufa-moyu-alpha-label{white-space:nowrap}
|
|
1523
|
+
.gufa-moyu-alpha-range{width:120px;accent-color:var(--gufa-accent);cursor:pointer}
|
|
1524
|
+
.gufa-moyu-alpha-value{min-width:34px;text-align:right;font-variant-numeric:tabular-nums}
|
|
1417
1525
|
.gufa-brand{display:flex;align-items:center;gap:8px;min-width:0}
|
|
1418
1526
|
.gufa-brand-logo{width:24px;height:24px;flex:0 0 auto}
|
|
1419
1527
|
.gufa-brand-name{font-weight:650;font-size:14px;letter-spacing:.02em;white-space:nowrap}
|
|
1528
|
+
.gufa-build-tag{font-size:9.5px;color:var(--gufa-text-dim);opacity:.6;letter-spacing:.3px;flex:0 0 auto}
|
|
1420
1529
|
.gufa-brand-sub{font-size:10px;letter-spacing:.18em;color:var(--gufa-text-dim);white-space:nowrap}
|
|
1421
1530
|
.gufa-project{appearance:none;border:0;background:transparent;font:inherit;color:inherit;cursor:pointer}
|
|
1422
1531
|
.gufa-project:hover{background:var(--gufa-hover)}
|
|
@@ -3709,6 +3818,17 @@ function gufaTermPalette(props) {
|
|
|
3709
3818
|
* @param {string} mode 'dark' | 'light'
|
|
3710
3819
|
* @param {object|null} palette 插件合成的实色调色板(优先于 mode)
|
|
3711
3820
|
*/
|
|
3821
|
+
function gufaTermFloatMode() {
|
|
3822
|
+
try {
|
|
3823
|
+
return typeof G.isFloatMode === 'function' && G.isFloatMode() === true
|
|
3824
|
+
} catch {
|
|
3825
|
+
return false
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
/** 摸鱼窗口里终端容器的半透明底色(跟随标题栏透明度滑块) */
|
|
3830
|
+
const GUFA_TERM_FLOAT_BG = 'rgba(30,30,30,var(--gufa-float-alpha))'
|
|
3831
|
+
|
|
3712
3832
|
function gufaTermTheme(mode, palette) {
|
|
3713
3833
|
const dark = palette !== null && palette !== undefined && typeof palette.isDark === 'boolean' ? palette.isDark : mode === 'dark'
|
|
3714
3834
|
if (dark) {
|
|
@@ -3735,7 +3855,11 @@ function gufaTermTheme(mode, palette) {
|
|
|
3735
3855
|
brightCyan: '#29b8db',
|
|
3736
3856
|
brightWhite: '#e5e5e5',
|
|
3737
3857
|
}
|
|
3738
|
-
|
|
3858
|
+
const themed = gufaApplyPaletteToTermTheme(darkTheme, palette)
|
|
3859
|
+
/* xterm 自身永远画透明底:背景色由外层容器用 IDE 调色板/透明度变量统一上色 */
|
|
3860
|
+
themed.background = 'rgba(0,0,0,0)'
|
|
3861
|
+
themed.cursorAccent = 'rgba(0,0,0,0)'
|
|
3862
|
+
return themed
|
|
3739
3863
|
}
|
|
3740
3864
|
const light = {
|
|
3741
3865
|
background: '#ffffff',
|
|
@@ -3760,7 +3884,10 @@ function gufaTermTheme(mode, palette) {
|
|
|
3760
3884
|
brightCyan: '#0598bc',
|
|
3761
3885
|
brightWhite: '#a5a5a5',
|
|
3762
3886
|
}
|
|
3763
|
-
|
|
3887
|
+
const themed = gufaApplyPaletteToTermTheme(light, palette)
|
|
3888
|
+
themed.background = 'rgba(0,0,0,0)'
|
|
3889
|
+
themed.cursorAccent = 'rgba(0,0,0,0)'
|
|
3890
|
+
return themed
|
|
3764
3891
|
}
|
|
3765
3892
|
|
|
3766
3893
|
/** 把皮肤实色调色板叠加到 xterm 主题(背景/前景/光标/选区跟随滑动变祖)。 */
|
|
@@ -4238,6 +4365,7 @@ function GufaTerminalView(props) {
|
|
|
4238
4365
|
try {
|
|
4239
4366
|
const terminal = new props.assets.Terminal({
|
|
4240
4367
|
allowProposedApi: false,
|
|
4368
|
+
allowTransparency: true,
|
|
4241
4369
|
convertEol: false,
|
|
4242
4370
|
cursorBlink: true,
|
|
4243
4371
|
cursorStyle: 'bar',
|
|
@@ -4479,7 +4607,9 @@ function GufaTerminalView(props) {
|
|
|
4479
4607
|
|
|
4480
4608
|
const monoFont = 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace'
|
|
4481
4609
|
const fallbackTheme = gufaTermTheme(props.theme, palette)
|
|
4482
|
-
|
|
4610
|
+
/* 终端背景由外层 .gufa-termpane 统一提供(和编辑器区域同一套透明度规则) */
|
|
4611
|
+
const shellBackground = 'transparent'
|
|
4612
|
+
const background = 'transparent'
|
|
4483
4613
|
const foreground = fallbackTheme.foreground
|
|
4484
4614
|
|
|
4485
4615
|
const body = fallback
|
|
@@ -4551,6 +4681,7 @@ function GufaTerminalView(props) {
|
|
|
4551
4681
|
return h(
|
|
4552
4682
|
'div',
|
|
4553
4683
|
{
|
|
4684
|
+
className: 'gufa-termview',
|
|
4554
4685
|
style: {
|
|
4555
4686
|
display: props.active === true ? 'flex' : 'none',
|
|
4556
4687
|
flexDirection: 'column',
|
|
@@ -4558,7 +4689,6 @@ function GufaTerminalView(props) {
|
|
|
4558
4689
|
minHeight: 0,
|
|
4559
4690
|
minWidth: 0,
|
|
4560
4691
|
position: 'relative',
|
|
4561
|
-
background,
|
|
4562
4692
|
},
|
|
4563
4693
|
},
|
|
4564
4694
|
body,
|
|
@@ -4610,6 +4740,9 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4610
4740
|
const theme = props.theme === 'light' ? 'light' : 'dark'
|
|
4611
4741
|
const visible = props.visible !== false
|
|
4612
4742
|
const [assets, setAssets] = useState({ status: 'loading', Terminal: null, FitAddon: null, error: '' })
|
|
4743
|
+
/* 未显式传 palette 时(例如古法编程主模式),从 IDE 主题 token 算一份实色调色板,
|
|
4744
|
+
让 xterm 的文字/选区颜色与周围面板一致,而不是永远用浅色主题 */
|
|
4745
|
+
const [computedPalette, setComputedPalette] = useState(null)
|
|
4613
4746
|
const [sessions, setSessions] = useState([])
|
|
4614
4747
|
const [activeId, setActiveId] = useState(null)
|
|
4615
4748
|
const [error, setError] = useState('')
|
|
@@ -4629,6 +4762,25 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4629
4762
|
useEffect(() => {
|
|
4630
4763
|
sessionsRef.current = sessions
|
|
4631
4764
|
}, [sessions])
|
|
4765
|
+
useEffect(() => {
|
|
4766
|
+
if (props.palette !== null && props.palette !== undefined) return undefined
|
|
4767
|
+
let cancelled = false
|
|
4768
|
+
const compute = () => {
|
|
4769
|
+
try {
|
|
4770
|
+
const el = sizeRef.current
|
|
4771
|
+
const value = typeof G.resolveSolidPalette === 'function' ? G.resolveSolidPalette(el) : null
|
|
4772
|
+
if (!cancelled && value !== null && value !== undefined) setComputedPalette(value)
|
|
4773
|
+
} catch {
|
|
4774
|
+
/* ignore */
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
compute()
|
|
4778
|
+
const timer = window.setTimeout(compute, 400)
|
|
4779
|
+
return () => {
|
|
4780
|
+
cancelled = true
|
|
4781
|
+
window.clearTimeout(timer)
|
|
4782
|
+
}
|
|
4783
|
+
}, [props.palette])
|
|
4632
4784
|
useEffect(() => {
|
|
4633
4785
|
activeRef.current = activeId
|
|
4634
4786
|
}, [activeId])
|
|
@@ -4877,7 +5029,7 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4877
5029
|
active: session.id === activeId,
|
|
4878
5030
|
visible,
|
|
4879
5031
|
theme,
|
|
4880
|
-
palette: props.palette,
|
|
5032
|
+
palette: props.palette !== null && props.palette !== undefined ? props.palette : computedPalette,
|
|
4881
5033
|
assets,
|
|
4882
5034
|
register: registerChannel,
|
|
4883
5035
|
unregister: unregisterChannel,
|
|
@@ -4894,6 +5046,7 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4894
5046
|
return h(
|
|
4895
5047
|
'div',
|
|
4896
5048
|
{
|
|
5049
|
+
className: 'gufa-termpane',
|
|
4897
5050
|
style: {
|
|
4898
5051
|
height,
|
|
4899
5052
|
flex: '0 0 auto',
|
|
@@ -4902,12 +5055,12 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4902
5055
|
minHeight: 0,
|
|
4903
5056
|
minWidth: 0,
|
|
4904
5057
|
borderTop: '1px solid var(--gufa-border)',
|
|
4905
|
-
background: 'var(--gufa-bg)',
|
|
4906
5058
|
},
|
|
4907
5059
|
},
|
|
4908
5060
|
h(
|
|
4909
5061
|
'div',
|
|
4910
5062
|
{
|
|
5063
|
+
className: 'gufa-termhead',
|
|
4911
5064
|
style: {
|
|
4912
5065
|
display: 'flex',
|
|
4913
5066
|
alignItems: 'center',
|
|
@@ -4916,7 +5069,6 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4916
5069
|
padding: '0 6px 0 8px',
|
|
4917
5070
|
flex: '0 0 auto',
|
|
4918
5071
|
borderBottom: '1px solid var(--gufa-border)',
|
|
4919
|
-
background: 'var(--gufa-layer)',
|
|
4920
5072
|
minWidth: 0,
|
|
4921
5073
|
},
|
|
4922
5074
|
},
|
|
@@ -4953,7 +5105,7 @@ G.TerminalPane = function TerminalPane(props) {
|
|
|
4953
5105
|
: null,
|
|
4954
5106
|
h(
|
|
4955
5107
|
'div',
|
|
4956
|
-
{ ref: sizeRef, style: { position: 'relative', flex: '1 1 auto', display: 'flex', flexDirection: 'column', minHeight: 0, minWidth: 0
|
|
5108
|
+
{ ref: sizeRef, className: 'gufa-termbody', style: { position: 'relative', flex: '1 1 auto', display: 'flex', flexDirection: 'column', minHeight: 0, minWidth: 0 } },
|
|
4957
5109
|
body,
|
|
4958
5110
|
),
|
|
4959
5111
|
)
|
|
@@ -7774,7 +7926,10 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
7774
7926
|
const canvasRef = useRef(null)
|
|
7775
7927
|
const strengthRaw = typeof props.strength === 'number' && Number.isFinite(props.strength) ? props.strength : 1
|
|
7776
7928
|
const strength = Math.max(0, Math.min(1, strengthRaw))
|
|
7929
|
+
/* 摸鱼窗口里背景层是被 CSS 隐藏的:完全不要创建 canvas / 跑动画,省 CPU 与内存 */
|
|
7930
|
+
const skipFloat = typeof G.isFloatMode === 'function' && G.isFloatMode() === true
|
|
7777
7931
|
useEffect(() => {
|
|
7932
|
+
if (skipFloat) return undefined
|
|
7778
7933
|
const canvas = canvasRef.current
|
|
7779
7934
|
if (canvas === null || canvas === undefined) return undefined
|
|
7780
7935
|
const context = canvas.getContext('2d')
|
|
@@ -7787,7 +7942,7 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
7787
7942
|
}
|
|
7788
7943
|
if (reduced) return undefined
|
|
7789
7944
|
|
|
7790
|
-
const dpr = Math.min(1.
|
|
7945
|
+
const dpr = Math.min(1.25, window.devicePixelRatio || 1)
|
|
7791
7946
|
let width = 0
|
|
7792
7947
|
let height = 0
|
|
7793
7948
|
const resize = () => {
|
|
@@ -7843,9 +7998,11 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
7843
7998
|
const pointer = { x: -1e4, y: -1e4, down: false }
|
|
7844
7999
|
let last = 0
|
|
7845
8000
|
let raf = 0
|
|
8001
|
+
let paused = document.visibilityState === 'hidden'
|
|
7846
8002
|
const tick = (now) => {
|
|
8003
|
+
if (paused) { raf = 0; return }
|
|
7847
8004
|
raf = window.requestAnimationFrame(tick)
|
|
7848
|
-
if (now - last <
|
|
8005
|
+
if (now - last < 40) return
|
|
7849
8006
|
const dt = Math.min(0.048, (last === 0 ? 0.016 : (now - last) / 1000))
|
|
7850
8007
|
last = now
|
|
7851
8008
|
context.clearRect(0, 0, width, height)
|
|
@@ -7902,13 +8059,28 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
7902
8059
|
}
|
|
7903
8060
|
const onPointerDown = () => { pointer.down = true }
|
|
7904
8061
|
const onPointerUp = () => { pointer.down = false }
|
|
8062
|
+
const resume = () => {
|
|
8063
|
+
paused = false
|
|
8064
|
+
last = 0
|
|
8065
|
+
if (raf === 0) raf = window.requestAnimationFrame(tick)
|
|
8066
|
+
}
|
|
8067
|
+
const pause = () => {
|
|
8068
|
+
paused = true
|
|
8069
|
+
if (raf !== 0) { window.cancelAnimationFrame(raf); raf = 0 }
|
|
8070
|
+
}
|
|
8071
|
+
const onVisibility = () => { if (document.visibilityState === 'hidden') pause(); else resume() }
|
|
8072
|
+
const onBlur = () => pause()
|
|
8073
|
+
const onFocus = () => resume()
|
|
8074
|
+
document.addEventListener('visibilitychange', onVisibility)
|
|
8075
|
+
window.addEventListener('blur', onBlur)
|
|
8076
|
+
window.addEventListener('focus', onFocus)
|
|
7905
8077
|
window.addEventListener('pointermove', onPointerMove)
|
|
7906
8078
|
window.addEventListener('pointerdown', onPointerDown)
|
|
7907
8079
|
window.addEventListener('pointerup', onPointerUp)
|
|
7908
8080
|
window.addEventListener('pointerleave', onPointerLeave)
|
|
7909
8081
|
window.addEventListener('resize', resize)
|
|
7910
8082
|
resize()
|
|
7911
|
-
raf = window.requestAnimationFrame(tick)
|
|
8083
|
+
if (!paused) raf = window.requestAnimationFrame(tick)
|
|
7912
8084
|
try {
|
|
7913
8085
|
void G.api('dev.log', { message: `particles-start count=${activeCount} size=2-5.2css dpr=${dpr} canvas=${width}x${height}` }).catch(() => {})
|
|
7914
8086
|
} catch {
|
|
@@ -7916,13 +8088,17 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
7916
8088
|
}
|
|
7917
8089
|
return () => {
|
|
7918
8090
|
if (raf !== 0) window.cancelAnimationFrame(raf)
|
|
8091
|
+
document.removeEventListener('visibilitychange', onVisibility)
|
|
8092
|
+
window.removeEventListener('blur', onBlur)
|
|
8093
|
+
window.removeEventListener('focus', onFocus)
|
|
7919
8094
|
window.removeEventListener('pointermove', onPointerMove)
|
|
7920
8095
|
window.removeEventListener('pointerdown', onPointerDown)
|
|
7921
8096
|
window.removeEventListener('pointerup', onPointerUp)
|
|
7922
8097
|
window.removeEventListener('pointerleave', onPointerLeave)
|
|
7923
8098
|
window.removeEventListener('resize', resize)
|
|
7924
8099
|
}
|
|
7925
|
-
}, [strength])
|
|
8100
|
+
}, [strength, skipFloat])
|
|
8101
|
+
if (skipFloat) return null
|
|
7926
8102
|
return h('canvas', { ref: canvasRef, className: 'gufa-backdrop-particles', 'aria-hidden': 'true', style: { mixBlendMode: 'screen' } })
|
|
7927
8103
|
}
|
|
7928
8104
|
|
|
@@ -9139,21 +9315,23 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
9139
9315
|
try {
|
|
9140
9316
|
if (typeof window !== 'undefined' && window !== null) {
|
|
9141
9317
|
if (wrapped.length < expected) {
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
service.__gufaIntegrationTimer
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9318
|
+
/* 累计尝试次数上限:配置变更会反复触发安装,不能每次都重新开 40 次重试(之前会变成常驻 2Hz 循环) */
|
|
9319
|
+
if ((service.__gufaIntegrationAttempts ?? 0) < 40) {
|
|
9320
|
+
if (service.__gufaIntegrationTimer === undefined || service.__gufaIntegrationTimer === null) {
|
|
9321
|
+
service.__gufaIntegrationTimer = window.setInterval(() => {
|
|
9322
|
+
service.__gufaIntegrationAttempts = (service.__gufaIntegrationAttempts ?? 0) + 1
|
|
9323
|
+
if (service.__gufaIntegrationAttempts > 40) {
|
|
9324
|
+
window.clearInterval(service.__gufaIntegrationTimer)
|
|
9325
|
+
service.__gufaIntegrationTimer = null
|
|
9326
|
+
return
|
|
9327
|
+
}
|
|
9328
|
+
try {
|
|
9329
|
+
G.installShortcutIntegration(service)
|
|
9330
|
+
} catch {
|
|
9331
|
+
/* ignore */
|
|
9332
|
+
}
|
|
9333
|
+
}, 500)
|
|
9334
|
+
}
|
|
9157
9335
|
}
|
|
9158
9336
|
} else {
|
|
9159
9337
|
if (service.__gufaIntegrationTimer !== undefined && service.__gufaIntegrationTimer !== null) {
|
|
@@ -9275,7 +9453,11 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
9275
9453
|
} catch {
|
|
9276
9454
|
edrvIds = []
|
|
9277
9455
|
}
|
|
9278
|
-
|
|
9456
|
+
const signature = `${JSON.stringify(wrapped)}|${totalCommands}|${configStatus}|${edrvIds.length}|${edrvBindings.length}`
|
|
9457
|
+
if (service.__gufaLastIntegrationSignature !== signature) {
|
|
9458
|
+
service.__gufaLastIntegrationSignature = signature
|
|
9459
|
+
void G.api('dev.log', { message: `shortcut-integration wrapped=${JSON.stringify(wrapped)} total=${totalCommands} configStatus=${configStatus} edrv=${JSON.stringify(edrvIds).slice(0, 1500)} edrvBindings=${JSON.stringify(edrvBindings).slice(0, 2500)}` }).catch(() => {})
|
|
9460
|
+
}
|
|
9279
9461
|
} catch {
|
|
9280
9462
|
/* ignore */
|
|
9281
9463
|
}
|
|
@@ -9539,6 +9721,50 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9539
9721
|
const [floatBusy, setFloatBusy] = useState(false)
|
|
9540
9722
|
/* 摸鱼窗口选择器:null | {status:'loading'|'ready'|'permission'|'error', windows:[], error:''} */
|
|
9541
9723
|
const [floatPicker, setFloatPicker] = useState(null)
|
|
9724
|
+
/* 摸鱼模式(悬浮窗实例)与界面透明度 */
|
|
9725
|
+
const [moyuMode] = useState(() => G.isFloatMode())
|
|
9726
|
+
const [floatAlpha, setFloatAlpha] = useState(() => {
|
|
9727
|
+
try {
|
|
9728
|
+
const saved = Number(localStorage.getItem('gufa-code:float-alpha'))
|
|
9729
|
+
if (Number.isFinite(saved) && saved >= 20 && saved <= 100) return Math.round(saved)
|
|
9730
|
+
} catch {
|
|
9731
|
+
/* ignore */
|
|
9732
|
+
}
|
|
9733
|
+
return 55
|
|
9734
|
+
})
|
|
9735
|
+
useEffect(() => {
|
|
9736
|
+
try {
|
|
9737
|
+
document.documentElement.style.setProperty('--gufa-float-alpha', String(floatAlpha / 100))
|
|
9738
|
+
localStorage.setItem('gufa-code:float-alpha', String(floatAlpha))
|
|
9739
|
+
} catch {
|
|
9740
|
+
/* ignore */
|
|
9741
|
+
}
|
|
9742
|
+
/* 摸鱼窗口里调整透明度时同步到 Host,下次新建摸鱼窗口沿用 */
|
|
9743
|
+
if (moyuMode) {
|
|
9744
|
+
const timer = window.setTimeout(() => {
|
|
9745
|
+
void G.api('float.setPrefs', { alpha: floatAlpha }).catch(() => {})
|
|
9746
|
+
}, 400)
|
|
9747
|
+
return () => window.clearTimeout(timer)
|
|
9748
|
+
}
|
|
9749
|
+
return undefined
|
|
9750
|
+
}, [floatAlpha, moyuMode])
|
|
9751
|
+
/* 摸鱼窗口启动时优先使用 Host 偏好里的透明度 */
|
|
9752
|
+
useEffect(() => {
|
|
9753
|
+
if (!moyuMode) return
|
|
9754
|
+
let cancelled = false
|
|
9755
|
+
void (async () => {
|
|
9756
|
+
try {
|
|
9757
|
+
const prefs = await G.api('float.getPrefs')
|
|
9758
|
+
const alpha = Number(prefs?.alpha)
|
|
9759
|
+
if (!cancelled && Number.isFinite(alpha) && alpha >= 20 && alpha <= 100) setFloatAlpha(Math.round(alpha))
|
|
9760
|
+
} catch {
|
|
9761
|
+
/* ignore */
|
|
9762
|
+
}
|
|
9763
|
+
})()
|
|
9764
|
+
return () => {
|
|
9765
|
+
cancelled = true
|
|
9766
|
+
}
|
|
9767
|
+
}, [moyuMode])
|
|
9542
9768
|
/* 会话弹窗里选中的工作区(null = 跟随当前 IDE 项目) */
|
|
9543
9769
|
const [sessionWorkspacePath, setSessionWorkspacePath] = useState(null)
|
|
9544
9770
|
const [sessionWorkspacePicker, setSessionWorkspacePicker] = useState(false)
|
|
@@ -9553,8 +9779,16 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9553
9779
|
return Array.isArray(parsed) ? parsed : []
|
|
9554
9780
|
}, [recentSessionsJson])
|
|
9555
9781
|
|
|
9782
|
+
/* 摸鱼窗口:主窗口注入的状态(项目/UI/标签页/会话) */
|
|
9783
|
+
const floatState = G.floatState
|
|
9784
|
+
const appInstanceId = useRef(0)
|
|
9785
|
+
if (appInstanceId.current === 0) {
|
|
9786
|
+
appInstanceId.current = Math.random().toString(36).slice(2, 8)
|
|
9787
|
+
void G.api('dev.log', { message: `app-mount id=${appInstanceId.current} float=${G.isFloatMode()} href=${String(location.href).slice(0, 80)}` }).catch(() => {})
|
|
9788
|
+
}
|
|
9556
9789
|
const [ui, setUi] = useState(() => {
|
|
9557
|
-
const
|
|
9790
|
+
const fromFloat = floatState !== null && floatState !== undefined && floatState.ui !== null && typeof floatState.ui === 'object' ? floatState.ui : null
|
|
9791
|
+
const saved = fromFloat ?? readJson(GUFA_LS.ui) ?? {}
|
|
9558
9792
|
return {
|
|
9559
9793
|
view: typeof saved.view === 'string' ? saved.view : 'explorer',
|
|
9560
9794
|
chatOpen: saved.chatOpen !== false,
|
|
@@ -9633,6 +9867,22 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9633
9867
|
bootedRef.current = true
|
|
9634
9868
|
let cancelled = false
|
|
9635
9869
|
void (async () => {
|
|
9870
|
+
/* 从工作区菜单点进来的:跳过「恢复上次项目」,直接按入口工作区打开 */
|
|
9871
|
+
const pendingEntry = G.pendingEntryWorkspace
|
|
9872
|
+
if (pendingEntry !== null && pendingEntry !== undefined && typeof pendingEntry.key === 'string') {
|
|
9873
|
+
try {
|
|
9874
|
+
const listValue = await G.api('workspaces.list', {})
|
|
9875
|
+
const list = Array.isArray(listValue?.workspaces) ? listValue.workspaces : []
|
|
9876
|
+
const matched = list.find((item) => item !== null && item.id === pendingEntry.key)
|
|
9877
|
+
if (matched !== undefined && typeof matched.path === 'string' && matched.path !== '') {
|
|
9878
|
+
const value = await G.api('project.open', { path: matched.path })
|
|
9879
|
+
if (!cancelled) applyProject(value)
|
|
9880
|
+
return
|
|
9881
|
+
}
|
|
9882
|
+
} catch {
|
|
9883
|
+
/* 回落到恢复上次项目 */
|
|
9884
|
+
}
|
|
9885
|
+
}
|
|
9636
9886
|
const saved = floatState !== null && floatState !== undefined && typeof floatState.projectRoot === 'string' && floatState.projectRoot !== ''
|
|
9637
9887
|
? floatState.projectRoot
|
|
9638
9888
|
: readJson(GUFA_LS.project)
|
|
@@ -9645,7 +9895,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9645
9895
|
writeJson(GUFA_LS.project, null)
|
|
9646
9896
|
}
|
|
9647
9897
|
}
|
|
9648
|
-
if (G.
|
|
9898
|
+
if (G.isFloatMode()) return
|
|
9649
9899
|
if (typeof sessionCwd === 'string' && sessionCwd !== '') {
|
|
9650
9900
|
try {
|
|
9651
9901
|
const value = await G.api('project.open', { path: sessionCwd })
|
|
@@ -9710,13 +9960,38 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9710
9960
|
}
|
|
9711
9961
|
try {
|
|
9712
9962
|
const doc = await G.api('fs.read', { root: project.root, path })
|
|
9713
|
-
|
|
9963
|
+
/* 用函数式更新去重:并发/恢复场景下闭包里的 tabs 可能还没刷新,直接追加会产生重复标签 */
|
|
9964
|
+
setTabs((current) => (
|
|
9965
|
+
current.some((tab) => tab.path === path)
|
|
9966
|
+
? current
|
|
9967
|
+
: [...current, { ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision }]
|
|
9968
|
+
))
|
|
9714
9969
|
setActivePath(path)
|
|
9715
9970
|
} catch (error) {
|
|
9716
9971
|
setBanner(G.errorText(error))
|
|
9717
9972
|
}
|
|
9718
9973
|
}, [project, tabs])
|
|
9719
9974
|
|
|
9975
|
+
/* 原子恢复标签集合:按快照顺序、去重、最后激活指定文件(避免 openFile 并发产生重复标签) */
|
|
9976
|
+
const applyTabs = useCallback(async (paths, active) => {
|
|
9977
|
+
if (project === null || !Array.isArray(paths)) return
|
|
9978
|
+
const docs = []
|
|
9979
|
+
const seen = new Set()
|
|
9980
|
+
for (const path of paths.slice(0, 12)) {
|
|
9981
|
+
if (typeof path !== 'string' || path === '' || seen.has(path)) continue
|
|
9982
|
+
seen.add(path)
|
|
9983
|
+
try {
|
|
9984
|
+
const doc = await G.api('fs.read', { root: project.root, path })
|
|
9985
|
+
docs.push({ ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision })
|
|
9986
|
+
} catch {
|
|
9987
|
+
/* 快照里的文件可能已被删除:忽略 */
|
|
9988
|
+
}
|
|
9989
|
+
}
|
|
9990
|
+
setTabs(docs)
|
|
9991
|
+
const wanted = typeof active === 'string' && docs.some((doc) => doc.path === active) ? active : (docs.length > 0 ? docs[docs.length - 1].path : null)
|
|
9992
|
+
setActivePath(wanted)
|
|
9993
|
+
}, [project])
|
|
9994
|
+
|
|
9720
9995
|
const activeTab = useMemo(() => tabs.find((tab) => tab.path === activePath) ?? null, [tabs, activePath])
|
|
9721
9996
|
|
|
9722
9997
|
const patchTab = useCallback((path, patch) => {
|
|
@@ -10221,7 +10496,6 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10221
10496
|
try {
|
|
10222
10497
|
await G.api('float.stop')
|
|
10223
10498
|
setFloatRunning(false)
|
|
10224
|
-
setBanner('已退出摸鱼:主窗口已恢复')
|
|
10225
10499
|
} catch (error) {
|
|
10226
10500
|
setBanner(G.errorText(error))
|
|
10227
10501
|
} finally {
|
|
@@ -10250,20 +10524,25 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10250
10524
|
}, [floatBusy])
|
|
10251
10525
|
|
|
10252
10526
|
/* 选中某个 App 窗口 → 启动悬浮层并吸附它 */
|
|
10527
|
+
/* 当前编辑器状态快照(进出摸鱼都以它为准) */
|
|
10528
|
+
const buildFloatSnapshot = useCallback(() => ({
|
|
10529
|
+
/* 诊断:快照里项目字段 */
|
|
10530
|
+
projectRoot: project !== null && typeof project.root === 'string' ? project.root : null,
|
|
10531
|
+
activePath: typeof activePath === 'string' ? activePath : null,
|
|
10532
|
+
tabs: tabs
|
|
10533
|
+
.filter((tab) => tab !== null && tab !== undefined && typeof tab.path === 'string' && tab.kind !== 'diff' && tab.kind !== 'graph')
|
|
10534
|
+
.map((tab) => tab.path)
|
|
10535
|
+
.slice(0, 10),
|
|
10536
|
+
ui: ui,
|
|
10537
|
+
sessionId: typeof currentSessionId === 'string' ? currentSessionId : null,
|
|
10538
|
+
}), [project, activePath, tabs, ui, currentSessionId])
|
|
10539
|
+
|
|
10253
10540
|
const startFloatForWindow = useCallback(async (target) => {
|
|
10254
10541
|
if (floatBusy || target === null || target === undefined) return
|
|
10255
10542
|
setFloatBusy(true)
|
|
10256
10543
|
try {
|
|
10257
|
-
const floatState =
|
|
10258
|
-
|
|
10259
|
-
activePath: typeof activePath === 'string' ? activePath : null,
|
|
10260
|
-
tabs: tabs
|
|
10261
|
-
.filter((tab) => tab !== null && tab !== undefined && typeof tab.path === 'string' && tab.kind !== 'diff' && tab.kind !== 'graph')
|
|
10262
|
-
.map((tab) => tab.path)
|
|
10263
|
-
.slice(0, 10),
|
|
10264
|
-
ui: readJson(GUFA_LS.ui) ?? {},
|
|
10265
|
-
sessionId: typeof currentSessionId === 'string' ? currentSessionId : null,
|
|
10266
|
-
}
|
|
10544
|
+
const floatState = buildFloatSnapshot()
|
|
10545
|
+
void G.api('dev.log', { message: `float-start-instance id=${appInstanceId.current} project=${String(floatState.projectRoot)} tabs=${floatState.tabs.length}` }).catch(() => {})
|
|
10267
10546
|
const value = await G.api('float.start', {
|
|
10268
10547
|
follow: {
|
|
10269
10548
|
pid: Number(target.pid) || 0,
|
|
@@ -10274,24 +10553,21 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10274
10553
|
})
|
|
10275
10554
|
setFloatRunning(value?.running === true)
|
|
10276
10555
|
setFloatPicker(null)
|
|
10277
|
-
const name = typeof target.owner === 'string' && target.owner !== '' ? target.owner : '所选窗口'
|
|
10278
|
-
setBanner(`摸鱼模式已开启:已吸附 ${name};⌃⌥⌘G 切换点击穿透,菜单栏「古法」可退出`)
|
|
10279
10556
|
} catch (error) {
|
|
10280
10557
|
setBanner(G.errorText(error))
|
|
10281
10558
|
} finally {
|
|
10282
10559
|
setFloatBusy(false)
|
|
10283
10560
|
}
|
|
10284
|
-
}, [floatBusy])
|
|
10561
|
+
}, [floatBusy, buildFloatSnapshot])
|
|
10285
10562
|
|
|
10286
|
-
/*
|
|
10563
|
+
/* 自由悬浮(不吸附窗口):同样带上当前编辑器状态快照 */
|
|
10287
10564
|
const startFloatFree = useCallback(async () => {
|
|
10288
10565
|
if (floatBusy) return
|
|
10289
10566
|
setFloatBusy(true)
|
|
10290
10567
|
try {
|
|
10291
|
-
const value = await G.api('float.start')
|
|
10568
|
+
const value = await G.api('float.start', { state: buildFloatSnapshot() })
|
|
10292
10569
|
setFloatRunning(value?.running === true)
|
|
10293
10570
|
setFloatPicker(null)
|
|
10294
|
-
setBanner('悬浮层已启动(自由悬浮)')
|
|
10295
10571
|
} catch (error) {
|
|
10296
10572
|
setBanner(G.errorText(error))
|
|
10297
10573
|
} finally {
|
|
@@ -10302,10 +10578,140 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10302
10578
|
/* 内部 QA:允许自动化脚本在悬浮窗里打开摸鱼列表(仅供自测,不影响正常交互) */
|
|
10303
10579
|
G.debugOpenFloatPicker = openFloatPicker
|
|
10304
10580
|
|
|
10305
|
-
|
|
10306
|
-
|
|
10581
|
+
/* 悬浮窗里点「退出摸鱼」:把当前状态交还主窗口,再关闭悬浮层 */
|
|
10582
|
+
const exitMoyu = useCallback(async () => {
|
|
10583
|
+
if (floatBusy) return
|
|
10584
|
+
setFloatBusy(true)
|
|
10585
|
+
try {
|
|
10586
|
+
const state = {
|
|
10587
|
+
projectRoot: project !== null && typeof project.root === 'string' ? project.root : null,
|
|
10588
|
+
activePath: typeof activePath === 'string' ? activePath : null,
|
|
10589
|
+
tabs: tabs
|
|
10590
|
+
.filter((tab) => tab !== null && tab !== undefined && typeof tab.path === 'string' && tab.kind !== 'diff' && tab.kind !== 'graph')
|
|
10591
|
+
.map((tab) => tab.path)
|
|
10592
|
+
.slice(0, 10),
|
|
10593
|
+
ui: ui,
|
|
10594
|
+
sessionId: typeof currentSessionId === 'string' ? currentSessionId : null,
|
|
10595
|
+
}
|
|
10596
|
+
await G.api('float.saveExitState', { state })
|
|
10597
|
+
await G.api('float.stop')
|
|
10598
|
+
setFloatRunning(false)
|
|
10599
|
+
} catch (error) {
|
|
10600
|
+
setBanner(G.errorText(error))
|
|
10601
|
+
} finally {
|
|
10602
|
+
setFloatBusy(false)
|
|
10603
|
+
}
|
|
10604
|
+
}, [floatBusy, project, activePath, tabs, currentSessionId, ui])
|
|
10605
|
+
|
|
10606
|
+
/* 主窗口回到前台时:取回退出摸鱼时的状态(项目/标签页/会话) */
|
|
10607
|
+
const consumeExitStateRef = useRef(false)
|
|
10608
|
+
useEffect(() => {
|
|
10609
|
+
if (G.isFloatMode()) return undefined
|
|
10610
|
+
let running = false
|
|
10611
|
+
const consume = async () => {
|
|
10612
|
+
if (running) return
|
|
10613
|
+
running = true
|
|
10614
|
+
try {
|
|
10615
|
+
const value = await G.api('float.consumeExitState')
|
|
10616
|
+
const state = value?.state ?? null
|
|
10617
|
+
if (state !== null && typeof state === 'object') {
|
|
10618
|
+
void G.api('dev.log', { message: `moyu-exit-state consume project=${String(state.projectRoot)} tabs=${Array.isArray(state.tabs) ? state.tabs.length : 0} session=${String(state.sessionId)}` }).catch(() => {})
|
|
10619
|
+
const restore = G.floatRestoreRef
|
|
10620
|
+
if (restore === null || restore === undefined) {
|
|
10621
|
+
/* 主窗口当前不在 IDE 模式:把状态写进 localStorage,等下次进 IDE 时恢复 */
|
|
10622
|
+
try {
|
|
10623
|
+
if (typeof state.projectRoot === 'string' && state.projectRoot !== '') localStorage.setItem('gufa-code:project', JSON.stringify(state.projectRoot))
|
|
10624
|
+
localStorage.setItem('gufa-code:float-state', JSON.stringify(state))
|
|
10625
|
+
} catch {
|
|
10626
|
+
/* ignore */
|
|
10627
|
+
}
|
|
10628
|
+
return
|
|
10629
|
+
}
|
|
10630
|
+
let projectValue = null
|
|
10631
|
+
if (typeof state.projectRoot === 'string' && state.projectRoot !== '') {
|
|
10632
|
+
try {
|
|
10633
|
+
projectValue = await G.api('project.open', { path: state.projectRoot })
|
|
10634
|
+
} catch {
|
|
10635
|
+
projectValue = null
|
|
10636
|
+
}
|
|
10637
|
+
}
|
|
10638
|
+
if (projectValue !== null && restore !== null && restore !== undefined && typeof restore.applyProject === 'function') {
|
|
10639
|
+
restore.applyProject(projectValue)
|
|
10640
|
+
}
|
|
10641
|
+
try {
|
|
10642
|
+
if (typeof G.floatApplyUiRef === 'function' && state.ui !== null && typeof state.ui === 'object') G.floatApplyUiRef(state.ui)
|
|
10643
|
+
} catch {
|
|
10644
|
+
/* ignore */
|
|
10645
|
+
}
|
|
10646
|
+
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
10647
|
+
const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
|
|
10648
|
+
const ordered = paths
|
|
10649
|
+
const activeOne = typeof state.activePath === 'string' && state.activePath !== '' ? state.activePath : null
|
|
10650
|
+
/* applyProject 后 App 已重渲染:重新取恢复入口,原子恢复标签集合 */
|
|
10651
|
+
const latest = G.floatRestoreRef
|
|
10652
|
+
if (latest !== null && latest !== undefined && typeof latest.applyTabs === 'function') {
|
|
10653
|
+
await latest.applyTabs(ordered, activeOne)
|
|
10654
|
+
}
|
|
10655
|
+
const openedCount = ordered.length
|
|
10656
|
+
void G.api('dev.log', { message: `moyu-exit-applied project=${String(state.projectRoot)} tabs=${openedCount} ui=${JSON.stringify(state.ui ?? null)}` }).catch(() => {})
|
|
10657
|
+
if (typeof state.sessionId === 'string' && state.sessionId !== '') {
|
|
10658
|
+
try {
|
|
10659
|
+
const workspace = G.ctx === null || G.ctx === undefined ? undefined : G.ctx.get('uiWorkspace')
|
|
10660
|
+
if (workspace !== undefined && workspace !== null && typeof workspace.openSession === 'function') workspace.openSession(state.sessionId)
|
|
10661
|
+
} catch {
|
|
10662
|
+
/* ignore */
|
|
10663
|
+
}
|
|
10664
|
+
}
|
|
10665
|
+
}
|
|
10666
|
+
} catch {
|
|
10667
|
+
/* ignore */
|
|
10668
|
+
} finally {
|
|
10669
|
+
running = false
|
|
10670
|
+
}
|
|
10671
|
+
}
|
|
10672
|
+
const syncFloatStatus = async () => {
|
|
10673
|
+
try {
|
|
10674
|
+
const value = await G.api('float.status')
|
|
10675
|
+
const next = value?.running === true
|
|
10676
|
+
setFloatRunning((current) => (current === next ? current : next))
|
|
10677
|
+
} catch {
|
|
10678
|
+
/* ignore */
|
|
10679
|
+
}
|
|
10680
|
+
}
|
|
10681
|
+
const onFocus = () => { void syncFloatStatus(); void consume() }
|
|
10682
|
+
window.addEventListener('focus', onFocus)
|
|
10683
|
+
/* 摸鱼退出后主窗口可能因隐藏/恢复丢失 focus 事件,低频轮询兜底 */
|
|
10684
|
+
const pollTimer = window.setInterval(() => {
|
|
10685
|
+
if (document.visibilityState !== 'visible') return
|
|
10686
|
+
void consume()
|
|
10687
|
+
void syncFloatStatus()
|
|
10688
|
+
}, 5000)
|
|
10689
|
+
const onVisible = () => { if (document.visibilityState === 'visible') { void syncFloatStatus(); void consume() } }
|
|
10690
|
+
document.addEventListener('visibilitychange', onVisible)
|
|
10691
|
+
if (consumeExitStateRef.current !== true) {
|
|
10692
|
+
consumeExitStateRef.current = true
|
|
10693
|
+
void consume()
|
|
10694
|
+
}
|
|
10695
|
+
return () => {
|
|
10696
|
+
window.removeEventListener('focus', onFocus)
|
|
10697
|
+
document.removeEventListener('visibilitychange', onVisible)
|
|
10698
|
+
window.clearInterval(pollTimer)
|
|
10699
|
+
}
|
|
10700
|
+
}, [])
|
|
10701
|
+
|
|
10702
|
+
const toggleFloatWindow = useCallback(async () => {
|
|
10703
|
+
if (floatBusy) return
|
|
10704
|
+
/* 以 Host 的真实运行状态为准:避免退出摸鱼后主窗口状态残留,第一次点击失效 */
|
|
10705
|
+
let running = floatRunning
|
|
10706
|
+
try {
|
|
10707
|
+
const status = await G.api('float.status')
|
|
10708
|
+
running = status?.running === true
|
|
10709
|
+
} catch {
|
|
10710
|
+
running = false
|
|
10711
|
+
}
|
|
10712
|
+
if (floatRequested === true || running) await stopFloatWindow()
|
|
10307
10713
|
else void openFloatPicker()
|
|
10308
|
-
}, [floatRequested, floatRunning, stopFloatWindow, openFloatPicker])
|
|
10714
|
+
}, [floatBusy, floatRequested, floatRunning, stopFloatWindow, openFloatPicker])
|
|
10309
10715
|
|
|
10310
10716
|
/* ── 右侧 AI 面板与当前工作区保持一致 ─────────────────────────────────
|
|
10311
10717
|
* ChatDock 停靠的是 DSH「主视图会话」,但主视图会话可能属于别的工作区
|
|
@@ -10313,7 +10719,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10313
10719
|
const dockSyncRef = useRef('')
|
|
10314
10720
|
useEffect(() => {
|
|
10315
10721
|
if (sessionPinnedRef.current === true) return undefined
|
|
10316
|
-
if (G.
|
|
10722
|
+
if (G.isFloatMode()) return undefined
|
|
10317
10723
|
if (project === null || typeof project.root !== 'string' || project.root === '') return undefined
|
|
10318
10724
|
if (dockSyncRef.current === project.root) return undefined
|
|
10319
10725
|
if (typeof sessionCwd === 'string' && sessionCwd !== '' && sessionCwd === project.root) {
|
|
@@ -10358,20 +10764,24 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10358
10764
|
const entryWorkspaceSyncedRef = useRef(false)
|
|
10359
10765
|
useEffect(() => {
|
|
10360
10766
|
if (entryWorkspaceSyncedRef.current) return
|
|
10361
|
-
/*
|
|
10362
|
-
if (G.
|
|
10767
|
+
/* 悬浮层(摸鱼):项目/会话由主窗口状态注入,不做「入口工作区」同步 */
|
|
10768
|
+
if (G.isFloatMode()) {
|
|
10363
10769
|
entryWorkspaceSyncedRef.current = true
|
|
10364
10770
|
return
|
|
10365
10771
|
}
|
|
10366
|
-
if (project === null) return
|
|
10772
|
+
if (project === null && (G.pendingEntryWorkspace === null || G.pendingEntryWorkspace === undefined)) return
|
|
10367
10773
|
const pending = G.pendingEntryWorkspace
|
|
10368
10774
|
if (pending === null || pending === undefined || typeof pending.key !== 'string') {
|
|
10369
10775
|
if (typeof sessionCwd !== 'string' || sessionCwd === '') return
|
|
10370
10776
|
entryWorkspaceSyncedRef.current = true
|
|
10371
|
-
if (project.root
|
|
10777
|
+
if (project !== null && typeof project.root === 'string' && project.root !== sessionCwd) {
|
|
10778
|
+
void openProjectPath(sessionCwd).catch((error) => setBanner(G.errorText(error)))
|
|
10779
|
+
}
|
|
10372
10780
|
return
|
|
10373
10781
|
}
|
|
10374
10782
|
entryWorkspaceSyncedRef.current = true
|
|
10783
|
+
const currentRoot = project !== null && typeof project.root === 'string' ? project.root : ''
|
|
10784
|
+
void G.api('dev.log', { message: `entry-sync pending=${String(pending.key)} project=${currentRoot === '' ? 'null' : currentRoot} sessionCwd=${typeof sessionCwd === 'string' ? sessionCwd : ''}` }).catch(() => {})
|
|
10375
10785
|
void (async () => {
|
|
10376
10786
|
try {
|
|
10377
10787
|
let targetPath = ''
|
|
@@ -10387,7 +10797,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10387
10797
|
const sameWorkspace = typeof sessionCwd === 'string' && sessionCwd !== '' && targetPath !== '' && sessionCwd === targetPath
|
|
10388
10798
|
if (sameWorkspace) {
|
|
10389
10799
|
/* 当前正在聊的会话就在这个工作区:直接用它,只把项目根对齐 */
|
|
10390
|
-
if (
|
|
10800
|
+
if (currentRoot !== targetPath) await openProjectPath(targetPath)
|
|
10391
10801
|
return
|
|
10392
10802
|
}
|
|
10393
10803
|
/* 会话属于别的工作区:切到目标工作区最近的会话,再对齐项目根 */
|
|
@@ -10405,7 +10815,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10405
10815
|
setBanner(G.errorText(error))
|
|
10406
10816
|
}
|
|
10407
10817
|
})()
|
|
10408
|
-
}, [project, sessionCwd, openProjectPath, setBanner])
|
|
10818
|
+
}, [project, sessionCwd, openProjectPath, setBanner, gufaModeVisible])
|
|
10409
10819
|
|
|
10410
10820
|
/* ── 已删除文件的标签自动关闭 ──────────────────────────────────────── */
|
|
10411
10821
|
const pruneMissingTabs = useCallback(async () => {
|
|
@@ -10682,7 +11092,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10682
11092
|
useEffect(() => {
|
|
10683
11093
|
if (sessionPinnedRef.current === true) return
|
|
10684
11094
|
/* 悬浮层里项目由主窗口状态注入,不跟随(Web 版客户端自己的)会话 cwd 切换 */
|
|
10685
|
-
if (G.
|
|
11095
|
+
if (G.isFloatMode()) {
|
|
10686
11096
|
lastSessionCwdRef.current = sessionCwd
|
|
10687
11097
|
return
|
|
10688
11098
|
}
|
|
@@ -10887,6 +11297,14 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10887
11297
|
if (project === null) return
|
|
10888
11298
|
let state = null
|
|
10889
11299
|
state = G.floatState
|
|
11300
|
+
if (state === null || state === undefined) {
|
|
11301
|
+
try {
|
|
11302
|
+
const raw = localStorage.getItem('gufa-code:float-state')
|
|
11303
|
+
state = raw === null ? null : JSON.parse(raw)
|
|
11304
|
+
} catch {
|
|
11305
|
+
state = null
|
|
11306
|
+
}
|
|
11307
|
+
}
|
|
10890
11308
|
if (state === null || typeof state !== 'object') return
|
|
10891
11309
|
floatTabsRestoredRef.current = true
|
|
10892
11310
|
const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
|
|
@@ -10906,11 +11324,21 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10906
11324
|
|
|
10907
11325
|
/* 悬浮层恢复入口:主窗口把状态带过来后,由 99-main 显式调用(不依赖 App 自己的启动时序) */
|
|
10908
11326
|
useEffect(() => {
|
|
10909
|
-
G.floatRestoreRef = { applyProject, openFile }
|
|
11327
|
+
G.floatRestoreRef = { applyProject, openFile, applyTabs }
|
|
11328
|
+
G.floatGetTabs = () => tabs
|
|
11329
|
+
G.floatApplyUiRef = (nextUi) => {
|
|
11330
|
+
if (nextUi === null || nextUi === undefined || typeof nextUi !== 'object') return
|
|
11331
|
+
patchUi({
|
|
11332
|
+
view: typeof nextUi.view === 'string' ? nextUi.view : undefined,
|
|
11333
|
+
chatOpen: typeof nextUi.chatOpen === 'boolean' ? nextUi.chatOpen : undefined,
|
|
11334
|
+
terminalOpen: typeof nextUi.terminalOpen === 'boolean' ? nextUi.terminalOpen : undefined,
|
|
11335
|
+
sidebarOpen: typeof nextUi.sidebarOpen === 'boolean' ? nextUi.sidebarOpen : undefined,
|
|
11336
|
+
})
|
|
11337
|
+
}
|
|
10910
11338
|
return () => {
|
|
10911
11339
|
if (G.floatRestoreRef !== undefined && G.floatRestoreRef !== null && G.floatRestoreRef.applyProject === applyProject) G.floatRestoreRef = null
|
|
10912
11340
|
}
|
|
10913
|
-
}, [applyProject, openFile])
|
|
11341
|
+
}, [applyProject, openFile, applyTabs, tabs])
|
|
10914
11342
|
|
|
10915
11343
|
const activeFileForChat = useMemo(() => {
|
|
10916
11344
|
if (activeTab === null || activeTab.kind === 'diff' || activeTab.kind === 'graph') return null
|
|
@@ -11216,6 +11644,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11216
11644
|
h(G.Seal, { size: 24, className: 'gufa-brand-logo' }),
|
|
11217
11645
|
h('span', { className: 'gufa-brand-name' }, t('app.title')),
|
|
11218
11646
|
h('span', { className: 'gufa-brand-sub' }, t('app.subtitle')),
|
|
11647
|
+
h('span', { className: 'gufa-build-tag', title: '古法编程客户端版本(排查缓存用)' }, G.BUILD !== undefined ? G.BUILD : ''),
|
|
11219
11648
|
),
|
|
11220
11649
|
h(
|
|
11221
11650
|
'button',
|
|
@@ -11234,8 +11663,24 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11234
11663
|
h(
|
|
11235
11664
|
'div',
|
|
11236
11665
|
{ className: 'gufa-titlebar-actions' },
|
|
11237
|
-
|
|
11238
|
-
|
|
11666
|
+
moyuMode
|
|
11667
|
+
? h(
|
|
11668
|
+
'label',
|
|
11669
|
+
{ className: 'gufa-moyu-alpha', title: '摸鱼界面透明度' },
|
|
11670
|
+
h('span', { className: 'gufa-moyu-alpha-label' }, '透明度'),
|
|
11671
|
+
h('input', {
|
|
11672
|
+
className: 'gufa-moyu-alpha-range',
|
|
11673
|
+
type: 'range',
|
|
11674
|
+
min: 20,
|
|
11675
|
+
max: 100,
|
|
11676
|
+
step: 1,
|
|
11677
|
+
value: floatAlpha,
|
|
11678
|
+
onChange: (event) => setFloatAlpha(Number(event.target.value)),
|
|
11679
|
+
}),
|
|
11680
|
+
h('span', { className: 'gufa-moyu-alpha-value' }, `${floatAlpha}%`),
|
|
11681
|
+
)
|
|
11682
|
+
: h(G.Button, { icon: 'plus', title: t('app.newWorkspace'), disabled: workspaceBusy, onClick: () => void createWorkspace() }, t('app.newWorkspace')),
|
|
11683
|
+
moyuMode === false && skinBackdrop.available === true && backdropActive
|
|
11239
11684
|
? h(G.BackdropStrengthSlider, {
|
|
11240
11685
|
value: backdropStrength === null || backdropStrength === undefined ? Math.round((skinBackdrop.portraitOpacity ?? 1) * 100) : backdropStrength,
|
|
11241
11686
|
onChange: (value) => {
|
|
@@ -11248,7 +11693,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11248
11693
|
},
|
|
11249
11694
|
})
|
|
11250
11695
|
: null,
|
|
11251
|
-
skinBackdrop.available === true
|
|
11696
|
+
moyuMode === false && skinBackdrop.available === true
|
|
11252
11697
|
? h(G.IconButton, {
|
|
11253
11698
|
title: backdropActive ? t('app.backdropOff') : t('app.backdropOn'),
|
|
11254
11699
|
'data-active': backdropActive ? '' : undefined,
|
|
@@ -11259,19 +11704,32 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11259
11704
|
}),
|
|
11260
11705
|
}, h(G.Icon, { name: 'image', size: 16 }))
|
|
11261
11706
|
: null,
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11707
|
+
moyuMode === false
|
|
11708
|
+
? h('button', {
|
|
11709
|
+
type: 'button',
|
|
11710
|
+
className: 'gufa-moyu-btn',
|
|
11711
|
+
title: '摸鱼模式:选择一个 App 吸附并悬浮',
|
|
11712
|
+
disabled: floatBusy,
|
|
11713
|
+
onClick: () => void toggleFloatWindow(),
|
|
11714
|
+
}, '摸鱼')
|
|
11715
|
+
: null,
|
|
11716
|
+
moyuMode === false
|
|
11717
|
+
? h(G.IconButton, { title: t('app.refresh'), onClick: () => { setRefreshToken((token) => token + 1); setGitRefreshToken((token) => token + 1); setSshRefreshToken((token) => token + 1) } }, h(G.Icon, { name: 'refresh', size: 15 }))
|
|
11718
|
+
: null,
|
|
11269
11719
|
h(G.IconButton, {
|
|
11270
11720
|
title: ui.chatOpen ? t('activity.collapseChat') : t('activity.expandChat'),
|
|
11271
11721
|
'data-active': ui.chatOpen ? '' : undefined,
|
|
11272
11722
|
onClick: () => patchUi({ chatOpen: !ui.chatOpen }),
|
|
11273
11723
|
}, h(G.Icon, { name: 'panel-right', size: 16 })),
|
|
11274
|
-
|
|
11724
|
+
moyuMode
|
|
11725
|
+
? h('button', {
|
|
11726
|
+
type: 'button',
|
|
11727
|
+
className: 'gufa-moyu-exit',
|
|
11728
|
+
title: '退出摸鱼:关闭悬浮层,回到主窗口并带回当前状态',
|
|
11729
|
+
disabled: floatBusy,
|
|
11730
|
+
onClick: () => void exitMoyu(),
|
|
11731
|
+
}, '退出摸鱼')
|
|
11732
|
+
: h(G.Button, { icon: 'arrow-left', title: t('app.exitHint'), onClick: exitMode }, t('app.exit')),
|
|
11275
11733
|
),
|
|
11276
11734
|
),
|
|
11277
11735
|
/* 主体 */
|
|
@@ -12259,6 +12717,23 @@ const GUFA_PLUGIN = {
|
|
|
12259
12717
|
if (floatMode) {
|
|
12260
12718
|
document.documentElement.setAttribute('data-gufa-float', '1')
|
|
12261
12719
|
document.documentElement.setAttribute('data-gufa-booting', '1')
|
|
12720
|
+
/* 摸鱼窗口不需要皮肤:关掉皮肤插件的动画开关并移除其背景节点,
|
|
12721
|
+
否则它仍在 rAF 里持续写 body.style / 画 canvas(看不见但耗 CPU、占内存) */
|
|
12722
|
+
const disableSkin = () => {
|
|
12723
|
+
try {
|
|
12724
|
+
const root = document.documentElement
|
|
12725
|
+
if (root.getAttribute('data-liang-skin') === 'on') root.setAttribute('data-liang-skin', 'off')
|
|
12726
|
+
root.removeAttribute('data-liang-stage')
|
|
12727
|
+
root.removeAttribute('data-gufa-skin-live')
|
|
12728
|
+
for (const node of document.querySelectorAll('.liang-skin-backdrop, .liang-ambient, .liang-skin-portrait, .liang-skin-root')) {
|
|
12729
|
+
node.remove()
|
|
12730
|
+
}
|
|
12731
|
+
} catch {
|
|
12732
|
+
/* ignore */
|
|
12733
|
+
}
|
|
12734
|
+
}
|
|
12735
|
+
disableSkin()
|
|
12736
|
+
for (const delay of [400, 1200, 2600, 5000]) window.setTimeout(disableSkin, delay)
|
|
12262
12737
|
let attempts = 0
|
|
12263
12738
|
const timer = window.setInterval(() => {
|
|
12264
12739
|
attempts += 1
|
|
@@ -12272,10 +12747,100 @@ const GUFA_PLUGIN = {
|
|
|
12272
12747
|
window.clearInterval(timer)
|
|
12273
12748
|
/* 显式恢复主窗口状态(项目 → 标签页 → 会话),避免依赖 Web 版 App 的启动时序 */
|
|
12274
12749
|
try {
|
|
12750
|
+
/* 诊断:找出某个点上所有「会画背景」的元素(含 pointer-events:none 的覆盖层) */
|
|
12751
|
+
try {
|
|
12752
|
+
const describe = (el) => {
|
|
12753
|
+
const cs = window.getComputedStyle(el)
|
|
12754
|
+
const cls = typeof el.className === 'string' ? el.className.replace(/\s+/g, '.').slice(0, 32) : ''
|
|
12755
|
+
const r = el.getBoundingClientRect()
|
|
12756
|
+
return `${el.tagName.toLowerCase()}.${cls}[bg=${cs.backgroundColor} op=${cs.opacity} z=${cs.zIndex} pe=${cs.pointerEvents} bf=${cs.backdropFilter !== 'none' ? 'Y' : ''} img=${cs.backgroundImage !== 'none' ? 'Y' : ''}]@${Math.round(r.left)},${Math.round(r.top)} ${Math.round(r.width)}x${Math.round(r.height)}`
|
|
12757
|
+
}
|
|
12758
|
+
const paintersAt = (x, y) => {
|
|
12759
|
+
const out = []
|
|
12760
|
+
for (const el of document.querySelectorAll('body *')) {
|
|
12761
|
+
const r = el.getBoundingClientRect()
|
|
12762
|
+
if (!(x >= r.left && x <= r.right && y >= r.top && y <= r.bottom)) continue
|
|
12763
|
+
const cs = window.getComputedStyle(el)
|
|
12764
|
+
if (cs.backgroundColor !== 'rgba(0, 0, 0, 0)' || cs.backgroundImage !== 'none' || cs.backdropFilter !== 'none') {
|
|
12765
|
+
out.push(describe(el) + (el.closest('.gufa-overlay-root') === null ? ' [OUTSIDE]' : ''))
|
|
12766
|
+
if (out.length >= 18) break
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
return out.join(' || ')
|
|
12770
|
+
}
|
|
12771
|
+
const w = window.innerWidth
|
|
12772
|
+
const h = window.innerHeight
|
|
12773
|
+
void G.api('dev.log', { message: `float-painters chat=[${paintersAt(Math.round(w * 0.92), Math.round(h * 0.35))}]` }).catch(() => {})
|
|
12774
|
+
} catch {
|
|
12775
|
+
/* ignore */
|
|
12776
|
+
}
|
|
12777
|
+
/* 诊断:从像素点反查元素链,找出右侧会话框多出来的深色层 */
|
|
12778
|
+
try {
|
|
12779
|
+
const desc = (el) => {
|
|
12780
|
+
if (el === null || el === undefined) return 'null'
|
|
12781
|
+
const cs = window.getComputedStyle(el)
|
|
12782
|
+
const cls = typeof el.className === 'string' ? el.className.replace(/\s+/g, '.').slice(0, 40) : ''
|
|
12783
|
+
const img = cs.backgroundImage === 'none' ? '' : ` img=${cs.backgroundImage.slice(0, 50)}`
|
|
12784
|
+
const bf = cs.backdropFilter === 'none' ? '' : ` bf=${cs.backdropFilter}`
|
|
12785
|
+
return `${el.tagName.toLowerCase()}.${cls}[bg=${cs.backgroundColor} op=${cs.opacity}${img}${bf}]`
|
|
12786
|
+
}
|
|
12787
|
+
const chain = (x, y) => {
|
|
12788
|
+
let el = document.elementFromPoint(x, y)
|
|
12789
|
+
const parts = []
|
|
12790
|
+
for (let i = 0; i < 7 && el !== null; i += 1) {
|
|
12791
|
+
parts.push(desc(el))
|
|
12792
|
+
const before = window.getComputedStyle(el, '::before').backgroundColor
|
|
12793
|
+
if (before !== 'rgba(0, 0, 0, 0)' && before !== 'transparent') parts.push(`::before=${before}`)
|
|
12794
|
+
el = el.parentElement
|
|
12795
|
+
}
|
|
12796
|
+
return parts.join(' <- ')
|
|
12797
|
+
}
|
|
12798
|
+
const w = window.innerWidth
|
|
12799
|
+
const h = window.innerHeight
|
|
12800
|
+
void G.api('dev.log', {
|
|
12801
|
+
message: `float-probe editor=[${chain(Math.round(w * 0.45), Math.round(h * 0.55))}] chat=[${chain(Math.round(w * 0.92), Math.round(h * 0.4))}]`,
|
|
12802
|
+
}).catch(() => {})
|
|
12803
|
+
} catch {
|
|
12804
|
+
/* ignore */
|
|
12805
|
+
}
|
|
12806
|
+
/* 诊断:找出会话框里非透明的背景元素(排查透明度不一致) */
|
|
12807
|
+
try {
|
|
12808
|
+
const chat = document.querySelector('.gufa-chatpane')
|
|
12809
|
+
const found = []
|
|
12810
|
+
if (chat !== null) {
|
|
12811
|
+
for (const el of chat.querySelectorAll('*')) {
|
|
12812
|
+
const bg = window.getComputedStyle(el).backgroundColor
|
|
12813
|
+
if (bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent') {
|
|
12814
|
+
found.push(`${el.tagName.toLowerCase()}.${String(el.className || '').replace(/\s+/g, '.').slice(0, 60)}=${bg}`)
|
|
12815
|
+
if (found.length >= 10) break
|
|
12816
|
+
}
|
|
12817
|
+
}
|
|
12818
|
+
}
|
|
12819
|
+
void G.api('dev.log', { message: `float-chat-bgs ${found.join(' | ') || 'none'}` }).catch(() => {})
|
|
12820
|
+
} catch {
|
|
12821
|
+
/* ignore */
|
|
12822
|
+
}
|
|
12823
|
+
/* 诊断:摸鱼窗口里各面板的实际底色(排查透明度不一致) */
|
|
12824
|
+
try {
|
|
12825
|
+
const pick = (sel) => {
|
|
12826
|
+
const el = document.querySelector(sel)
|
|
12827
|
+
if (el === null) return `${sel}=none`
|
|
12828
|
+
const cs = window.getComputedStyle(el)
|
|
12829
|
+
return `${sel}=${cs.backgroundColor}/${cs.opacity}`
|
|
12830
|
+
}
|
|
12831
|
+
const root = document.querySelector('.gufa-root')
|
|
12832
|
+
void G.api('dev.log', {
|
|
12833
|
+
message: `float-styles backdrop=${root === null ? '?' : root.getAttribute('data-backdrop')} ${pick('.gufa-overlay-root')} ${pick('.gufa-editor-area')} ${pick('.gufa-chatpane')} ${pick('.gufa-termpane')} ${pick('.gufa-termhead')} ${pick('.gufa-sidepanel')} ${pick('.gufa-main')} alphaVar=${window.getComputedStyle(document.documentElement).getPropertyValue('--gufa-float-alpha')}`,
|
|
12834
|
+
}).catch(() => {})
|
|
12835
|
+
} catch {
|
|
12836
|
+
/* ignore */
|
|
12837
|
+
}
|
|
12838
|
+
void G.api('dev.log', { message: `float-boot hasState=${G.floatState !== null && G.floatState !== undefined} restoreRef=${G.floatRestoreRef !== null && G.floatRestoreRef !== undefined} state=${G.floatState === null || G.floatState === undefined ? 'null' : JSON.stringify({ projectRoot: G.floatState.projectRoot, tabs: Array.isArray(G.floatState.tabs) ? G.floatState.tabs.length : 0, activePath: G.floatState.activePath })}` }).catch(() => {})
|
|
12275
12839
|
if (window.__gufaFloatRestored !== true && G.floatState !== null && G.floatState !== undefined) {
|
|
12276
12840
|
window.__gufaFloatRestored = true
|
|
12277
12841
|
void (async () => {
|
|
12278
12842
|
const state = G.floatState
|
|
12843
|
+
const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
|
|
12279
12844
|
let projectValue = null
|
|
12280
12845
|
if (typeof state.projectRoot === 'string' && state.projectRoot !== '') {
|
|
12281
12846
|
try {
|
|
@@ -12287,20 +12852,28 @@ const GUFA_PLUGIN = {
|
|
|
12287
12852
|
const restore = G.floatRestoreRef
|
|
12288
12853
|
if (projectValue !== null && restore !== null && restore !== undefined && typeof restore.applyProject === 'function') {
|
|
12289
12854
|
restore.applyProject(projectValue)
|
|
12855
|
+
void G.api('dev.log', { message: `float-restore project=${String(projectValue.root)} tabs=${paths.length}` }).catch(() => {})
|
|
12856
|
+
} else {
|
|
12857
|
+
void G.api('dev.log', { message: `float-restore-failed projectValue=${projectValue === null ? 'null' : 'ok'} ref=${restore !== null && restore !== undefined}` }).catch(() => {})
|
|
12290
12858
|
}
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12859
|
+
/* 先恢复 UI 面板状态(终端/视图等) */
|
|
12860
|
+
try {
|
|
12861
|
+
if (typeof G.floatApplyUiRef === 'function' && state.ui !== null && typeof state.ui === 'object') G.floatApplyUiRef(state.ui)
|
|
12862
|
+
} catch {
|
|
12863
|
+
/* ignore */
|
|
12864
|
+
}
|
|
12865
|
+
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
12866
|
+
/* 按快照里的标签顺序打开,最后再激活 activePath,避免顺序漂移 */
|
|
12867
|
+
const ordered = paths
|
|
12868
|
+
const activeOne = typeof state.activePath === 'string' && state.activePath !== '' ? state.activePath : null
|
|
12869
|
+
/* 关键:applyProject 之后 App 已重渲染,取最新恢复入口;优先原子恢复标签集合 */
|
|
12870
|
+
await new Promise((resolve) => setTimeout(resolve, 250))
|
|
12871
|
+
const latest = G.floatRestoreRef
|
|
12872
|
+
if (latest !== null && latest !== undefined && typeof latest.applyTabs === 'function') {
|
|
12873
|
+
await latest.applyTabs(ordered, activeOne)
|
|
12874
|
+
} else if (latest !== null && latest !== undefined && typeof latest.openFile === 'function') {
|
|
12298
12875
|
for (const path of ordered.slice(0, 10)) {
|
|
12299
|
-
try {
|
|
12300
|
-
await openFile(path)
|
|
12301
|
-
} catch {
|
|
12302
|
-
/* ignore */
|
|
12303
|
-
}
|
|
12876
|
+
try { await latest.openFile(path) } catch { /* ignore */ }
|
|
12304
12877
|
}
|
|
12305
12878
|
}
|
|
12306
12879
|
if (typeof state.sessionId === 'string' && state.sessionId !== '') {
|
|
@@ -12420,7 +12993,7 @@ const GUFA_PLUGIN = {
|
|
|
12420
12993
|
try {
|
|
12421
12994
|
const transport = typeof globalThis.__DSH_TRANSPORT__ === 'object' && globalThis.__DSH_TRANSPORT__ !== null ? globalThis.__DSH_TRANSPORT__ : null
|
|
12422
12995
|
void G.api('dev.log', {
|
|
12423
|
-
message: `boot href=${location.href} base=${G.serverBase()} transport=${transport === null ? 'none' : JSON.stringify(transport)}`,
|
|
12996
|
+
message: `boot build=${G.BUILD || '?'} href=${location.href} base=${G.serverBase()} transport=${transport === null ? 'none' : JSON.stringify(transport)}`,
|
|
12424
12997
|
}).catch(() => {})
|
|
12425
12998
|
} catch {
|
|
12426
12999
|
/* 诊断失败不影响启动 */
|