dsh-dock 0.24.0 → 0.25.1
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 +20 -2
- package/client.js +1891 -126
- package/features/dshtools/host.js +14 -0
- package/features/git/host.js +884 -0
- package/features/git/rpc.js +156 -0
- package/features/git/view.jsx +1994 -0
- package/index.js +3 -0
- package/package.json +3 -3
- package/src/client.jsx +20 -2
- package/src/host-core.js +13 -0
|
@@ -0,0 +1,1994 @@
|
|
|
1
|
+
// dsh-dock · 功能模块【Git 管理】· 客户端视图
|
|
2
|
+
//
|
|
3
|
+
// 形态(按用户 2026-11-28 的要求重做):
|
|
4
|
+
// 1. **不再是功能坞里的一个菜单**——功能坞面板里没有它;
|
|
5
|
+
// 2. 入口在【DSH功能】页里的一个开关「Git 管理面板」:打开后
|
|
6
|
+
// - DSH 右侧抽屉(ui-sidebar-right)里多一个「Git」页签,默认显示**当前会话目录**的仓库;
|
|
7
|
+
// - 「工作区文件」的目录 / 文件右键里多一条「查看 Git 历史」,点了直接定位到那个路径所在的仓库;
|
|
8
|
+
// 3. 不依赖任何原生目录选择弹窗——服务器部署(无桌面)同样可用:目录从会话目录与右键路径来,
|
|
9
|
+
// 也可以在面板里手填绝对路径。
|
|
10
|
+
//
|
|
11
|
+
// Host 通信见 features/git/host.js 与 features/git/rpc.js。所有请求都走文档相对路径,
|
|
12
|
+
// 兼容反向代理的子路径挂载。
|
|
13
|
+
import { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
14
|
+
import { stateOf } from "../../src/shared.js";
|
|
15
|
+
import { valueOf, ensureLoaded as ensureDshtoolsLoaded, subscribe as subscribeDshtools } from "../dshtools/view.jsx";
|
|
16
|
+
import {
|
|
17
|
+
rpc, fmtAgo, fmtTime, fmtDateTime, truncate, shortRefs, currentSessionDir, pickDirectory,
|
|
18
|
+
} from "./rpc.js";
|
|
19
|
+
|
|
20
|
+
// ---------- 差异渲染 ----------
|
|
21
|
+
// 一个 hunk = 头部 + 若干行;行按 kind(+/−/空格)上色,带新旧行号。
|
|
22
|
+
function DiffHunk(props) {
|
|
23
|
+
const h = props.hunk;
|
|
24
|
+
let oldNo = h.oldStart;
|
|
25
|
+
let newNo = h.newStart;
|
|
26
|
+
return (
|
|
27
|
+
<div className="dkg-hunk">
|
|
28
|
+
<div className="dkg-hunk-head">{h.header}</div>
|
|
29
|
+
{h.lines.map((line, i) => {
|
|
30
|
+
const isAdd = line.kind === "+";
|
|
31
|
+
const isDel = line.kind === "-";
|
|
32
|
+
const oldLabel = isAdd ? "" : String(oldNo++);
|
|
33
|
+
const newLabel = isDel ? "" : String(newNo++);
|
|
34
|
+
return (
|
|
35
|
+
<div key={i} className={"dkg-line" + (isAdd ? " add" : isDel ? " del" : "")}>
|
|
36
|
+
<span className="dkg-ln">{oldLabel}</span>
|
|
37
|
+
<span className="dkg-ln">{newLabel}</span>
|
|
38
|
+
<span className="dkg-sign">{isAdd ? "+" : isDel ? "−" : " "}</span>
|
|
39
|
+
<span className="dkg-code">{line.text || " "}</span>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
})}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 单个文件的差异卡:标题(路径 + 状态 + 增删)+ 各 hunk;点标题折叠。
|
|
48
|
+
function DiffFile(props) {
|
|
49
|
+
const f = props.file;
|
|
50
|
+
const [open, setOpen] = useState(props.defaultOpen !== false);
|
|
51
|
+
const statusLabel = f.status === "added" ? "新增" : f.status === "deleted" ? "删除" : f.status === "renamed" ? "重命名" : "修改";
|
|
52
|
+
return (
|
|
53
|
+
<div className={"dkg-file" + (open ? " open" : "")}>
|
|
54
|
+
<button type="button" className="dkg-file-head" onClick={() => setOpen((v) => !v)}>
|
|
55
|
+
<span className="dkg-caret">{open ? "▾" : "▸"}</span>
|
|
56
|
+
<span className="dkg-file-path" title={f.path}>{f.path}</span>
|
|
57
|
+
{f.oldPath && f.oldPath !== f.path ? <span className="dkg-file-old" title={f.oldPath}>← {f.oldPath}</span> : null}
|
|
58
|
+
<span className={"dkg-tag " + f.status}>{statusLabel}</span>
|
|
59
|
+
<span className="dkg-add">+{f.additions}</span>
|
|
60
|
+
<span className="dkg-del">−{f.deletions}</span>
|
|
61
|
+
</button>
|
|
62
|
+
{open ? (
|
|
63
|
+
f.binary ? (
|
|
64
|
+
<div className="dkg-note">二进制文件,不显示逐行差异。</div>
|
|
65
|
+
) : f.hunks.length === 0 ? (
|
|
66
|
+
<div className="dkg-note">没有可显示的差异(可能只是文件模式变化)。</div>
|
|
67
|
+
) : (
|
|
68
|
+
<div className="dkg-diff">
|
|
69
|
+
{f.hunks.map((h, i) => <DiffHunk key={i} hunk={h} />)}
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
) : null}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 变更文件树:按目录层级折叠成树,点击选中某个文件。
|
|
78
|
+
function buildTree(files) {
|
|
79
|
+
const root = { name: "", path: "", dirs: new Map(), files: [] };
|
|
80
|
+
for (const f of files) {
|
|
81
|
+
const parts = f.path.split("/");
|
|
82
|
+
let node = root;
|
|
83
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
84
|
+
const name = parts[i];
|
|
85
|
+
if (!node.dirs.has(name)) {
|
|
86
|
+
node.dirs.set(name, { name, path: parts.slice(0, i + 1).join("/"), dirs: new Map(), files: [] });
|
|
87
|
+
}
|
|
88
|
+
node = node.dirs.get(name);
|
|
89
|
+
}
|
|
90
|
+
node.files.push(f);
|
|
91
|
+
}
|
|
92
|
+
return root;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function FileTree(props) {
|
|
96
|
+
const tree = useMemo(() => buildTree(props.files || []), [props.files]);
|
|
97
|
+
const [collapsed, setCollapsed] = useState({});
|
|
98
|
+
const toggle = (path) => setCollapsed((prev) => Object.assign({}, prev, { [path]: !prev[path] }));
|
|
99
|
+
const render = (node, depth) => {
|
|
100
|
+
const out = [];
|
|
101
|
+
for (const dir of node.dirs.values()) {
|
|
102
|
+
const key = "d:" + dir.path;
|
|
103
|
+
const isCollapsed = !!collapsed[dir.path];
|
|
104
|
+
out.push(
|
|
105
|
+
<button type="button" key={key} className="dkg-tree-row dir" style={{ paddingLeft: (depth * 12 + 6) + "px" }} onClick={() => toggle(dir.path)}>
|
|
106
|
+
<span className="dkg-caret">{isCollapsed ? "▸" : "▾"}</span>
|
|
107
|
+
<span className="dkg-tree-name">{dir.name}</span>
|
|
108
|
+
</button>,
|
|
109
|
+
);
|
|
110
|
+
if (!isCollapsed) out.push(...render(dir, depth + 1));
|
|
111
|
+
}
|
|
112
|
+
for (const f of node.files) {
|
|
113
|
+
const selected = props.selected === f.path;
|
|
114
|
+
out.push(
|
|
115
|
+
<button type="button" key={"f:" + f.path} className={"dkg-tree-row file" + (selected ? " on" : "")} style={{ paddingLeft: (depth * 12 + 18) + "px" }} onClick={() => props.onSelect(f.path)} title={f.path}>
|
|
116
|
+
<span className="dkg-tree-name">{f.path.split("/").pop()}</span>
|
|
117
|
+
<span className="dkg-add">+{f.additions}</span>
|
|
118
|
+
<span className="dkg-del">−{f.deletions}</span>
|
|
119
|
+
</button>,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
};
|
|
124
|
+
return <div className="dkg-tree">{render(tree, 0)}</div>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// ---------- 列定义 ----------
|
|
129
|
+
/**
|
|
130
|
+
* 提交表格的列。
|
|
131
|
+
*
|
|
132
|
+
* 为什么要数据驱动:用户要求「列可以勾选,不勾的默认藏起来」。硬编码 6 个 span 的话,
|
|
133
|
+
* 隐藏一列还得同步改 grid-template-columns,否则表头与行会错位。
|
|
134
|
+
* 这里把「标识 / 标题 / 宽度 / 能否隐藏」放一处,渲染与列宽都从它派生。
|
|
135
|
+
*
|
|
136
|
+
* `fixed: true` 的列(分支图与说明)不允许隐藏——说明是主列,藏了表格就没意义了。
|
|
137
|
+
*/
|
|
138
|
+
export const COMMIT_COLUMNS = [
|
|
139
|
+
{ id: "graph", title: "", width: "12px", fixed: true },
|
|
140
|
+
{ id: "subject", title: "说明", width: "minmax(0,1fr)", fixed: true },
|
|
141
|
+
{ id: "refs", title: "引用", width: "64px" },
|
|
142
|
+
{ id: "author", title: "作者", width: "78px" },
|
|
143
|
+
{ id: "date", title: "日期", width: "56px" },
|
|
144
|
+
{ id: "datetime", title: "日期时间", width: "132px" },
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
/** 默认显示哪些列:用户要「不勾的默认硬藏」,所以日期时间默认不显示。 */
|
|
148
|
+
export const DEFAULT_VISIBLE_COLUMNS = ["graph", "subject", "refs", "author", "date"];
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 由可见列集合算出 grid 列宽。
|
|
152
|
+
* @param {string[]} visible 可见列 id
|
|
153
|
+
* @returns {string} 可直接用于 grid-template-columns 的值
|
|
154
|
+
*/
|
|
155
|
+
export function columnsTemplate(visible) {
|
|
156
|
+
const set = new Set(Array.isArray(visible) ? visible : []);
|
|
157
|
+
// 固定列始终参与布局,其余按可见性
|
|
158
|
+
const parts = COMMIT_COLUMNS
|
|
159
|
+
.filter((c) => c.fixed || set.has(c.id))
|
|
160
|
+
.map((c) => c.width);
|
|
161
|
+
return parts.join(" ");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 勾选/取消勾选参与查询的仓库。
|
|
166
|
+
*
|
|
167
|
+
* 关键:允许取消**当前仓库**。用户就是要去掉父仓库只看子仓库;
|
|
168
|
+
* 之前查询列表写成 [当前仓库].concat(勾选的子仓库),当前仓库被强制包含,取消勾选毫无效果。
|
|
169
|
+
* 但至少要留一个——全空就没东西可查了。
|
|
170
|
+
* @param {string[]} prev 当前选中集合
|
|
171
|
+
* @param {string} path 要切换的仓库
|
|
172
|
+
* @param {string} current 当前仓库(prev 为空时的初始值)
|
|
173
|
+
* @returns {string[]} 新的选中集合
|
|
174
|
+
*/
|
|
175
|
+
export function toggleRepoSelection(prev, path, current) {
|
|
176
|
+
const list = Array.isArray(prev) && prev.length > 0 ? prev : [current].filter(Boolean);
|
|
177
|
+
if (list.includes(path)) {
|
|
178
|
+
const next = list.filter((p) => p !== path);
|
|
179
|
+
return next.length > 0 ? next : list;
|
|
180
|
+
}
|
|
181
|
+
return list.concat(path);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ---------- 提交列表 ----------
|
|
185
|
+
// 提交表格的一行:分支图 | 说明 | 引用 | 作者 | 日期(与表头同列宽,GoLand Log 表格的形态)
|
|
186
|
+
function CommitRow(props) {
|
|
187
|
+
const c = props.commit;
|
|
188
|
+
const refs = shortRefs(c.refs);
|
|
189
|
+
// 可见列由调用方决定(列勾选菜单);未传时全部显示
|
|
190
|
+
const visible = Array.isArray(props.visibleCols) ? props.visibleCols : null;
|
|
191
|
+
const show = (id) => (visible ? visible.includes(id) : true);
|
|
192
|
+
return (
|
|
193
|
+
<div
|
|
194
|
+
className={"dkg-tr" + (props.active ? " on" : "")}
|
|
195
|
+
role="row"
|
|
196
|
+
tabIndex={-1}
|
|
197
|
+
onClick={() => props.onSelect(c)}
|
|
198
|
+
onKeyDown={(ev) => { if (ev.key === "Enter" || ev.key === " ") { ev.preventDefault(); props.onSelect(c); } }}
|
|
199
|
+
title={c.subject}
|
|
200
|
+
>
|
|
201
|
+
<span className="dkg-td graph" aria-hidden="true">
|
|
202
|
+
<span className="dkg-graph-line" />
|
|
203
|
+
<span className="dkg-graph-dot" />
|
|
204
|
+
</span>
|
|
205
|
+
<span className="dkg-td subject">
|
|
206
|
+
{/* 多仓库合并展示时标出这条提交属于哪个仓库,否则分不清 */}
|
|
207
|
+
{c.__repo ? <span className="dkg-repo-tag" title={c.__repo}>{c.__repo.split("/").filter(Boolean).pop()}</span> : null}
|
|
208
|
+
<span className="dkg-commit-subject">{c.subject}</span>
|
|
209
|
+
{refs.length > 0 ? (
|
|
210
|
+
<span className="dkg-commit-refs">
|
|
211
|
+
{refs.map((r) => <span key={r} className={"dkg-ref" + (/^(origin|upstream)\//.test(r) ? " remote" : "")}>{r}</span>)}
|
|
212
|
+
</span>
|
|
213
|
+
) : null}
|
|
214
|
+
</span>
|
|
215
|
+
{show("refs") ? (
|
|
216
|
+
<span className="dkg-td refs">
|
|
217
|
+
{refs.length === 0 ? <span className="dkg-muted">—</span> : null}
|
|
218
|
+
</span>
|
|
219
|
+
) : null}
|
|
220
|
+
{show("author") ? <span className="dkg-td author" title={c.authorEmail}>{c.author}</span> : null}
|
|
221
|
+
{show("date") ? <span className="dkg-td date" title={fmtTime(c.authorDate)}>{fmtAgo(c.authorDate)}</span> : null}
|
|
222
|
+
{show("datetime") ? <span className="dkg-td datetime" title={fmtTime(c.authorDate)}>{fmtDateTime(c.authorDate)}</span> : null}
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ---------- 历史页 ----------
|
|
228
|
+
function HistoryPane(props) {
|
|
229
|
+
const { repo, refs } = props;
|
|
230
|
+
const repoOptions = Array.isArray(props.repos) ? props.repos : [];
|
|
231
|
+
// 参与查询的仓库集合(完整,含当前仓库)。
|
|
232
|
+
// 取消勾选当前仓库后它就不该再被查——所以这里直接用选中集合,不再强制拼上 repo。
|
|
233
|
+
const pickedRepos = Array.isArray(props.selectedRepos) && props.selectedRepos.length > 0
|
|
234
|
+
? props.selectedRepos
|
|
235
|
+
: [repo];
|
|
236
|
+
// 用 join 做稳定的依赖键:props.selectedRepos 每次渲染都是新数组,
|
|
237
|
+
// 直接进 useCallback 依赖会让 load 每帧重建、effect 反复触发并互相取消。
|
|
238
|
+
const repoKey = pickedRepos.join("\u0000");
|
|
239
|
+
const [commits, setCommits] = useState([]);
|
|
240
|
+
const [loading, setLoading] = useState(false);
|
|
241
|
+
const [error, setError] = useState("");
|
|
242
|
+
const [search, setSearch] = useState("");
|
|
243
|
+
const [author, setAuthor] = useState("");
|
|
244
|
+
const [path, setPath] = useState(props.initialPath || "");
|
|
245
|
+
const [branch, setBranch] = useState("");
|
|
246
|
+
const [limit, setLimit] = useState(100);
|
|
247
|
+
const [since, setSince] = useState("");
|
|
248
|
+
const [until, setUntil] = useState("");
|
|
249
|
+
// 提交人:下拉候选 + 当前选择(空串表示不限)
|
|
250
|
+
const [authors, setAuthors] = useState([]);
|
|
251
|
+
const [authorPick, setAuthorPick] = useState("");
|
|
252
|
+
// 多仓库时按仓库分组展示
|
|
253
|
+
const [groups, setGroups] = useState([]);
|
|
254
|
+
// 可见列:默认按 DEFAULT_VISIBLE_COLUMNS(日期时间默认藏起来)
|
|
255
|
+
const [visibleCols, setVisibleCols] = useState(DEFAULT_VISIBLE_COLUMNS);
|
|
256
|
+
const [colMenu, setColMenu] = useState(false);
|
|
257
|
+
const showCol = (id) => visibleCols.includes(id);
|
|
258
|
+
const toggleCol = (id) => {
|
|
259
|
+
const col = COMMIT_COLUMNS.find((c) => c.id === id);
|
|
260
|
+
if (!col || col.fixed) return;
|
|
261
|
+
setVisibleCols((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : prev.concat(id));
|
|
262
|
+
};
|
|
263
|
+
const [selected, setSelected] = useState(null);
|
|
264
|
+
const [detail, setDetail] = useState(null);
|
|
265
|
+
const [detailLoading, setDetailLoading] = useState(false);
|
|
266
|
+
const [activeFile, setActiveFile] = useState("");
|
|
267
|
+
|
|
268
|
+
const load = useCallback(async () => {
|
|
269
|
+
if (!repo) return;
|
|
270
|
+
setLoading(true);
|
|
271
|
+
setError("");
|
|
272
|
+
// 参与查询的仓库:当前仓库 + 勾选的子仓库
|
|
273
|
+
// 查询集合 = 勾选集合。用户取消当前仓库后,历史里就不该再出现它的提交。
|
|
274
|
+
const repoList = repoKey.split("\u0000").filter(Boolean);
|
|
275
|
+
if (repoList.length === 0) { setLoading(false); return; }
|
|
276
|
+
const common = {
|
|
277
|
+
limit, search: search.trim(), author: authorPick || author.trim(),
|
|
278
|
+
path: path.trim(), branch: branch || undefined,
|
|
279
|
+
since: since || undefined, until: until || undefined,
|
|
280
|
+
};
|
|
281
|
+
try {
|
|
282
|
+
// 单仓走 repo 字段只是省一层数组;这里必须用 repoList[0],
|
|
283
|
+
// 不能写死成当前仓库——用户取消当前仓库后只剩子仓库时,
|
|
284
|
+
// 写死会让历史仍然查父仓库(这就是「取消勾选没反应」的另一半原因)。
|
|
285
|
+
const data = repoList.length === 1
|
|
286
|
+
? await rpc("commits", Object.assign({ repo: repoList[0] }, common))
|
|
287
|
+
: await rpc("commits", Object.assign({ repos: repoList }, common));
|
|
288
|
+
const results = (data && data.results) || [];
|
|
289
|
+
// 单仓失败不拖垮其它仓库:只标记该仓库
|
|
290
|
+
const ok = results.filter((r) => r && r.ok !== false);
|
|
291
|
+
const failed = results.filter((r) => r && r.ok === false);
|
|
292
|
+
setGroups(ok.map((r) => ({ repo: r.repo, commits: r.commits || [] })));
|
|
293
|
+
const flat = [];
|
|
294
|
+
for (const r of ok) {
|
|
295
|
+
for (const c of (r.commits || [])) flat.push(Object.assign({ __repo: r.repo }, c));
|
|
296
|
+
}
|
|
297
|
+
// 多仓合并时按时间倒序,保持「最新在上」的直觉
|
|
298
|
+
if (repoList.length > 1) {
|
|
299
|
+
flat.sort((a, b) => String(b.authorDate).localeCompare(String(a.authorDate)));
|
|
300
|
+
}
|
|
301
|
+
setCommits(flat);
|
|
302
|
+
if (failed.length > 0) setError(failed.map((r) => r.repo + ":" + (r.error || "读取失败")).join(";"));
|
|
303
|
+
if (flat.length > 0) selectCommit(flat[0]);
|
|
304
|
+
else { setSelected(null); setDetail(null); }
|
|
305
|
+
} catch (e) {
|
|
306
|
+
setCommits([]);
|
|
307
|
+
setGroups([]);
|
|
308
|
+
setError((e && e.message) || String(e));
|
|
309
|
+
} finally {
|
|
310
|
+
setLoading(false);
|
|
311
|
+
}
|
|
312
|
+
}, [repo, repoKey, limit, search, author, authorPick, path, branch, since, until]);
|
|
313
|
+
|
|
314
|
+
const selectCommit = async (c) => {
|
|
315
|
+
setSelected(c);
|
|
316
|
+
setDetailLoading(true);
|
|
317
|
+
setActiveFile("");
|
|
318
|
+
try {
|
|
319
|
+
// 多仓库合并展示时,每条提交带着自己的仓库(__repo)。
|
|
320
|
+
// 必须用它的仓库,不能写死成当前仓库——取消勾选当前仓库后,
|
|
321
|
+
// 列表里的提交属于子仓库,拿父仓库去查那个提交号会报 fatal: bad object。
|
|
322
|
+
const owner = c.__repo || repo;
|
|
323
|
+
const data = await rpc("commit", { repo: owner, sha: c.sha });
|
|
324
|
+
setDetail(data && data.commit);
|
|
325
|
+
} catch (e) {
|
|
326
|
+
setDetail({ error: (e && e.message) || String(e) });
|
|
327
|
+
} finally {
|
|
328
|
+
setDetailLoading(false);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
if (!repo) return;
|
|
334
|
+
const timer = setTimeout(() => { load(); }, 200);
|
|
335
|
+
return () => clearTimeout(timer);
|
|
336
|
+
}, [load]);
|
|
337
|
+
|
|
338
|
+
// 提交人下拉候选:仓库变了就重新拉一次(失败不影响主流程,退化成手输)
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
if (!repo) return;
|
|
341
|
+
let stopped = false;
|
|
342
|
+
rpc("authors", { repo })
|
|
343
|
+
.then((data) => { if (!stopped) setAuthors((data && data.authors) || []); })
|
|
344
|
+
.catch(() => { if (!stopped) setAuthors([]); });
|
|
345
|
+
return () => { stopped = true; };
|
|
346
|
+
}, [repo]);
|
|
347
|
+
|
|
348
|
+
// 键盘上下选提交:表格类界面必须能用方向键走,否则要一直摸鼠标
|
|
349
|
+
const onListKeyDown = (ev) => {
|
|
350
|
+
if (commits.length === 0) return;
|
|
351
|
+
const index = selected ? commits.findIndex((c) => c.sha === selected.sha) : -1;
|
|
352
|
+
if (ev.key === "ArrowDown") {
|
|
353
|
+
ev.preventDefault();
|
|
354
|
+
const next = commits[Math.min(commits.length - 1, index + 1)];
|
|
355
|
+
if (next) selectCommit(next);
|
|
356
|
+
} else if (ev.key === "ArrowUp") {
|
|
357
|
+
ev.preventDefault();
|
|
358
|
+
const prev = commits[Math.max(0, index - 1)];
|
|
359
|
+
if (prev) selectCommit(prev);
|
|
360
|
+
} else if (ev.key === "Home") {
|
|
361
|
+
ev.preventDefault();
|
|
362
|
+
selectCommit(commits[0]);
|
|
363
|
+
} else if (ev.key === "End") {
|
|
364
|
+
ev.preventDefault();
|
|
365
|
+
selectCommit(commits[commits.length - 1]);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const localBranches = (refs && refs.local) || [];
|
|
370
|
+
const remoteBranches = (refs && refs.remote) || [];
|
|
371
|
+
const tags = (refs && refs.tags) || [];
|
|
372
|
+
const diffFiles = (detail && detail.diff && detail.diff.files) || [];
|
|
373
|
+
const shownFiles = activeFile ? diffFiles.filter((f) => f.path === activeFile) : diffFiles;
|
|
374
|
+
|
|
375
|
+
// 两个可拖的比例:
|
|
376
|
+
// mainPct —— 列表区与详情区之间(抽屉上下堆叠时决定详情整块多高)
|
|
377
|
+
// detailPct —— 详情内部「差异 / 说明」之间
|
|
378
|
+
// GoLand 这两处都能拖,用户要的正是这个。
|
|
379
|
+
const [mainPct, setMainPct] = useState(50);
|
|
380
|
+
const [detailPct, setDetailPct] = useState(50);
|
|
381
|
+
// 拖动基准容器:必须精确指给分隔条,让它自己去猜祖先很容易猜错
|
|
382
|
+
// (分隔条外面那层 slot 只有 10px 高,拿它当基准算出来的比例完全失真)。
|
|
383
|
+
const bodyRef = useRef(null);
|
|
384
|
+
const detailRef = useRef(null);
|
|
385
|
+
|
|
386
|
+
return (
|
|
387
|
+
<div className="dkg-body" ref={bodyRef} style={{ "--dkg-main-pct": mainPct + "%", "--dkg-detail-pct": detailPct + "%", "--dkg-cols": columnsTemplate(visibleCols) }}>
|
|
388
|
+
{/* 左栏:分支 / 远端 / 标签(GoLand 的 Branches 弹出对应物) */}
|
|
389
|
+
<div className="dkg-side">
|
|
390
|
+
<button type="button" className={"dkg-side-item" + (branch === "" ? " on" : "")} onClick={() => setBranch("")}>
|
|
391
|
+
<span className="dkg-side-icon">◈</span>
|
|
392
|
+
<span className="dkg-ellipsis">HEAD(当前分支)</span>
|
|
393
|
+
</button>
|
|
394
|
+
<div className="dkg-side-group">
|
|
395
|
+
<div className="dkg-side-title">本地</div>
|
|
396
|
+
{localBranches.map((b) => (
|
|
397
|
+
<button type="button" key={b.full} className={"dkg-side-item" + (branch === b.name ? " on" : "")} onClick={() => setBranch(b.name)} title={b.subject}>
|
|
398
|
+
<span className="dkg-side-icon">⎇</span>
|
|
399
|
+
<span className="dkg-ellipsis">{b.name}</span>
|
|
400
|
+
</button>
|
|
401
|
+
))}
|
|
402
|
+
</div>
|
|
403
|
+
{remoteBranches.length > 0 ? (
|
|
404
|
+
<div className="dkg-side-group">
|
|
405
|
+
<div className="dkg-side-title">远端</div>
|
|
406
|
+
{remoteBranches.map((b) => (
|
|
407
|
+
<button type="button" key={b.full} className={"dkg-side-item" + (branch === b.name ? " on" : "")} onClick={() => setBranch(b.name)} title={b.subject}>
|
|
408
|
+
<span className="dkg-side-icon remote">☁</span>
|
|
409
|
+
<span className="dkg-ellipsis">{b.name}</span>
|
|
410
|
+
</button>
|
|
411
|
+
))}
|
|
412
|
+
</div>
|
|
413
|
+
) : null}
|
|
414
|
+
{tags.length > 0 ? (
|
|
415
|
+
<div className="dkg-side-group">
|
|
416
|
+
<div className="dkg-side-title">标签</div>
|
|
417
|
+
{tags.slice().reverse().map((t) => (
|
|
418
|
+
<button type="button" key={t.full} className={"dkg-side-item" + (branch === t.name ? " on" : "")} onClick={() => setBranch(t.name)} title={t.subject}>
|
|
419
|
+
<span className="dkg-side-icon tag">◆</span>
|
|
420
|
+
<span className="dkg-ellipsis">{t.name}</span>
|
|
421
|
+
</button>
|
|
422
|
+
))}
|
|
423
|
+
</div>
|
|
424
|
+
) : null}
|
|
425
|
+
</div>
|
|
426
|
+
|
|
427
|
+
{/* 中栏:筛选条 + 提交表格(GoLand 的 Log 表格:分支图 | 说明 | 作者 | 日期) */}
|
|
428
|
+
<div className="dkg-mid">
|
|
429
|
+
<div className="dkg-toolbar">
|
|
430
|
+
<input className="dkg-input" value={search} placeholder="搜索关键词(说明 / 哈希)" onChange={(e) => setSearch(e.target.value)} />
|
|
431
|
+
{/* 提交人:有候选就用下拉,取不到就退化成手输 */}
|
|
432
|
+
{authors.length > 0 ? (
|
|
433
|
+
<select className="dkg-select" value={authorPick} onChange={(e) => setAuthorPick(e.target.value)} title="按提交人筛选">
|
|
434
|
+
<option value="">全部提交人</option>
|
|
435
|
+
{authors.map((a) => (
|
|
436
|
+
<option key={a.name} value={a.name}>{a.name}({a.count})</option>
|
|
437
|
+
))}
|
|
438
|
+
</select>
|
|
439
|
+
) : (
|
|
440
|
+
<input className="dkg-input sm" value={author} placeholder="提交人" onChange={(e) => setAuthor(e.target.value)} />
|
|
441
|
+
)}
|
|
442
|
+
<input className="dkg-input sm" value={path} placeholder="路径" onChange={(e) => setPath(e.target.value)} />
|
|
443
|
+
{/* 时间段:两端都可空,只填一端也能用 */}
|
|
444
|
+
<input className="dkg-input sm" type="date" value={since} onChange={(e) => setSince(e.target.value)} title="起始日期(含)" />
|
|
445
|
+
<span className="dkg-hint">→</span>
|
|
446
|
+
<input className="dkg-input sm" type="date" value={until} onChange={(e) => setUntil(e.target.value)} title="结束日期(含)" />
|
|
447
|
+
{/* 子仓库多选:收进下拉,和时间选择器排在一起 */}
|
|
448
|
+
{repoOptions.length > 1 ? (
|
|
449
|
+
<RepoPicker
|
|
450
|
+
repos={repoOptions}
|
|
451
|
+
selected={pickedRepos}
|
|
452
|
+
current={repo}
|
|
453
|
+
onToggle={props.onToggleRepo}
|
|
454
|
+
onOnlyCurrent={props.onOnlyCurrent}
|
|
455
|
+
onSelectAll={props.onSelectAll}
|
|
456
|
+
/>
|
|
457
|
+
) : null}
|
|
458
|
+
<select className="dkg-select" value={limit} onChange={(e) => setLimit(Number(e.target.value))}>
|
|
459
|
+
<option value={50}>50</option>
|
|
460
|
+
<option value={100}>100</option>
|
|
461
|
+
<option value={200}>200</option>
|
|
462
|
+
<option value={500}>500</option>
|
|
463
|
+
</select>
|
|
464
|
+
{/* 列勾选:不勾的列直接不渲染(不是隐藏后留白) */}
|
|
465
|
+
<div className="dkg-colpick">
|
|
466
|
+
<button
|
|
467
|
+
type="button"
|
|
468
|
+
className="dkg-icon-btn"
|
|
469
|
+
onClick={() => setColMenu(!colMenu)}
|
|
470
|
+
title="选择要显示的列"
|
|
471
|
+
>▤</button>
|
|
472
|
+
{colMenu ? (
|
|
473
|
+
<div className="dkg-colpick-menu" role="listbox" aria-multiselectable="true">
|
|
474
|
+
{COMMIT_COLUMNS.map((c) => (
|
|
475
|
+
<button
|
|
476
|
+
type="button"
|
|
477
|
+
key={c.id}
|
|
478
|
+
role="option"
|
|
479
|
+
aria-selected={c.fixed || showCol(c.id)}
|
|
480
|
+
disabled={!!c.fixed}
|
|
481
|
+
className={"dkg-colpick-row" + ((c.fixed || showCol(c.id)) ? " on" : "") + (c.fixed ? " locked" : "")}
|
|
482
|
+
title={c.fixed ? "该列不可隐藏" : "点击切换显示"}
|
|
483
|
+
onClick={() => toggleCol(c.id)}
|
|
484
|
+
>
|
|
485
|
+
<span className="dkg-chip-check" aria-hidden="true">{(c.fixed || showCol(c.id)) ? "☑" : "☐"}</span>
|
|
486
|
+
<span>{c.title || "(分支图)"}</span>
|
|
487
|
+
</button>
|
|
488
|
+
))}
|
|
489
|
+
</div>
|
|
490
|
+
) : null}
|
|
491
|
+
</div>
|
|
492
|
+
<button type="button" className="dkg-icon-btn" onClick={load} disabled={loading} title="刷新">{loading ? "…" : "⟳"}</button>
|
|
493
|
+
</div>
|
|
494
|
+
{branch ? (
|
|
495
|
+
<div className="dkg-filter-tag">
|
|
496
|
+
分支:{branch}
|
|
497
|
+
<button type="button" className="dkg-link" onClick={() => setBranch("")}>清除</button>
|
|
498
|
+
</div>
|
|
499
|
+
) : null}
|
|
500
|
+
{error ? <div className="dkg-error">{error}</div> : null}
|
|
501
|
+
|
|
502
|
+
{/* 表头:按可见列渲染,与行共用同一套列宽 */}
|
|
503
|
+
<div className="dkg-thead">
|
|
504
|
+
{COMMIT_COLUMNS.filter((c) => c.fixed || showCol(c.id)).map((c) => (
|
|
505
|
+
<span key={c.id} className={"dkg-th " + c.id}>{c.title}</span>
|
|
506
|
+
))}
|
|
507
|
+
</div>
|
|
508
|
+
<div className="dkg-commits" tabIndex={0} onKeyDown={onListKeyDown} role="grid" aria-label="提交列表">
|
|
509
|
+
{commits.length === 0 && !loading ? <div className="dkg-note">没有匹配的提交。</div> : null}
|
|
510
|
+
{commits.map((c, i) => (
|
|
511
|
+
<CommitRow key={c.sha} commit={c} index={i} visibleCols={visibleCols} active={selected && selected.sha === c.sha} onSelect={selectCommit} />
|
|
512
|
+
))}
|
|
513
|
+
</div>
|
|
514
|
+
</div>
|
|
515
|
+
|
|
516
|
+
{/* 列表与详情之间的分隔条:抽屉里上下堆叠时,整块详情的高度由它拖动决定 */}
|
|
517
|
+
<div className="dkg-splitter-slot dkg-splitter-main">
|
|
518
|
+
<DragSplitter value={mainPct} onChange={setMainPct} min={20} max={85} containerRef={bodyRef} />
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
{/* 右栏:详情按上下分区(GoLand 的 Commit 面板:上方差异、下方说明),可拖动 */}
|
|
522
|
+
<div className="dkg-detail" ref={detailRef}>
|
|
523
|
+
{!selected ? <div className="dkg-note">选择左侧一条提交查看详情。</div> : null}
|
|
524
|
+
{selected && detailLoading ? <div className="dkg-note">读取中…</div> : null}
|
|
525
|
+
{detail && detail.error ? <div className="dkg-error">{detail.error}</div> : null}
|
|
526
|
+
{detail && !detail.error && !detailLoading ? (
|
|
527
|
+
<>
|
|
528
|
+
{/* 上方:变更文件与逐行差异 */}
|
|
529
|
+
<div className="dkg-detail-diff">
|
|
530
|
+
{diffFiles.length > 0 ? (
|
|
531
|
+
<div className="dkg-detail-split">
|
|
532
|
+
<FileTree files={diffFiles} selected={activeFile} onSelect={(p) => setActiveFile(activeFile === p ? "" : p)} />
|
|
533
|
+
<div className="dkg-diffs">
|
|
534
|
+
{activeFile ? <button type="button" className="dkg-link" onClick={() => setActiveFile("")}>显示全部文件</button> : null}
|
|
535
|
+
{shownFiles.map((f) => <DiffFile key={f.path} file={f} defaultOpen={!!activeFile || diffFiles.length <= 3} />)}
|
|
536
|
+
{detail.diff && detail.diff.truncated ? <div className="dkg-note">差异过大,已截断显示。</div> : null}
|
|
537
|
+
</div>
|
|
538
|
+
</div>
|
|
539
|
+
) : <div className="dkg-note">这条提交没有可显示的差异。</div>}
|
|
540
|
+
</div>
|
|
541
|
+
|
|
542
|
+
{/* 分区条:上下拖动改下方说明区高度 */}
|
|
543
|
+
<div className="dkg-splitter-slot">
|
|
544
|
+
<DragSplitter value={detailPct} onChange={setDetailPct} min={15} max={85} containerRef={detailRef} />
|
|
545
|
+
</div>
|
|
546
|
+
|
|
547
|
+
{/* 下方:提交信息(哈希 / 作者 / 时间 / 正文) */}
|
|
548
|
+
<div className="dkg-detail-msgbox">
|
|
549
|
+
<div className="dkg-detail-subject">{detail.subject}</div>
|
|
550
|
+
<div className="dkg-detail-meta">
|
|
551
|
+
<span className="dkg-sha">{detail.sha}</span>
|
|
552
|
+
{detail.parents && detail.parents.length > 1 ? <span className="dkg-tag">合并提交</span> : null}
|
|
553
|
+
<span>{detail.author} <{detail.authorEmail}></span>
|
|
554
|
+
<span>{fmtTime(detail.authorDate)}</span>
|
|
555
|
+
<span className="dkg-add">+{detail.additions}</span>
|
|
556
|
+
<span className="dkg-del">−{detail.deletions}</span>
|
|
557
|
+
</div>
|
|
558
|
+
{detail.body ? <pre className="dkg-detail-msg">{detail.body}</pre> : null}
|
|
559
|
+
</div>
|
|
560
|
+
</>
|
|
561
|
+
) : null}
|
|
562
|
+
</div>
|
|
563
|
+
</div>
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// ---------- 工作区页 ----------
|
|
568
|
+
// 三组:已暂存 / 未暂存 / 未跟踪。勾选文件加入或移出暂存区;
|
|
569
|
+
// 提交前先「预览变更」,看到完整差异再确认提交,提交后可一键推送。
|
|
570
|
+
function WorktreePane(props) {
|
|
571
|
+
const { repo, status, onRefresh } = props;
|
|
572
|
+
const [checked, setChecked] = useState({});
|
|
573
|
+
const [message, setMessage] = useState("");
|
|
574
|
+
const [busy, setBusy] = useState("");
|
|
575
|
+
const [error, setError] = useState("");
|
|
576
|
+
const [preview, setPreview] = useState(null);
|
|
577
|
+
const [previewLoading, setPreviewLoading] = useState(false);
|
|
578
|
+
const [result, setResult] = useState(null);
|
|
579
|
+
const [activeFile, setActiveFile] = useState("");
|
|
580
|
+
|
|
581
|
+
const entries = (status && status.entries) || [];
|
|
582
|
+
const staged = entries.filter((e) => e.staged);
|
|
583
|
+
const unstaged = entries.filter((e) => !e.staged && !e.untracked);
|
|
584
|
+
const untracked = entries.filter((e) => e.untracked);
|
|
585
|
+
|
|
586
|
+
const toggle = (path) => setChecked((prev) => Object.assign({}, prev, { [path]: !prev[path] }));
|
|
587
|
+
const toggleAll = (list) => {
|
|
588
|
+
const allOn = list.length > 0 && list.every((e) => checked[e.path]);
|
|
589
|
+
const next = Object.assign({}, checked);
|
|
590
|
+
for (const e of list) next[e.path] = !allOn;
|
|
591
|
+
setChecked(next);
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
const doStage = async (paths, unstage) => {
|
|
595
|
+
if (paths.length === 0) return;
|
|
596
|
+
setBusy(unstage ? "取消暂存…" : "暂存中…");
|
|
597
|
+
setError("");
|
|
598
|
+
try {
|
|
599
|
+
await rpc("stage", { repo, paths, unstage: unstage === true, confirm: true });
|
|
600
|
+
setChecked({});
|
|
601
|
+
await onRefresh();
|
|
602
|
+
} catch (e) {
|
|
603
|
+
setError((e && e.message) || String(e));
|
|
604
|
+
} finally {
|
|
605
|
+
setBusy("");
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
const loadPreview = async () => {
|
|
610
|
+
setPreviewLoading(true);
|
|
611
|
+
setError("");
|
|
612
|
+
setActiveFile("");
|
|
613
|
+
try {
|
|
614
|
+
const data = await rpc("diff", { repo, staged: true });
|
|
615
|
+
setPreview(data);
|
|
616
|
+
} catch (e) {
|
|
617
|
+
setError((e && e.message) || String(e));
|
|
618
|
+
setPreview(null);
|
|
619
|
+
} finally {
|
|
620
|
+
setPreviewLoading(false);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
const doCommit = async () => {
|
|
625
|
+
if (!message.trim()) { setError("请先填写提交说明"); return; }
|
|
626
|
+
if (staged.length === 0) { setError("暂存区为空,先勾选要提交的文件"); return; }
|
|
627
|
+
setBusy("提交中…");
|
|
628
|
+
setError("");
|
|
629
|
+
try {
|
|
630
|
+
const data = await rpc("create-commit", { repo, message: message.trim(), confirm: true });
|
|
631
|
+
setResult(data && data.commit);
|
|
632
|
+
setMessage("");
|
|
633
|
+
setPreview(null);
|
|
634
|
+
setChecked({});
|
|
635
|
+
await onRefresh();
|
|
636
|
+
} catch (e) {
|
|
637
|
+
setError((e && e.message) || String(e));
|
|
638
|
+
} finally {
|
|
639
|
+
setBusy("");
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
const doPush = async () => {
|
|
644
|
+
setBusy("推送中…");
|
|
645
|
+
setError("");
|
|
646
|
+
try {
|
|
647
|
+
const data = await rpc("push", { repo, confirm: true });
|
|
648
|
+
setResult({ pushed: true, output: data && data.output });
|
|
649
|
+
await onRefresh();
|
|
650
|
+
} catch (e) {
|
|
651
|
+
setError((e && e.message) || String(e));
|
|
652
|
+
} finally {
|
|
653
|
+
setBusy("");
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const previewFiles = (preview && preview.files) || [];
|
|
658
|
+
const shownPreview = activeFile ? previewFiles.filter((f) => f.path === activeFile) : previewFiles;
|
|
659
|
+
|
|
660
|
+
const group = (title, list, stagedGroup) => (
|
|
661
|
+
<div className="dkg-wt-group">
|
|
662
|
+
<div className="dkg-wt-head">
|
|
663
|
+
<label className="dkg-check">
|
|
664
|
+
<input type="checkbox" checked={list.length > 0 && list.every((e) => checked[e.path])} onChange={() => toggleAll(list)} />
|
|
665
|
+
<span>{title}</span>
|
|
666
|
+
<span className="dkg-hint">{list.length}</span>
|
|
667
|
+
</label>
|
|
668
|
+
{list.length > 0 ? (
|
|
669
|
+
<button type="button" className="dkg-link" disabled={!!busy} onClick={() => {
|
|
670
|
+
const paths = list.filter((e) => checked[e.path]).map((e) => e.path);
|
|
671
|
+
doStage(paths.length > 0 ? paths : list.map((e) => e.path), stagedGroup);
|
|
672
|
+
}}>
|
|
673
|
+
{stagedGroup ? "全部取消暂存" : "全部暂存"}
|
|
674
|
+
</button>
|
|
675
|
+
) : null}
|
|
676
|
+
</div>
|
|
677
|
+
{list.length === 0 ? <div className="dkg-note dkg-wt-empty">无</div> : list.map((e) => (
|
|
678
|
+
<label key={e.path} className={"dkg-wt-item" + (checked[e.path] ? " on" : "")}>
|
|
679
|
+
<input type="checkbox" checked={!!checked[e.path]} onChange={() => toggle(e.path)} />
|
|
680
|
+
<span className="dkg-wt-code">{e.index}{e.worktree}</span>
|
|
681
|
+
<span className="dkg-ellipsis" title={e.origPath ? (e.origPath + " → " + e.path) : e.path}>{e.path}</span>
|
|
682
|
+
<span className="dkg-wt-actions">
|
|
683
|
+
{stagedGroup ? (
|
|
684
|
+
<button type="button" className="dkg-link" disabled={!!busy} onClick={(ev) => { ev.preventDefault(); doStage([e.path], true); }}>取消暂存</button>
|
|
685
|
+
) : (
|
|
686
|
+
<button type="button" className="dkg-link" disabled={!!busy} onClick={(ev) => { ev.preventDefault(); doStage([e.path], false); }}>暂存</button>
|
|
687
|
+
)}
|
|
688
|
+
</span>
|
|
689
|
+
</label>
|
|
690
|
+
))}
|
|
691
|
+
</div>
|
|
692
|
+
);
|
|
693
|
+
|
|
694
|
+
return (
|
|
695
|
+
<div className="dkg-wt">
|
|
696
|
+
<div className="dkg-wt-files">
|
|
697
|
+
{group("已暂存", staged, true)}
|
|
698
|
+
{group("未暂存", unstaged, false)}
|
|
699
|
+
{group("未跟踪", untracked, false)}
|
|
700
|
+
{entries.length === 0 ? <div className="dkg-note">工作区干净,没有可提交的改动。</div> : null}
|
|
701
|
+
</div>
|
|
702
|
+
<div className="dkg-wt-commit">
|
|
703
|
+
<textarea
|
|
704
|
+
className="dkg-textarea"
|
|
705
|
+
rows={4}
|
|
706
|
+
value={message}
|
|
707
|
+
placeholder="提交说明(第一行是标题,空一行后可写正文)"
|
|
708
|
+
onChange={(e) => setMessage(e.target.value)}
|
|
709
|
+
/>
|
|
710
|
+
<div className="dkg-wt-actions">
|
|
711
|
+
<button type="button" className="dkg-btn" onClick={loadPreview} disabled={!!busy || staged.length === 0}>
|
|
712
|
+
{previewLoading ? "读取中…" : "预览变更"}
|
|
713
|
+
</button>
|
|
714
|
+
<button type="button" className="dkg-btn primary" onClick={doCommit} disabled={!!busy || staged.length === 0 || !message.trim()}>
|
|
715
|
+
提交
|
|
716
|
+
</button>
|
|
717
|
+
<button type="button" className="dkg-btn" onClick={doPush} disabled={!!busy || (status && status.ahead === 0)} title={status && status.ahead === 0 ? "没有待推送的提交" : "推送到远端"}>
|
|
718
|
+
{status && status.ahead > 0 ? "推送 " + status.ahead + " 个提交" : "推送"}
|
|
719
|
+
</button>
|
|
720
|
+
</div>
|
|
721
|
+
{busy ? <div className="dkg-hint">{busy}</div> : null}
|
|
722
|
+
{error ? <div className="dkg-error">{error}</div> : null}
|
|
723
|
+
{result && result.pushed ? (
|
|
724
|
+
<div className="dkg-ok">
|
|
725
|
+
推送完成{result.output ? ":" + truncate(result.output, 200) : ""}
|
|
726
|
+
</div>
|
|
727
|
+
) : null}
|
|
728
|
+
{result && result.subject ? (
|
|
729
|
+
<div className="dkg-ok">已提交 {result.shortSha}:{truncate(result.subject, 80)}</div>
|
|
730
|
+
) : null}
|
|
731
|
+
{preview ? (
|
|
732
|
+
<div className="dkg-preview">
|
|
733
|
+
<div className="dkg-preview-head">
|
|
734
|
+
<span>提交预览:{previewFiles.length} 个文件</span>
|
|
735
|
+
<button type="button" className="dkg-link" onClick={() => { setPreview(null); setActiveFile(""); }}>收起</button>
|
|
736
|
+
</div>
|
|
737
|
+
<div className="dkg-detail-split">
|
|
738
|
+
<FileTree files={previewFiles} selected={activeFile} onSelect={(p) => setActiveFile(activeFile === p ? "" : p)} />
|
|
739
|
+
<div className="dkg-diffs">
|
|
740
|
+
{shownPreview.map((f) => <DiffFile key={f.path} file={f} defaultOpen={!!activeFile || previewFiles.length <= 3} />)}
|
|
741
|
+
</div>
|
|
742
|
+
</div>
|
|
743
|
+
</div>
|
|
744
|
+
) : null}
|
|
745
|
+
</div>
|
|
746
|
+
</div>
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* 把百分比夹到 [min, max]。
|
|
755
|
+
* 单独提出来是为了能脱离 React 直接测——拖动与键盘两条路径都要用它。
|
|
756
|
+
* @param {number} value 目标百分比
|
|
757
|
+
* @param {number} [min] 下限
|
|
758
|
+
* @param {number} [max] 上限
|
|
759
|
+
* @returns {number} 夹取后的值
|
|
760
|
+
*/
|
|
761
|
+
export function clampPercent(value, min, max) {
|
|
762
|
+
const lo = typeof min === "number" ? min : 15;
|
|
763
|
+
const hi = typeof max === "number" ? max : 85;
|
|
764
|
+
const n = Number(value);
|
|
765
|
+
if (!Number.isFinite(n)) return lo;
|
|
766
|
+
return Math.min(hi, Math.max(lo, Math.round(n)));
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* 分隔条的键盘步进:算出按键后的新百分比。
|
|
771
|
+
* @param {string} key 按键名
|
|
772
|
+
* @param {number} value 当前百分比
|
|
773
|
+
* @param {number} [min] 下限
|
|
774
|
+
* @param {number} [max] 上限
|
|
775
|
+
* @returns {number|null} 新值;该键不处理时返回 null
|
|
776
|
+
*/
|
|
777
|
+
export function splitterStep(key, value, min, max) {
|
|
778
|
+
const lo = typeof min === "number" ? min : 15;
|
|
779
|
+
const hi = typeof max === "number" ? max : 85;
|
|
780
|
+
if (key === "ArrowUp") return clampPercent(value + 2, lo, hi);
|
|
781
|
+
if (key === "ArrowDown") return clampPercent(value - 2, lo, hi);
|
|
782
|
+
if (key === "Home") return lo;
|
|
783
|
+
if (key === "End") return hi;
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* 拖动换算:根据指针位移算出新的比例。
|
|
790
|
+
*
|
|
791
|
+
* 为什么用**增量**而不是「指针到容器底部的绝对距离」:
|
|
792
|
+
* 绝对距离会读当前布局,而布局又被这次拖动改变,形成反馈环——
|
|
793
|
+
* 拖动改高度 → 布局变 → 量到新高度 → 值再变 → 布局再变,表现为抖动与「自动掉落」。
|
|
794
|
+
* 增量只与指针走了多远有关,与布局此刻长什么样无关,因此不会自激。
|
|
795
|
+
*
|
|
796
|
+
* @param {number} startValue 起拖时的比例(%)
|
|
797
|
+
* @param {number} deltaY 指针相对起点的纵向位移(像素,向下为正)
|
|
798
|
+
* @param {number} containerHeight 起拖时容器的高度(像素)
|
|
799
|
+
* @param {number} [min] 下限
|
|
800
|
+
* @param {number} [max] 上限
|
|
801
|
+
* @returns {number} 新的比例(%),已夹在上下限内
|
|
802
|
+
*/
|
|
803
|
+
export function dragToPercent(startValue, deltaY, containerHeight, min, max) {
|
|
804
|
+
const lo = typeof min === "number" ? min : 15;
|
|
805
|
+
const hi = typeof max === "number" ? max : 85;
|
|
806
|
+
if (!(containerHeight > 0)) return clampPercent(startValue, lo, hi);
|
|
807
|
+
const deltaPct = (deltaY / containerHeight) * 100;
|
|
808
|
+
// 指针下移 → 下方区域变矮 → 比例减小
|
|
809
|
+
return clampPercent(startValue - deltaPct, lo, hi);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* 子仓库多选下拉。
|
|
815
|
+
*
|
|
816
|
+
* 为什么不做平铺 chips:仓库一多(父目录下十几个)就占掉三四行高度,
|
|
817
|
+
* 把提交列表挤得只剩几条;而且那个位置离筛选器很远,不像一组控件。
|
|
818
|
+
* 收进下拉后只占一个按钮的宽度,展开才看清单。
|
|
819
|
+
*
|
|
820
|
+
* @param {{ repos: Array, selected: string[], current: string, onToggle: (p: string) => void, onOnlyCurrent: () => void }} props
|
|
821
|
+
*/
|
|
822
|
+
function RepoPicker(props) {
|
|
823
|
+
const { repos, selected, current, onToggle, onOnlyCurrent, onSelectAll } = props;
|
|
824
|
+
const [open, setOpen] = useState(false);
|
|
825
|
+
const rootRef = useRef(null);
|
|
826
|
+
|
|
827
|
+
// 点外面关闭:下拉必须能随手关掉,否则挡住列表
|
|
828
|
+
useEffect(() => {
|
|
829
|
+
if (!open) return;
|
|
830
|
+
const onDown = (ev) => {
|
|
831
|
+
const root = rootRef.current;
|
|
832
|
+
if (root && ev.target && !root.contains(ev.target)) setOpen(false);
|
|
833
|
+
};
|
|
834
|
+
const onKey = (ev) => { if (ev.key === "Escape") setOpen(false); };
|
|
835
|
+
document.addEventListener("mousedown", onDown);
|
|
836
|
+
document.addEventListener("keydown", onKey);
|
|
837
|
+
return () => {
|
|
838
|
+
document.removeEventListener("mousedown", onDown);
|
|
839
|
+
document.removeEventListener("keydown", onKey);
|
|
840
|
+
};
|
|
841
|
+
}, [open]);
|
|
842
|
+
|
|
843
|
+
const picked = selected.length > 0 ? selected : [current];
|
|
844
|
+
// 标签要说实话:取消当前仓库后只剩子仓库,还说「当前仓库」会误导
|
|
845
|
+
const onlyCurrent = picked.length === 1 && picked[0] === current;
|
|
846
|
+
const label = onlyCurrent ? "当前仓库" : (picked.length + " 个仓库");
|
|
847
|
+
|
|
848
|
+
return (
|
|
849
|
+
<div className="dkg-repopick" ref={rootRef}>
|
|
850
|
+
<button
|
|
851
|
+
type="button"
|
|
852
|
+
className={"dkg-repopick-btn" + (picked.length > 1 ? " on" : "")}
|
|
853
|
+
onClick={() => setOpen(!open)}
|
|
854
|
+
title={picked.join("\n")}
|
|
855
|
+
>
|
|
856
|
+
<span>仓库:{label}</span>
|
|
857
|
+
<span className="dkg-caret" aria-hidden="true">{open ? "▴" : "▾"}</span>
|
|
858
|
+
</button>
|
|
859
|
+
{open ? (
|
|
860
|
+
<div className="dkg-repopick-menu" role="listbox" aria-multiselectable="true">
|
|
861
|
+
{/* 全选 / 取消全选:仓库多的时候逐个点太慢,两个动作都得有 */}
|
|
862
|
+
<div className="dkg-repopick-all">
|
|
863
|
+
<button
|
|
864
|
+
type="button"
|
|
865
|
+
className="dkg-repopick-allbtn"
|
|
866
|
+
onClick={() => onSelectAll(repos.map((r) => r.path))}
|
|
867
|
+
title="勾选全部仓库"
|
|
868
|
+
>
|
|
869
|
+
☑ 全选
|
|
870
|
+
</button>
|
|
871
|
+
<button
|
|
872
|
+
type="button"
|
|
873
|
+
className="dkg-repopick-allbtn"
|
|
874
|
+
onClick={() => onSelectAll([current])}
|
|
875
|
+
title="只保留当前仓库"
|
|
876
|
+
>
|
|
877
|
+
☐ 取消全选
|
|
878
|
+
</button>
|
|
879
|
+
</div>
|
|
880
|
+
{repos.map((r) => {
|
|
881
|
+
const checked = picked.includes(r.path);
|
|
882
|
+
return (
|
|
883
|
+
<button
|
|
884
|
+
type="button"
|
|
885
|
+
key={r.path}
|
|
886
|
+
role="option"
|
|
887
|
+
aria-selected={checked}
|
|
888
|
+
className={"dkg-repopick-row" + (checked ? " on" : "")}
|
|
889
|
+
title={r.path}
|
|
890
|
+
onClick={() => onToggle(r.path)}
|
|
891
|
+
>
|
|
892
|
+
<span className="dkg-chip-check" aria-hidden="true">{checked ? "☑" : "☐"}</span>
|
|
893
|
+
<span className="dkg-ellipsis">{r.isRoot ? (r.name + "(当前目录)") : r.relPath}</span>
|
|
894
|
+
<span className="dkg-hint">{r.branch}{r.dirty > 0 ? " · " + r.dirty : ""}</span>
|
|
895
|
+
</button>
|
|
896
|
+
);
|
|
897
|
+
})}
|
|
898
|
+
{picked.length > 1 ? (
|
|
899
|
+
<button type="button" className="dkg-repopick-foot" onClick={onOnlyCurrent}>只看当前仓库</button>
|
|
900
|
+
) : null}
|
|
901
|
+
</div>
|
|
902
|
+
) : null}
|
|
903
|
+
</div>
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// ---------- 可拖动的分隔条 ----------
|
|
908
|
+
/**
|
|
909
|
+
* 一条可拖动的分隔条:按住上下拖,改变上下两块的高度比例。
|
|
910
|
+
*
|
|
911
|
+
* 为什么不用 CSS resize:原生 `resize: vertical` 只对 textarea 这类元素有效,
|
|
912
|
+
* 且样式在各浏览器不一致;这里需要的是「拖动分隔条改布局比例」,所以自己实现。
|
|
913
|
+
*
|
|
914
|
+
* @param {{ value: number, onChange: (next: number) => void, min?: number, max?: number }} props
|
|
915
|
+
* value 是下方区域的高度百分比(0~100)。
|
|
916
|
+
*/
|
|
917
|
+
export function DragSplitter(props) {
|
|
918
|
+
const { value, onChange } = props;
|
|
919
|
+
const min = typeof props.min === "number" ? props.min : 15;
|
|
920
|
+
const max = typeof props.max === "number" ? props.max : 85;
|
|
921
|
+
const [dragging, setDragging] = useState(false);
|
|
922
|
+
const boxRef = useRef(null);
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* 一次拖动会话的固定基准。
|
|
926
|
+
*
|
|
927
|
+
* 关键:**起拖时测一次容器,整个拖动过程不再重新测量**。
|
|
928
|
+
* 之前每帧都读 getBoundingClientRect 并据此反算比例,形成反馈环:
|
|
929
|
+
* 拖动改高度 → 布局变 → 量到的新高度又参与计算 → 值再变 → 布局再变。
|
|
930
|
+
* 表现为抖动、拖不准、松手后位置「自动掉落」。
|
|
931
|
+
*
|
|
932
|
+
* 另外也不能用 parentElement:分隔条外面还有一层 .dkg-splitter-slot,
|
|
933
|
+
* 它的高度只有分隔条本身那么高(约 10px),拿它当基准算出来的比例完全失真。
|
|
934
|
+
*/
|
|
935
|
+
const session = useRef(null);
|
|
936
|
+
const frame = useRef(0);
|
|
937
|
+
const pendingY = useRef(0);
|
|
938
|
+
const latestValue = useRef(value);
|
|
939
|
+
latestValue.current = value;
|
|
940
|
+
|
|
941
|
+
/** 找真正参与分配高度的容器:优先用调用方给的 ref,其次向上找有实际高度的祖先。 */
|
|
942
|
+
const resolveContainer = () => {
|
|
943
|
+
const given = props.containerRef && props.containerRef.current;
|
|
944
|
+
if (given) return given;
|
|
945
|
+
let node = boxRef.current;
|
|
946
|
+
while (node && node.parentElement) {
|
|
947
|
+
node = node.parentElement;
|
|
948
|
+
if (node.getBoundingClientRect().height > 60) return node;
|
|
949
|
+
}
|
|
950
|
+
return null;
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
const begin = (clientY) => {
|
|
954
|
+
const container = resolveContainer();
|
|
955
|
+
if (!container) return;
|
|
956
|
+
const rect = container.getBoundingClientRect();
|
|
957
|
+
if (rect.height <= 0) return;
|
|
958
|
+
session.current = {
|
|
959
|
+
top: rect.top,
|
|
960
|
+
height: rect.height,
|
|
961
|
+
startY: clientY,
|
|
962
|
+
startValue: clampPercent(latestValue.current, min, max),
|
|
963
|
+
};
|
|
964
|
+
setDragging(true);
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
const apply = () => {
|
|
968
|
+
frame.current = 0;
|
|
969
|
+
const s = session.current;
|
|
970
|
+
if (!s) return;
|
|
971
|
+
// 用**位移增量**换算,不用「指针到容器底部的绝对距离」:
|
|
972
|
+
// 增量只跟指针走了多远有关,与布局此刻长什么样无关,因此不会自激。
|
|
973
|
+
// 指针下移 → 下方区域变矮 → 比例减小。
|
|
974
|
+
onChange(dragToPercent(s.startValue, pendingY.current - s.startY, s.height, min, max));
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
const moveTo = (clientY) => {
|
|
978
|
+
pendingY.current = clientY;
|
|
979
|
+
// 每帧最多算一次:mousemove 密度远高于渲染帧率,逐条 setState 会明显卡顿
|
|
980
|
+
if (frame.current) return;
|
|
981
|
+
if (typeof requestAnimationFrame === "function") {
|
|
982
|
+
frame.current = requestAnimationFrame(apply);
|
|
983
|
+
} else {
|
|
984
|
+
apply();
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
const end = () => {
|
|
989
|
+
session.current = null;
|
|
990
|
+
if (frame.current && typeof cancelAnimationFrame === "function") {
|
|
991
|
+
cancelAnimationFrame(frame.current);
|
|
992
|
+
frame.current = 0;
|
|
993
|
+
}
|
|
994
|
+
setDragging(false);
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
useEffect(() => {
|
|
998
|
+
if (!dragging) return;
|
|
999
|
+
const onMouseMove = (ev) => moveTo(ev.clientY);
|
|
1000
|
+
const onTouchMove = (ev) => {
|
|
1001
|
+
const t = ev.touches && ev.touches[0];
|
|
1002
|
+
if (!t) return;
|
|
1003
|
+
// 触摸拖动时阻止页面滚动,否则手指一动页面就跟着滑,分隔条不跟手
|
|
1004
|
+
if (typeof ev.preventDefault === "function" && ev.cancelable !== false) ev.preventDefault();
|
|
1005
|
+
moveTo(t.clientY);
|
|
1006
|
+
};
|
|
1007
|
+
const onUp = () => end();
|
|
1008
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
1009
|
+
document.addEventListener("mouseup", onUp);
|
|
1010
|
+
document.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
1011
|
+
document.addEventListener("touchend", onUp);
|
|
1012
|
+
document.addEventListener("touchcancel", onUp);
|
|
1013
|
+
// 拖到窗口外松手、或窗口失焦:必须收尾,否则会一直卡在拖动态
|
|
1014
|
+
window.addEventListener("blur", onUp);
|
|
1015
|
+
document.body.classList.add("dkg-resizing");
|
|
1016
|
+
return () => {
|
|
1017
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
1018
|
+
document.removeEventListener("mouseup", onUp);
|
|
1019
|
+
document.removeEventListener("touchmove", onTouchMove);
|
|
1020
|
+
document.removeEventListener("touchend", onUp);
|
|
1021
|
+
document.removeEventListener("touchcancel", onUp);
|
|
1022
|
+
window.removeEventListener("blur", onUp);
|
|
1023
|
+
document.body.classList.remove("dkg-resizing");
|
|
1024
|
+
if (frame.current && typeof cancelAnimationFrame === "function") {
|
|
1025
|
+
cancelAnimationFrame(frame.current);
|
|
1026
|
+
frame.current = 0;
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
}, [dragging, onChange, min, max]);
|
|
1030
|
+
|
|
1031
|
+
// 键盘也能调:可访问性要求分隔条可聚焦、可用方向键调整
|
|
1032
|
+
const onKeyDown = (ev) => {
|
|
1033
|
+
const next = splitterStep(ev.key, value, min, max);
|
|
1034
|
+
if (next === null) return;
|
|
1035
|
+
ev.preventDefault();
|
|
1036
|
+
onChange(next);
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
return (
|
|
1040
|
+
<div
|
|
1041
|
+
ref={boxRef}
|
|
1042
|
+
className={"dkg-splitter" + (dragging ? " dragging" : "")}
|
|
1043
|
+
role="separator"
|
|
1044
|
+
aria-orientation="horizontal"
|
|
1045
|
+
aria-valuenow={value}
|
|
1046
|
+
aria-valuemin={min}
|
|
1047
|
+
aria-valuemax={max}
|
|
1048
|
+
tabIndex={0}
|
|
1049
|
+
title="拖动调整高度(也可用方向键)"
|
|
1050
|
+
onMouseDown={(ev) => { ev.preventDefault(); begin(ev.clientY); }}
|
|
1051
|
+
onTouchStart={(ev) => { const t = ev.touches && ev.touches[0]; if (t) begin(t.clientY); }}
|
|
1052
|
+
onKeyDown={onKeyDown}
|
|
1053
|
+
onDoubleClick={() => onChange(50)}
|
|
1054
|
+
>
|
|
1055
|
+
<span className="dkg-splitter-grip" aria-hidden="true" />
|
|
1056
|
+
</div>
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// ---------- 目录浏览器 ----------
|
|
1061
|
+
// 为什么不直接用系统对话框:uiWorkspace.pickDirectory() 走的是原生 picker,
|
|
1062
|
+
// 装在服务器上(没有桌面环境)时它根本弹不出来。这里改用 uiWorkspace.listDirectory(),
|
|
1063
|
+
// 它只需要 Host 有目录读取能力,服务器部署同样可用。
|
|
1064
|
+
//
|
|
1065
|
+
// 交互:从当前目录或家目录起浏览 → 点目录进入 → 「上一级」/ 面包屑跳转 →
|
|
1066
|
+
// 「选这个目录」确认。只列目录,不列文件(我们要的是仓库或父目录)。
|
|
1067
|
+
export function DirBrowser(props) {
|
|
1068
|
+
const ctx = props.ctx;
|
|
1069
|
+
const [listing, setListing] = useState(null);
|
|
1070
|
+
const [loading, setLoading] = useState(false);
|
|
1071
|
+
const [error, setError] = useState("");
|
|
1072
|
+
const [showHidden, setShowHidden] = useState(false);
|
|
1073
|
+
const [input, setInput] = useState(props.startPath || "");
|
|
1074
|
+
|
|
1075
|
+
const load = useCallback(async (path) => {
|
|
1076
|
+
setLoading(true);
|
|
1077
|
+
setError("");
|
|
1078
|
+
try {
|
|
1079
|
+
const uiw = ctx && typeof ctx.get === "function" ? ctx.get("uiWorkspace") : null;
|
|
1080
|
+
if (!uiw || typeof uiw.listDirectory !== "function") {
|
|
1081
|
+
throw new Error("当前环境没有目录浏览能力(uiWorkspace.listDirectory 不可用)");
|
|
1082
|
+
}
|
|
1083
|
+
const data = await uiw.listDirectory(path || undefined);
|
|
1084
|
+
setListing(data);
|
|
1085
|
+
setInput(data && data.path ? data.path : "");
|
|
1086
|
+
} catch (e) {
|
|
1087
|
+
setError((e && e.message) || String(e));
|
|
1088
|
+
} finally {
|
|
1089
|
+
setLoading(false);
|
|
1090
|
+
}
|
|
1091
|
+
}, [ctx]);
|
|
1092
|
+
|
|
1093
|
+
useEffect(() => {
|
|
1094
|
+
load(props.startPath || "");
|
|
1095
|
+
}, [load, props.startPath]);
|
|
1096
|
+
|
|
1097
|
+
const entries = ((listing && listing.entries) || []).filter((e) => showHidden || !e.hidden);
|
|
1098
|
+
const crumbs = (listing && listing.crumbs) || [];
|
|
1099
|
+
|
|
1100
|
+
return (
|
|
1101
|
+
<div className="dkg-picker">
|
|
1102
|
+
<div className="dkg-picker-head">
|
|
1103
|
+
<span className="dkg-picker-title">选择目录</span>
|
|
1104
|
+
<button type="button" className="dkg-link" onClick={props.onClose}>关闭</button>
|
|
1105
|
+
</div>
|
|
1106
|
+
|
|
1107
|
+
{/* 面包屑:从根到当前目录,每一级都可点 */}
|
|
1108
|
+
<div className="dkg-crumbs">
|
|
1109
|
+
{crumbs.map((c, i) => (
|
|
1110
|
+
<button
|
|
1111
|
+
type="button"
|
|
1112
|
+
key={c.path}
|
|
1113
|
+
className={"dkg-crumb" + (i === crumbs.length - 1 ? " on" : "")}
|
|
1114
|
+
title={c.path}
|
|
1115
|
+
onClick={() => load(c.path)}
|
|
1116
|
+
>
|
|
1117
|
+
{i === 0 ? (c.name || "/") : c.name}
|
|
1118
|
+
</button>
|
|
1119
|
+
))}
|
|
1120
|
+
</div>
|
|
1121
|
+
|
|
1122
|
+
<div className="dkg-picker-bar">
|
|
1123
|
+
<input
|
|
1124
|
+
className="dkg-input"
|
|
1125
|
+
value={input}
|
|
1126
|
+
placeholder="绝对路径"
|
|
1127
|
+
spellCheck={false}
|
|
1128
|
+
onChange={(e) => setInput(e.target.value)}
|
|
1129
|
+
onKeyDown={(e) => { if (e.key === "Enter") load(input.trim()); }}
|
|
1130
|
+
/>
|
|
1131
|
+
<button type="button" className="dkg-btn" onClick={() => load(input.trim())} disabled={loading}>前往</button>
|
|
1132
|
+
<label className="dkg-check">
|
|
1133
|
+
<input type="checkbox" checked={showHidden} onChange={(e) => setShowHidden(e.target.checked)} />
|
|
1134
|
+
<span>隐藏项</span>
|
|
1135
|
+
</label>
|
|
1136
|
+
</div>
|
|
1137
|
+
|
|
1138
|
+
{error ? <div className="dkg-error">{error}</div> : null}
|
|
1139
|
+
|
|
1140
|
+
<div className="dkg-picker-list">
|
|
1141
|
+
{loading ? <div className="dkg-note">读取中…</div> : null}
|
|
1142
|
+
{!loading && entries.length === 0 && !error ? <div className="dkg-note">这个目录下没有子目录。</div> : null}
|
|
1143
|
+
{entries.map((entry) => (
|
|
1144
|
+
<button
|
|
1145
|
+
type="button"
|
|
1146
|
+
key={entry.path}
|
|
1147
|
+
className="dkg-picker-row"
|
|
1148
|
+
title={entry.path}
|
|
1149
|
+
onClick={() => load(entry.path)}
|
|
1150
|
+
>
|
|
1151
|
+
<span className="dkg-folder">▸</span>
|
|
1152
|
+
<span className="dkg-ellipsis">{entry.name}</span>
|
|
1153
|
+
</button>
|
|
1154
|
+
))}
|
|
1155
|
+
{listing && listing.truncated ? <div className="dkg-note">目录过多,只显示了前面一部分。</div> : null}
|
|
1156
|
+
</div>
|
|
1157
|
+
|
|
1158
|
+
<div className="dkg-picker-foot">
|
|
1159
|
+
<span className="dkg-hint" title={listing && listing.path}>{listing && listing.path ? truncate(listing.path, 60) : ""}</span>
|
|
1160
|
+
<button
|
|
1161
|
+
type="button"
|
|
1162
|
+
className="dkg-btn primary"
|
|
1163
|
+
disabled={!listing || loading}
|
|
1164
|
+
onClick={() => { if (listing && listing.path) props.onPick(listing.path); }}
|
|
1165
|
+
>
|
|
1166
|
+
选这个目录
|
|
1167
|
+
</button>
|
|
1168
|
+
</div>
|
|
1169
|
+
</div>
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// ---------- 主视图(抽屉页签 / 也可独立使用) ----------
|
|
1174
|
+
// props:
|
|
1175
|
+
// repo 直接指定仓库(右键入口传进来,跳过发现)
|
|
1176
|
+
// initialPath 仓库内相对路径(右键某个文件时用它预填路径过滤)
|
|
1177
|
+
// compact 抽屉里为 true:省掉「包含子目录仓库」那一段,布局更紧凑
|
|
1178
|
+
export function GitView(props) {
|
|
1179
|
+
const ctx = props && props.ctx;
|
|
1180
|
+
const [dir, setDir] = useState(props && props.repo ? props.repo : "");
|
|
1181
|
+
// 默认开启:当前目录装着一堆仓库(父目录场景)时,子仓库列表要直接可勾选,
|
|
1182
|
+
// 否则用户得先找到一个开关才知道「还能一起看」。只有单个仓库时它不产生任何多余 UI。
|
|
1183
|
+
const [includeSubdirs, setIncludeSubdirs] = useState(true);
|
|
1184
|
+
const [repos, setRepos] = useState([]);
|
|
1185
|
+
// 勾选参与历史查询的仓库集合:当前仓库总是包含在内
|
|
1186
|
+
// 勾选参与历史查询的仓库集合。
|
|
1187
|
+
// 注意:初值必须是空数组而不是 [repo]——repo 此刻还没初始化,
|
|
1188
|
+
// 真正参与查询的集合在下面 activeRepos 里派生。
|
|
1189
|
+
const [selectedRepos, setSelectedRepos] = useState([]);
|
|
1190
|
+
// 全选 / 取消全选:paths 为空或只有当前仓库时即「取消全选」
|
|
1191
|
+
const setAllRepos = (paths) => {
|
|
1192
|
+
const list = Array.isArray(paths) ? paths.filter(Boolean) : [];
|
|
1193
|
+
setSelectedRepos(list.length > 0 ? list : [repo]);
|
|
1194
|
+
};
|
|
1195
|
+
// 勾选/取消勾选参与查询的仓库。
|
|
1196
|
+
// 允许取消当前仓库——用户就是要去掉它只看子仓库;
|
|
1197
|
+
// 但至少要留一个,全空就没东西可查了。
|
|
1198
|
+
const toggleRepo = (path) => setSelectedRepos((prev) => toggleRepoSelection(prev, path, repo));
|
|
1199
|
+
const [repo, setRepo] = useState(props && props.repo ? props.repo : "");
|
|
1200
|
+
const [refs, setRefs] = useState(null);
|
|
1201
|
+
const [status, setStatus] = useState(null);
|
|
1202
|
+
const [tab, setTab] = useState("history");
|
|
1203
|
+
const [loading, setLoading] = useState(false);
|
|
1204
|
+
const [error, setError] = useState("");
|
|
1205
|
+
const [note, setError2] = useState("");
|
|
1206
|
+
const booted = useRef(false);
|
|
1207
|
+
|
|
1208
|
+
// 首次进入:有 props.repo 就直接用;否则取**本会话**的工作目录
|
|
1209
|
+
// (不弹选择框,服务器上也能用)。宿主进程 cwd 只作为最后的兜底。
|
|
1210
|
+
useEffect(() => {
|
|
1211
|
+
if (booted.current) return;
|
|
1212
|
+
booted.current = true;
|
|
1213
|
+
let stopped = false;
|
|
1214
|
+
rpc("info").then((info) => {
|
|
1215
|
+
if (stopped) return;
|
|
1216
|
+
const given = props && props.repo;
|
|
1217
|
+
const sessionDir = currentSessionDir(ctx, props && props.sessionId);
|
|
1218
|
+
// 兜底到宿主进程 cwd 时必须说明,否则用户会以为「路径被写死了」:
|
|
1219
|
+
// 面板默认应该跟着会话走,落到进程目录只说明没读到会话目录。
|
|
1220
|
+
const start = given || sessionDir || (info && info.defaultDir) || "";
|
|
1221
|
+
setDir(start);
|
|
1222
|
+
// 调用方已经指定了仓库路径:直接采用,不必再绕一次 resolve。
|
|
1223
|
+
// 少了这步的话,repo 要等 resolve 回来才有值,
|
|
1224
|
+
// 历史页会先空一屏,resolve 失败时更是彻底空白。
|
|
1225
|
+
if (given) setRepo(given);
|
|
1226
|
+
if (!given && !sessionDir) {
|
|
1227
|
+
setError("没能读到当前会话的工作目录,先显示宿主进程的目录。可以在上方手动填写仓库路径,或点「选择目录…」。");
|
|
1228
|
+
}
|
|
1229
|
+
if (info && info.available === false) {
|
|
1230
|
+
setError("本机没有可用的 git 命令(PATH 里找不到 git),无法读取提交记录。");
|
|
1231
|
+
}
|
|
1232
|
+
}).catch((e) => { if (!stopped) setError((e && e.message) || String(e)); });
|
|
1233
|
+
return () => { stopped = true; };
|
|
1234
|
+
}, []);
|
|
1235
|
+
|
|
1236
|
+
// 目录 → 仓库:先尝试把目录本身解析成仓库(右键入口的路径可能就在仓库里)
|
|
1237
|
+
/**
|
|
1238
|
+
* 把输入路径解析成仓库。
|
|
1239
|
+
*
|
|
1240
|
+
* 关键行为:目录**本身不是仓库**时不直接报错,而是往下找子目录仓库——
|
|
1241
|
+
* 用户填 /Users/me/develop(一个装着多个仓库的父目录)是常见用法,
|
|
1242
|
+
* 以前这里直接抛「该路径不在任何 Git 仓库内」,等于把最自然的用法堵死了。
|
|
1243
|
+
* 只有「自己不是仓库、下面也没有仓库」才报错。
|
|
1244
|
+
*/
|
|
1245
|
+
const resolveAndSet = useCallback(async (target) => {
|
|
1246
|
+
if (!target) return;
|
|
1247
|
+
setLoading(true);
|
|
1248
|
+
setError("");
|
|
1249
|
+
try {
|
|
1250
|
+
const resolved = await rpc("resolve", { path: target });
|
|
1251
|
+
setRepo(resolved.repo);
|
|
1252
|
+
if (!props || !props.repo) setDir(resolved.repo);
|
|
1253
|
+
} catch (e) {
|
|
1254
|
+
// 自己不是仓库:扫一遍子目录,有仓库就用第一个,没有才报错
|
|
1255
|
+
try {
|
|
1256
|
+
const scanned = await rpc("repos", { dir: target, includeSubdirs: true, depth: 3 });
|
|
1257
|
+
const list = (scanned && scanned.repos) || [];
|
|
1258
|
+
setRepos(list);
|
|
1259
|
+
if (list.length > 0) {
|
|
1260
|
+
const first = list[0];
|
|
1261
|
+
setRepo(first.path);
|
|
1262
|
+
if (!props || !props.repo) setDir(first.path);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
} catch {
|
|
1266
|
+
// 扫描也失败:往下走,报原始错误
|
|
1267
|
+
}
|
|
1268
|
+
setRepos([]);
|
|
1269
|
+
setRepo("");
|
|
1270
|
+
setError((e && e.message) || String(e));
|
|
1271
|
+
} finally {
|
|
1272
|
+
setLoading(false);
|
|
1273
|
+
}
|
|
1274
|
+
}, []);
|
|
1275
|
+
|
|
1276
|
+
// 目录变化后解析仓库(防抖;输入到一半不刷)
|
|
1277
|
+
useEffect(() => {
|
|
1278
|
+
if (!dir) return;
|
|
1279
|
+
let stopped = false;
|
|
1280
|
+
const timer = setTimeout(() => { if (!stopped) resolveAndSet(dir); }, 200);
|
|
1281
|
+
return () => { stopped = true; clearTimeout(timer); };
|
|
1282
|
+
}, [dir, resolveAndSet]);
|
|
1283
|
+
|
|
1284
|
+
// 「包含子目录仓库」时才扫描多仓库
|
|
1285
|
+
const scanRepos = useCallback(async (target) => {
|
|
1286
|
+
if (!target || !includeSubdirs) { setRepos([]); return; }
|
|
1287
|
+
try {
|
|
1288
|
+
const data = await rpc("repos", { dir: target, includeSubdirs: true, depth: 3 });
|
|
1289
|
+
setRepos((data && data.repos) || []);
|
|
1290
|
+
} catch { setRepos([]); }
|
|
1291
|
+
}, [includeSubdirs]);
|
|
1292
|
+
|
|
1293
|
+
useEffect(() => { scanRepos(dir); }, [dir, scanRepos]);
|
|
1294
|
+
|
|
1295
|
+
// 仓库变化后拉引用与工作区状态
|
|
1296
|
+
const refreshRepo = useCallback(async () => {
|
|
1297
|
+
if (!repo) { setRefs(null); setStatus(null); return; }
|
|
1298
|
+
try {
|
|
1299
|
+
const [r, s] = await Promise.all([rpc("refs", { repo }), rpc("status", { repo })]);
|
|
1300
|
+
setRefs(r);
|
|
1301
|
+
setStatus(s);
|
|
1302
|
+
} catch (e) {
|
|
1303
|
+
setError((e && e.message) || String(e));
|
|
1304
|
+
setRefs(null);
|
|
1305
|
+
setStatus(null);
|
|
1306
|
+
}
|
|
1307
|
+
}, [repo]);
|
|
1308
|
+
|
|
1309
|
+
useEffect(() => { refreshRepo(); }, [refreshRepo]);
|
|
1310
|
+
|
|
1311
|
+
// 目录选择:优先用内置目录浏览器(服务器也能用),没有该能力时退回原生对话框
|
|
1312
|
+
const [picking, setPicking] = useState(false);
|
|
1313
|
+
const canBrowse = (() => {
|
|
1314
|
+
try {
|
|
1315
|
+
const uiw = ctx && typeof ctx.get === "function" ? ctx.get("uiWorkspace") : null;
|
|
1316
|
+
return !!(uiw && typeof uiw.listDirectory === "function");
|
|
1317
|
+
} catch {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
})();
|
|
1321
|
+
const pick = async () => {
|
|
1322
|
+
if (canBrowse) { setPicking(true); return; }
|
|
1323
|
+
// 没有目录浏览能力(旧宿主 / 极简环境):退回原生对话框
|
|
1324
|
+
const chosen = await pickDirectory(ctx);
|
|
1325
|
+
if (chosen) setDir(chosen);
|
|
1326
|
+
};
|
|
1327
|
+
|
|
1328
|
+
const branch = (refs && refs.branch) || "";
|
|
1329
|
+
const ahead = (status && status.ahead) || 0;
|
|
1330
|
+
const behind = (status && status.behind) || 0;
|
|
1331
|
+
const dirty = status ? (status.stagedCount + status.unstagedCount + status.untrackedCount) : 0;
|
|
1332
|
+
const compact = props && props.compact === true;
|
|
1333
|
+
|
|
1334
|
+
return (
|
|
1335
|
+
<div className={"dkg" + (compact ? " dkg-compact" : "")}>
|
|
1336
|
+
{/* 仓库条:手填路径 + 目录浏览(内置浏览器不依赖系统对话框,服务器也能用) */}
|
|
1337
|
+
<div className="dkg-bar">
|
|
1338
|
+
<input className="dkg-input" value={dir} placeholder="仓库或父目录的绝对路径" spellCheck={false} onChange={(e) => setDir(e.target.value)} />
|
|
1339
|
+
<button type="button" className="dkg-btn" onClick={() => resolveAndSet(dir)} disabled={!dir || loading}>{loading ? "…" : "打开"}</button>
|
|
1340
|
+
<button type="button" className="dkg-btn" onClick={pick} title={canBrowse ? "浏览目录(服务器可用)" : "打开系统目录对话框"}>
|
|
1341
|
+
{picking ? "浏览中…" : "选择目录…"}
|
|
1342
|
+
</button>
|
|
1343
|
+
</div>
|
|
1344
|
+
|
|
1345
|
+
{picking ? (
|
|
1346
|
+
<DirBrowser
|
|
1347
|
+
ctx={ctx}
|
|
1348
|
+
startPath={dir}
|
|
1349
|
+
onClose={() => setPicking(false)}
|
|
1350
|
+
onPick={(chosen) => { setPicking(false); setDir(chosen); resolveAndSet(chosen); }}
|
|
1351
|
+
/>
|
|
1352
|
+
) : null}
|
|
1353
|
+
|
|
1354
|
+
{!compact ? (
|
|
1355
|
+
<div className="dkg-bar">
|
|
1356
|
+
<label className="dkg-check">
|
|
1357
|
+
<input type="checkbox" checked={includeSubdirs} onChange={(e) => setIncludeSubdirs(e.target.checked)} />
|
|
1358
|
+
<span>包含子目录仓库</span>
|
|
1359
|
+
</label>
|
|
1360
|
+
<span className="dkg-hint">{loading ? "正在解析…" : (repos.length > 0 ? (repos.length + " 个仓库") : "")}</span>
|
|
1361
|
+
</div>
|
|
1362
|
+
) : null}
|
|
1363
|
+
|
|
1364
|
+
{error ? <div className="dkg-error">{error}</div> : null}
|
|
1365
|
+
|
|
1366
|
+
{repo ? (
|
|
1367
|
+
<>
|
|
1368
|
+
{/* 当前仓库 + 页签 */}
|
|
1369
|
+
<div className="dkg-tabbar">
|
|
1370
|
+
<span className="dkg-repo-name" title={repo}>{repo}</span>
|
|
1371
|
+
<span className="dkg-badge">{branch || "(分离 HEAD)"}</span>
|
|
1372
|
+
{behind > 0 ? <span className="dkg-badge warn">落后 {behind}</span> : null}
|
|
1373
|
+
{ahead > 0 ? <span className="dkg-badge ok">待推送 {ahead}</span> : null}
|
|
1374
|
+
{dirty > 0 ? <span className="dkg-badge">{dirty} 处改动</span> : null}
|
|
1375
|
+
<div className="dkg-tabs">
|
|
1376
|
+
<button type="button" className={"dkg-tab" + (tab === "history" ? " on" : "")} onClick={() => setTab("history")}>历史</button>
|
|
1377
|
+
<button type="button" className={"dkg-tab" + (tab === "worktree" ? " on" : "")} onClick={() => setTab("worktree")}>工作区{dirty > 0 ? " (" + dirty + ")" : ""}</button>
|
|
1378
|
+
</div>
|
|
1379
|
+
<button type="button" className="dkg-btn" onClick={refreshRepo}>刷新</button>
|
|
1380
|
+
</div>
|
|
1381
|
+
|
|
1382
|
+
{tab === "history"
|
|
1383
|
+
? <HistoryPane
|
|
1384
|
+
repo={repo}
|
|
1385
|
+
repos={repos}
|
|
1386
|
+
// 选中集合就是查询集合:取消当前仓库时它真的不查了
|
|
1387
|
+
selectedRepos={selectedRepos.length > 0 ? selectedRepos : [repo]}
|
|
1388
|
+
currentRepo={repo}
|
|
1389
|
+
onToggleRepo={toggleRepo}
|
|
1390
|
+
onOnlyCurrent={() => setSelectedRepos([repo])}
|
|
1391
|
+
onSelectAll={setAllRepos}
|
|
1392
|
+
refs={refs}
|
|
1393
|
+
initialPath={props && props.initialPath}
|
|
1394
|
+
/>
|
|
1395
|
+
: <WorktreePane repo={repo} status={status} onRefresh={refreshRepo} />}
|
|
1396
|
+
</>
|
|
1397
|
+
) : (
|
|
1398
|
+
<div className="dkg-note">正在解析目录所在的仓库…(也可以在上面填一个绝对路径后点「打开」)</div>
|
|
1399
|
+
)}
|
|
1400
|
+
</div>
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
// ---------- 抽屉页签的对外入口 ----------
|
|
1405
|
+
/** 页签类型 id:注册 sidebarRightTabs 与 tab body/title 都用它。 */
|
|
1406
|
+
export const GIT_TAB_ID = "dsh-dock.git";
|
|
1407
|
+
/** 页签类型 kind:openTab("dsh-dock-git") 用它。 */
|
|
1408
|
+
export const GIT_TAB_KIND = "dsh-dock-git";
|
|
1409
|
+
/** 右键菜单图标的插槽键:菜单项的 icon.key 只是索引,图标本身要注册到 contextMenu.icon。 */
|
|
1410
|
+
export const GIT_ICON_KEY = "dsh-dock.git";
|
|
1411
|
+
/** 面板名:抽屉页签标题与引导卡片共用。 */
|
|
1412
|
+
export const GIT_PANEL_NAME = "Git仓库操作";
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* 打开 Git 页签(抽屉里)。
|
|
1416
|
+
* @param {object} ctx 客户端 context
|
|
1417
|
+
* @param {{ repo?: string, path?: string, sessionId?: string }} target 仓库或路径
|
|
1418
|
+
*/
|
|
1419
|
+
export function openGitTab(ctx, target) {
|
|
1420
|
+
if (!ctx) return false;
|
|
1421
|
+
const sidebar = typeof ctx.get === "function" ? ctx.get("sidebarRight") : ctx.sidebarRight;
|
|
1422
|
+
if (!sidebar || typeof sidebar.openTab !== "function") return false;
|
|
1423
|
+
const params = {};
|
|
1424
|
+
if (target && target.repo) params.repo = target.repo;
|
|
1425
|
+
if (target && target.path) params.path = target.path;
|
|
1426
|
+
try {
|
|
1427
|
+
// openTabIn 能指定会话;没有就退回 openTab(当前会话)
|
|
1428
|
+
if (target && target.sessionId && typeof sidebar.openTabIn === "function") {
|
|
1429
|
+
sidebar.openTabIn(target.sessionId, GIT_TAB_KIND, { params });
|
|
1430
|
+
} else {
|
|
1431
|
+
sidebar.openTab(GIT_TAB_KIND, { params });
|
|
1432
|
+
}
|
|
1433
|
+
return true;
|
|
1434
|
+
} catch {
|
|
1435
|
+
return false;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* 抽屉页签的正文:从 navigation.params 读 repo / path,交给 GitView。
|
|
1441
|
+
* 用 PropsRuntime 的 useTabInfo 拿参数(与官方页签写法一致)。
|
|
1442
|
+
*/
|
|
1443
|
+
/**
|
|
1444
|
+
* 装配时捕获的客户端 context。
|
|
1445
|
+
*
|
|
1446
|
+
* 页签正文的 props 里**没有 ctx**(slot 的 GlobalStandardProps 是空接口),
|
|
1447
|
+
* 但视图要它去读当前会话目录。所以 installClient 时把 ctx 存下来,正文从这里取。
|
|
1448
|
+
*/
|
|
1449
|
+
let dockCtx = null;
|
|
1450
|
+
|
|
1451
|
+
export function GitTabBody(props) {
|
|
1452
|
+
const tab = props.useTabInfo();
|
|
1453
|
+
const params = (tab && tab.tab && tab.tab.navigation && tab.tab.navigation.params) || {};
|
|
1454
|
+
const repo = typeof params.repo === "string" ? params.repo : "";
|
|
1455
|
+
const path = typeof params.path === "string" ? params.path : "";
|
|
1456
|
+
const [target, setTarget] = useState({ repo, path });
|
|
1457
|
+
|
|
1458
|
+
// 同一页签换参数(右键了另一个仓库)时重新定位
|
|
1459
|
+
useEffect(() => {
|
|
1460
|
+
setTarget({ repo, path });
|
|
1461
|
+
}, [repo, path]);
|
|
1462
|
+
|
|
1463
|
+
// ctx 优先用 props 里透传的(测试/独立使用),否则用装配时捕获的
|
|
1464
|
+
const ctx = props.ctx || dockCtx;
|
|
1465
|
+
// 作用域是 session 的页签,props 里直接有 sessionId——用它查目录,
|
|
1466
|
+
// 不能靠「界面上当前那个会话」,否则从不同会话打开会显示同一个目录。
|
|
1467
|
+
return <GitView ctx={ctx} repo={target.repo} initialPath={target.path} sessionId={props.sessionId} compact />;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/** 页签标题:显示仓库名,没有就显示「Git」。 */
|
|
1471
|
+
export function GitTabTitle(props) {
|
|
1472
|
+
const tab = props.useTabInfo();
|
|
1473
|
+
const params = (tab && tab.tab && tab.tab.navigation && tab.tab.navigation.params) || {};
|
|
1474
|
+
const repo = typeof params.repo === "string" ? params.repo : "";
|
|
1475
|
+
const name = repo ? repo.split("/").filter(Boolean).pop() : "";
|
|
1476
|
+
// 有仓库名就显示仓库名(页签上更有辨识度),没有就显示面板名
|
|
1477
|
+
return <span title={repo}>{name || GIT_PANEL_NAME}</span>;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// ---------- 样式(dkg- 前缀;全部走主题变量,暗/亮色自适应) ----------
|
|
1481
|
+
export const css = [
|
|
1482
|
+
".dkg{display:flex;flex-direction:column;gap:8px;min-height:0;height:100%;}",
|
|
1483
|
+
".dkg.dkg-compact{gap:6px;padding:0;}",
|
|
1484
|
+
".dkg-bar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;}",
|
|
1485
|
+
".dkg-input{flex:1;min-width:120px;box-sizing:border-box;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:4px 8px;}",
|
|
1486
|
+
".dkg-input.sm{min-width:70px;flex:0 1 100px;}",
|
|
1487
|
+
".dkg-input:focus{outline:none;border-color:var(--dk-accent);}",
|
|
1488
|
+
".dkg-select{flex:none;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:4px 6px;}",
|
|
1489
|
+
".dkg-btn{flex:none;cursor:pointer;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-primary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:3px 9px;}",
|
|
1490
|
+
".dkg-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1491
|
+
".dkg-btn:disabled{opacity:.45;cursor:default;}",
|
|
1492
|
+
".dkg-btn.primary{border-color:var(--dk-accent);color:var(--dk-accent);}",
|
|
1493
|
+
".dkg-btn.primary:hover:not(:disabled){background:var(--dk-accent-soft);}",
|
|
1494
|
+
".dkg-link{cursor:pointer;font-family:inherit;font-size:11px;color:var(--dk-accent);background:transparent;border:0;padding:0;}",
|
|
1495
|
+
".dkg-link:disabled{opacity:.5;cursor:default;}",
|
|
1496
|
+
".dkg-check{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--dsw-alias-label-secondary);cursor:pointer;}",
|
|
1497
|
+
".dkg-hint{font-size:11px;color:var(--dsw-alias-label-tertiary);}",
|
|
1498
|
+
".dkg-note{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.6;}",
|
|
1499
|
+
".dkg-error{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent);color:var(--dsw-alias-state-error-primary);border-radius:8px;padding:6px 10px;font-size:12px;line-height:1.6;word-break:break-all;}",
|
|
1500
|
+
".dkg-ok{border:1px solid color-mix(in srgb,var(--dsw-alias-state-success-primary) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 8%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:8px;padding:6px 10px;font-size:12px;line-height:1.6;word-break:break-all;}",
|
|
1501
|
+
|
|
1502
|
+
// 子仓库多选下拉
|
|
1503
|
+
".dkg-repopick{position:relative;flex:0 1 auto;}",
|
|
1504
|
+
".dkg-repopick-btn{display:flex;align-items:center;gap:4px;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 8px;white-space:nowrap;}",
|
|
1505
|
+
".dkg-repopick-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);}",
|
|
1506
|
+
".dkg-repopick-btn.on{border-color:var(--dk-accent);color:var(--dk-accent);}",
|
|
1507
|
+
".dkg-caret{font-size:9px;opacity:.8;}",
|
|
1508
|
+
".dkg-repopick-menu{position:absolute;top:calc(100% + 4px);right:0;z-index:20;min-width:260px;max-width:min(420px,90vw);max-height:300px;overflow:auto;display:flex;flex-direction:column;gap:1px;padding:4px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.28);}",
|
|
1509
|
+
".dkg-repopick-row{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid transparent;border-radius:5px;padding:4px 6px;min-width:0;}",
|
|
1510
|
+
".dkg-repopick-row:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1511
|
+
".dkg-repopick-row.on{color:var(--dsw-alias-label-primary);}",
|
|
1512
|
+
".dkg-repopick-all{display:flex;gap:4px;flex:none;border-bottom:1px solid var(--dsw-alias-border-l1);padding:2px 2px 5px;margin-bottom:2px;}",
|
|
1513
|
+
".dkg-repopick-allbtn{flex:1;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dk-accent);background:transparent;border:1px solid var(--dsw-alias-border-l1);border-radius:5px;padding:3px 6px;}",
|
|
1514
|
+
".dkg-repopick-allbtn:hover{background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dk-accent);}",
|
|
1515
|
+
".dkg-repopick-foot{flex:none;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dk-accent);background:transparent;border:0;border-top:1px solid var(--dsw-alias-border-l1);padding:5px 6px;margin-top:2px;text-align:left;}",
|
|
1516
|
+
".dkg-repopick-foot:hover{text-decoration:underline;}",
|
|
1517
|
+
".dkg-tabbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--dsw-alias-border-l1);padding-bottom:5px;}",
|
|
1518
|
+
".dkg-repo-name{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary);max-width:42%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;direction:rtl;text-align:left;}",
|
|
1519
|
+
".dkg-badge{font-size:10px;border:1px solid var(--dsw-alias-border-l2);border-radius:999px;padding:0 8px;color:var(--dsw-alias-label-tertiary);}",
|
|
1520
|
+
".dkg-badge.ok{color:var(--dsw-alias-state-success-primary);border-color:currentColor;}",
|
|
1521
|
+
".dkg-badge.warn{color:var(--dk-warn);border-color:currentColor;}",
|
|
1522
|
+
".dkg-tabs{display:flex;gap:4px;margin-left:auto;}",
|
|
1523
|
+
".dkg-tab{cursor:pointer;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid transparent;border-radius:8px;padding:2px 9px;}",
|
|
1524
|
+
".dkg-tab.on{color:var(--dk-accent);border-color:currentColor;background:var(--dk-accent-soft);}",
|
|
1525
|
+
// 抽屉里三栏改为上下堆叠,宽度不够时更可用
|
|
1526
|
+
".dkg-body{display:flex;gap:6px;min-height:0;flex:1;overflow:hidden;}",
|
|
1527
|
+
".dkg-compact .dkg-body{flex-direction:column;}",
|
|
1528
|
+
".dkg-side{flex:none;width:150px;overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);padding:5px;display:flex;flex-direction:column;gap:1px;}",
|
|
1529
|
+
".dkg-compact .dkg-side{width:auto;max-height:110px;flex-direction:row;flex-wrap:wrap;align-items:center;}",
|
|
1530
|
+
".dkg-compact .dkg-side-group{flex-direction:row;flex-wrap:wrap;margin-top:0;}",
|
|
1531
|
+
".dkg-compact .dkg-side-title{display:none;}",
|
|
1532
|
+
".dkg-compact .dkg-side-item{width:auto;flex:none;max-width:180px;}",
|
|
1533
|
+
".dkg-side-group{display:flex;flex-direction:column;gap:1px;margin-top:4px;}",
|
|
1534
|
+
".dkg-side-title{font-size:10px;text-transform:uppercase;letter-spacing:.04em;color:var(--dsw-alias-label-tertiary);padding:4px 6px 2px;}",
|
|
1535
|
+
".dkg-side-item{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid transparent;border-radius:6px;padding:2px 6px;min-width:0;}",
|
|
1536
|
+
".dkg-side-item:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1537
|
+
".dkg-side-item.on{color:var(--dk-accent);background:var(--dk-accent-soft);border-color:color-mix(in srgb,var(--dk-accent) 35%,transparent);}",
|
|
1538
|
+
".dkg-branch-icon{flex:none;font-size:10px;color:var(--dsw-alias-label-tertiary);}",
|
|
1539
|
+
".dkg-branch-icon.remote{color:var(--dsw-alias-label-secondary);}",
|
|
1540
|
+
".dkg-branch-icon.tag{color:var(--dk-warn);}",
|
|
1541
|
+
".dkg-ellipsis{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1542
|
+
".dkg-mid{flex:1 1 40%;min-width:0;min-height:0;display:flex;flex-direction:column;gap:5px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);padding:6px;}",
|
|
1543
|
+
".dkg-compact .dkg-mid{flex:1 1 auto;min-height:80px;overflow:hidden;}",
|
|
1544
|
+
".dkg-filters{display:flex;flex-direction:column;gap:5px;}",
|
|
1545
|
+
".dkg-filter-row{display:flex;gap:5px;flex-wrap:wrap;align-items:center;}",
|
|
1546
|
+
".dkg-filter-tag{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--dk-accent);}",
|
|
1547
|
+
".dkg-commits{flex:1;min-height:60px;overflow:auto;display:flex;flex-direction:column;gap:1px;}",
|
|
1548
|
+
".dkg-commit{display:grid;grid-template-columns:12px minmax(0,1fr) auto;align-items:center;gap:6px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-primary);background:transparent;border:1px solid transparent;border-radius:6px;padding:3px 5px;}",
|
|
1549
|
+
".dkg-commit:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1550
|
+
".dkg-commit.on{background:var(--dk-accent-soft);border-color:color-mix(in srgb,var(--dk-accent) 35%,transparent);}",
|
|
1551
|
+
".dkg-graph{display:flex;align-items:center;justify-content:center;position:relative;height:100%;}",
|
|
1552
|
+
".dkg-graph::before{content:'';position:absolute;top:-4px;bottom:-4px;width:1px;background:var(--dsw-alias-border-l2);}",
|
|
1553
|
+
".dkg-graph-dot{position:relative;width:6px;height:6px;border-radius:50%;background:var(--dk-accent);box-shadow:0 0 0 2px var(--dsw-alias-bg-layer-1);}",
|
|
1554
|
+
".dkg-commit-subject{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1555
|
+
".dkg-commit-refs{display:none;}",
|
|
1556
|
+
".dkg-compact .dkg-commit-refs{display:none;}",
|
|
1557
|
+
".dkg-commit-meta-line{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--dsw-alias-label-tertiary);overflow:hidden;}",
|
|
1558
|
+
".dkg-ref{font-size:10px;border:1px solid var(--dsw-alias-border-l2);border-radius:999px;padding:0 6px;color:var(--dsw-alias-label-secondary);}",
|
|
1559
|
+
".dkg-ref.remote{color:var(--dsw-alias-label-tertiary);}",
|
|
1560
|
+
".dkg-commit-author{font-size:11px;color:var(--dsw-alias-label-secondary);flex:none;max-width:80px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1561
|
+
".dkg-commit-time{font-size:11px;color:var(--dsw-alias-label-tertiary);flex:none;min-width:58px;text-align:right;}",
|
|
1562
|
+
".dkg-detail{flex:1 1 46%;min-width:0;min-height:0;overflow:hidden;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);padding:8px;display:flex;flex-direction:column;gap:4px;}",
|
|
1563
|
+
".dkg-compact .dkg-detail{flex:none;height:var(--dkg-main-pct,50%);max-height:none;min-height:80px;}",
|
|
1564
|
+
|
|
1565
|
+
// 拖动分隔条:只在上下堆叠(抽屉)时占位,宽屏三栏下隐藏
|
|
1566
|
+
// 列表↔详情 的分隔条:只在抽屉(上下堆叠)时出现;宽屏三栏时详情在右侧,不需要它
|
|
1567
|
+
".dkg-splitter-main{display:none;}",
|
|
1568
|
+
".dkg-compact .dkg-splitter-main{display:block;flex:none;}",
|
|
1569
|
+
// 详情内部(差异↔说明)的分隔条:任何布局都显示
|
|
1570
|
+
|
|
1571
|
+
// 拖动期间:全局光标改成上下调整,并禁止选中文字
|
|
1572
|
+
// (不禁止的话拖快了会连带选中面板里的文本,出现蓝色选区,视觉上就是「闪」)
|
|
1573
|
+
"body.dkg-resizing{cursor:row-resize !important;user-select:none !important;}",
|
|
1574
|
+
"body.dkg-resizing *{cursor:row-resize !important;user-select:none !important;}",
|
|
1575
|
+
// 拖动期间禁用过渡/动画:任何过渡都会让高度变化「追」不上指针,看起来像抖
|
|
1576
|
+
"body.dkg-resizing *{transition:none !important;animation:none !important;}",
|
|
1577
|
+
".dkg-splitter{will-change:transform;}",
|
|
1578
|
+
".dkg-splitter-slot{display:block;flex:none;}",
|
|
1579
|
+
".dkg-splitter{display:flex;align-items:center;justify-content:center;height:10px;cursor:row-resize;border-radius:4px;background:transparent;touch-action:none;}",
|
|
1580
|
+
".dkg-splitter:hover,.dkg-splitter.dragging{background:var(--dk-accent-soft);}",
|
|
1581
|
+
".dkg-splitter:focus-visible{outline:2px solid var(--dk-accent);outline-offset:-2px;}",
|
|
1582
|
+
".dkg-splitter-grip{display:block;width:36px;height:2px;border-radius:1px;background:var(--dsw-alias-border-l2);}",
|
|
1583
|
+
".dkg-splitter:hover .dkg-splitter-grip,.dkg-splitter.dragging .dkg-splitter-grip{background:var(--dk-accent);}",
|
|
1584
|
+
|
|
1585
|
+
// ---- GoLand 风格提交表格 ----
|
|
1586
|
+
".dkg-toolbar{display:flex;align-items:center;gap:4px;flex-wrap:wrap;flex:none;}",
|
|
1587
|
+
".dkg-toolbar .dkg-input{flex:1 1 120px;min-width:80px;}",
|
|
1588
|
+
".dkg-toolbar .dkg-input.sm{flex:0 1 84px;min-width:60px;}",
|
|
1589
|
+
".dkg-icon-btn{flex:none;cursor:pointer;font-family:inherit;font-size:13px;line-height:1;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l1);border-radius:6px;padding:4px 7px;}",
|
|
1590
|
+
".dkg-icon-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);}",
|
|
1591
|
+
".dkg-icon-btn:disabled{opacity:.5;cursor:default;}",
|
|
1592
|
+
".dkg-colpick{position:relative;flex:none;}",
|
|
1593
|
+
".dkg-colpick-menu{position:absolute;top:calc(100% + 4px);right:0;z-index:20;min-width:150px;display:flex;flex-direction:column;gap:1px;padding:4px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.28);}",
|
|
1594
|
+
".dkg-colpick-row{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid transparent;border-radius:5px;padding:4px 6px;}",
|
|
1595
|
+
".dkg-colpick-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1596
|
+
".dkg-colpick-row.on{color:var(--dsw-alias-label-primary);}",
|
|
1597
|
+
".dkg-colpick-row.locked{opacity:.55;cursor:default;}",
|
|
1598
|
+
|
|
1599
|
+
// 表头与行共用同一套列宽:图 14px / 说明 1fr / 引用 88px / 作者 96px / 日期 64px
|
|
1600
|
+
".dkg-thead,.dkg-tr{display:grid;grid-template-columns:var(--dkg-cols,12px minmax(0,1fr) 64px 78px 56px);align-items:center;gap:5px;}",
|
|
1601
|
+
".dkg-thead{flex:none;padding:3px 6px;border-bottom:1px solid var(--dsw-alias-border-l1);font-size:11px;color:var(--dsw-alias-label-tertiary);user-select:none;}",
|
|
1602
|
+
".dkg-th.date,.dkg-td.date{text-align:right;}",
|
|
1603
|
+
".dkg-th.refs,.dkg-td.refs{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1604
|
+
".dkg-tr{cursor:default;padding:3px 6px;border-radius:4px;font-size:12px;color:var(--dsw-alias-label-primary);border:1px solid transparent;}",
|
|
1605
|
+
".dkg-tr:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1606
|
+
".dkg-tr.on{background:var(--dk-accent-soft);border-color:var(--dk-accent);}",
|
|
1607
|
+
".dkg-td{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1608
|
+
".dkg-td.subject{display:flex;align-items:center;gap:5px;min-width:0;}",
|
|
1609
|
+
".dkg-td.author{font-size:11px;color:var(--dsw-alias-label-secondary);}",
|
|
1610
|
+
".dkg-td.date{font-size:11px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;}",
|
|
1611
|
+
".dkg-td.datetime{font-size:11px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;white-space:nowrap;}",
|
|
1612
|
+
".dkg-th.datetime{white-space:nowrap;}",
|
|
1613
|
+
// 抽屉很窄时先牺牲「引用」列:它多数行是空的,说明与时间更要紧
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
".dkg-muted{color:var(--dsw-alias-label-tertiary);}",
|
|
1617
|
+
".dkg-repo-tag{flex:none;font-size:10px;padding:0 4px;border-radius:3px;background:var(--dk-accent-soft);color:var(--dk-accent);white-space:nowrap;}",
|
|
1618
|
+
".dkg-chip-check{flex:none;font-size:11px;line-height:1;}",
|
|
1619
|
+
".dkg-toolbar input[type=date]{flex:0 1 120px;min-width:100px;}",
|
|
1620
|
+
|
|
1621
|
+
// 分支图:一条竖线 + 一个点,像 IDE 的 Log 图列
|
|
1622
|
+
".dkg-td.graph{position:relative;display:flex;align-items:center;justify-content:center;height:100%;}",
|
|
1623
|
+
".dkg-graph-line{position:absolute;top:0;bottom:0;left:50%;width:1px;background:var(--dsw-alias-border-l2);transform:translateX(-50%);}",
|
|
1624
|
+
".dkg-graph-dot{position:relative;width:6px;height:6px;border-radius:50%;background:var(--dk-accent);box-shadow:0 0 0 2px var(--dsw-alias-bg-layer-1);}",
|
|
1625
|
+
|
|
1626
|
+
// 右栏详情:上下分区(上方差异 / 下方说明),可拖动
|
|
1627
|
+
".dkg-detail-diff{flex:1 1 0;min-height:60px;overflow:auto;display:flex;flex-direction:column;gap:6px;}",
|
|
1628
|
+
".dkg-detail-msgbox{flex:0 0 auto;overflow:auto;display:flex;flex-direction:column;gap:5px;border-top:1px solid var(--dsw-alias-border-l1);padding-top:6px;height:var(--dkg-detail-pct,50%);}",
|
|
1629
|
+
".dkg-detail .dkg-splitter-slot{display:block;flex:none;}",
|
|
1630
|
+
".dkg-detail-head{display:flex;flex-direction:column;gap:5px;border-bottom:1px solid var(--dsw-alias-border-l1);padding-bottom:6px;}",
|
|
1631
|
+
".dkg-detail-subject{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary);word-break:break-word;}",
|
|
1632
|
+
".dkg-detail-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:11px;color:var(--dsw-alias-label-tertiary);word-break:break-all;}",
|
|
1633
|
+
".dkg-sha{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--dk-accent);}",
|
|
1634
|
+
".dkg-detail-msg{margin:0;font-size:11px;line-height:1.55;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;word-break:break-word;max-height:120px;overflow:auto;background:var(--dsw-alias-bg-layer-2);border-radius:6px;padding:6px 8px;}",
|
|
1635
|
+
".dkg-detail-split{display:flex;gap:6px;min-height:0;}",
|
|
1636
|
+
".dkg-compact .dkg-detail-split{flex-direction:column;}",
|
|
1637
|
+
".dkg-diffs{flex:1;min-width:0;display:flex;flex-direction:column;gap:5px;}",
|
|
1638
|
+
".dkg-tree{flex:none;width:150px;max-height:280px;overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:6px;padding:3px;display:flex;flex-direction:column;gap:1px;}",
|
|
1639
|
+
".dkg-compact .dkg-tree{width:auto;max-height:110px;flex-direction:row;flex-wrap:wrap;}",
|
|
1640
|
+
".dkg-tree-row{display:flex;align-items:center;gap:5px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dsw-alias-label-secondary);background:transparent;border:0;border-radius:5px;padding:1px 4px;min-width:0;}",
|
|
1641
|
+
".dkg-tree-row:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1642
|
+
".dkg-tree-row.file.on{background:var(--dk-accent-soft);color:var(--dk-accent);}",
|
|
1643
|
+
".dkg-tree-row.dir{color:var(--dsw-alias-label-tertiary);}",
|
|
1644
|
+
".dkg-tree-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1645
|
+
".dkg-file{border:1px solid var(--dsw-alias-border-l1);border-radius:6px;overflow:hidden;background:var(--dsw-alias-bg-layer-2);}",
|
|
1646
|
+
".dkg-file-head{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:11px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:0;padding:4px 6px;min-width:0;}",
|
|
1647
|
+
".dkg-file-head:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1648
|
+
".dkg-file-path{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;}",
|
|
1649
|
+
".dkg-file-old{font-size:10px;color:var(--dsw-alias-label-tertiary);max-width:30%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1650
|
+
".dkg-caret{flex:none;font-size:9px;color:var(--dsw-alias-label-tertiary);width:10px;}",
|
|
1651
|
+
".dkg-tag{flex:none;font-size:10px;border-radius:999px;padding:0 6px;color:var(--dsw-alias-label-tertiary);border:1px solid var(--dsw-alias-border-l2);}",
|
|
1652
|
+
".dkg-tag.added{color:var(--dsw-alias-state-success-primary);border-color:currentColor;}",
|
|
1653
|
+
".dkg-tag.deleted{color:var(--dsw-alias-state-error-primary);border-color:currentColor;}",
|
|
1654
|
+
".dkg-add{color:var(--dsw-alias-state-success-primary);flex:none;font-size:11px;}",
|
|
1655
|
+
".dkg-del{color:var(--dsw-alias-state-error-primary);flex:none;font-size:11px;}",
|
|
1656
|
+
".dkg-diff{max-height:320px;overflow:auto;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:1.5;}",
|
|
1657
|
+
".dkg-hunk-head{color:var(--dk-accent);background:color-mix(in srgb,var(--dk-accent) 8%,transparent);padding:2px 6px;font-size:10px;white-space:pre;}",
|
|
1658
|
+
".dkg-line{display:flex;align-items:flex-start;gap:0;white-space:pre;}",
|
|
1659
|
+
".dkg-line.add{background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 12%,transparent);}",
|
|
1660
|
+
".dkg-line.del{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent);}",
|
|
1661
|
+
".dkg-ln{flex:none;width:34px;text-align:right;padding-right:5px;color:var(--dsw-alias-label-tertiary);user-select:none;}",
|
|
1662
|
+
".dkg-sign{flex:none;width:10px;color:var(--dsw-alias-label-tertiary);}",
|
|
1663
|
+
".dkg-code{flex:1;min-width:0;overflow-x:auto;color:var(--dsw-alias-label-primary);}",
|
|
1664
|
+
".dkg-wt{display:flex;gap:6px;min-height:0;flex:1;overflow:hidden;}",
|
|
1665
|
+
".dkg-compact .dkg-wt{flex-direction:column;}",
|
|
1666
|
+
".dkg-wt-files{flex:1 1 48%;min-width:0;overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);padding:6px;display:flex;flex-direction:column;gap:6px;}",
|
|
1667
|
+
".dkg-compact .dkg-wt-files{max-height:44%;}",
|
|
1668
|
+
".dkg-wt-group{display:flex;flex-direction:column;gap:1px;}",
|
|
1669
|
+
".dkg-wt-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:2px 4px;border-bottom:1px solid var(--dsw-alias-border-l1);margin-bottom:2px;}",
|
|
1670
|
+
".dkg-wt-empty{padding-left:22px;font-size:11px;}",
|
|
1671
|
+
".dkg-wt-item{display:flex;align-items:center;gap:6px;padding:2px 5px;border-radius:5px;cursor:pointer;font-size:12px;min-width:0;color:var(--dsw-alias-label-secondary);}",
|
|
1672
|
+
".dkg-wt-item:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1673
|
+
".dkg-wt-item.on{background:var(--dk-accent-soft);}",
|
|
1674
|
+
".dkg-wt-code{flex:none;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;color:var(--dk-warn);width:20px;}",
|
|
1675
|
+
".dkg-wt-actions{flex:none;}",
|
|
1676
|
+
".dkg-wt-commit{flex:1 1 52%;min-width:0;display:flex;flex-direction:column;gap:6px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);padding:6px;overflow:auto;}",
|
|
1677
|
+
".dkg-textarea{width:100%;box-sizing:border-box;font-family:inherit;font-size:12px;line-height:1.55;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:6px 8px;resize:vertical;}",
|
|
1678
|
+
".dkg-textarea:focus{outline:none;border-color:var(--dk-accent);}",
|
|
1679
|
+
".dkg-wt-actions{display:flex;gap:5px;flex-wrap:wrap;}",
|
|
1680
|
+
".dkg-preview{border-top:1px solid var(--dsw-alias-border-l1);padding-top:6px;display:flex;flex-direction:column;gap:5px;}",
|
|
1681
|
+
".dkg-preview-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:var(--dsw-alias-label-primary);}",
|
|
1682
|
+
|
|
1683
|
+
// 目录浏览器
|
|
1684
|
+
".dkg-picker{display:flex;flex-direction:column;gap:6px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2);padding:8px;max-height:340px;overflow:hidden;}",
|
|
1685
|
+
".dkg-picker-head{display:flex;align-items:center;justify-content:space-between;gap:8px;}",
|
|
1686
|
+
".dkg-picker-title{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary);}",
|
|
1687
|
+
".dkg-crumbs{display:flex;align-items:center;gap:2px;flex-wrap:wrap;font-size:11px;max-height:48px;overflow:auto;}",
|
|
1688
|
+
".dkg-crumb{cursor:pointer;font-family:inherit;font-size:11px;color:var(--dk-accent);background:transparent;border:0;padding:1px 4px;border-radius:4px;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
1689
|
+
".dkg-crumb:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
1690
|
+
".dkg-crumb.on{color:var(--dsw-alias-label-primary);font-weight:600;}",
|
|
1691
|
+
".dkg-picker-bar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;}",
|
|
1692
|
+
".dkg-picker-list{flex:1;min-height:80px;overflow:auto;display:flex;flex-direction:column;gap:1px;}",
|
|
1693
|
+
".dkg-picker-row{display:flex;align-items:center;gap:6px;width:100%;box-sizing:border-box;text-align:left;cursor:pointer;font-family:inherit;font-size:12px;color:var(--dsw-alias-label-primary);background:transparent;border:1px solid transparent;border-radius:6px;padding:3px 6px;min-width:0;}",
|
|
1694
|
+
".dkg-picker-row:hover{background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l1);}",
|
|
1695
|
+
".dkg-folder{flex:none;font-size:10px;color:var(--dk-warn);}",
|
|
1696
|
+
".dkg-picker-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;border-top:1px solid var(--dsw-alias-border-l1);padding-top:6px;}",
|
|
1697
|
+
].join("\n");
|
|
1698
|
+
|
|
1699
|
+
// 样式随功能坞的统一 <style data-plugin="dsh-dock"> 注入(见 src/client.jsx 的 fullDockCss):
|
|
1700
|
+
// 本模块只在功能坞里启用时才注入,不额外挂一个无主 <style> 标签——否则会被别的插件 claim 走。
|
|
1701
|
+
|
|
1702
|
+
// ---------- 客户端接线:抽屉页签 + 工作区右键 ----------
|
|
1703
|
+
// 由 src/client.jsx 的 apply() 调一次。开关在【DSH功能】页的「界面增强 → Git 管理面板」,
|
|
1704
|
+
// 关掉后页签与右键入口都不出现(已经打开的页签保持可用,避免把人正在看的内容抽走)。
|
|
1705
|
+
//
|
|
1706
|
+
// 依赖用 ctx.inject 延迟获取:功能坞可能先于 ui-sidebar-right / ui-context-menu 加载。
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* 取服务:先试 get(),再退回属性访问。
|
|
1710
|
+
*
|
|
1711
|
+
* 顺序很关键:Cordis 对**没在 inject 里声明的**属性访问会直接抛
|
|
1712
|
+
* `cannot get property "x" without inject`,而不是返回 undefined。
|
|
1713
|
+
* 所以不能先写 `scope[name]`——那在缺少声明的上下文里是个异常源。
|
|
1714
|
+
* ctx.get() 只对已 provide 的服务返回实例,取不到就是 undefined,安全。
|
|
1715
|
+
*/
|
|
1716
|
+
function serviceOf(scope, name) {
|
|
1717
|
+
if (!scope) return undefined;
|
|
1718
|
+
try {
|
|
1719
|
+
if (typeof scope.get === "function") {
|
|
1720
|
+
const viaGet = scope.get(name);
|
|
1721
|
+
if (viaGet !== undefined) return viaGet;
|
|
1722
|
+
}
|
|
1723
|
+
} catch {
|
|
1724
|
+
// get() 在个别精简 ctx 上不可用:继续尝试属性访问
|
|
1725
|
+
}
|
|
1726
|
+
try {
|
|
1727
|
+
return scope[name];
|
|
1728
|
+
} catch {
|
|
1729
|
+
// 属性访问需要 inject 声明;没声明时 Cordis 抛错,这里按「取不到」处理
|
|
1730
|
+
return undefined;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
/** 在依赖服务就绪后执行;没有 ctx.inject(测试桩)时直接尝试一次。 */
|
|
1735
|
+
function onServices(ctx, names, run) {
|
|
1736
|
+
if (typeof ctx.inject === "function") {
|
|
1737
|
+
try {
|
|
1738
|
+
ctx.inject(names, (scope) => run(scope));
|
|
1739
|
+
return;
|
|
1740
|
+
} catch (e) {
|
|
1741
|
+
// 桩 ctx 的 inject 不可用时退回直接取服务
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
run(ctx);
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/** 开关是否打开(未取到配置时按关闭处理,避免宿主旧版本上突然多出入口)。 */
|
|
1748
|
+
export function gitPanelEnabled() {
|
|
1749
|
+
try {
|
|
1750
|
+
const state = stateOf("dshtools");
|
|
1751
|
+
if (!state || state.enabled !== true) return false;
|
|
1752
|
+
return valueOf("interface", "gitPanel") === true;
|
|
1753
|
+
} catch {
|
|
1754
|
+
return false;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/** 解析目标路径:交给宿主判断它属于哪个仓库(服务器上没有原生选目录也能用)。 */
|
|
1759
|
+
async function resolveTarget(path) {
|
|
1760
|
+
try {
|
|
1761
|
+
const data = await rpc("resolve", { path });
|
|
1762
|
+
return data && data.repo ? data : null;
|
|
1763
|
+
} catch {
|
|
1764
|
+
return null;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* 打开 Git 页签:有仓库就带上,没有就打开当前会话目录的。
|
|
1770
|
+
*
|
|
1771
|
+
* 整段(含取服务)都必须在 try 里:菜单项的 run() 一旦抛错,
|
|
1772
|
+
* ui-context-menu 会统一弹「操作失败,请重试」,把真实原因盖掉。
|
|
1773
|
+
* 这里取不到抽屉服务就返回 false,由调用方给出可读提示。
|
|
1774
|
+
* @returns {boolean} 是否成功发起了打开
|
|
1775
|
+
*/
|
|
1776
|
+
function openGit(ctx, target) {
|
|
1777
|
+
try {
|
|
1778
|
+
const sidebar = serviceOf(ctx, "sidebarRight");
|
|
1779
|
+
if (!sidebar) return false;
|
|
1780
|
+
const params = {};
|
|
1781
|
+
if (target && target.repo) params.repo = target.repo;
|
|
1782
|
+
if (target && target.path) params.path = target.path;
|
|
1783
|
+
if (target && target.sessionId && typeof sidebar.openTabIn === "function") {
|
|
1784
|
+
sidebar.openTabIn(target.sessionId, GIT_TAB_KIND, { params });
|
|
1785
|
+
} else if (typeof sidebar.openTab === "function") {
|
|
1786
|
+
sidebar.openTab(GIT_TAB_KIND, { params });
|
|
1787
|
+
} else {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
return true;
|
|
1791
|
+
} catch {
|
|
1792
|
+
return false;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* 客户端装配:注册抽屉页签与右键入口。
|
|
1798
|
+
* @param {object} ctx 客户端 context
|
|
1799
|
+
*/
|
|
1800
|
+
export function installClient(ctx) {
|
|
1801
|
+
if (!ctx || typeof ctx !== "object") return;
|
|
1802
|
+
// 页签正文拿不到 ctx,装配时存一份给 GitTabBody 用
|
|
1803
|
+
dockCtx = ctx;
|
|
1804
|
+
// 先把 DSH功能 的配置拉一次:开关值决定入口出不出现。
|
|
1805
|
+
// 这是**异步**的:同步读到的还是空 store,直接判断会把开关当成关着,
|
|
1806
|
+
// 页签永远不注册。所以加载落定后要统一重跑一次 sync。
|
|
1807
|
+
/** 各挂载点的 sync 函数,加载完成后统一重跑。 */
|
|
1808
|
+
const syncers = [];
|
|
1809
|
+
function syncAll() {
|
|
1810
|
+
for (const fn of syncers) { try { fn(); } catch { /* 单个失败不影响其它 */ } }
|
|
1811
|
+
}
|
|
1812
|
+
try {
|
|
1813
|
+
const pending = ensureDshtoolsLoaded();
|
|
1814
|
+
if (pending && typeof pending.then === "function") pending.then(syncAll, syncAll);
|
|
1815
|
+
else syncAll();
|
|
1816
|
+
} catch { /* 旧宿主/桩:按关闭处理 */ }
|
|
1817
|
+
|
|
1818
|
+
// ---- 1. 抽屉页签:类型 + 正文 + 标题 ----
|
|
1819
|
+
onServices(ctx, ["sidebarRightTabs", "slots"], (scope) => {
|
|
1820
|
+
const tabs = serviceOf(scope, "sidebarRightTabs");
|
|
1821
|
+
const slots = serviceOf(scope, "slots");
|
|
1822
|
+
if (!tabs || typeof tabs.register !== "function") return;
|
|
1823
|
+
if (!slots || typeof slots.inject !== "function" || typeof slots.register !== "function") return;
|
|
1824
|
+
/**
|
|
1825
|
+
* 注册抽屉页签与引导卡片。
|
|
1826
|
+
*
|
|
1827
|
+
* 开关关着时必须**什么都不注册**:用户明确要求「没勾选就啥都不显示」,
|
|
1828
|
+
* 引导卡片是总入口,之前这里无条件注册,导致刚装好、还没勾选就能在入口列表里看到它。
|
|
1829
|
+
*/
|
|
1830
|
+
const mount = () => {
|
|
1831
|
+
const disposers = [];
|
|
1832
|
+
disposers.push(tabs.register({
|
|
1833
|
+
id: GIT_TAB_ID,
|
|
1834
|
+
kind: GIT_TAB_KIND,
|
|
1835
|
+
priority: "extension",
|
|
1836
|
+
// 页签标题与引导卡片统一叫「Git仓库操作」:只写 Git 会被当成 Git 客户端/工具入口,
|
|
1837
|
+
// 这个名字说明它是「对仓库做操作」的面板。
|
|
1838
|
+
title: () => GIT_PANEL_NAME,
|
|
1839
|
+
guide: [{
|
|
1840
|
+
id: "git",
|
|
1841
|
+
order: 40,
|
|
1842
|
+
title: () => GIT_PANEL_NAME,
|
|
1843
|
+
description: () => "查看当前目录的提交历史与工作区,支持提交与推送",
|
|
1844
|
+
icon: GitGuideArtwork,
|
|
1845
|
+
}],
|
|
1846
|
+
}));
|
|
1847
|
+
disposers.push(slots.inject("sidebar.right.pane.tab", () => slots.register(
|
|
1848
|
+
{ name: "sidebar.right.pane.tab", key: GIT_TAB_ID },
|
|
1849
|
+
GitTabBody,
|
|
1850
|
+
)));
|
|
1851
|
+
disposers.push(slots.inject("sidebar.right.pane.tab.title", () => slots.register(
|
|
1852
|
+
{ name: "sidebar.right.pane.tab.title", key: GIT_TAB_ID },
|
|
1853
|
+
GitTabTitle,
|
|
1854
|
+
)));
|
|
1855
|
+
return () => {
|
|
1856
|
+
for (const dispose of disposers) {
|
|
1857
|
+
try { dispose(); } catch { /* 已卸载 */ }
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
};
|
|
1861
|
+
/**
|
|
1862
|
+
* 按当前开关状态挂载或卸载。
|
|
1863
|
+
*
|
|
1864
|
+
* 关掉时不仅要注销注册,还要把已经打开的页签关掉——否则用户取消勾选后,
|
|
1865
|
+
* 抽屉里那个页签还在,只是点进去报错。
|
|
1866
|
+
*/
|
|
1867
|
+
let unmount = null;
|
|
1868
|
+
const sync = () => {
|
|
1869
|
+
const want = gitPanelEnabled();
|
|
1870
|
+
if (want && !unmount) {
|
|
1871
|
+
unmount = mount();
|
|
1872
|
+
} else if (!want && unmount) {
|
|
1873
|
+
try { unmount(); } catch { /* 已卸载 */ }
|
|
1874
|
+
unmount = null;
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
syncers.push(sync);
|
|
1878
|
+
const start = () => {
|
|
1879
|
+
sync();
|
|
1880
|
+
// 开关变化时重新对齐:勾上就出现,取消就消失
|
|
1881
|
+
return subscribeDshtools(sync);
|
|
1882
|
+
};
|
|
1883
|
+
if (typeof scope.effect === "function") {
|
|
1884
|
+
scope.effect(() => {
|
|
1885
|
+
const stop = start();
|
|
1886
|
+
return () => {
|
|
1887
|
+
try { stop(); } catch { /* 已卸载 */ }
|
|
1888
|
+
if (unmount) { try { unmount(); } catch { /* 已卸载 */ } unmount = null; }
|
|
1889
|
+
};
|
|
1890
|
+
}, "dsh-dock: Git 抽屉页签");
|
|
1891
|
+
} else {
|
|
1892
|
+
start();
|
|
1893
|
+
}
|
|
1894
|
+
});
|
|
1895
|
+
|
|
1896
|
+
// ---- 2. 右键菜单图标:菜单项的 icon.key 只是索引,必须注册到 contextMenu.icon 插槽才有图标 ----
|
|
1897
|
+
onServices(ctx, ["slots"], (scope) => {
|
|
1898
|
+
const slots = serviceOf(scope, "slots");
|
|
1899
|
+
if (!slots || typeof slots.inject !== "function" || typeof slots.register !== "function") return;
|
|
1900
|
+
const register = () => {
|
|
1901
|
+
const disposers = [];
|
|
1902
|
+
disposers.push(slots.inject("contextMenu.icon", function* () {
|
|
1903
|
+
yield slots.register({ name: "contextMenu.icon", key: GIT_ICON_KEY }, GitHistoryIcon);
|
|
1904
|
+
}));
|
|
1905
|
+
return () => {
|
|
1906
|
+
for (const dispose of disposers) {
|
|
1907
|
+
try { dispose(); } catch { /* 已卸载 */ }
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
};
|
|
1911
|
+
if (typeof scope.effect === "function") scope.effect(register, "dsh-dock: Git 菜单图标");
|
|
1912
|
+
else register();
|
|
1913
|
+
});
|
|
1914
|
+
|
|
1915
|
+
// ---- 3. 工作区文件右键:查看 Git 历史 ----
|
|
1916
|
+
// 依赖里必须同时声明 sidebarRight:菜单项点击后要打开抽屉页签。
|
|
1917
|
+
// 只声明 contextMenus 的话,run 里拿不到抽屉服务——点击只会弹「操作失败」。
|
|
1918
|
+
onServices(ctx, ["contextMenus", "sidebarRight"], (scope) => {
|
|
1919
|
+
const menus = serviceOf(scope, "contextMenus");
|
|
1920
|
+
if (!menus || typeof menus.register !== "function") return;
|
|
1921
|
+
const makeResolve = (kind) => async (target, signal) => {
|
|
1922
|
+
if (!gitPanelEnabled()) return [];
|
|
1923
|
+
// 目录与文件都先解析成仓库;解析不到就不出现这一项
|
|
1924
|
+
const resolved = await resolveTarget(target.path);
|
|
1925
|
+
if (signal && typeof signal.throwIfAborted === "function") signal.throwIfAborted();
|
|
1926
|
+
if (!resolved) return [];
|
|
1927
|
+
return [{
|
|
1928
|
+
id: "git-history",
|
|
1929
|
+
label: kind === "directory" ? "查看 Git 历史" : "查看该文件的 Git 历史",
|
|
1930
|
+
icon: { key: GIT_ICON_KEY },
|
|
1931
|
+
// run 绝不抛错:抛了 ui-context-menu 只会弹「操作失败,请重试」,把真实原因盖掉。
|
|
1932
|
+
// 打不开时自己用菜单的通知通道说清楚原因。
|
|
1933
|
+
run: () => {
|
|
1934
|
+
// 用注入到的 scope(含 sidebarRight),不是外层 ctx
|
|
1935
|
+
const ok = openGit(scope, {
|
|
1936
|
+
repo: resolved.repo,
|
|
1937
|
+
path: resolved.relPath === "." ? "" : resolved.relPath,
|
|
1938
|
+
sessionId: target.sessionId,
|
|
1939
|
+
});
|
|
1940
|
+
if (!ok) {
|
|
1941
|
+
try {
|
|
1942
|
+
menus.notify("Git 面板未就绪:请确认「DSH功能 → 界面增强 → Git 管理面板」已打开,并重启过 dsh web", false);
|
|
1943
|
+
} catch { /* 通知通道不可用就算了,至少不抛错 */ }
|
|
1944
|
+
}
|
|
1945
|
+
},
|
|
1946
|
+
}];
|
|
1947
|
+
};
|
|
1948
|
+
const register = () => {
|
|
1949
|
+
const disposers = [
|
|
1950
|
+
menus.register({ id: "dsh-dock.git.directory", target: "directory", order: 220, resolve: makeResolve("directory") }),
|
|
1951
|
+
menus.register({ id: "dsh-dock.git.file", target: "file", order: 220, resolve: makeResolve("file") }),
|
|
1952
|
+
];
|
|
1953
|
+
return () => {
|
|
1954
|
+
for (const dispose of disposers) {
|
|
1955
|
+
try { dispose(); } catch { /* 已卸载 */ }
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
if (typeof scope.effect === "function") scope.effect(register, "dsh-dock: Git 右键入口");
|
|
1960
|
+
else register();
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
|
|
1965
|
+
/**
|
|
1966
|
+
* 抽屉引导卡片的插图(与 DSH 自带条目同款风格:36px 画布、固定配色)。
|
|
1967
|
+
*
|
|
1968
|
+
* 不提供 icon 时引导页会画一个占位方块——用户截图里那个方块就是它。
|
|
1969
|
+
* 这里画分支图形:两个提交点 + 一个分叉点 + 连线。
|
|
1970
|
+
* @param {{ size?: number, className?: string }} props 画布尺寸与布局类
|
|
1971
|
+
*/
|
|
1972
|
+
export function GitGuideArtwork({ size = 36, className } = {}) {
|
|
1973
|
+
return (
|
|
1974
|
+
<svg width={size} height={size} className={className} aria-hidden="true" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1975
|
+
<circle cx="11" cy="8" r="3" stroke="#F97316" strokeWidth="2" />
|
|
1976
|
+
<circle cx="11" cy="28" r="3" stroke="#F97316" strokeWidth="2" />
|
|
1977
|
+
<circle cx="25" cy="18" r="3" stroke="#F97316" strokeWidth="2" />
|
|
1978
|
+
<path d="M11 11v14" stroke="#F97316" strokeWidth="2" strokeLinecap="square" />
|
|
1979
|
+
<path d="M14 8h4a4 4 0 0 1 4 4v2M14 28h4a4 4 0 0 0 4-4v-2" stroke="#F97316" strokeWidth="2" strokeLinecap="square" />
|
|
1980
|
+
</svg>
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/** 给右键菜单用的图标(分支样式)。 */
|
|
1985
|
+
export function GitHistoryIcon() {
|
|
1986
|
+
return (
|
|
1987
|
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
1988
|
+
<circle cx="4" cy="3.5" r="1.6" stroke="currentColor" strokeWidth="1.3" />
|
|
1989
|
+
<circle cx="4" cy="12.5" r="1.6" stroke="currentColor" strokeWidth="1.3" />
|
|
1990
|
+
<circle cx="12" cy="8" r="1.6" stroke="currentColor" strokeWidth="1.3" />
|
|
1991
|
+
<path d="M4 5.1v5.8M5.6 3.5h2.6a2.2 2.2 0 0 1 2.2 2.2v.7M5.6 12.5h2.6a2.2 2.2 0 0 0 2.2-2.2v-.7" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
|
|
1992
|
+
</svg>
|
|
1993
|
+
);
|
|
1994
|
+
}
|