dsh-gufa-code 1.3.184 → 1.3.187
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 +44 -8
- package/desktop/float/bin/win-x64/gufa-float-win.exe +0 -0
- package/desktop/float/win/main.cpp +127 -18
- package/host/code.js +11 -2
- package/package.json +1 -1
- package/src/client/00-core.js +10 -0
- package/src/client/60-dock.js +17 -2
- package/src/client/85-shortcuts.js +3 -0
- package/src/client/90-app.js +13 -5
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
|
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
18
|
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
-
G.BUILD = '1.3.
|
|
19
|
+
G.BUILD = '1.3.187'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -1236,6 +1236,16 @@ html[data-gufa-float] .gufa-tabs,
|
|
|
1236
1236
|
html[data-gufa-float] .gufa-statusbar,
|
|
1237
1237
|
html[data-gufa-float] [data-gufa-dock],
|
|
1238
1238
|
html[data-gufa-float] [data-gufa-dock] > *{background:transparent!important}
|
|
1239
|
+
/* 摸鱼模式:Monaco 自己画实色背景,必须显式透明,否则编辑区在透明悬浮窗里是一块实色
|
|
1240
|
+
(Windows helper 尤其明显;mac 之前靠 backdrop=on 的分支碰巧覆盖了) */
|
|
1241
|
+
html[data-gufa-float] .gufa-editor-host{background:transparent!important}
|
|
1242
|
+
html[data-gufa-float] .gufa-editor-host .monaco-editor,
|
|
1243
|
+
html[data-gufa-float] .gufa-editor-host .monaco-editor .margin,
|
|
1244
|
+
html[data-gufa-float] .gufa-editor-host .monaco-editor-background,
|
|
1245
|
+
html[data-gufa-float] .gufa-editor-host .monaco-diff-editor .editor.original,
|
|
1246
|
+
html[data-gufa-float] .gufa-editor-host .monaco-diff-editor .editor.modified,
|
|
1247
|
+
html[data-gufa-float] .gufa-editor-host .gufa-empty,
|
|
1248
|
+
html[data-gufa-float] .gufa-editor-host .gufa-editor-fallback{background:transparent!important}
|
|
1239
1249
|
/* 官方会话停靠层(toolbar/host)自带底色,摸鱼里一并透明,避免会话框叠两层 */
|
|
1240
1250
|
html[data-gufa-float] .gufa-dock-toolbar,
|
|
1241
1251
|
html[data-gufa-float] .gufa-dock-host,
|
|
@@ -11347,11 +11357,26 @@ function gufaParseMentionButton(button) {
|
|
|
11347
11357
|
|
|
11348
11358
|
async function gufaOpenMention(mention) {
|
|
11349
11359
|
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
11350
|
-
|
|
11360
|
+
/* 必须原样传 Host 登记的 project.root:Windows 上 Host 用反斜杠规范化过,
|
|
11361
|
+
ProjectRegistry.ensure 是精确字符串匹配;改成 / 会被拒绝(project-not-open),
|
|
11362
|
+
表现就是 Windows 上引用点不开。 */
|
|
11363
|
+
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/[\\/]+$/, '') : ''
|
|
11351
11364
|
if (root === '') return
|
|
11365
|
+
/* Windows 的会话引用可能带 file:///C:/ 前缀、%20 编码或反斜杠;先归一化再让 Host 解析 */
|
|
11366
|
+
let rawPath = String(mention.path ?? '').trim()
|
|
11367
|
+
if (/^file:\/\//i.test(rawPath)) {
|
|
11368
|
+
rawPath = rawPath.replace(/^file:\/\//i, '')
|
|
11369
|
+
try { rawPath = decodeURIComponent(rawPath) } catch { /* ignore */ }
|
|
11370
|
+
}
|
|
11371
|
+
rawPath = rawPath.replace(/\\/g, '/').replace(/^\/[A-Za-z]:\//, (m) => m.slice(1))
|
|
11352
11372
|
let resolved = null
|
|
11353
11373
|
try {
|
|
11354
|
-
resolved = await G.api('code.resolvePath', { root, path:
|
|
11374
|
+
resolved = await G.api('code.resolvePath', { root, path: rawPath })
|
|
11375
|
+
/* 完整路径解析不到时,退一步只按 basename 找(Windows 盘符/大小写差异常见) */
|
|
11376
|
+
if (resolved === null || resolved === undefined || typeof resolved.path !== 'string' || resolved.path === '') {
|
|
11377
|
+
const base = rawPath.split('/').filter((part) => part !== '').pop() ?? ''
|
|
11378
|
+
if (base !== '' && base !== rawPath) resolved = await G.api('code.resolvePath', { root, path: base })
|
|
11379
|
+
}
|
|
11355
11380
|
} catch {
|
|
11356
11381
|
return
|
|
11357
11382
|
}
|
|
@@ -12188,6 +12213,9 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12188
12213
|
'sidebar.left.toggle': 'toggleSidebar',
|
|
12189
12214
|
'edrv.save': 'save',
|
|
12190
12215
|
'edrv.closeTab': 'closeTab',
|
|
12216
|
+
/* DSH 桌面端把 Ctrl+W/Cmd+W 默认绑给右侧页面关闭(page.close),
|
|
12217
|
+
它在 main 进程就被截走,浏览器里的 keydown 收不到;IDE 里要改派成关标签页。 */
|
|
12218
|
+
'page.close': 'closeTab',
|
|
12191
12219
|
'edrv.reloadWindow': 'refresh',
|
|
12192
12220
|
'edrv.toggleSidebar': 'toggleSidebar',
|
|
12193
12221
|
'shortcuts.open': 'shortcuts',
|
|
@@ -12743,6 +12771,11 @@ G.useSplitter = function useSplitter(options) {
|
|
|
12743
12771
|
|
|
12744
12772
|
|
|
12745
12773
|
|
|
12774
|
+
/** 项目相对路径统一成 POSIX 风格:Windows Host/会话引用可能带反斜杠或前导 ./ */
|
|
12775
|
+
function gufaNormalizeProjectPath(value) {
|
|
12776
|
+
return String(value ?? '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+/, '')
|
|
12777
|
+
}
|
|
12778
|
+
|
|
12746
12779
|
G.GufaApp = function GufaApp(props) {
|
|
12747
12780
|
const t = G.useT()
|
|
12748
12781
|
const theme = G.useTheme()
|
|
@@ -13098,10 +13131,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13098
13131
|
}, [gitStatus, project])
|
|
13099
13132
|
|
|
13100
13133
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
13101
|
-
const openFile = useCallback(async (
|
|
13134
|
+
const openFile = useCallback(async (rawPath) => {
|
|
13102
13135
|
if (project === null) return
|
|
13136
|
+
const path = gufaNormalizeProjectPath(rawPath)
|
|
13137
|
+
if (path === '') return
|
|
13103
13138
|
flushBuffersRef.current?.()
|
|
13104
|
-
const existing = tabs.find((tab) => tab.path === path)
|
|
13139
|
+
const existing = tabs.find((tab) => gufaNormalizeProjectPath(tab.path) === path)
|
|
13105
13140
|
if (existing !== undefined) {
|
|
13106
13141
|
/* 已经打开的文件再次点击:先对齐磁盘最新版本(AI/外部修改后不用关掉重开) */
|
|
13107
13142
|
try {
|
|
@@ -13116,7 +13151,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13116
13151
|
const doc = await G.api('fs.read', { root: project.root, path })
|
|
13117
13152
|
/* 用函数式更新去重:并发/恢复场景下闭包里的 tabs 可能还没刷新,直接追加会产生重复标签 */
|
|
13118
13153
|
setTabs((current) => (
|
|
13119
|
-
current.some((tab) => tab.path === path)
|
|
13154
|
+
current.some((tab) => gufaNormalizeProjectPath(tab.path) === gufaNormalizeProjectPath(doc.path ?? path))
|
|
13120
13155
|
? current
|
|
13121
13156
|
: [...current, { ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision }]
|
|
13122
13157
|
))
|
|
@@ -13127,8 +13162,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13127
13162
|
}, [project, tabs])
|
|
13128
13163
|
|
|
13129
13164
|
/* 从搜索/定位结果打开文件并跳到指定行列(等 tab 切换完成后再触发编辑器 reveal) */
|
|
13130
|
-
const openFileAt = useCallback(async (
|
|
13131
|
-
if (typeof
|
|
13165
|
+
const openFileAt = useCallback(async (rawPath, line, column) => {
|
|
13166
|
+
if (typeof rawPath !== 'string' || rawPath === '') return
|
|
13167
|
+
const path = gufaNormalizeProjectPath(rawPath)
|
|
13132
13168
|
await openFile(path)
|
|
13133
13169
|
const targetLine = Number.isFinite(Number(line)) ? Math.max(1, Math.trunc(Number(line))) : 1
|
|
13134
13170
|
const targetColumn = Number.isFinite(Number(column)) ? Math.max(1, Math.trunc(Number(column))) : 1
|
|
Binary file
|
|
@@ -78,6 +78,9 @@ constexpr UINT_PTR kTimerControllerWatchdog = 9;
|
|
|
78
78
|
|
|
79
79
|
constexpr int kMenuExit = 1;
|
|
80
80
|
constexpr int kMenuResetFrame = 2;
|
|
81
|
+
constexpr int kMenuToggleClickThrough = 3;
|
|
82
|
+
constexpr int kMenuStopFollow = 4;
|
|
83
|
+
constexpr UINT kHotkeyClickThrough = 0x4755; // 全局热键 id:Ctrl+Alt+Shift+G 切换鼠标穿透
|
|
81
84
|
|
|
82
85
|
constexpr int kResizeBorderDip = 8; // 左右/底部可缩放边缘宽度(DIP)
|
|
83
86
|
constexpr int kDragStripDip = 22; // 顶部拖动条高度(DIP,与网页 CSS 的 22px 对齐)
|
|
@@ -906,22 +909,10 @@ HWND FindFollowWindowForProcess(DWORD processId, const std::wstring& title) {
|
|
|
906
909
|
}
|
|
907
910
|
|
|
908
911
|
/* 悬浮层右键菜单:windowed 模式由拖动条子窗口触发;composition 模式由主窗口
|
|
909
|
-
* 顶部 22px 拖动区的 WM_NCRBUTTONUP 触发。命令统一 PostMessage 给主窗口处理。
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
if (menu == nullptr) return;
|
|
914
|
-
AppendMenuW(menu, MF_STRING, kMenuExit, L"退出摸鱼(恢复主窗口)");
|
|
915
|
-
AppendMenuW(menu, MF_STRING, kMenuResetFrame, L"重置窗口位置和大小");
|
|
916
|
-
POINT cursor;
|
|
917
|
-
GetCursorPos(&cursor);
|
|
918
|
-
const int command = static_cast<int>(TrackPopupMenu(
|
|
919
|
-
menu, TPM_RETURNCMD | TPM_RIGHTBUTTON, cursor.x, cursor.y, 0, owner, nullptr));
|
|
920
|
-
DestroyMenu(menu);
|
|
921
|
-
if (command != 0) {
|
|
922
|
-
PostMessageW(owner, kMsgStripMenu, static_cast<WPARAM>(command), 0);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
912
|
+
* 顶部 22px 拖动区的 WM_NCRBUTTONUP 触发。命令统一 PostMessage 给主窗口处理。
|
|
913
|
+
* 实现在 FloatApp 类之后(需要读取穿透/跟随状态)。 */
|
|
914
|
+
class FloatApp;
|
|
915
|
+
static void ShowFloatContextMenu(HWND owner, FloatApp* app);
|
|
925
916
|
|
|
926
917
|
/* ────────────────────────────── 悬浮层窗口 ────────────────────────────── */
|
|
927
918
|
|
|
@@ -939,6 +930,10 @@ class FloatApp {
|
|
|
939
930
|
void RequestExit(int exitCode);
|
|
940
931
|
bool IsCiProbe() const { return payload_.ciProbe; }
|
|
941
932
|
std::wstring CiProbeOutputPath() const { return payload_.ciProbeOut; }
|
|
933
|
+
bool clickThroughEnabled() const { return clickThrough_; }
|
|
934
|
+
bool followActive() const { return followActivated_ && followWindow_ != nullptr; }
|
|
935
|
+
void ToggleClickThrough();
|
|
936
|
+
void StopFollowing();
|
|
942
937
|
/* 兜底:ciProbe 进程即将结束但还没写结果时,补写一个 ok:false 的探针文件。 */
|
|
943
938
|
void EnsureCiProbeResultWritten(const std::wstring& reason);
|
|
944
939
|
|
|
@@ -977,6 +972,7 @@ class FloatApp {
|
|
|
977
972
|
|
|
978
973
|
void OnFollowTimer();
|
|
979
974
|
void ApplyFollowFrame();
|
|
975
|
+
void ApplyClickThrough();
|
|
980
976
|
void OnHideDshTimer();
|
|
981
977
|
void HideDshWindows();
|
|
982
978
|
void RestoreDshWindows();
|
|
@@ -1047,8 +1043,45 @@ class FloatApp {
|
|
|
1047
1043
|
bool mouseCaptured_ = false;
|
|
1048
1044
|
bool suppressWindowDestroy_ = false;
|
|
1049
1045
|
bool hideDshDone_ = false;
|
|
1046
|
+
bool clickThrough_ = false;
|
|
1047
|
+
bool clickThroughLayered_ = false;
|
|
1048
|
+
bool clickThroughHotkey_ = false;
|
|
1050
1049
|
};
|
|
1051
1050
|
|
|
1051
|
+
namespace {
|
|
1052
|
+
BOOL CALLBACK SetChildClickThrough(HWND child, LPARAM lparam) {
|
|
1053
|
+
const bool enable = lparam != 0;
|
|
1054
|
+
LONG_PTR exStyle = GetWindowLongPtrW(child, GWL_EXSTYLE);
|
|
1055
|
+
LONG_PTR next = enable ? (exStyle | WS_EX_TRANSPARENT)
|
|
1056
|
+
: (exStyle & ~static_cast<LONG_PTR>(WS_EX_TRANSPARENT));
|
|
1057
|
+
if (next != exStyle) SetWindowLongPtrW(child, GWL_EXSTYLE, next);
|
|
1058
|
+
return TRUE;
|
|
1059
|
+
}
|
|
1060
|
+
} // namespace
|
|
1061
|
+
|
|
1062
|
+
static void ShowFloatContextMenu(HWND owner, FloatApp* app) {
|
|
1063
|
+
if (owner == nullptr) return;
|
|
1064
|
+
HMENU menu = CreatePopupMenu();
|
|
1065
|
+
if (menu == nullptr) return;
|
|
1066
|
+
if (app != nullptr && app->followActive()) {
|
|
1067
|
+
AppendMenuW(menu, MF_STRING, kMenuStopFollow, L"停止跟随 App 窗口");
|
|
1068
|
+
AppendMenuW(menu, MF_SEPARATOR, 0, nullptr);
|
|
1069
|
+
}
|
|
1070
|
+
AppendMenuW(menu, static_cast<UINT>(MF_STRING) | ((app != nullptr && app->clickThroughEnabled()) ? static_cast<UINT>(MF_CHECKED) : 0U),
|
|
1071
|
+
kMenuToggleClickThrough, L"切换鼠标穿透(Ctrl+Alt+Shift+G)");
|
|
1072
|
+
AppendMenuW(menu, MF_STRING, kMenuResetFrame, L"重置窗口位置和大小");
|
|
1073
|
+
AppendMenuW(menu, MF_SEPARATOR, 0, nullptr);
|
|
1074
|
+
AppendMenuW(menu, MF_STRING, kMenuExit, L"退出摸鱼(恢复主窗口)");
|
|
1075
|
+
POINT cursor;
|
|
1076
|
+
GetCursorPos(&cursor);
|
|
1077
|
+
const int command = static_cast<int>(TrackPopupMenu(
|
|
1078
|
+
menu, TPM_RETURNCMD | TPM_RIGHTBUTTON, cursor.x, cursor.y, 0, owner, nullptr));
|
|
1079
|
+
DestroyMenu(menu);
|
|
1080
|
+
if (command != 0) {
|
|
1081
|
+
PostMessageW(owner, kMsgStripMenu, static_cast<WPARAM>(command), 0);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1052
1085
|
FloatApp::~FloatApp() {
|
|
1053
1086
|
if (hostProcess_ != nullptr) {
|
|
1054
1087
|
CloseHandle(hostProcess_);
|
|
@@ -1142,7 +1175,7 @@ LRESULT CALLBACK FloatApp::StripWndProc(HWND hwnd, UINT message, WPARAM wparam,
|
|
|
1142
1175
|
return 0;
|
|
1143
1176
|
}
|
|
1144
1177
|
case WM_RBUTTONUP:
|
|
1145
|
-
ShowFloatContextMenu(GetParent(hwnd));
|
|
1178
|
+
ShowFloatContextMenu(GetParent(hwnd), app);
|
|
1146
1179
|
return 0;
|
|
1147
1180
|
case WM_SETCURSOR:
|
|
1148
1181
|
SetCursor(LoadCursorW(nullptr, IDC_ARROW));
|
|
@@ -1334,6 +1367,12 @@ bool FloatApp::CreateHostWindow(const RECT& rect, bool composition) {
|
|
|
1334
1367
|
LogFmt(L"main-window-created composition=%d rect=(%ld,%ld)-(%ld,%ld) dpi=%u",
|
|
1335
1368
|
composition ? 1 : 0, static_cast<long>(rect.left), static_cast<long>(rect.top),
|
|
1336
1369
|
static_cast<long>(rect.right), static_cast<long>(rect.bottom), WindowDpi(hwnd_));
|
|
1370
|
+
if (RegisterHotKey(hwnd_, kHotkeyClickThrough, MOD_CONTROL | MOD_ALT | MOD_SHIFT, 'G')) {
|
|
1371
|
+
clickThroughHotkey_ = true;
|
|
1372
|
+
Log(L"click-through-hotkey=registered Ctrl+Alt+Shift+G");
|
|
1373
|
+
} else {
|
|
1374
|
+
LogFmt(L"click-through-hotkey=register-failed err=%lu", static_cast<unsigned long>(GetLastError()));
|
|
1375
|
+
}
|
|
1337
1376
|
if (composition) return true;
|
|
1338
1377
|
return CreateStripChildWindow();
|
|
1339
1378
|
}
|
|
@@ -1643,6 +1682,9 @@ bool FloatApp::OnCompositionMouseMessage(UINT message, WPARAM wparam, LPARAM lpa
|
|
|
1643
1682
|
}
|
|
1644
1683
|
|
|
1645
1684
|
LRESULT FloatApp::HandleNcHitTest(HWND hwnd, LPARAM lparam) {
|
|
1685
|
+
/* 鼠标穿透:双击/拖动都不要再命中本窗口,让点击落到下层 App。
|
|
1686
|
+
WS_EX_TRANSPARENT 在部分 WebView2/Composition 窗口上不生效,这里加 HTTRANSPARENT 兜底。 */
|
|
1687
|
+
if (clickThrough_) return HTTRANSPARENT;
|
|
1646
1688
|
POINT point;
|
|
1647
1689
|
point.x = GET_X_LPARAM(lparam);
|
|
1648
1690
|
point.y = GET_Y_LPARAM(lparam);
|
|
@@ -2126,6 +2168,9 @@ void FloatApp::FinishControllerSetup() {
|
|
|
2126
2168
|
}
|
|
2127
2169
|
controllerReady_ = true;
|
|
2128
2170
|
Log(L"webview2-controller-ready");
|
|
2171
|
+
if (clickThrough_) {
|
|
2172
|
+
ApplyClickThrough();
|
|
2173
|
+
}
|
|
2129
2174
|
ConfigureWebView();
|
|
2130
2175
|
LayoutChildren();
|
|
2131
2176
|
StartScriptInjection();
|
|
@@ -2472,12 +2517,59 @@ void FloatApp::CleanupWebView() {
|
|
|
2472
2517
|
environment_.Reset();
|
|
2473
2518
|
}
|
|
2474
2519
|
|
|
2520
|
+
void FloatApp::ToggleClickThrough() {
|
|
2521
|
+
clickThrough_ = !clickThrough_;
|
|
2522
|
+
ApplyClickThrough();
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
void FloatApp::ApplyClickThrough() {
|
|
2526
|
+
if (hwnd_ == nullptr) return;
|
|
2527
|
+
LONG_PTR exStyle = GetWindowLongPtrW(hwnd_, GWL_EXSTYLE);
|
|
2528
|
+
LONG_PTR next = clickThrough_ ? (exStyle | WS_EX_TRANSPARENT)
|
|
2529
|
+
: (exStyle & ~static_cast<LONG_PTR>(WS_EX_TRANSPARENT));
|
|
2530
|
+
/* windowed 模式需要 layered 才能让点击稳定穿透到下层窗口;composition 模式
|
|
2531
|
+
使用 WS_EX_NOREDIRECTIONBITMAP,不能叠加 layered。 */
|
|
2532
|
+
if (hostingMode_ == HostingMode::Windowed) {
|
|
2533
|
+
if (clickThrough_) {
|
|
2534
|
+
if ((next & WS_EX_LAYERED) == 0) {
|
|
2535
|
+
next |= WS_EX_LAYERED;
|
|
2536
|
+
clickThroughLayered_ = true;
|
|
2537
|
+
SetLayeredWindowAttributes(hwnd_, 0, 255, LWA_ALPHA);
|
|
2538
|
+
}
|
|
2539
|
+
} else if (clickThroughLayered_) {
|
|
2540
|
+
next &= ~static_cast<LONG_PTR>(WS_EX_LAYERED);
|
|
2541
|
+
clickThroughLayered_ = false;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
if (next != exStyle) {
|
|
2545
|
+
SetWindowLongPtrW(hwnd_, GWL_EXSTYLE, next);
|
|
2546
|
+
SetWindowPos(hwnd_, nullptr, 0, 0, 0, 0,
|
|
2547
|
+
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
|
2548
|
+
}
|
|
2549
|
+
EnumChildWindows(hwnd_, SetChildClickThrough, clickThrough_ ? 1 : 0);
|
|
2550
|
+
LogFmt(L"click-through=%d", clickThrough_ ? 1 : 0);
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
void FloatApp::StopFollowing() {
|
|
2554
|
+
if (!followActivated_ && followWindow_ == nullptr && !payload_.hasFollow) return;
|
|
2555
|
+
payload_.hasFollow = false;
|
|
2556
|
+
followActivated_ = false;
|
|
2557
|
+
followWindow_ = nullptr;
|
|
2558
|
+
followMissCount_ = 0;
|
|
2559
|
+
if (hwnd_ != nullptr) KillTimer(hwnd_, kTimerFollow);
|
|
2560
|
+
Log(L"follow-stopped-by-menu");
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2475
2563
|
void FloatApp::DoGracefulExit() {
|
|
2476
2564
|
if (hwnd_ == nullptr) {
|
|
2477
2565
|
PostQuitMessage(exitCode_);
|
|
2478
2566
|
return;
|
|
2479
2567
|
}
|
|
2480
2568
|
Log(L"graceful-exit-start");
|
|
2569
|
+
if (clickThroughHotkey_ && hwnd_ != nullptr) {
|
|
2570
|
+
UnregisterHotKey(hwnd_, kHotkeyClickThrough);
|
|
2571
|
+
clickThroughHotkey_ = false;
|
|
2572
|
+
}
|
|
2481
2573
|
KillAllTimers();
|
|
2482
2574
|
RestoreDshWindows();
|
|
2483
2575
|
DeleteControlFile();
|
|
@@ -2494,6 +2586,10 @@ void FloatApp::DoGracefulExit() {
|
|
|
2494
2586
|
}
|
|
2495
2587
|
|
|
2496
2588
|
void FloatApp::OnWindowDestroyed() {
|
|
2589
|
+
if (clickThroughHotkey_ && hwnd_ != nullptr) {
|
|
2590
|
+
UnregisterHotKey(hwnd_, kHotkeyClickThrough);
|
|
2591
|
+
clickThroughHotkey_ = false;
|
|
2592
|
+
}
|
|
2497
2593
|
KillAllTimers();
|
|
2498
2594
|
if (mouseCaptured_) {
|
|
2499
2595
|
mouseCaptured_ = false;
|
|
@@ -2528,7 +2624,7 @@ LRESULT FloatApp::OnMainMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM l
|
|
|
2528
2624
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2529
2625
|
case WM_NCRBUTTONUP:
|
|
2530
2626
|
if (hostingMode_ == HostingMode::Composition) {
|
|
2531
|
-
ShowFloatContextMenu(hwnd);
|
|
2627
|
+
ShowFloatContextMenu(hwnd, this);
|
|
2532
2628
|
return 0;
|
|
2533
2629
|
}
|
|
2534
2630
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
@@ -2538,6 +2634,9 @@ LRESULT FloatApp::OnMainMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM l
|
|
|
2538
2634
|
return TRUE;
|
|
2539
2635
|
}
|
|
2540
2636
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2637
|
+
case WM_MOUSEACTIVATE:
|
|
2638
|
+
if (clickThrough_) return MA_NOACTIVATE;
|
|
2639
|
+
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2541
2640
|
case WM_ACTIVATE:
|
|
2542
2641
|
if (hostingMode_ == HostingMode::Composition && LOWORD(wparam) != WA_INACTIVE &&
|
|
2543
2642
|
controller_.Get() != nullptr) {
|
|
@@ -2600,8 +2699,18 @@ LRESULT FloatApp::OnMainMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM l
|
|
|
2600
2699
|
RequestExit(0);
|
|
2601
2700
|
} else if (wparam == static_cast<WPARAM>(kMenuResetFrame)) {
|
|
2602
2701
|
ResetWindowFrame();
|
|
2702
|
+
} else if (wparam == static_cast<WPARAM>(kMenuToggleClickThrough)) {
|
|
2703
|
+
ToggleClickThrough();
|
|
2704
|
+
} else if (wparam == static_cast<WPARAM>(kMenuStopFollow)) {
|
|
2705
|
+
StopFollowing();
|
|
2603
2706
|
}
|
|
2604
2707
|
return 0;
|
|
2708
|
+
case WM_HOTKEY:
|
|
2709
|
+
if (wparam == kHotkeyClickThrough) {
|
|
2710
|
+
ToggleClickThrough();
|
|
2711
|
+
return 0;
|
|
2712
|
+
}
|
|
2713
|
+
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2605
2714
|
case WM_SYSKEYDOWN:
|
|
2606
2715
|
if (wparam == VK_F4) {
|
|
2607
2716
|
RequestExit(0);
|
package/host/code.js
CHANGED
|
@@ -383,9 +383,18 @@ function insideProject(root, target) {
|
|
|
383
383
|
export async function resolvePath(body, env) {
|
|
384
384
|
const project = env.projects.ensure(typeof body.root === 'string' ? body.root : '')
|
|
385
385
|
const root = project.root
|
|
386
|
-
let hint = String(body.path ?? '').
|
|
386
|
+
let hint = String(body.path ?? '').trim()
|
|
387
|
+
if (hint === '') return { path: null, matches: [] }
|
|
388
|
+
/* 会话里的文件引用在 Windows 上可能是 file:///C:/... 或反斜杠绝对路径;
|
|
389
|
+
统一转成 node 能识别的路径,并去掉 file:// 前导和驱动器前的多余斜杠。 */
|
|
390
|
+
if (/^file:\/\//i.test(hint)) {
|
|
391
|
+
hint = hint.replace(/^file:\/\//i, '')
|
|
392
|
+
try { hint = decodeURIComponent(hint) } catch { /* ignore */ }
|
|
393
|
+
}
|
|
394
|
+
hint = hint.replace(/\\/g, '/').trim()
|
|
395
|
+
if (/^\/[A-Za-z]:\//.test(hint)) hint = hint.slice(1)
|
|
396
|
+
if (hint.startsWith('./')) hint = hint.slice(2)
|
|
387
397
|
if (hint === '') return { path: null, matches: [] }
|
|
388
|
-
hint = hint.replace(/^file:\/\//, '').replace(/^\.\//, '')
|
|
389
398
|
if (isAbsolute(hint)) {
|
|
390
399
|
const absolute = resolve(hint)
|
|
391
400
|
if (!insideProject(root, absolute)) return { path: null, matches: [] }
|
package/package.json
CHANGED
package/src/client/00-core.js
CHANGED
|
@@ -1228,6 +1228,16 @@ html[data-gufa-float] .gufa-tabs,
|
|
|
1228
1228
|
html[data-gufa-float] .gufa-statusbar,
|
|
1229
1229
|
html[data-gufa-float] [data-gufa-dock],
|
|
1230
1230
|
html[data-gufa-float] [data-gufa-dock] > *{background:transparent!important}
|
|
1231
|
+
/* 摸鱼模式:Monaco 自己画实色背景,必须显式透明,否则编辑区在透明悬浮窗里是一块实色
|
|
1232
|
+
(Windows helper 尤其明显;mac 之前靠 backdrop=on 的分支碰巧覆盖了) */
|
|
1233
|
+
html[data-gufa-float] .gufa-editor-host{background:transparent!important}
|
|
1234
|
+
html[data-gufa-float] .gufa-editor-host .monaco-editor,
|
|
1235
|
+
html[data-gufa-float] .gufa-editor-host .monaco-editor .margin,
|
|
1236
|
+
html[data-gufa-float] .gufa-editor-host .monaco-editor-background,
|
|
1237
|
+
html[data-gufa-float] .gufa-editor-host .monaco-diff-editor .editor.original,
|
|
1238
|
+
html[data-gufa-float] .gufa-editor-host .monaco-diff-editor .editor.modified,
|
|
1239
|
+
html[data-gufa-float] .gufa-editor-host .gufa-empty,
|
|
1240
|
+
html[data-gufa-float] .gufa-editor-host .gufa-editor-fallback{background:transparent!important}
|
|
1231
1241
|
/* 官方会话停靠层(toolbar/host)自带底色,摸鱼里一并透明,避免会话框叠两层 */
|
|
1232
1242
|
html[data-gufa-float] .gufa-dock-toolbar,
|
|
1233
1243
|
html[data-gufa-float] .gufa-dock-host,
|
package/src/client/60-dock.js
CHANGED
|
@@ -475,11 +475,26 @@ function gufaParseMentionButton(button) {
|
|
|
475
475
|
|
|
476
476
|
async function gufaOpenMention(mention) {
|
|
477
477
|
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
478
|
-
|
|
478
|
+
/* 必须原样传 Host 登记的 project.root:Windows 上 Host 用反斜杠规范化过,
|
|
479
|
+
ProjectRegistry.ensure 是精确字符串匹配;改成 / 会被拒绝(project-not-open),
|
|
480
|
+
表现就是 Windows 上引用点不开。 */
|
|
481
|
+
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/[\\/]+$/, '') : ''
|
|
479
482
|
if (root === '') return
|
|
483
|
+
/* Windows 的会话引用可能带 file:///C:/ 前缀、%20 编码或反斜杠;先归一化再让 Host 解析 */
|
|
484
|
+
let rawPath = String(mention.path ?? '').trim()
|
|
485
|
+
if (/^file:\/\//i.test(rawPath)) {
|
|
486
|
+
rawPath = rawPath.replace(/^file:\/\//i, '')
|
|
487
|
+
try { rawPath = decodeURIComponent(rawPath) } catch { /* ignore */ }
|
|
488
|
+
}
|
|
489
|
+
rawPath = rawPath.replace(/\\/g, '/').replace(/^\/[A-Za-z]:\//, (m) => m.slice(1))
|
|
480
490
|
let resolved = null
|
|
481
491
|
try {
|
|
482
|
-
resolved = await G.api('code.resolvePath', { root, path:
|
|
492
|
+
resolved = await G.api('code.resolvePath', { root, path: rawPath })
|
|
493
|
+
/* 完整路径解析不到时,退一步只按 basename 找(Windows 盘符/大小写差异常见) */
|
|
494
|
+
if (resolved === null || resolved === undefined || typeof resolved.path !== 'string' || resolved.path === '') {
|
|
495
|
+
const base = rawPath.split('/').filter((part) => part !== '').pop() ?? ''
|
|
496
|
+
if (base !== '' && base !== rawPath) resolved = await G.api('code.resolvePath', { root, path: base })
|
|
497
|
+
}
|
|
483
498
|
} catch {
|
|
484
499
|
return
|
|
485
500
|
}
|
|
@@ -274,6 +274,9 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
274
274
|
'sidebar.left.toggle': 'toggleSidebar',
|
|
275
275
|
'edrv.save': 'save',
|
|
276
276
|
'edrv.closeTab': 'closeTab',
|
|
277
|
+
/* DSH 桌面端把 Ctrl+W/Cmd+W 默认绑给右侧页面关闭(page.close),
|
|
278
|
+
它在 main 进程就被截走,浏览器里的 keydown 收不到;IDE 里要改派成关标签页。 */
|
|
279
|
+
'page.close': 'closeTab',
|
|
277
280
|
'edrv.reloadWindow': 'refresh',
|
|
278
281
|
'edrv.toggleSidebar': 'toggleSidebar',
|
|
279
282
|
'shortcuts.open': 'shortcuts',
|
package/src/client/90-app.js
CHANGED
|
@@ -217,6 +217,11 @@ G.useSplitter = function useSplitter(options) {
|
|
|
217
217
|
|
|
218
218
|
|
|
219
219
|
|
|
220
|
+
/** 项目相对路径统一成 POSIX 风格:Windows Host/会话引用可能带反斜杠或前导 ./ */
|
|
221
|
+
function gufaNormalizeProjectPath(value) {
|
|
222
|
+
return String(value ?? '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+/, '')
|
|
223
|
+
}
|
|
224
|
+
|
|
220
225
|
G.GufaApp = function GufaApp(props) {
|
|
221
226
|
const t = G.useT()
|
|
222
227
|
const theme = G.useTheme()
|
|
@@ -572,10 +577,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
572
577
|
}, [gitStatus, project])
|
|
573
578
|
|
|
574
579
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
575
|
-
const openFile = useCallback(async (
|
|
580
|
+
const openFile = useCallback(async (rawPath) => {
|
|
576
581
|
if (project === null) return
|
|
582
|
+
const path = gufaNormalizeProjectPath(rawPath)
|
|
583
|
+
if (path === '') return
|
|
577
584
|
flushBuffersRef.current?.()
|
|
578
|
-
const existing = tabs.find((tab) => tab.path === path)
|
|
585
|
+
const existing = tabs.find((tab) => gufaNormalizeProjectPath(tab.path) === path)
|
|
579
586
|
if (existing !== undefined) {
|
|
580
587
|
/* 已经打开的文件再次点击:先对齐磁盘最新版本(AI/外部修改后不用关掉重开) */
|
|
581
588
|
try {
|
|
@@ -590,7 +597,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
590
597
|
const doc = await G.api('fs.read', { root: project.root, path })
|
|
591
598
|
/* 用函数式更新去重:并发/恢复场景下闭包里的 tabs 可能还没刷新,直接追加会产生重复标签 */
|
|
592
599
|
setTabs((current) => (
|
|
593
|
-
current.some((tab) => tab.path === path)
|
|
600
|
+
current.some((tab) => gufaNormalizeProjectPath(tab.path) === gufaNormalizeProjectPath(doc.path ?? path))
|
|
594
601
|
? current
|
|
595
602
|
: [...current, { ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision }]
|
|
596
603
|
))
|
|
@@ -601,8 +608,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
601
608
|
}, [project, tabs])
|
|
602
609
|
|
|
603
610
|
/* 从搜索/定位结果打开文件并跳到指定行列(等 tab 切换完成后再触发编辑器 reveal) */
|
|
604
|
-
const openFileAt = useCallback(async (
|
|
605
|
-
if (typeof
|
|
611
|
+
const openFileAt = useCallback(async (rawPath, line, column) => {
|
|
612
|
+
if (typeof rawPath !== 'string' || rawPath === '') return
|
|
613
|
+
const path = gufaNormalizeProjectPath(rawPath)
|
|
606
614
|
await openFile(path)
|
|
607
615
|
const targetLine = Number.isFinite(Number(line)) ? Math.max(1, Math.trunc(Number(line))) : 1
|
|
608
616
|
const targetColumn = Number.isFinite(Number(column)) ? Math.max(1, Math.trunc(Number(column))) : 1
|