dsh-gufa-code 1.3.187 → 1.3.189
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 +30 -2
- package/desktop/float/bin/win-x64/gufa-float-win.exe +0 -0
- package/desktop/float/win/main.cpp +13 -1
- package/host/git.js +16 -0
- package/package.json +1 -1
- package/src/client/50-panels.js +10 -1
- package/src/client/90-app.js +19 -0
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.189'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -9037,6 +9037,15 @@ G.GitPanel = function GitPanel(props) {
|
|
|
9037
9037
|
}
|
|
9038
9038
|
}, [])
|
|
9039
9039
|
|
|
9040
|
+
/* 手动刷新:先 fetch 远端,再读 status(否则 behind 可能是 0) */
|
|
9041
|
+
const refreshRemote = useCallback(async () => {
|
|
9042
|
+
const target = rootRef.current
|
|
9043
|
+
if (target) {
|
|
9044
|
+
try { await G.api('git.fetch', { root: target }) } catch { /* 离线等失败不打扰 */ }
|
|
9045
|
+
}
|
|
9046
|
+
await refresh()
|
|
9047
|
+
}, [refresh])
|
|
9048
|
+
|
|
9040
9049
|
/* 项目变化:清空并重新拉取 */
|
|
9041
9050
|
useEffect(() => {
|
|
9042
9051
|
setStatus(null)
|
|
@@ -9226,7 +9235,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
9226
9235
|
)
|
|
9227
9236
|
: null,
|
|
9228
9237
|
h(G.IconButton, { title: t('graph.open'), onClick: () => props.onOpenGraph?.() }, h(G.Icon, { name: 'graph', size: 13 })),
|
|
9229
|
-
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void
|
|
9238
|
+
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void refreshRemote() }, h(G.Icon, { name: 'refresh', size: 13 })),
|
|
9230
9239
|
h(G.IconButton, {
|
|
9231
9240
|
title: t('git.more'),
|
|
9232
9241
|
onClick: (event) => {
|
|
@@ -12920,6 +12929,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
12920
12929
|
const [gitStatus, setGitStatus] = useState(null)
|
|
12921
12930
|
const gitSignatureRef = useRef('')
|
|
12922
12931
|
const gitInFlightRef = useRef(false)
|
|
12932
|
+
const gitFetchRef = useRef({ root: '', at: 0 })
|
|
12923
12933
|
const [modal, setModal] = useState(null)
|
|
12924
12934
|
const [shortcutsOpen, setShortcutsOpen] = useState(false)
|
|
12925
12935
|
const [definitionPicker, setDefinitionPicker] = useState(null)
|
|
@@ -13105,6 +13115,24 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13105
13115
|
}
|
|
13106
13116
|
}, [project, refreshGit])
|
|
13107
13117
|
|
|
13118
|
+
/* 进入 Git 面板时主动 fetch 一次(限流 15s):否则 behind 只看本地 remote-tracking ref,
|
|
13119
|
+
远端新提交在 fetch 之前永远显示 0。 */
|
|
13120
|
+
useEffect(() => {
|
|
13121
|
+
if (project === null || project.isGit !== true) return undefined
|
|
13122
|
+
if (ui.sidebarOpen !== true || ui.view !== 'git') return undefined
|
|
13123
|
+
const now = Date.now()
|
|
13124
|
+
const last = gitFetchRef.current
|
|
13125
|
+
if (last.root === project.root && now - last.at < 15000) return undefined
|
|
13126
|
+
gitFetchRef.current = { root: project.root, at: now }
|
|
13127
|
+
let cancelled = false
|
|
13128
|
+
void G.api('git.fetch', { root: project.root }).then((value) => {
|
|
13129
|
+
if (cancelled || value?.ok !== true) return
|
|
13130
|
+
setGitRefreshToken((token) => token + 1)
|
|
13131
|
+
setRefreshToken((token) => token + 1)
|
|
13132
|
+
}).catch(() => {})
|
|
13133
|
+
return () => { cancelled = true }
|
|
13134
|
+
}, [project, ui.sidebarOpen, ui.view])
|
|
13135
|
+
|
|
13108
13136
|
const gitStatuses = useMemo(() => {
|
|
13109
13137
|
const map = {}
|
|
13110
13138
|
for (const change of gitStatus?.changes ?? []) map[change.path] = change.status
|
|
Binary file
|
|
@@ -1049,12 +1049,20 @@ class FloatApp {
|
|
|
1049
1049
|
};
|
|
1050
1050
|
|
|
1051
1051
|
namespace {
|
|
1052
|
+
BOOL CALLBACK CountChildWindow(HWND, LPARAM lparam) {
|
|
1053
|
+
if (lparam != 0) *reinterpret_cast<int*>(lparam) += 1;
|
|
1054
|
+
return TRUE;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1052
1057
|
BOOL CALLBACK SetChildClickThrough(HWND child, LPARAM lparam) {
|
|
1053
1058
|
const bool enable = lparam != 0;
|
|
1054
1059
|
LONG_PTR exStyle = GetWindowLongPtrW(child, GWL_EXSTYLE);
|
|
1055
1060
|
LONG_PTR next = enable ? (exStyle | WS_EX_TRANSPARENT)
|
|
1056
1061
|
: (exStyle & ~static_cast<LONG_PTR>(WS_EX_TRANSPARENT));
|
|
1057
1062
|
if (next != exStyle) SetWindowLongPtrW(child, GWL_EXSTYLE, next);
|
|
1063
|
+
/* windowed 模式的 WebView2 是子 HWND,不会继承父窗口的 ex-style;
|
|
1064
|
+
只设置 WS_EX_TRANSPARENT 仍可能被它吃掉点击。穿透期间直接禁用输入。 */
|
|
1065
|
+
EnableWindow(child, enable ? FALSE : TRUE);
|
|
1058
1066
|
return TRUE;
|
|
1059
1067
|
}
|
|
1060
1068
|
} // namespace
|
|
@@ -2546,8 +2554,12 @@ void FloatApp::ApplyClickThrough() {
|
|
|
2546
2554
|
SetWindowPos(hwnd_, nullptr, 0, 0, 0, 0,
|
|
2547
2555
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
|
2548
2556
|
}
|
|
2557
|
+
int childCount = 0;
|
|
2558
|
+
EnumChildWindows(hwnd_, CountChildWindow, reinterpret_cast<LPARAM>(&childCount));
|
|
2549
2559
|
EnumChildWindows(hwnd_, SetChildClickThrough, clickThrough_ ? 1 : 0);
|
|
2550
|
-
LogFmt(L"click-through=%d", clickThrough_ ? 1 : 0
|
|
2560
|
+
LogFmt(L"click-through=%d mode=%s layered=%d children=%d", clickThrough_ ? 1 : 0,
|
|
2561
|
+
hostingMode_ == HostingMode::Composition ? L"composition" : L"windowed",
|
|
2562
|
+
clickThroughLayered_ ? 1 : 0, childCount);
|
|
2551
2563
|
}
|
|
2552
2564
|
|
|
2553
2565
|
void FloatApp::StopFollowing() {
|
package/host/git.js
CHANGED
|
@@ -148,6 +148,22 @@ export function register(router, env) {
|
|
|
148
148
|
return { isGit: true, ...parseStatus(await git(project.root, ['status', '--porcelain=v1', '--branch', '--untracked-files=all'])) }
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
+
/* 主动 fetch:git.status 的 behind 只反映本地已知的 remote-tracking ref,
|
|
152
|
+
远端有新提交但没 fetch 时箭头永远是 0。进 Git 面板/点刷新时先 fetch。 */
|
|
153
|
+
router.method('git.fetch', async (body) => {
|
|
154
|
+
const project = await ensureRepo(env, body)
|
|
155
|
+
if (project.isGit !== true) return { ok: false, reason: 'not-git' }
|
|
156
|
+
try {
|
|
157
|
+
const remotes = (await git(project.root, ['remote']).catch(() => '')).trim()
|
|
158
|
+
.split('\n').map((line) => line.trim()).filter(Boolean)
|
|
159
|
+
const args = remotes.length > 0 ? ['fetch', '--prune', '--quiet', remotes[0]] : ['fetch', '--prune', '--quiet']
|
|
160
|
+
await git(project.root, args, 60_000)
|
|
161
|
+
return { ok: true, remote: remotes[0] ?? '' }
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return { ok: false, reason: String(error?.message ?? error).slice(0, 800) }
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
|
|
151
167
|
router.method('git.stage', async (body) => {
|
|
152
168
|
const project = await projectOf(env, body)
|
|
153
169
|
const paths = Array.isArray(body.paths) ? body.paths.filter((item) => typeof item === 'string' && item !== '') : []
|
package/package.json
CHANGED
package/src/client/50-panels.js
CHANGED
|
@@ -1083,6 +1083,15 @@ G.GitPanel = function GitPanel(props) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
}, [])
|
|
1085
1085
|
|
|
1086
|
+
/* 手动刷新:先 fetch 远端,再读 status(否则 behind 可能是 0) */
|
|
1087
|
+
const refreshRemote = useCallback(async () => {
|
|
1088
|
+
const target = rootRef.current
|
|
1089
|
+
if (target) {
|
|
1090
|
+
try { await G.api('git.fetch', { root: target }) } catch { /* 离线等失败不打扰 */ }
|
|
1091
|
+
}
|
|
1092
|
+
await refresh()
|
|
1093
|
+
}, [refresh])
|
|
1094
|
+
|
|
1086
1095
|
/* 项目变化:清空并重新拉取 */
|
|
1087
1096
|
useEffect(() => {
|
|
1088
1097
|
setStatus(null)
|
|
@@ -1272,7 +1281,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
1272
1281
|
)
|
|
1273
1282
|
: null,
|
|
1274
1283
|
h(G.IconButton, { title: t('graph.open'), onClick: () => props.onOpenGraph?.() }, h(G.Icon, { name: 'graph', size: 13 })),
|
|
1275
|
-
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void
|
|
1284
|
+
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void refreshRemote() }, h(G.Icon, { name: 'refresh', size: 13 })),
|
|
1276
1285
|
h(G.IconButton, {
|
|
1277
1286
|
title: t('git.more'),
|
|
1278
1287
|
onClick: (event) => {
|
package/src/client/90-app.js
CHANGED
|
@@ -366,6 +366,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
366
366
|
const [gitStatus, setGitStatus] = useState(null)
|
|
367
367
|
const gitSignatureRef = useRef('')
|
|
368
368
|
const gitInFlightRef = useRef(false)
|
|
369
|
+
const gitFetchRef = useRef({ root: '', at: 0 })
|
|
369
370
|
const [modal, setModal] = useState(null)
|
|
370
371
|
const [shortcutsOpen, setShortcutsOpen] = useState(false)
|
|
371
372
|
const [definitionPicker, setDefinitionPicker] = useState(null)
|
|
@@ -551,6 +552,24 @@ G.GufaApp = function GufaApp(props) {
|
|
|
551
552
|
}
|
|
552
553
|
}, [project, refreshGit])
|
|
553
554
|
|
|
555
|
+
/* 进入 Git 面板时主动 fetch 一次(限流 15s):否则 behind 只看本地 remote-tracking ref,
|
|
556
|
+
远端新提交在 fetch 之前永远显示 0。 */
|
|
557
|
+
useEffect(() => {
|
|
558
|
+
if (project === null || project.isGit !== true) return undefined
|
|
559
|
+
if (ui.sidebarOpen !== true || ui.view !== 'git') return undefined
|
|
560
|
+
const now = Date.now()
|
|
561
|
+
const last = gitFetchRef.current
|
|
562
|
+
if (last.root === project.root && now - last.at < 15000) return undefined
|
|
563
|
+
gitFetchRef.current = { root: project.root, at: now }
|
|
564
|
+
let cancelled = false
|
|
565
|
+
void G.api('git.fetch', { root: project.root }).then((value) => {
|
|
566
|
+
if (cancelled || value?.ok !== true) return
|
|
567
|
+
setGitRefreshToken((token) => token + 1)
|
|
568
|
+
setRefreshToken((token) => token + 1)
|
|
569
|
+
}).catch(() => {})
|
|
570
|
+
return () => { cancelled = true }
|
|
571
|
+
}, [project, ui.sidebarOpen, ui.view])
|
|
572
|
+
|
|
554
573
|
const gitStatuses = useMemo(() => {
|
|
555
574
|
const map = {}
|
|
556
575
|
for (const change of gitStatus?.changes ?? []) map[change.path] = change.status
|