dsh-gufa-code 1.3.184 → 1.3.186
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 +40 -7
- package/desktop/float/bin/win-x64/gufa-float-win.exe +0 -0
- package/desktop/float/win/main.cpp +121 -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 +13 -1
- 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.186'
|
|
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,
|
|
@@ -11349,9 +11359,21 @@ async function gufaOpenMention(mention) {
|
|
|
11349
11359
|
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
11350
11360
|
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/\\/g, '/').replace(/\/+$/, '') : ''
|
|
11351
11361
|
if (root === '') return
|
|
11362
|
+
/* Windows 的会话引用可能带 file:///C:/ 前缀、%20 编码或反斜杠;先归一化再让 Host 解析 */
|
|
11363
|
+
let rawPath = String(mention.path ?? '').trim()
|
|
11364
|
+
if (/^file:\/\//i.test(rawPath)) {
|
|
11365
|
+
rawPath = rawPath.replace(/^file:\/\//i, '')
|
|
11366
|
+
try { rawPath = decodeURIComponent(rawPath) } catch { /* ignore */ }
|
|
11367
|
+
}
|
|
11368
|
+
rawPath = rawPath.replace(/\\/g, '/').replace(/^\/[A-Za-z]:\//, (m) => m.slice(1))
|
|
11352
11369
|
let resolved = null
|
|
11353
11370
|
try {
|
|
11354
|
-
resolved = await G.api('code.resolvePath', { root, path:
|
|
11371
|
+
resolved = await G.api('code.resolvePath', { root, path: rawPath })
|
|
11372
|
+
/* 完整路径解析不到时,退一步只按 basename 找(Windows 盘符/大小写差异常见) */
|
|
11373
|
+
if (resolved === null || resolved === undefined || typeof resolved.path !== 'string' || resolved.path === '') {
|
|
11374
|
+
const base = rawPath.split('/').filter((part) => part !== '').pop() ?? ''
|
|
11375
|
+
if (base !== '' && base !== rawPath) resolved = await G.api('code.resolvePath', { root, path: base })
|
|
11376
|
+
}
|
|
11355
11377
|
} catch {
|
|
11356
11378
|
return
|
|
11357
11379
|
}
|
|
@@ -12188,6 +12210,9 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12188
12210
|
'sidebar.left.toggle': 'toggleSidebar',
|
|
12189
12211
|
'edrv.save': 'save',
|
|
12190
12212
|
'edrv.closeTab': 'closeTab',
|
|
12213
|
+
/* DSH 桌面端把 Ctrl+W/Cmd+W 默认绑给右侧页面关闭(page.close),
|
|
12214
|
+
它在 main 进程就被截走,浏览器里的 keydown 收不到;IDE 里要改派成关标签页。 */
|
|
12215
|
+
'page.close': 'closeTab',
|
|
12191
12216
|
'edrv.reloadWindow': 'refresh',
|
|
12192
12217
|
'edrv.toggleSidebar': 'toggleSidebar',
|
|
12193
12218
|
'shortcuts.open': 'shortcuts',
|
|
@@ -12743,6 +12768,11 @@ G.useSplitter = function useSplitter(options) {
|
|
|
12743
12768
|
|
|
12744
12769
|
|
|
12745
12770
|
|
|
12771
|
+
/** 项目相对路径统一成 POSIX 风格:Windows Host/会话引用可能带反斜杠或前导 ./ */
|
|
12772
|
+
function gufaNormalizeProjectPath(value) {
|
|
12773
|
+
return String(value ?? '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+/, '')
|
|
12774
|
+
}
|
|
12775
|
+
|
|
12746
12776
|
G.GufaApp = function GufaApp(props) {
|
|
12747
12777
|
const t = G.useT()
|
|
12748
12778
|
const theme = G.useTheme()
|
|
@@ -13098,10 +13128,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13098
13128
|
}, [gitStatus, project])
|
|
13099
13129
|
|
|
13100
13130
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
13101
|
-
const openFile = useCallback(async (
|
|
13131
|
+
const openFile = useCallback(async (rawPath) => {
|
|
13102
13132
|
if (project === null) return
|
|
13133
|
+
const path = gufaNormalizeProjectPath(rawPath)
|
|
13134
|
+
if (path === '') return
|
|
13103
13135
|
flushBuffersRef.current?.()
|
|
13104
|
-
const existing = tabs.find((tab) => tab.path === path)
|
|
13136
|
+
const existing = tabs.find((tab) => gufaNormalizeProjectPath(tab.path) === path)
|
|
13105
13137
|
if (existing !== undefined) {
|
|
13106
13138
|
/* 已经打开的文件再次点击:先对齐磁盘最新版本(AI/外部修改后不用关掉重开) */
|
|
13107
13139
|
try {
|
|
@@ -13116,7 +13148,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13116
13148
|
const doc = await G.api('fs.read', { root: project.root, path })
|
|
13117
13149
|
/* 用函数式更新去重:并发/恢复场景下闭包里的 tabs 可能还没刷新,直接追加会产生重复标签 */
|
|
13118
13150
|
setTabs((current) => (
|
|
13119
|
-
current.some((tab) => tab.path === path)
|
|
13151
|
+
current.some((tab) => gufaNormalizeProjectPath(tab.path) === gufaNormalizeProjectPath(doc.path ?? path))
|
|
13120
13152
|
? current
|
|
13121
13153
|
: [...current, { ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision }]
|
|
13122
13154
|
))
|
|
@@ -13127,8 +13159,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13127
13159
|
}, [project, tabs])
|
|
13128
13160
|
|
|
13129
13161
|
/* 从搜索/定位结果打开文件并跳到指定行列(等 tab 切换完成后再触发编辑器 reveal) */
|
|
13130
|
-
const openFileAt = useCallback(async (
|
|
13131
|
-
if (typeof
|
|
13162
|
+
const openFileAt = useCallback(async (rawPath, line, column) => {
|
|
13163
|
+
if (typeof rawPath !== 'string' || rawPath === '') return
|
|
13164
|
+
const path = gufaNormalizeProjectPath(rawPath)
|
|
13132
13165
|
await openFile(path)
|
|
13133
13166
|
const targetLine = Number.isFinite(Number(line)) ? Math.max(1, Math.trunc(Number(line))) : 1
|
|
13134
13167
|
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
|
}
|
|
@@ -2126,6 +2165,9 @@ void FloatApp::FinishControllerSetup() {
|
|
|
2126
2165
|
}
|
|
2127
2166
|
controllerReady_ = true;
|
|
2128
2167
|
Log(L"webview2-controller-ready");
|
|
2168
|
+
if (clickThrough_) {
|
|
2169
|
+
ApplyClickThrough();
|
|
2170
|
+
}
|
|
2129
2171
|
ConfigureWebView();
|
|
2130
2172
|
LayoutChildren();
|
|
2131
2173
|
StartScriptInjection();
|
|
@@ -2472,12 +2514,59 @@ void FloatApp::CleanupWebView() {
|
|
|
2472
2514
|
environment_.Reset();
|
|
2473
2515
|
}
|
|
2474
2516
|
|
|
2517
|
+
void FloatApp::ToggleClickThrough() {
|
|
2518
|
+
clickThrough_ = !clickThrough_;
|
|
2519
|
+
ApplyClickThrough();
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
void FloatApp::ApplyClickThrough() {
|
|
2523
|
+
if (hwnd_ == nullptr) return;
|
|
2524
|
+
LONG_PTR exStyle = GetWindowLongPtrW(hwnd_, GWL_EXSTYLE);
|
|
2525
|
+
LONG_PTR next = clickThrough_ ? (exStyle | WS_EX_TRANSPARENT)
|
|
2526
|
+
: (exStyle & ~static_cast<LONG_PTR>(WS_EX_TRANSPARENT));
|
|
2527
|
+
/* windowed 模式需要 layered 才能让点击稳定穿透到下层窗口;composition 模式
|
|
2528
|
+
使用 WS_EX_NOREDIRECTIONBITMAP,不能叠加 layered。 */
|
|
2529
|
+
if (hostingMode_ == HostingMode::Windowed) {
|
|
2530
|
+
if (clickThrough_) {
|
|
2531
|
+
if ((next & WS_EX_LAYERED) == 0) {
|
|
2532
|
+
next |= WS_EX_LAYERED;
|
|
2533
|
+
clickThroughLayered_ = true;
|
|
2534
|
+
SetLayeredWindowAttributes(hwnd_, 0, 255, LWA_ALPHA);
|
|
2535
|
+
}
|
|
2536
|
+
} else if (clickThroughLayered_) {
|
|
2537
|
+
next &= ~static_cast<LONG_PTR>(WS_EX_LAYERED);
|
|
2538
|
+
clickThroughLayered_ = false;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
if (next != exStyle) {
|
|
2542
|
+
SetWindowLongPtrW(hwnd_, GWL_EXSTYLE, next);
|
|
2543
|
+
SetWindowPos(hwnd_, nullptr, 0, 0, 0, 0,
|
|
2544
|
+
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
|
2545
|
+
}
|
|
2546
|
+
EnumChildWindows(hwnd_, SetChildClickThrough, clickThrough_ ? 1 : 0);
|
|
2547
|
+
LogFmt(L"click-through=%d", clickThrough_ ? 1 : 0);
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
void FloatApp::StopFollowing() {
|
|
2551
|
+
if (!followActivated_ && followWindow_ == nullptr && !payload_.hasFollow) return;
|
|
2552
|
+
payload_.hasFollow = false;
|
|
2553
|
+
followActivated_ = false;
|
|
2554
|
+
followWindow_ = nullptr;
|
|
2555
|
+
followMissCount_ = 0;
|
|
2556
|
+
if (hwnd_ != nullptr) KillTimer(hwnd_, kTimerFollow);
|
|
2557
|
+
Log(L"follow-stopped-by-menu");
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2475
2560
|
void FloatApp::DoGracefulExit() {
|
|
2476
2561
|
if (hwnd_ == nullptr) {
|
|
2477
2562
|
PostQuitMessage(exitCode_);
|
|
2478
2563
|
return;
|
|
2479
2564
|
}
|
|
2480
2565
|
Log(L"graceful-exit-start");
|
|
2566
|
+
if (clickThroughHotkey_ && hwnd_ != nullptr) {
|
|
2567
|
+
UnregisterHotKey(hwnd_, kHotkeyClickThrough);
|
|
2568
|
+
clickThroughHotkey_ = false;
|
|
2569
|
+
}
|
|
2481
2570
|
KillAllTimers();
|
|
2482
2571
|
RestoreDshWindows();
|
|
2483
2572
|
DeleteControlFile();
|
|
@@ -2494,6 +2583,10 @@ void FloatApp::DoGracefulExit() {
|
|
|
2494
2583
|
}
|
|
2495
2584
|
|
|
2496
2585
|
void FloatApp::OnWindowDestroyed() {
|
|
2586
|
+
if (clickThroughHotkey_ && hwnd_ != nullptr) {
|
|
2587
|
+
UnregisterHotKey(hwnd_, kHotkeyClickThrough);
|
|
2588
|
+
clickThroughHotkey_ = false;
|
|
2589
|
+
}
|
|
2497
2590
|
KillAllTimers();
|
|
2498
2591
|
if (mouseCaptured_) {
|
|
2499
2592
|
mouseCaptured_ = false;
|
|
@@ -2528,7 +2621,7 @@ LRESULT FloatApp::OnMainMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM l
|
|
|
2528
2621
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2529
2622
|
case WM_NCRBUTTONUP:
|
|
2530
2623
|
if (hostingMode_ == HostingMode::Composition) {
|
|
2531
|
-
ShowFloatContextMenu(hwnd);
|
|
2624
|
+
ShowFloatContextMenu(hwnd, this);
|
|
2532
2625
|
return 0;
|
|
2533
2626
|
}
|
|
2534
2627
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
@@ -2600,8 +2693,18 @@ LRESULT FloatApp::OnMainMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM l
|
|
|
2600
2693
|
RequestExit(0);
|
|
2601
2694
|
} else if (wparam == static_cast<WPARAM>(kMenuResetFrame)) {
|
|
2602
2695
|
ResetWindowFrame();
|
|
2696
|
+
} else if (wparam == static_cast<WPARAM>(kMenuToggleClickThrough)) {
|
|
2697
|
+
ToggleClickThrough();
|
|
2698
|
+
} else if (wparam == static_cast<WPARAM>(kMenuStopFollow)) {
|
|
2699
|
+
StopFollowing();
|
|
2603
2700
|
}
|
|
2604
2701
|
return 0;
|
|
2702
|
+
case WM_HOTKEY:
|
|
2703
|
+
if (wparam == kHotkeyClickThrough) {
|
|
2704
|
+
ToggleClickThrough();
|
|
2705
|
+
return 0;
|
|
2706
|
+
}
|
|
2707
|
+
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2605
2708
|
case WM_SYSKEYDOWN:
|
|
2606
2709
|
if (wparam == VK_F4) {
|
|
2607
2710
|
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
|
@@ -477,9 +477,21 @@ async function gufaOpenMention(mention) {
|
|
|
477
477
|
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
478
478
|
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/\\/g, '/').replace(/\/+$/, '') : ''
|
|
479
479
|
if (root === '') return
|
|
480
|
+
/* Windows 的会话引用可能带 file:///C:/ 前缀、%20 编码或反斜杠;先归一化再让 Host 解析 */
|
|
481
|
+
let rawPath = String(mention.path ?? '').trim()
|
|
482
|
+
if (/^file:\/\//i.test(rawPath)) {
|
|
483
|
+
rawPath = rawPath.replace(/^file:\/\//i, '')
|
|
484
|
+
try { rawPath = decodeURIComponent(rawPath) } catch { /* ignore */ }
|
|
485
|
+
}
|
|
486
|
+
rawPath = rawPath.replace(/\\/g, '/').replace(/^\/[A-Za-z]:\//, (m) => m.slice(1))
|
|
480
487
|
let resolved = null
|
|
481
488
|
try {
|
|
482
|
-
resolved = await G.api('code.resolvePath', { root, path:
|
|
489
|
+
resolved = await G.api('code.resolvePath', { root, path: rawPath })
|
|
490
|
+
/* 完整路径解析不到时,退一步只按 basename 找(Windows 盘符/大小写差异常见) */
|
|
491
|
+
if (resolved === null || resolved === undefined || typeof resolved.path !== 'string' || resolved.path === '') {
|
|
492
|
+
const base = rawPath.split('/').filter((part) => part !== '').pop() ?? ''
|
|
493
|
+
if (base !== '' && base !== rawPath) resolved = await G.api('code.resolvePath', { root, path: base })
|
|
494
|
+
}
|
|
483
495
|
} catch {
|
|
484
496
|
return
|
|
485
497
|
}
|
|
@@ -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
|