dsh-github-flow 0.1.0
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 +130 -0
- package/cordis.patch.yml +7 -0
- package/icon.svg +17 -0
- package/lib/api/routes.d.ts +3 -0
- package/lib/api/routes.js +230 -0
- package/lib/client/icons.d.ts +13 -0
- package/lib/client/icons.js +41 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +36 -0
- package/lib/client/panel.d.ts +1 -0
- package/lib/client/panel.js +75 -0
- package/lib/client/style.d.ts +1 -0
- package/lib/client/style.js +190 -0
- package/lib/client.d.ts +11 -0
- package/lib/client.js +615 -0
- package/lib/commands/gh.d.ts +2 -0
- package/lib/commands/gh.js +63 -0
- package/lib/executor.d.ts +22 -0
- package/lib/executor.js +207 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +57 -0
- package/lib/service.d.ts +28 -0
- package/lib/service.js +34 -0
- package/lib/tools/api.d.ts +2 -0
- package/lib/tools/api.js +55 -0
- package/lib/tools/define.d.ts +6 -0
- package/lib/tools/define.js +15 -0
- package/lib/tools/issue.d.ts +2 -0
- package/lib/tools/issue.js +109 -0
- package/lib/tools/pr.d.ts +2 -0
- package/lib/tools/pr.js +130 -0
- package/lib/tools/repo.d.ts +2 -0
- package/lib/tools/repo.js +68 -0
- package/lib/tools/run.d.ts +2 -0
- package/lib/tools/run.js +87 -0
- package/lib/types.d.ts +167 -0
- package/lib/types.js +4 -0
- package/package.json +56 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-github-flow",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
var React = require("react");
|
|
8
|
+
var GITHUB_PANEL_CSS = `
|
|
9
|
+
.dsh-github-icon {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
color: var(--dsw-alias-label-secondary, #8c8c8c);
|
|
17
|
+
transition: color 0.15s ease;
|
|
18
|
+
}
|
|
19
|
+
.dsh-github-icon:hover {
|
|
20
|
+
color: var(--dsw-alias-label-primary, #ffffff);
|
|
21
|
+
}
|
|
22
|
+
.dsh-github-icon svg {
|
|
23
|
+
width: 18px;
|
|
24
|
+
height: 18px;
|
|
25
|
+
fill: currentColor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* 右侧栏专属容器 (Right Sidebar Container) */
|
|
29
|
+
.dsh-github-rightbar-container {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
padding: 16px 18px;
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
background: var(--dsw-alias-bg-primary, #1e1e20);
|
|
38
|
+
color: var(--dsw-alias-label-primary, #ececec);
|
|
39
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* 顶部与通用面板 */
|
|
43
|
+
.dsh-github-panel {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
overflow-y: auto;
|
|
49
|
+
padding: 24px 32px;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
background: var(--dsw-alias-bg-primary, #1e1e20);
|
|
52
|
+
color: var(--dsw-alias-label-primary, #ececec);
|
|
53
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
54
|
+
}
|
|
55
|
+
.dsh-github-header {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: space-between;
|
|
59
|
+
margin-bottom: 20px;
|
|
60
|
+
padding-bottom: 12px;
|
|
61
|
+
border-bottom: 1px solid var(--dsw-alias-border-l1, #333336);
|
|
62
|
+
}
|
|
63
|
+
.dsh-github-title {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: 10px;
|
|
67
|
+
}
|
|
68
|
+
.dsh-github-title h2 {
|
|
69
|
+
margin: 0;
|
|
70
|
+
font-size: 18px;
|
|
71
|
+
font-weight: 600;
|
|
72
|
+
}
|
|
73
|
+
.dsh-github-refresh-btn {
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
gap: 6px;
|
|
77
|
+
padding: 5px 12px;
|
|
78
|
+
font-size: 12px;
|
|
79
|
+
border-radius: 6px;
|
|
80
|
+
border: 1px solid var(--dsw-alias-border-l1, #444);
|
|
81
|
+
background: var(--dsw-alias-bg-secondary, #2a2a2e);
|
|
82
|
+
color: var(--dsw-alias-label-primary, #fff);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
transition: all 0.15s ease;
|
|
85
|
+
}
|
|
86
|
+
.dsh-github-refresh-btn:hover {
|
|
87
|
+
background: var(--dsw-alias-interactive-bg-hover, #333);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* 概览卡片区 */
|
|
91
|
+
.dsh-github-card {
|
|
92
|
+
padding: 14px 16px;
|
|
93
|
+
border-radius: 8px;
|
|
94
|
+
border: 1px solid var(--dsw-alias-border-l1, #38383c);
|
|
95
|
+
background: var(--dsw-alias-bg-secondary, #252528);
|
|
96
|
+
margin-bottom: 14px;
|
|
97
|
+
}
|
|
98
|
+
.dsh-github-card-title {
|
|
99
|
+
font-size: 11px;
|
|
100
|
+
text-transform: uppercase;
|
|
101
|
+
letter-spacing: 0.5px;
|
|
102
|
+
color: var(--dsw-alias-label-tertiary, #888);
|
|
103
|
+
margin-bottom: 6px;
|
|
104
|
+
}
|
|
105
|
+
.dsh-github-card-value {
|
|
106
|
+
font-size: 15px;
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
flex-wrap: wrap;
|
|
111
|
+
gap: 8px;
|
|
112
|
+
}
|
|
113
|
+
.dsh-github-badge {
|
|
114
|
+
display: inline-block;
|
|
115
|
+
font-size: 11px;
|
|
116
|
+
padding: 2px 8px;
|
|
117
|
+
border-radius: 12px;
|
|
118
|
+
font-weight: 500;
|
|
119
|
+
}
|
|
120
|
+
.dsh-badge-green { background: rgba(46, 160, 67, 0.2); color: #3fb950; }
|
|
121
|
+
.dsh-badge-red { background: rgba(248, 81, 73, 0.2); color: #f85149; }
|
|
122
|
+
.dsh-badge-yellow { background: rgba(210, 153, 34, 0.2); color: #d29922; }
|
|
123
|
+
|
|
124
|
+
/* 快捷操作网格按钮 */
|
|
125
|
+
.dsh-github-quick-actions {
|
|
126
|
+
display: grid;
|
|
127
|
+
grid-template-columns: 1fr 1fr;
|
|
128
|
+
gap: 8px;
|
|
129
|
+
margin-bottom: 16px;
|
|
130
|
+
}
|
|
131
|
+
.dsh-github-action-btn {
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
gap: 6px;
|
|
136
|
+
padding: 8px 10px;
|
|
137
|
+
border-radius: 6px;
|
|
138
|
+
border: 1px solid var(--dsw-alias-border-l1, #444);
|
|
139
|
+
background: var(--dsw-alias-bg-secondary, #28282b);
|
|
140
|
+
color: var(--dsw-alias-label-primary, #fff);
|
|
141
|
+
font-size: 12px;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
transition: all 0.15s ease;
|
|
144
|
+
}
|
|
145
|
+
.dsh-github-action-btn:hover {
|
|
146
|
+
background: var(--dsw-alias-interactive-bg-hover, #343438);
|
|
147
|
+
border-color: #58a6ff;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* 列表条目 */
|
|
151
|
+
.dsh-github-section {
|
|
152
|
+
margin-bottom: 18px;
|
|
153
|
+
}
|
|
154
|
+
.dsh-github-section-header {
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: space-between;
|
|
158
|
+
margin-bottom: 8px;
|
|
159
|
+
}
|
|
160
|
+
.dsh-github-section-header h3 {
|
|
161
|
+
margin: 0;
|
|
162
|
+
font-size: 13px;
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
color: var(--dsw-alias-label-secondary, #ccc);
|
|
165
|
+
}
|
|
166
|
+
.dsh-github-list {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
gap: 6px;
|
|
170
|
+
}
|
|
171
|
+
.dsh-github-item {
|
|
172
|
+
display: flex;
|
|
173
|
+
flex-direction: column;
|
|
174
|
+
gap: 4px;
|
|
175
|
+
padding: 10px 12px;
|
|
176
|
+
border-radius: 6px;
|
|
177
|
+
border: 1px solid var(--dsw-alias-border-l1, #333336);
|
|
178
|
+
background: var(--dsw-alias-bg-secondary, #252528);
|
|
179
|
+
}
|
|
180
|
+
.dsh-github-item:hover {
|
|
181
|
+
border-color: var(--dsw-alias-border-l2, #555);
|
|
182
|
+
}
|
|
183
|
+
.dsh-github-item-title {
|
|
184
|
+
font-size: 13px;
|
|
185
|
+
font-weight: 500;
|
|
186
|
+
color: var(--dsw-alias-label-primary, #fff);
|
|
187
|
+
text-decoration: none;
|
|
188
|
+
}
|
|
189
|
+
.dsh-github-item-title:hover {
|
|
190
|
+
text-decoration: underline;
|
|
191
|
+
}
|
|
192
|
+
.dsh-github-item-meta {
|
|
193
|
+
font-size: 11px;
|
|
194
|
+
color: var(--dsw-alias-label-secondary, #8c8c8c);
|
|
195
|
+
display: flex;
|
|
196
|
+
flex-wrap: wrap;
|
|
197
|
+
gap: 8px;
|
|
198
|
+
}
|
|
199
|
+
.dsh-github-empty {
|
|
200
|
+
padding: 18px;
|
|
201
|
+
text-align: center;
|
|
202
|
+
font-size: 12px;
|
|
203
|
+
color: var(--dsw-alias-label-tertiary, #666);
|
|
204
|
+
border: 1px dashed var(--dsw-alias-border-l1, #333);
|
|
205
|
+
border-radius: 6px;
|
|
206
|
+
}
|
|
207
|
+
.dsh-github-tabs {
|
|
208
|
+
display: flex;
|
|
209
|
+
gap: 8px;
|
|
210
|
+
margin-bottom: 18px;
|
|
211
|
+
border-bottom: 1px solid var(--dsw-alias-border-l1, #333);
|
|
212
|
+
padding-bottom: 8px;
|
|
213
|
+
}
|
|
214
|
+
.dsh-github-tab-btn {
|
|
215
|
+
padding: 6px 14px;
|
|
216
|
+
border-radius: 6px;
|
|
217
|
+
font-size: 13px;
|
|
218
|
+
font-weight: 500;
|
|
219
|
+
border: 0;
|
|
220
|
+
background: transparent;
|
|
221
|
+
color: var(--dsw-alias-label-secondary, #8c8c8c);
|
|
222
|
+
cursor: pointer;
|
|
223
|
+
transition: all 0.15s ease;
|
|
224
|
+
}
|
|
225
|
+
.dsh-github-tab-btn:hover {
|
|
226
|
+
color: var(--dsw-alias-label-primary, #fff);
|
|
227
|
+
background: rgba(255, 255, 255, 0.05);
|
|
228
|
+
}
|
|
229
|
+
.dsh-github-tab-btn.active {
|
|
230
|
+
color: #58a6ff;
|
|
231
|
+
background: rgba(88, 166, 255, 0.12);
|
|
232
|
+
font-weight: 600;
|
|
233
|
+
}
|
|
234
|
+
.dsh-github-search-input {
|
|
235
|
+
width: 100%;
|
|
236
|
+
max-width: 320px;
|
|
237
|
+
padding: 6px 12px;
|
|
238
|
+
font-size: 12px;
|
|
239
|
+
border-radius: 6px;
|
|
240
|
+
border: 1px solid var(--dsw-alias-border-l1, #444);
|
|
241
|
+
background: var(--dsw-alias-bg-secondary, #252528);
|
|
242
|
+
color: #fff;
|
|
243
|
+
outline: none;
|
|
244
|
+
margin-bottom: 14px;
|
|
245
|
+
}
|
|
246
|
+
.dsh-github-search-input:focus {
|
|
247
|
+
border-color: #58a6ff;
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
function injectStyles() {
|
|
251
|
+
var styleId = "dsh-plugin-github-styles";
|
|
252
|
+
if (document.getElementById(styleId))
|
|
253
|
+
return () => { };
|
|
254
|
+
var style = document.createElement("style");
|
|
255
|
+
style.id = styleId;
|
|
256
|
+
style.textContent = GITHUB_PANEL_CSS;
|
|
257
|
+
document.head.appendChild(style);
|
|
258
|
+
return () => style.remove();
|
|
259
|
+
}
|
|
260
|
+
// 官方高清 Octocat SVG 矢量组件
|
|
261
|
+
function renderOctocat(size = 18, color = "currentColor") {
|
|
262
|
+
return React.createElement("svg", {
|
|
263
|
+
viewBox: "0 0 16 16",
|
|
264
|
+
width: size,
|
|
265
|
+
height: size,
|
|
266
|
+
fill: color,
|
|
267
|
+
style: { flexShrink: 0, display: "inline-block", verticalAlign: "middle" }
|
|
268
|
+
}, React.createElement("path", {
|
|
269
|
+
fillRule: "evenodd",
|
|
270
|
+
clipRule: "evenodd",
|
|
271
|
+
d: "M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.72 6.56 11.52C4.78 11.32 2.92 10.63 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.32 9.47 11.52C9.76 11.77 10.01 12.25 10.01 13C10.01 14.08 10 14.95 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z"
|
|
272
|
+
}));
|
|
273
|
+
}
|
|
274
|
+
// 现代暗黑科技风勋章图标(深邃蓝紫微渐变 + 白描)
|
|
275
|
+
function renderOctocatBadge(size = 32) {
|
|
276
|
+
return React.createElement("div", {
|
|
277
|
+
style: {
|
|
278
|
+
display: "flex",
|
|
279
|
+
alignItems: "center",
|
|
280
|
+
justifyContent: "center",
|
|
281
|
+
width: size + "px",
|
|
282
|
+
height: size + "px",
|
|
283
|
+
borderRadius: Math.round(size * 0.25) + "px",
|
|
284
|
+
background: "linear-gradient(135deg, #2ea043 0%, #1f6feb 60%, #8957e5 100%)",
|
|
285
|
+
boxShadow: "0 2px 8px rgba(31, 111, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25)",
|
|
286
|
+
flexShrink: 0
|
|
287
|
+
}
|
|
288
|
+
}, renderOctocat(Math.round(size * 0.58), "#ffffff"));
|
|
289
|
+
}
|
|
290
|
+
// 渲染 GitHub 仓库信息与操作视图的核心函数
|
|
291
|
+
function renderGithubRepoView(h, data, loading, error, onRefresh, isRightbar = false) {
|
|
292
|
+
var auth = data ? data.auth : null;
|
|
293
|
+
var repo = data ? data.repo : null;
|
|
294
|
+
var prs = (data && data.pullRequests) || [];
|
|
295
|
+
var runs = (data && data.runs) || [];
|
|
296
|
+
var headerEl = h("div", { className: "dsh-github-header" }, h("div", { className: "dsh-github-title" }, renderOctocatBadge(isRightbar ? 26 : 30), h("h2", null, isRightbar ? "GitHub 仓库" : "GitHub 工作台")), h("button", {
|
|
297
|
+
className: "dsh-github-refresh-btn",
|
|
298
|
+
onClick: onRefresh,
|
|
299
|
+
disabled: loading,
|
|
300
|
+
}, loading ? "刷新中..." : "🔄 刷新"));
|
|
301
|
+
// 操作执行函数
|
|
302
|
+
const runAction = async (action, extra = {}) => {
|
|
303
|
+
try {
|
|
304
|
+
const res = await fetch("/api/github/action", {
|
|
305
|
+
method: "POST",
|
|
306
|
+
headers: { "Content-Type": "application/json" },
|
|
307
|
+
body: JSON.stringify({ action, ...extra }),
|
|
308
|
+
});
|
|
309
|
+
const json = await res.json();
|
|
310
|
+
alert(json.ok ? `✅ ${json.message || "操作已完成"}` : `❌ ${json.error || "操作失败"}`);
|
|
311
|
+
if (json.ok)
|
|
312
|
+
onRefresh();
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
alert(`网络异常: ${err.message}`);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
// 仓库基础卡片
|
|
319
|
+
var repoCardEl = h("div", { className: "dsh-github-card" }, h("div", { className: "dsh-github-card-title" }, "当前工作区 GitHub 仓库"), h("div", { className: "dsh-github-card-value" }, repo
|
|
320
|
+
? h("a", { href: repo.url, target: "_blank", style: { color: "#58a6ff", textDecoration: "none" } }, repo.nameWithOwner)
|
|
321
|
+
: h("span", { style: { color: "#f85149" } }, "未检测到关联的 GitHub 仓库"), repo ? h("span", { className: "dsh-github-badge dsh-badge-green" }, repo.defaultBranch) : null), repo && repo.description
|
|
322
|
+
? h("div", { style: { fontSize: "12px", color: "#bbb", marginTop: "4px" } }, repo.description)
|
|
323
|
+
: null, auth && auth.loggedIn
|
|
324
|
+
? h("div", { style: { fontSize: "11px", color: "#888", marginTop: "6px" } }, `CLI 认证账号: ${auth.user} (${auth.scopes?.join(", ") || "已登录"})`)
|
|
325
|
+
: null, !repo
|
|
326
|
+
? h("div", { style: { fontSize: "11px", color: "#888", marginTop: "6px" } }, "若本地已有 git 仓库,请运行 `git remote add github <url>` 或 `git remote add origin <url>` 关联远程仓库。")
|
|
327
|
+
: null);
|
|
328
|
+
// 快捷操作栏
|
|
329
|
+
var actionsBarEl = h("div", { className: "dsh-github-quick-actions" }, h("button", {
|
|
330
|
+
className: "dsh-github-action-btn",
|
|
331
|
+
onClick: () => {
|
|
332
|
+
if (repo?.url) {
|
|
333
|
+
window.open(repo.url, "_blank", "noopener,noreferrer");
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
alert("当前工作区尚未关联 GitHub 仓库");
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
}, "🌐 浏览器打开"), h("button", {
|
|
340
|
+
className: "dsh-github-action-btn",
|
|
341
|
+
onClick: () => {
|
|
342
|
+
if (repo?.url) {
|
|
343
|
+
window.open(`${repo.url}/pulls`, "_blank", "noopener,noreferrer");
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
alert("当前工作区尚未关联 GitHub 仓库");
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
}, "🔀 查看所有 PRs"), h("button", {
|
|
350
|
+
className: "dsh-github-action-btn",
|
|
351
|
+
onClick: () => {
|
|
352
|
+
var title = prompt("请输入要创建的 PR 标题:");
|
|
353
|
+
if (title)
|
|
354
|
+
runAction("create_pr", { title });
|
|
355
|
+
},
|
|
356
|
+
}, "🚀 快速创建 PR"), h("button", {
|
|
357
|
+
className: "dsh-github-action-btn",
|
|
358
|
+
onClick: () => {
|
|
359
|
+
var title = prompt("请输入 Issue 标题:");
|
|
360
|
+
if (title)
|
|
361
|
+
runAction("create_issue", { title });
|
|
362
|
+
},
|
|
363
|
+
}, "📝 新建 Issue"));
|
|
364
|
+
// PR 列表
|
|
365
|
+
var prSectionEl = h("div", { className: "dsh-github-section" }, h("div", { className: "dsh-github-section-header" }, h("h3", null, `🔀 Pull Requests (${prs.length})`)), prs.length === 0
|
|
366
|
+
? h("div", { className: "dsh-github-empty" }, "当前无开放中的 PR")
|
|
367
|
+
: h("div", { className: "dsh-github-list" }, prs.map((pr) => h("div", { key: pr.number, className: "dsh-github-item" }, h("a", { className: "dsh-github-item-title", href: pr.url, target: "_blank" }, `#${pr.number} ${pr.title}`), h("div", { className: "dsh-github-item-meta" }, h("span", null, `${pr.headRefName} → ${pr.baseRefName}`), pr.mergeable === "CONFLICTING"
|
|
368
|
+
? h("span", { className: "dsh-github-badge dsh-badge-red" }, "代码冲突")
|
|
369
|
+
: h("span", { className: "dsh-github-badge dsh-badge-green" }, "可合并"))))));
|
|
370
|
+
// Actions 流水线
|
|
371
|
+
var runSectionEl = h("div", { className: "dsh-github-section" }, h("div", { className: "dsh-github-section-header" }, h("h3", null, `⚡ 最近 Actions 流水线 (${runs.length})`)), runs.length === 0
|
|
372
|
+
? h("div", { className: "dsh-github-empty" }, "暂无工作流记录")
|
|
373
|
+
: h("div", { className: "dsh-github-list" }, runs.map((r) => h("div", { key: r.databaseId, className: "dsh-github-item" }, h("a", { className: "dsh-github-item-title", href: r.url, target: "_blank" }, r.name), h("div", { className: "dsh-github-item-meta" }, h("span", null, `分支: ${r.headBranch}`), r.conclusion === "success"
|
|
374
|
+
? h("span", { className: "dsh-github-badge dsh-badge-green" }, "✓ 成功")
|
|
375
|
+
: r.conclusion === "failure"
|
|
376
|
+
? h("span", { className: "dsh-github-badge dsh-badge-red" }, "✕ 失败")
|
|
377
|
+
: h("span", { className: "dsh-github-badge dsh-badge-yellow" }, r.status))))));
|
|
378
|
+
return [headerEl, repoCardEl, actionsBarEl, prSectionEl, runSectionEl];
|
|
379
|
+
}
|
|
380
|
+
// 1. 右侧栏专属视图 (Right Sidebar Tab Body)
|
|
381
|
+
function GithubRightbarBody(props) {
|
|
382
|
+
var [loading, setLoading] = React.useState(true);
|
|
383
|
+
var [data, setData] = React.useState(null);
|
|
384
|
+
var [error, setError] = React.useState(null);
|
|
385
|
+
// 核心:直接从会话 Props 拿到真实物理工作区路径!
|
|
386
|
+
var cwd = null;
|
|
387
|
+
if (props && props.useSessions && props.sessionId) {
|
|
388
|
+
try {
|
|
389
|
+
cwd = props.useSessions((sessions) => sessions?.byId?.[props.sessionId]?.cwd);
|
|
390
|
+
}
|
|
391
|
+
catch (e) { }
|
|
392
|
+
}
|
|
393
|
+
var loadData = React.useCallback(async (forceRefresh = false) => {
|
|
394
|
+
setLoading(true);
|
|
395
|
+
setError(null);
|
|
396
|
+
try {
|
|
397
|
+
if (forceRefresh) {
|
|
398
|
+
await fetch("/api/github/refresh", { method: "POST" }).catch(() => { });
|
|
399
|
+
}
|
|
400
|
+
var url = "/api/github/overview";
|
|
401
|
+
var params = [];
|
|
402
|
+
if (props && props.sessionId) {
|
|
403
|
+
params.push("sessionId=" + encodeURIComponent(props.sessionId));
|
|
404
|
+
}
|
|
405
|
+
if (cwd) {
|
|
406
|
+
params.push("cwd=" + encodeURIComponent(cwd));
|
|
407
|
+
}
|
|
408
|
+
if (params.length > 0) {
|
|
409
|
+
url += "?" + params.join("&");
|
|
410
|
+
}
|
|
411
|
+
var res = await fetch(url);
|
|
412
|
+
var json = await res.json();
|
|
413
|
+
if (json.ok && json.data) {
|
|
414
|
+
setData(json.data);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
setError(json.error || "获取状态失败");
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
catch (err) {
|
|
421
|
+
setError(err.message || "网络异常");
|
|
422
|
+
}
|
|
423
|
+
finally {
|
|
424
|
+
setLoading(false);
|
|
425
|
+
}
|
|
426
|
+
}, [cwd, props]);
|
|
427
|
+
React.useEffect(() => {
|
|
428
|
+
loadData(false);
|
|
429
|
+
}, [loadData]);
|
|
430
|
+
var h = React.createElement;
|
|
431
|
+
return h("div", { className: "dsh-github-rightbar-container" }, ...renderGithubRepoView(h, data, loading, error, () => loadData(true), true));
|
|
432
|
+
}
|
|
433
|
+
// 2. 右侧栏 Tab 标题组件
|
|
434
|
+
function GithubRightbarTitle() {
|
|
435
|
+
var h = React.createElement;
|
|
436
|
+
return h("span", { style: { display: "flex", alignItems: "center", gap: "6px" } }, renderOctocat(15, "#58a6ff"), h("span", null, "GitHub"));
|
|
437
|
+
}
|
|
438
|
+
// 3. 右侧栏“开始”引导页的大图标 (Artwork)
|
|
439
|
+
function GithubArtwork() {
|
|
440
|
+
return renderOctocatBadge(32);
|
|
441
|
+
}
|
|
442
|
+
// 4. 左侧栏全局入口与中央大面板
|
|
443
|
+
function GithubSidebarIcon(props) {
|
|
444
|
+
const active = Boolean(props && props.active);
|
|
445
|
+
return React.createElement("div", {
|
|
446
|
+
className: "dsh-github-icon" + (active ? " active" : ""),
|
|
447
|
+
title: "GitHub 全景驾驶舱",
|
|
448
|
+
style: {
|
|
449
|
+
display: "flex",
|
|
450
|
+
alignItems: "center",
|
|
451
|
+
justifyContent: "center",
|
|
452
|
+
width: "100%",
|
|
453
|
+
height: "100%",
|
|
454
|
+
cursor: "pointer",
|
|
455
|
+
transition: "all 0.2s cubic-bezier(0.16, 1, 0.3, 1)"
|
|
456
|
+
}
|
|
457
|
+
}, React.createElement("div", {
|
|
458
|
+
style: {
|
|
459
|
+
display: "flex",
|
|
460
|
+
alignItems: "center",
|
|
461
|
+
justifyContent: "center",
|
|
462
|
+
width: "28px",
|
|
463
|
+
height: "28px",
|
|
464
|
+
borderRadius: "7px",
|
|
465
|
+
background: active ? "linear-gradient(135deg, rgba(46,160,67,0.3) 0%, rgba(31,111,235,0.45) 100%)" : "transparent",
|
|
466
|
+
color: active ? "#ffffff" : "var(--dsw-alias-label-secondary, #9ca3af)",
|
|
467
|
+
boxShadow: active ? "0 0 12px rgba(31, 111, 235, 0.4)" : "none",
|
|
468
|
+
border: active ? "1px solid rgba(88, 166, 255, 0.45)" : "1px solid transparent"
|
|
469
|
+
}
|
|
470
|
+
}, renderOctocat(18, active ? "#ffffff" : "currentColor")));
|
|
471
|
+
}
|
|
472
|
+
function GithubWorkspacePanel() {
|
|
473
|
+
var [loading, setLoading] = React.useState(true);
|
|
474
|
+
var [data, setData] = React.useState(null);
|
|
475
|
+
var [error, setError] = React.useState(null);
|
|
476
|
+
var [activeTab, setActiveTab] = React.useState("workspaces"); // 'workspaces' | 'repos' | 'mywork'
|
|
477
|
+
var [searchQuery, setSearchQuery] = React.useState("");
|
|
478
|
+
var loadData = React.useCallback(async (forceRefresh = false) => {
|
|
479
|
+
setLoading(true);
|
|
480
|
+
setError(null);
|
|
481
|
+
try {
|
|
482
|
+
if (forceRefresh)
|
|
483
|
+
await fetch("/api/github/refresh", { method: "POST" }).catch(() => { });
|
|
484
|
+
var res = await fetch("/api/github/global-overview");
|
|
485
|
+
var json = await res.json();
|
|
486
|
+
if (json.ok && json.data)
|
|
487
|
+
setData(json.data);
|
|
488
|
+
else
|
|
489
|
+
setError(json.error || "获取全局数据失败");
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
setError(err.message);
|
|
493
|
+
}
|
|
494
|
+
finally {
|
|
495
|
+
setLoading(false);
|
|
496
|
+
}
|
|
497
|
+
}, []);
|
|
498
|
+
React.useEffect(() => { loadData(false); }, [loadData]);
|
|
499
|
+
var h = React.createElement;
|
|
500
|
+
var headerEl = h("div", { className: "dsh-github-header" }, h("div", { className: "dsh-github-title" }, renderOctocatBadge(32), h("h2", null, "GitHub 全景驾驶舱")), h("button", {
|
|
501
|
+
className: "dsh-github-refresh-btn",
|
|
502
|
+
onClick: () => loadData(true),
|
|
503
|
+
disabled: loading,
|
|
504
|
+
}, loading ? "刷新中..." : "🔄 刷新全局数据"));
|
|
505
|
+
if (loading && !data) {
|
|
506
|
+
return h("div", { className: "dsh-github-panel" }, headerEl, h("div", { className: "dsh-github-empty" }, "正在加载全局 GitHub 账号与工作区数据..."));
|
|
507
|
+
}
|
|
508
|
+
var auth = data ? data.auth : null;
|
|
509
|
+
var userRepos = (data && data.userRepos) || [];
|
|
510
|
+
var workspaceMatrix = (data && data.workspaceMatrix) || [];
|
|
511
|
+
var myPrs = (data && data.myPrs) || [];
|
|
512
|
+
var myIssues = (data && data.myIssues) || [];
|
|
513
|
+
// 顶部统计卡片
|
|
514
|
+
var statsCardsEl = h("div", { className: "dsh-github-overview-cards" }, h("div", { className: "dsh-github-card" }, h("div", { className: "dsh-github-card-title" }, "CLI 认证账号"), h("div", { className: "dsh-github-card-value" }, auth?.loggedIn ? `👤 ${auth.user}` : "未登录", auth?.loggedIn ? h("span", { className: "dsh-github-badge dsh-badge-green" }, "Active") : null)), h("div", { className: "dsh-github-card" }, h("div", { className: "dsh-github-card-title" }, "账号云端仓库"), h("div", { className: "dsh-github-card-value" }, `${userRepos.length} 个 Repositories`)), h("div", { className: "dsh-github-card" }, h("div", { className: "dsh-github-card-title" }, "本地工作区联动"), h("div", { className: "dsh-github-card-value" }, `${workspaceMatrix.length} 个工作区 (${workspaceMatrix.filter((w) => w.repo).length} 个已关联)`)));
|
|
515
|
+
// Tab 栏
|
|
516
|
+
var tabsEl = h("div", { className: "dsh-github-tabs" }, h("button", { className: `dsh-github-tab-btn ${activeTab === 'workspaces' ? 'active' : ''}`, onClick: () => setActiveTab('workspaces') }, `📂 本地工作区矩阵 (${workspaceMatrix.length})`), h("button", { className: `dsh-github-tab-btn ${activeTab === 'repos' ? 'active' : ''}`, onClick: () => setActiveTab('repos') }, `☁️ 我的 GitHub 仓库 (${userRepos.length})`), h("button", { className: `dsh-github-tab-btn ${activeTab === 'mywork' ? 'active' : ''}`, onClick: () => setActiveTab('mywork') }, `📋 个人待办 (PR: ${myPrs.length} · Issue: ${myIssues.length})`));
|
|
517
|
+
// 内容区
|
|
518
|
+
var contentEl = null;
|
|
519
|
+
if (activeTab === 'workspaces') {
|
|
520
|
+
contentEl = h("div", { className: "dsh-github-list" }, workspaceMatrix.map((ws) => h("div", { key: ws.id, className: "dsh-github-card", style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "8px" } }, h("div", { style: { display: "flex", flexDirection: "column", gap: "4px" } }, h("div", { style: { fontSize: "14px", fontWeight: "600", color: "#fff" } }, ws.title), h("div", { style: { fontSize: "12px", color: "#888", fontFamily: "monospace" } }, ws.path), h("div", { style: { fontSize: "12px", marginTop: "4px", display: "flex", gap: "8px", alignItems: "center" } }, ws.repo
|
|
521
|
+
? h("span", { style: { color: "#58a6ff" } }, `🐙 关联远程: ${ws.repo.nameWithOwner} (${ws.repo.defaultBranch})`)
|
|
522
|
+
: h("span", { style: { color: "#888" } }, ws.hasGit ? "本地有 Git,未关联 GitHub 远程" : "本地无 Git 仓库"), ws.repo ? h("span", { className: "dsh-github-badge dsh-badge-green" }, "已关联") : null)), h("div", { style: { display: "flex", gap: "8px" } }, ws.repo
|
|
523
|
+
? h("a", { className: "dsh-github-btn-sm", href: ws.repo.url, target: "_blank", style: { textDecoration: "none" } }, "在 GitHub 打开")
|
|
524
|
+
: null))));
|
|
525
|
+
}
|
|
526
|
+
else if (activeTab === 'repos') {
|
|
527
|
+
var filteredRepos = userRepos.filter((r) => !searchQuery || r.nameWithOwner.toLowerCase().includes(searchQuery.toLowerCase()) || r.description?.toLowerCase().includes(searchQuery.toLowerCase()));
|
|
528
|
+
contentEl = h("div", null, h("input", {
|
|
529
|
+
className: "dsh-github-search-input",
|
|
530
|
+
placeholder: "🔍 搜索我的 GitHub 仓库...",
|
|
531
|
+
value: searchQuery,
|
|
532
|
+
onChange: (e) => setSearchQuery(e.target.value)
|
|
533
|
+
}), h("div", { className: "dsh-github-list" }, filteredRepos.map((r) => h("div", { key: r.nameWithOwner, className: "dsh-github-item" }, h("a", { className: "dsh-github-item-title", href: r.url, target: "_blank" }, r.nameWithOwner), r.description ? h("div", { style: { fontSize: "12px", color: "#bbb" } }, r.description) : null, h("div", { className: "dsh-github-item-meta" }, h("span", null, `默认分支: ${r.defaultBranch}`), r.isPrivate ? h("span", { className: "dsh-github-badge dsh-badge-yellow" }, "Private") : h("span", { className: "dsh-github-badge dsh-badge-green" }, "Public"), h("span", null, `⭐ ${r.stargazerCount}`))))));
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
contentEl = h("div", null, h("h3", { style: { fontSize: "14px", marginBottom: "8px" } }, `🔀 我发起的 PR (${myPrs.length})`), myPrs.length === 0 ? h("div", { className: "dsh-github-empty", style: { marginBottom: "16px" } }, "暂无开放中的 PR") : h("div", { className: "dsh-github-list", style: { marginBottom: "16px" } }, myPrs.map((pr) => h("div", { key: pr.number, className: "dsh-github-item" }, h("a", { className: "dsh-github-item-title", href: pr.url, target: "_blank" }, `[${pr.repository?.nameWithOwner || 'Repo'}] #${pr.number} ${pr.title}`)))), h("h3", { style: { fontSize: "14px", marginBottom: "8px" } }, `📝 我的待办 Issues (${myIssues.length})`), myIssues.length === 0 ? h("div", { className: "dsh-github-empty" }, "暂无开放中的 Issue") : h("div", { className: "dsh-github-list" }, myIssues.map((is) => h("div", { key: is.number, className: "dsh-github-item" }, h("a", { className: "dsh-github-item-title", href: is.url, target: "_blank" }, `[${is.repository?.nameWithOwner || 'Repo'}] #${is.number} ${is.title}`)))));
|
|
537
|
+
}
|
|
538
|
+
return h("div", { className: "dsh-github-panel" }, headerEl, statsCardsEl, tabsEl, contentEl);
|
|
539
|
+
}
|
|
540
|
+
var inject = ["slots", "sidebarRightTabs", "sessions", "layout"];
|
|
541
|
+
function apply(ctx) {
|
|
542
|
+
// 彻底清理历史在界面底部错位遗留的 DOM 元素
|
|
543
|
+
if (typeof window !== "undefined" && window.document) {
|
|
544
|
+
var sweep = () => {
|
|
545
|
+
document.querySelectorAll(".dsh-github-right-card, .dsh-github-mounted-card, #dsh-github-floating-drawer").forEach((el) => el.remove());
|
|
546
|
+
};
|
|
547
|
+
sweep();
|
|
548
|
+
setTimeout(sweep, 300);
|
|
549
|
+
setTimeout(sweep, 1500);
|
|
550
|
+
}
|
|
551
|
+
if (ctx.effect) {
|
|
552
|
+
ctx.effect(() => injectStyles(), "github: styles");
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
injectStyles();
|
|
556
|
+
}
|
|
557
|
+
// A. 原生接入 DSH 右侧栏 Tab 体系 (sidebarRightTabs)
|
|
558
|
+
// 这会让 GitHub 仓库自动、原生出现在“开始”引导页上(排在浏览器下方,无任何错位代码!)
|
|
559
|
+
if (ctx.sidebarRightTabs && typeof ctx.sidebarRightTabs.register === "function") {
|
|
560
|
+
ctx.effect(() => {
|
|
561
|
+
return ctx.sidebarRightTabs.register({
|
|
562
|
+
id: "dsh-github-flow",
|
|
563
|
+
kind: "github",
|
|
564
|
+
priority: "plugin",
|
|
565
|
+
title: () => "GitHub 仓库",
|
|
566
|
+
guide: [
|
|
567
|
+
{
|
|
568
|
+
id: "workspace.github",
|
|
569
|
+
commandId: "workspace.github",
|
|
570
|
+
order: 40,
|
|
571
|
+
title: () => "GitHub 仓库",
|
|
572
|
+
description: () => "查看与操作当前工作区目录下的 GitHub 仓库",
|
|
573
|
+
icon: GithubArtwork,
|
|
574
|
+
},
|
|
575
|
+
],
|
|
576
|
+
});
|
|
577
|
+
}, "github: sidebar right tab definition");
|
|
578
|
+
}
|
|
579
|
+
// B. 注册右侧栏的真实 Tab 内容与标题 (sidebar.right.pane.tab)
|
|
580
|
+
if (ctx.slots) {
|
|
581
|
+
ctx.slots.inject("sidebar.right.pane.tab", () => {
|
|
582
|
+
return ctx.slots.register({
|
|
583
|
+
name: "sidebar.right.pane.tab",
|
|
584
|
+
key: "dsh-github-flow",
|
|
585
|
+
}, GithubRightbarBody);
|
|
586
|
+
});
|
|
587
|
+
ctx.slots.inject("sidebar.right.pane.tab.title", () => {
|
|
588
|
+
return ctx.slots.register({
|
|
589
|
+
name: "sidebar.right.pane.tab.title",
|
|
590
|
+
key: "dsh-github-flow",
|
|
591
|
+
}, GithubRightbarTitle);
|
|
592
|
+
});
|
|
593
|
+
// C. 保留左侧栏导航与中央大面板(双向可达)
|
|
594
|
+
ctx.slots.inject("sidebar.panellist", () => {
|
|
595
|
+
return ctx.slots.register({
|
|
596
|
+
name: "sidebar.panellist",
|
|
597
|
+
id: "github",
|
|
598
|
+
order: 20,
|
|
599
|
+
label: "GitHub",
|
|
600
|
+
}, GithubSidebarIcon);
|
|
601
|
+
});
|
|
602
|
+
ctx.slots.inject("main", () => {
|
|
603
|
+
return ctx.slots.register({
|
|
604
|
+
name: "main",
|
|
605
|
+
key: "github",
|
|
606
|
+
}, GithubWorkspacePanel);
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
exports.apply = apply;
|
|
611
|
+
exports.inject = inject;
|
|
612
|
+
exports.name = "dsh-github-flow";
|
|
613
|
+
return module.exports;
|
|
614
|
+
}
|
|
615
|
+
});
|