dsh-commit-journal 0.0.0-stage → 0.6.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/CHANGELOG.md +84 -0
- package/LICENSE +21 -0
- package/README.md +182 -3
- package/client.js +3432 -0
- package/cordis.patch.yml +4 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3852 -0
- package/lib/index.js.map +1 -0
- package/package.json +95 -6
package/client.js
ADDED
|
@@ -0,0 +1,3432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commit Journal browser UI: horizontal tabs, DSH dual-theme tokens.
|
|
3
|
+
* Account switching lives on the Accounts tab (no global top bar).
|
|
4
|
+
*/
|
|
5
|
+
window.__ModuleLoader__.load({
|
|
6
|
+
id: 'dsh-commit-journal',
|
|
7
|
+
factory(require) {
|
|
8
|
+
const React = require('react')
|
|
9
|
+
const h = React.createElement
|
|
10
|
+
const { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } = React
|
|
11
|
+
let ReactDOM = null
|
|
12
|
+
try { ReactDOM = require('react-dom') } catch { ReactDOM = null }
|
|
13
|
+
|
|
14
|
+
let ui = null
|
|
15
|
+
try { ui = require('@deepseek-ai/dsh-client-ui-primitives') } catch { ui = null }
|
|
16
|
+
const UiButton = ui && ui.Button
|
|
17
|
+
const UiModal = ui && ui.Modal
|
|
18
|
+
const UiTag = ui && ui.Tag
|
|
19
|
+
const UiMenu = ui && ui.Menu
|
|
20
|
+
const UiToast = ui && ui.Toast
|
|
21
|
+
const IconPlus = ui && ui.IconPlusOutlineRegular
|
|
22
|
+
const IconRefresh = ui && ui.IconRefreshOutlineRegular
|
|
23
|
+
const IconEdit = ui && ui.IconEditOutlineRegular
|
|
24
|
+
const IconTrash = ui && ui.IconTrashOutlineRegular
|
|
25
|
+
const IconCheck = ui && ui.IconCheckOutlineRegular
|
|
26
|
+
const IconSearch = ui && ui.IconSearchOutlineRegular
|
|
27
|
+
const IconSave = ui && ui.IconSaveOutlineRegular
|
|
28
|
+
const IconClose = ui && ui.IconCloseOutlineRegular
|
|
29
|
+
const IconChevronLeft = ui && ui.IconChevronLeftOutlineRegular
|
|
30
|
+
const IconChevronRight = ui && ui.IconChevronRightOutlineRegular
|
|
31
|
+
const IconChevronDown = ui && ui.IconChevronDownOutlineRegular
|
|
32
|
+
const IconDownload = ui && ui.IconDownloadOutlineRegular
|
|
33
|
+
const IconGlobe = ui && ui.IconGlobeOutlineRegular
|
|
34
|
+
const IconLink = ui && (ui.IconRightUpOutlineRegular || ui.IconLinkOutlineRegular)
|
|
35
|
+
const UiSeg = ui && ui.SegmentedControl
|
|
36
|
+
|
|
37
|
+
const PANEL_ID = 'commit-journal'
|
|
38
|
+
const NS = 'commitJournal'
|
|
39
|
+
const API = 'http://127.0.0.1:39282'
|
|
40
|
+
const TABS = [
|
|
41
|
+
{ id: 'accounts', zh: '账号', en: 'Accounts' },
|
|
42
|
+
{ id: 'repos', zh: '仓库', en: 'Repos' },
|
|
43
|
+
{ id: 'commits', zh: '提交', en: 'Commits' },
|
|
44
|
+
{ id: 'activity', zh: '活跃', en: 'Activity' },
|
|
45
|
+
{ id: 'logs', zh: '日志', en: 'Logs' },
|
|
46
|
+
{ id: 'settings', zh: '设置', en: 'Settings' }
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
const DICTIONARIES = {
|
|
50
|
+
en: {
|
|
51
|
+
panelLabel: 'Commit Journal',
|
|
52
|
+
accounts: 'Accounts',
|
|
53
|
+
repos: 'Repos',
|
|
54
|
+
commits: 'Commits',
|
|
55
|
+
activity: 'Activity',
|
|
56
|
+
logs: 'Logs',
|
|
57
|
+
settings: 'Settings',
|
|
58
|
+
emptyAccount: 'Add an account first.',
|
|
59
|
+
newAccount: 'New account',
|
|
60
|
+
save: 'Save',
|
|
61
|
+
cancel: 'Cancel',
|
|
62
|
+
edit: 'Edit',
|
|
63
|
+
remove: 'Delete',
|
|
64
|
+
test: 'Test',
|
|
65
|
+
testScan: 'Scan test',
|
|
66
|
+
activate: 'Switch to this',
|
|
67
|
+
currentAccount: 'Current account',
|
|
68
|
+
switchAccount: 'Switch account',
|
|
69
|
+
active: 'Active',
|
|
70
|
+
refresh: 'Refresh',
|
|
71
|
+
refreshScan: 'Rescan',
|
|
72
|
+
sync: 'Sync',
|
|
73
|
+
syncWatched: 'Sync watched',
|
|
74
|
+
syncWatchedLocal: 'Sync watched (local)',
|
|
75
|
+
saveWatch: 'Save watched',
|
|
76
|
+
query: 'Query',
|
|
77
|
+
clearCommits: 'Reset local commits',
|
|
78
|
+
clearLogs: 'Clear logs',
|
|
79
|
+
accountMode: 'Mode',
|
|
80
|
+
modeRemote: 'Remote pull',
|
|
81
|
+
modeLocal: 'Local scan (git)',
|
|
82
|
+
modeRemoteShort: 'Remote',
|
|
83
|
+
modeLocalShort: 'Local',
|
|
84
|
+
modeHintRemote: 'Pull commits via provider API with a personal access token.',
|
|
85
|
+
modeHintLocal: 'Scans git repos under the folders you list — no token needed.',
|
|
86
|
+
provider: 'Provider',
|
|
87
|
+
providerCodeup: 'Codeup (Yunxiao)',
|
|
88
|
+
providerGitlab: 'GitLab',
|
|
89
|
+
providerGithub: 'GitHub / GHE',
|
|
90
|
+
localRoots: 'Scan roots',
|
|
91
|
+
localRootsPh: 'One absolute path per line\ne.g. F:\\Personal\\projects',
|
|
92
|
+
localRootsHint: 'Recursively find .git under each root (depth ≤ 5).',
|
|
93
|
+
name: 'Display name',
|
|
94
|
+
namePh: 'e.g. Work account',
|
|
95
|
+
edition: 'Org type',
|
|
96
|
+
editionCentral: 'Central (public cloud)',
|
|
97
|
+
editionRegion: 'Region (dedicated / private)',
|
|
98
|
+
editionHintCentral: 'Uses codeup.aliyun.com — fill organization ID below.',
|
|
99
|
+
editionHintRegion: 'Fill your dedicated instance API Base URL below.',
|
|
100
|
+
org: 'Organization / API',
|
|
101
|
+
orgId: 'organizationId',
|
|
102
|
+
orgIdPh: 'Org ID from Yunxiao org admin → Basic info',
|
|
103
|
+
orgIdPhGithub: 'Org or user login (e.g. yu-bobo); empty = all token-visible repos',
|
|
104
|
+
orgIdPhGitlab: 'Optional group path/id; empty = membership projects',
|
|
105
|
+
orgIdLabelGithub: 'Org / user (optional)',
|
|
106
|
+
orgIdLabelGitlab: 'Group (optional)',
|
|
107
|
+
apiBase: 'API Base URL',
|
|
108
|
+
apiBasePh: 'e.g. https://xxx.devops.aliyuncs.com',
|
|
109
|
+
apiBasePhGithub: 'Leave empty for github.com; GHE e.g. https://github.example.com',
|
|
110
|
+
apiBasePhGitlab: 'Leave empty for gitlab.com; self-hosted e.g. https://gitlab.example.com',
|
|
111
|
+
apiBaseHintGithub: 'Empty → api.github.com; Enterprise Server host gets /api/v3 appended if missing.',
|
|
112
|
+
apiBaseHintGitlab: 'Empty → gitlab.com/api/v4; self-hosted host gets /api/v4 appended if missing.',
|
|
113
|
+
authors: 'Author filters',
|
|
114
|
+
authorsHint: 'Email or name, comma-separated; empty = no filter',
|
|
115
|
+
authorsPh: 'you@example.com, Alice',
|
|
116
|
+
token: 'Personal access token',
|
|
117
|
+
tokenPh: 'Yunxiao → Personal settings → Personal access token',
|
|
118
|
+
tokenPhGithub:
|
|
119
|
+
'Avatar → Settings → Developer settings → Personal access tokens → Fine-grained or Tokens (classic)',
|
|
120
|
+
tokenPhGitlab: 'GitLab → Preferences → Access tokens (read_api / read_repository)',
|
|
121
|
+
tokenPhEdit: 'Leave blank to keep unchanged',
|
|
122
|
+
insecureSsl: 'Skip TLS certificate verification',
|
|
123
|
+
insecureSslHint:
|
|
124
|
+
'Use for corporate HTTPS proxy or self-signed certs (e.g. GitHub fetch failed / UNABLE_TO_VERIFY_LEAF_SIGNATURE). Less safe.',
|
|
125
|
+
defaultBranch: 'Default sync branch',
|
|
126
|
+
defaultBranchPh: 'master / main / develop',
|
|
127
|
+
watched: 'Watched',
|
|
128
|
+
branch: 'Branch',
|
|
129
|
+
branchFilterPh: 'Filter branches',
|
|
130
|
+
branchLoading: 'Loading branches…',
|
|
131
|
+
branchNoMatch: 'No matching branches',
|
|
132
|
+
time: 'Time',
|
|
133
|
+
repo: 'Repo',
|
|
134
|
+
title: 'Message',
|
|
135
|
+
author: 'Author',
|
|
136
|
+
sha: 'SHA',
|
|
137
|
+
diff: 'Diff',
|
|
138
|
+
level: 'Level',
|
|
139
|
+
levelInfo: 'Info',
|
|
140
|
+
levelWarn: 'Warn',
|
|
141
|
+
levelError: 'Error',
|
|
142
|
+
message: 'Message',
|
|
143
|
+
syncInterval: 'Sync interval (min)',
|
|
144
|
+
lookback: 'Lookback days',
|
|
145
|
+
exportsPath: 'Exports folder',
|
|
146
|
+
exportsPathHint: 'Markdown dumps from sync / period reports. Empty = ~/.dsh-commit-journal/exports',
|
|
147
|
+
recentYear: 'Past year',
|
|
148
|
+
totalCommits: 'Commits',
|
|
149
|
+
activeDays: 'Active days',
|
|
150
|
+
longestStreak: 'Longest streak',
|
|
151
|
+
maxDay: 'Peak day',
|
|
152
|
+
diffTotal: 'Diff',
|
|
153
|
+
noteDiff: '{n} commits with line stats',
|
|
154
|
+
noteDiffEmpty: 'Sync again to fill line stats',
|
|
155
|
+
noData: 'No data yet. Sync commits first.',
|
|
156
|
+
confirmDelete: 'Delete this account?',
|
|
157
|
+
confirmClearCommits: 'Clear local commits for this account?',
|
|
158
|
+
confirmClearLogs: 'Clear sync logs?',
|
|
159
|
+
keyword: 'Keyword',
|
|
160
|
+
from: 'From',
|
|
161
|
+
to: 'To',
|
|
162
|
+
allRepos: 'All repos',
|
|
163
|
+
openRepo: 'Open',
|
|
164
|
+
repoKeyword: 'Search repos',
|
|
165
|
+
pageOf: 'Page',
|
|
166
|
+
pageSizeLabel: '/ page',
|
|
167
|
+
totalItems: '{n} total',
|
|
168
|
+
syncOk: 'Synced: +{n} commits ({f} fetched)',
|
|
169
|
+
syncPartial: 'Synced +{n}, {e} repo error(s)',
|
|
170
|
+
refreshOk: 'Repos refreshed',
|
|
171
|
+
saveWatchOk: 'Watched repos saved',
|
|
172
|
+
testOk: 'Connection OK',
|
|
173
|
+
testScanOk: 'Scan OK ({n} repos)',
|
|
174
|
+
activateOk: 'Account activated',
|
|
175
|
+
saveOk: 'Saved',
|
|
176
|
+
clearOk: 'Cleared',
|
|
177
|
+
queryOk: 'Updated',
|
|
178
|
+
refreshScanOk: 'Rescanned roots',
|
|
179
|
+
currentStreak: 'Current streak',
|
|
180
|
+
avgPerDay: 'Avg / active day',
|
|
181
|
+
peakOn: 'Peak on',
|
|
182
|
+
weekdayDist: 'By weekday',
|
|
183
|
+
heatHint: 'Click a day with commits to open the side drawer.',
|
|
184
|
+
activityFootnote:
|
|
185
|
+
'Only locally synced commits are counted, bucketed by local calendar day. The first sync only looks back the days in Settings; earlier years may look sparse. For fuller history, raise lookback under Settings → Sync, reset local commits, then sync again.',
|
|
186
|
+
dayEmpty: 'No commits on this day.',
|
|
187
|
+
less: 'Less',
|
|
188
|
+
more: 'More',
|
|
189
|
+
noteTotal: 'All commits in range',
|
|
190
|
+
noteActiveDays: 'At least one commit',
|
|
191
|
+
noteStreak: 'Consecutive days with commits',
|
|
192
|
+
notePeak: 'No record yet',
|
|
193
|
+
unitDay: 'd',
|
|
194
|
+
unitCommit: '',
|
|
195
|
+
heatSummary: '{w} weeks · {a} active days · {c} commits',
|
|
196
|
+
dayLoading: 'Loading…',
|
|
197
|
+
dayCommits: '{n} commits',
|
|
198
|
+
filterAll: 'All',
|
|
199
|
+
filterWatched: 'Watched',
|
|
200
|
+
filterUnwatched: 'Unwatched',
|
|
201
|
+
descAccounts:
|
|
202
|
+
'Each account is remote (Codeup / GitLab / GitHub PAT) or local (scan roots). Switch the active account to change which data other tabs use.',
|
|
203
|
+
descRepos:
|
|
204
|
+
'“Sync watched” pulls all watched repos; each row can sync alone. With nothing watched, full sync covers every visible repo.',
|
|
205
|
+
descReposLocal:
|
|
206
|
+
'Rescan discovers git repos under your roots. Watch the ones to index; sync runs git log into the local cache.',
|
|
207
|
+
descCommits: 'Browse locally synced commits; filter by repo, date range, and keyword.',
|
|
208
|
+
descActivity: 'Contribution heatmap for the selected range.',
|
|
209
|
+
descLogs: 'Sync log for the current account; error rows show which repo failed.',
|
|
210
|
+
descSettings:
|
|
211
|
+
'Scheduled sync applies to every account (remote API or local rescan). Lookback days apply on first sync, after reset, and once after you raise the window; otherwise sync is incremental.',
|
|
212
|
+
syncSettingsTitle: 'Sync'
|
|
213
|
+
},
|
|
214
|
+
zh: {
|
|
215
|
+
panelLabel: '提交日志',
|
|
216
|
+
accounts: '账号',
|
|
217
|
+
repos: '仓库',
|
|
218
|
+
commits: '提交',
|
|
219
|
+
activity: '活跃',
|
|
220
|
+
logs: '日志',
|
|
221
|
+
settings: '设置',
|
|
222
|
+
emptyAccount: '请先添加账号。',
|
|
223
|
+
newAccount: '新建账号',
|
|
224
|
+
save: '保存',
|
|
225
|
+
cancel: '取消',
|
|
226
|
+
edit: '编辑',
|
|
227
|
+
remove: '删除',
|
|
228
|
+
test: '测试',
|
|
229
|
+
testScan: '扫描测试',
|
|
230
|
+
activate: '切换为当前',
|
|
231
|
+
currentAccount: '当前账号',
|
|
232
|
+
switchAccount: '切换账号',
|
|
233
|
+
active: '当前',
|
|
234
|
+
refresh: '刷新',
|
|
235
|
+
refreshScan: '重新扫描',
|
|
236
|
+
sync: '同步',
|
|
237
|
+
syncWatched: '同步关注',
|
|
238
|
+
syncWatchedLocal: '同步关注(本地)',
|
|
239
|
+
saveWatch: '保存关注',
|
|
240
|
+
query: '查询',
|
|
241
|
+
clearCommits: '重置本地提交',
|
|
242
|
+
clearLogs: '清除日志',
|
|
243
|
+
accountMode: '模式',
|
|
244
|
+
modeRemote: '远程拉取',
|
|
245
|
+
modeLocal: '本地扫描(git)',
|
|
246
|
+
modeRemoteShort: '远程',
|
|
247
|
+
modeLocalShort: '本地',
|
|
248
|
+
modeHintRemote: '使用对应平台的个人访问令牌,经 API 拉取提交。',
|
|
249
|
+
modeHintLocal: '扫描下方根目录中的本机 git 仓库,无需令牌。',
|
|
250
|
+
provider: '平台',
|
|
251
|
+
providerCodeup: 'Codeup(云效)',
|
|
252
|
+
providerGitlab: 'GitLab',
|
|
253
|
+
providerGithub: 'GitHub / 企业版',
|
|
254
|
+
localRoots: '扫描根目录',
|
|
255
|
+
localRootsPh: '每行一个绝对路径\n例如 F:\\Personal\\projects',
|
|
256
|
+
localRootsHint: '在各根目录下递归查找 .git(深度 ≤ 5)。',
|
|
257
|
+
name: '显示名称',
|
|
258
|
+
namePh: '例如:公司主账号',
|
|
259
|
+
edition: '组织类型',
|
|
260
|
+
editionCentral: '中心版(公共云)',
|
|
261
|
+
editionRegion: 'Region 版(专有云 / 独立实例)',
|
|
262
|
+
editionHintCentral: '走 codeup.aliyun.com,请在下方填写组织 ID。',
|
|
263
|
+
editionHintRegion: '请在下方填写专有云 / 独立实例的 API Base URL。',
|
|
264
|
+
org: '组织 / 接入点',
|
|
265
|
+
orgId: 'organizationId',
|
|
266
|
+
orgIdPh: '组织管理后台 → 基本信息里的组织 ID',
|
|
267
|
+
orgIdPhGithub: '组织或用户 login(如 yu-bobo);留空=令牌可见全部仓库',
|
|
268
|
+
orgIdPhGitlab: '可选 group 路径/ID;留空列出 membership 项目',
|
|
269
|
+
orgIdLabelGithub: '组织 / 用户(可选)',
|
|
270
|
+
orgIdLabelGitlab: 'Group(可选)',
|
|
271
|
+
apiBase: 'API Base URL',
|
|
272
|
+
apiBasePh: '实例访问域名,如 https://xxx.devops.aliyuncs.com',
|
|
273
|
+
apiBasePhGithub: 'github.com 可留空;GHE 如 https://github.example.com',
|
|
274
|
+
apiBasePhGitlab: 'gitlab.com 可留空;自建如 https://gitlab.example.com',
|
|
275
|
+
apiBaseHintGithub: '留空 → api.github.com;企业版主机缺 /api/v3 时会自动补。',
|
|
276
|
+
apiBaseHintGitlab: '留空 → gitlab.com/api/v4;自建主机缺 /api/v4 时会自动补。',
|
|
277
|
+
authors: '作者过滤',
|
|
278
|
+
authorsHint: '邮箱或姓名,逗号分隔;留空不过滤',
|
|
279
|
+
authorsPh: 'you@example.com, 张三',
|
|
280
|
+
token: '个人访问令牌',
|
|
281
|
+
tokenPh: '云效个人设置 → 个人访问令牌',
|
|
282
|
+
tokenPhGithub:
|
|
283
|
+
'头像 → Settings → Developer settings → Personal access tokens → Fine-grained 或 Tokens (classic)',
|
|
284
|
+
tokenPhGitlab: 'GitLab → Preferences → Access tokens(read_api / read_repository)',
|
|
285
|
+
tokenPhEdit: '留空则不修改',
|
|
286
|
+
insecureSsl: '跳过 TLS 证书校验',
|
|
287
|
+
insecureSslHint:
|
|
288
|
+
'公司代理 / HTTPS 解密 / 自签证书导致 fetch failed(如 UNABLE_TO_VERIFY_LEAF_SIGNATURE)时可勾选;安全性较低。',
|
|
289
|
+
defaultBranch: '默认同步分支',
|
|
290
|
+
defaultBranchPh: 'master / main / develop',
|
|
291
|
+
watched: '关注',
|
|
292
|
+
branch: '分支',
|
|
293
|
+
branchFilterPh: '过滤分支',
|
|
294
|
+
branchLoading: '分支加载中…',
|
|
295
|
+
branchNoMatch: '没有匹配的分支',
|
|
296
|
+
time: '时间',
|
|
297
|
+
repo: '仓库',
|
|
298
|
+
title: '说明',
|
|
299
|
+
author: '作者',
|
|
300
|
+
sha: 'SHA',
|
|
301
|
+
diff: '变更',
|
|
302
|
+
level: '级别',
|
|
303
|
+
levelInfo: '信息',
|
|
304
|
+
levelWarn: '警告',
|
|
305
|
+
levelError: '错误',
|
|
306
|
+
message: '内容',
|
|
307
|
+
syncInterval: '同步间隔(分钟)',
|
|
308
|
+
lookback: '回溯天数',
|
|
309
|
+
exportsPath: '导出目录',
|
|
310
|
+
exportsPathHint: '同步按日落盘与周期报告 Markdown 的目录;留空默认 ~/.dsh-commit-journal/exports',
|
|
311
|
+
recentYear: '近一年',
|
|
312
|
+
totalCommits: '提交总数',
|
|
313
|
+
activeDays: '活跃天数',
|
|
314
|
+
longestStreak: '最长连续',
|
|
315
|
+
maxDay: '单日最高',
|
|
316
|
+
diffTotal: '变更',
|
|
317
|
+
noteDiff: '{n} 条提交含行数统计',
|
|
318
|
+
noteDiffEmpty: '重新同步后可填充行数',
|
|
319
|
+
noData: '暂无数据,请先同步提交。',
|
|
320
|
+
confirmDelete: '确定删除该账号?',
|
|
321
|
+
confirmClearCommits: '清除该账号本地提交记录?',
|
|
322
|
+
confirmClearLogs: '清除同步日志?',
|
|
323
|
+
keyword: '关键词',
|
|
324
|
+
from: '开始',
|
|
325
|
+
to: '结束',
|
|
326
|
+
allRepos: '全部仓库',
|
|
327
|
+
openRepo: '打开',
|
|
328
|
+
repoKeyword: '搜索仓库',
|
|
329
|
+
pageOf: '页',
|
|
330
|
+
pageSizeLabel: '条/页',
|
|
331
|
+
totalItems: '共 {n} 条',
|
|
332
|
+
syncOk: '同步完成:新增 {n} 条(拉取 {f})',
|
|
333
|
+
syncPartial: '同步部分完成:新增 {n},{e} 个仓库出错',
|
|
334
|
+
refreshOk: '仓库列表已刷新',
|
|
335
|
+
saveWatchOk: '关注列表已保存',
|
|
336
|
+
testOk: '连接测试通过',
|
|
337
|
+
testScanOk: '扫描通过(发现 {n} 个仓库)',
|
|
338
|
+
activateOk: '已切换为当前账号',
|
|
339
|
+
saveOk: '已保存',
|
|
340
|
+
clearOk: '已清除',
|
|
341
|
+
queryOk: '已更新',
|
|
342
|
+
refreshScanOk: '已按根目录重新扫描',
|
|
343
|
+
currentStreak: '当前连续',
|
|
344
|
+
avgPerDay: '活跃日均',
|
|
345
|
+
peakOn: '峰值日期',
|
|
346
|
+
weekdayDist: '星期分布',
|
|
347
|
+
heatHint: '点击有提交的日期,右侧抽屉查看当日明细。',
|
|
348
|
+
activityFootnote:
|
|
349
|
+
'仅统计本地已同步的提交,按本地时区自然日归档。首次同步只回溯设置中的天数,更早的历史年份可能偏少;需要更完整的历史可在「设置 → 同步」调大回溯天数后重置记录再同步。',
|
|
350
|
+
dayEmpty: '当天没有提交记录',
|
|
351
|
+
less: '少',
|
|
352
|
+
more: '多',
|
|
353
|
+
noteTotal: '所选区间内全部提交',
|
|
354
|
+
noteActiveDays: '至少有一次提交',
|
|
355
|
+
noteStreak: '连续每天都有提交',
|
|
356
|
+
notePeak: '暂无记录',
|
|
357
|
+
unitDay: '天',
|
|
358
|
+
unitCommit: '条',
|
|
359
|
+
heatSummary: '共 {w} 周 · 活跃 {a} 天 · 合计 {c} 条',
|
|
360
|
+
dayLoading: '加载中',
|
|
361
|
+
dayCommits: '{n} 条提交',
|
|
362
|
+
filterAll: '全部',
|
|
363
|
+
filterWatched: '已关注',
|
|
364
|
+
filterUnwatched: '未关注',
|
|
365
|
+
descAccounts:
|
|
366
|
+
'每个账号可选远程(Codeup / GitLab / GitHub PAT)或本地(扫描根目录)。切换当前账号后,其它页签使用该账号数据。',
|
|
367
|
+
descRepos:
|
|
368
|
+
'「同步关注」拉取全部关注仓;单行可单独同步。未关注任何仓库时全量同步会覆盖全部可见仓。',
|
|
369
|
+
descReposLocal:
|
|
370
|
+
'「重新扫描」按根目录发现本机 git 仓;勾选关注后同步会执行 git log 写入本地缓存。',
|
|
371
|
+
descCommits: '查询本地已同步的提交记录;可按仓库、日期与关键词筛选。',
|
|
372
|
+
descActivity: '近一年 / 指定年份的提交活跃度。',
|
|
373
|
+
descLogs: '当前账号同步记录;错误行可查看具体仓库失败原因。',
|
|
374
|
+
descSettings:
|
|
375
|
+
'定时同步对所有账号生效(远程拉 API 或本地重扫)。回溯天数用于首次同步、重置记录后,以及调大该值后的下一次同步(会按新窗口回填一次历史);其余时间按上次同步时间增量拉取。',
|
|
376
|
+
syncSettingsTitle: '同步'
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const CSS = `
|
|
381
|
+
/* 与侧栏「新会话」同档(实测 #e5e5e5);挂 :root 以便 Modal/Toast portal 也能用 */
|
|
382
|
+
:root, .dsh-cj-root {
|
|
383
|
+
--dsh-cj-border: #e5e5e5;
|
|
384
|
+
--dsh-cj-border: color-mix(in srgb, var(--dsw-alias-label-primary, #000) 10%, transparent);
|
|
385
|
+
}
|
|
386
|
+
.dsh-cj-root {
|
|
387
|
+
--dsh-cj-heat-0: #ebedf0;
|
|
388
|
+
--dsh-cj-heat-1: #9be9a8;
|
|
389
|
+
--dsh-cj-heat-2: #40c463;
|
|
390
|
+
--dsh-cj-heat-3: #30a14e;
|
|
391
|
+
--dsh-cj-heat-4: #216e39;
|
|
392
|
+
--dsh-cj-add: var(--dsw-alias-state-success-primary, #16a34a);
|
|
393
|
+
--dsh-cj-del: var(--dsw-alias-state-error-primary, #dc2626);
|
|
394
|
+
position: relative;
|
|
395
|
+
box-sizing: border-box;
|
|
396
|
+
height: 100%;
|
|
397
|
+
display: flex;
|
|
398
|
+
flex-direction: column;
|
|
399
|
+
background: var(--dsw-alias-bg-base);
|
|
400
|
+
color: var(--dsw-alias-label-primary);
|
|
401
|
+
font-size: 13px;
|
|
402
|
+
line-height: 1.45;
|
|
403
|
+
overflow: hidden;
|
|
404
|
+
}
|
|
405
|
+
.dsh-cj-root[data-scheme="dark"],
|
|
406
|
+
:root[data-theme="dark"] .dsh-cj-root,
|
|
407
|
+
:root[data-color-scheme="dark"] .dsh-cj-root {
|
|
408
|
+
--dsh-cj-heat-0: #161b22;
|
|
409
|
+
--dsh-cj-heat-1: #0e4429;
|
|
410
|
+
--dsh-cj-heat-2: #006d32;
|
|
411
|
+
--dsh-cj-heat-3: #26a641;
|
|
412
|
+
--dsh-cj-heat-4: #39d353;
|
|
413
|
+
}
|
|
414
|
+
@media (prefers-color-scheme: dark) {
|
|
415
|
+
.dsh-cj-root:not([data-scheme="light"]) {
|
|
416
|
+
--dsh-cj-heat-0: #161b22;
|
|
417
|
+
--dsh-cj-heat-1: #0e4429;
|
|
418
|
+
--dsh-cj-heat-2: #006d32;
|
|
419
|
+
--dsh-cj-heat-3: #26a641;
|
|
420
|
+
--dsh-cj-heat-4: #39d353;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
.dsh-cj-root *, .dsh-cj-root *::before, .dsh-cj-root *::after { box-sizing: border-box; }
|
|
424
|
+
.dsh-cj-tabs {
|
|
425
|
+
display: flex;
|
|
426
|
+
gap: 4px;
|
|
427
|
+
padding: calc(var(--dsh-frame-top-clearance, 0px) + 12px) 20px 0;
|
|
428
|
+
border-bottom: 1px solid var(--dsh-cj-border);
|
|
429
|
+
flex-shrink: 0;
|
|
430
|
+
}
|
|
431
|
+
.dsh-cj-tab {
|
|
432
|
+
appearance: none;
|
|
433
|
+
border: 0;
|
|
434
|
+
background: transparent;
|
|
435
|
+
color: var(--dsw-alias-label-secondary);
|
|
436
|
+
padding: 10px 14px;
|
|
437
|
+
margin-bottom: -1px;
|
|
438
|
+
border-bottom: 2px solid transparent;
|
|
439
|
+
cursor: pointer;
|
|
440
|
+
font-size: 13px;
|
|
441
|
+
border-radius: 8px 8px 0 0;
|
|
442
|
+
}
|
|
443
|
+
.dsh-cj-tab[data-active="1"] {
|
|
444
|
+
color: var(--dsw-alias-label-primary);
|
|
445
|
+
border-bottom-color: var(--dsw-alias-brand-primary);
|
|
446
|
+
font-weight: 600;
|
|
447
|
+
}
|
|
448
|
+
.dsh-cj-body {
|
|
449
|
+
flex: 1;
|
|
450
|
+
min-height: 0;
|
|
451
|
+
overflow: hidden;
|
|
452
|
+
padding: 16px 20px 16px;
|
|
453
|
+
display: flex;
|
|
454
|
+
flex-direction: column;
|
|
455
|
+
}
|
|
456
|
+
/* Table pages: fill remaining height; table scrolls; pager stays put */
|
|
457
|
+
.dsh-cj-page-fill {
|
|
458
|
+
flex: 1;
|
|
459
|
+
min-height: 0;
|
|
460
|
+
display: flex;
|
|
461
|
+
flex-direction: column;
|
|
462
|
+
overflow: hidden;
|
|
463
|
+
}
|
|
464
|
+
.dsh-cj-page-fill > .dsh-cj-page-head,
|
|
465
|
+
.dsh-cj-page-fill > .dsh-cj-row,
|
|
466
|
+
.dsh-cj-page-fill > .dsh-cj-pager,
|
|
467
|
+
.dsh-cj-page-fill > .dsh-cj-muted,
|
|
468
|
+
.dsh-cj-page-fill > .dsh-cj-error {
|
|
469
|
+
flex-shrink: 0;
|
|
470
|
+
}
|
|
471
|
+
/* Non-table pages keep a single scroll area */
|
|
472
|
+
.dsh-cj-page-scroll {
|
|
473
|
+
flex: 1;
|
|
474
|
+
min-height: 0;
|
|
475
|
+
overflow: auto;
|
|
476
|
+
}
|
|
477
|
+
.dsh-cj-row {
|
|
478
|
+
display: flex;
|
|
479
|
+
flex-wrap: wrap;
|
|
480
|
+
gap: 8px;
|
|
481
|
+
align-items: center;
|
|
482
|
+
margin-bottom: 12px;
|
|
483
|
+
}
|
|
484
|
+
.dsh-cj-row-end { justify-content: space-between; }
|
|
485
|
+
.dsh-cj-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
|
486
|
+
.dsh-cj-table .dsh-cj-actions {
|
|
487
|
+
flex-wrap: nowrap;
|
|
488
|
+
gap: 6px;
|
|
489
|
+
justify-content: flex-end;
|
|
490
|
+
}
|
|
491
|
+
.dsh-cj-td-actions {
|
|
492
|
+
white-space: nowrap;
|
|
493
|
+
width: 1%;
|
|
494
|
+
vertical-align: middle !important;
|
|
495
|
+
}
|
|
496
|
+
.dsh-cj-td-clip {
|
|
497
|
+
max-width: 140px;
|
|
498
|
+
overflow: hidden;
|
|
499
|
+
text-overflow: ellipsis;
|
|
500
|
+
white-space: nowrap;
|
|
501
|
+
}
|
|
502
|
+
.dsh-cj-btn-icon.dsh-cj-btn-sized,
|
|
503
|
+
.dsh-cj-btn.dsh-cj-btn-icon {
|
|
504
|
+
padding: 0 8px !important;
|
|
505
|
+
min-width: 32px;
|
|
506
|
+
justify-content: center !important;
|
|
507
|
+
}
|
|
508
|
+
/* Size only — do not override official Button primary/outline colors */
|
|
509
|
+
.dsh-cj-btn-sized {
|
|
510
|
+
box-sizing: border-box !important;
|
|
511
|
+
height: 32px !important;
|
|
512
|
+
min-height: 32px !important;
|
|
513
|
+
max-height: 32px !important;
|
|
514
|
+
padding: 0 12px !important;
|
|
515
|
+
font-size: 12px !important;
|
|
516
|
+
line-height: 18px !important;
|
|
517
|
+
display: inline-flex !important;
|
|
518
|
+
align-items: center !important;
|
|
519
|
+
white-space: nowrap;
|
|
520
|
+
vertical-align: middle;
|
|
521
|
+
}
|
|
522
|
+
.dsh-cj-btn {
|
|
523
|
+
appearance: none;
|
|
524
|
+
box-sizing: border-box;
|
|
525
|
+
height: 32px;
|
|
526
|
+
min-height: 32px;
|
|
527
|
+
padding: 0 12px;
|
|
528
|
+
margin: 0;
|
|
529
|
+
border: 1px solid var(--dsh-cj-border, #e5e5e5);
|
|
530
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
531
|
+
color: var(--dsw-alias-label-primary);
|
|
532
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
533
|
+
font-size: 12px;
|
|
534
|
+
line-height: 18px;
|
|
535
|
+
cursor: pointer;
|
|
536
|
+
display: inline-flex;
|
|
537
|
+
align-items: center;
|
|
538
|
+
justify-content: center;
|
|
539
|
+
gap: 4px;
|
|
540
|
+
white-space: nowrap;
|
|
541
|
+
vertical-align: middle;
|
|
542
|
+
}
|
|
543
|
+
.dsh-cj-btn:disabled { opacity: .45; cursor: not-allowed; }
|
|
544
|
+
.dsh-cj-btn[data-primary="1"] {
|
|
545
|
+
background: var(--dsw-alias-brand-primary);
|
|
546
|
+
border-color: transparent;
|
|
547
|
+
color: #fff;
|
|
548
|
+
}
|
|
549
|
+
.dsh-cj-btn[data-danger="1"] {
|
|
550
|
+
color: var(--dsw-alias-state-error-primary);
|
|
551
|
+
border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 35%, transparent);
|
|
552
|
+
}
|
|
553
|
+
.dsh-cj-btn-danger {
|
|
554
|
+
color: var(--dsw-alias-state-error-primary) !important;
|
|
555
|
+
}
|
|
556
|
+
/* 控件描边与 --dsh-cj-border 同档;打到控件本身,不走官方 Input 偏浅的 l4 */
|
|
557
|
+
.dsh-cj-control,
|
|
558
|
+
.dsh-cj-input,
|
|
559
|
+
.dsh-cj-select,
|
|
560
|
+
.dsh-cj-select-trigger,
|
|
561
|
+
.dsh-cj-textarea {
|
|
562
|
+
box-sizing: border-box;
|
|
563
|
+
border: 1px solid var(--dsh-cj-border, #e5e5e5) !important;
|
|
564
|
+
border-radius: var(--dsw-radius-sm, 8px) !important;
|
|
565
|
+
background: var(--dsw-alias-bg-layer-1, #fff);
|
|
566
|
+
color: var(--dsw-alias-label-primary, #111);
|
|
567
|
+
}
|
|
568
|
+
.dsh-cj-control:focus-within,
|
|
569
|
+
.dsh-cj-input:focus,
|
|
570
|
+
.dsh-cj-select:focus,
|
|
571
|
+
.dsh-cj-select-trigger:focus,
|
|
572
|
+
.dsh-cj-select-trigger[aria-expanded="true"],
|
|
573
|
+
.dsh-cj-textarea:focus {
|
|
574
|
+
border-color: var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary, #1677ff)) !important;
|
|
575
|
+
outline: none !important;
|
|
576
|
+
}
|
|
577
|
+
.dsh-cj-input, .dsh-cj-select {
|
|
578
|
+
height: 32px;
|
|
579
|
+
min-height: 32px;
|
|
580
|
+
padding: 0 10px;
|
|
581
|
+
font-size: 12px;
|
|
582
|
+
line-height: 18px;
|
|
583
|
+
min-width: 0;
|
|
584
|
+
vertical-align: middle;
|
|
585
|
+
}
|
|
586
|
+
.dsh-cj-input[type="date"] {
|
|
587
|
+
min-width: 140px;
|
|
588
|
+
color-scheme: inherit;
|
|
589
|
+
}
|
|
590
|
+
.dsh-cj-select-trigger {
|
|
591
|
+
display: inline-flex !important;
|
|
592
|
+
align-items: center;
|
|
593
|
+
justify-content: space-between;
|
|
594
|
+
gap: 8px;
|
|
595
|
+
width: auto;
|
|
596
|
+
max-width: 100%;
|
|
597
|
+
min-width: 0;
|
|
598
|
+
height: 32px !important;
|
|
599
|
+
min-height: 32px !important;
|
|
600
|
+
max-height: 32px !important;
|
|
601
|
+
padding: 0 10px !important;
|
|
602
|
+
font-size: 12px !important;
|
|
603
|
+
line-height: 18px !important;
|
|
604
|
+
font-weight: 400 !important;
|
|
605
|
+
}
|
|
606
|
+
.dsh-cj-select-anchor {
|
|
607
|
+
display: block;
|
|
608
|
+
width: 100%;
|
|
609
|
+
max-width: 100%;
|
|
610
|
+
min-width: 0;
|
|
611
|
+
}
|
|
612
|
+
.dsh-cj-select-anchor .dsh-cj-select-trigger,
|
|
613
|
+
.dsh-cj-field .dsh-cj-select-trigger {
|
|
614
|
+
width: 100% !important;
|
|
615
|
+
}
|
|
616
|
+
.dsh-cj-select-trigger .dsh-cj-select-label {
|
|
617
|
+
overflow: hidden;
|
|
618
|
+
text-overflow: ellipsis;
|
|
619
|
+
white-space: nowrap;
|
|
620
|
+
min-width: 0;
|
|
621
|
+
flex: 1;
|
|
622
|
+
text-align: left;
|
|
623
|
+
}
|
|
624
|
+
.dsh-cj-select-trigger .dsh-cj-select-caret {
|
|
625
|
+
flex-shrink: 0;
|
|
626
|
+
opacity: 0.7;
|
|
627
|
+
font-size: 11px;
|
|
628
|
+
line-height: 1;
|
|
629
|
+
}
|
|
630
|
+
.dsh-cj-select-menu {
|
|
631
|
+
position: fixed;
|
|
632
|
+
z-index: 60;
|
|
633
|
+
max-height: min(280px, 50vh);
|
|
634
|
+
overflow: auto;
|
|
635
|
+
padding: 4px;
|
|
636
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
637
|
+
border: 1px solid var(--dsh-cj-border);
|
|
638
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1));
|
|
639
|
+
box-shadow: var(--dsw-elevation-prominent, 0 8px 24px rgba(0,0,0,.18));
|
|
640
|
+
}
|
|
641
|
+
/* 表体内的下拉挂在表体层,滚动时从下方穿过表头,不会盖住表头 */
|
|
642
|
+
.dsh-cj-select-menu.is-bound {
|
|
643
|
+
position: absolute;
|
|
644
|
+
z-index: 2;
|
|
645
|
+
}
|
|
646
|
+
.dsh-cj-select-menu.is-filterable {
|
|
647
|
+
display: flex;
|
|
648
|
+
flex-direction: column;
|
|
649
|
+
overflow: hidden;
|
|
650
|
+
padding: 0;
|
|
651
|
+
}
|
|
652
|
+
.dsh-cj-select-filter {
|
|
653
|
+
flex: none;
|
|
654
|
+
padding: 6px;
|
|
655
|
+
border-bottom: 1px solid var(--dsh-cj-border);
|
|
656
|
+
}
|
|
657
|
+
.dsh-cj-select-filter .dsh-cj-input {
|
|
658
|
+
display: block;
|
|
659
|
+
width: 100%;
|
|
660
|
+
height: 28px;
|
|
661
|
+
min-height: 28px;
|
|
662
|
+
}
|
|
663
|
+
.dsh-cj-select-list {
|
|
664
|
+
overflow: auto;
|
|
665
|
+
min-height: 0;
|
|
666
|
+
padding: 4px;
|
|
667
|
+
}
|
|
668
|
+
.dsh-cj-select-status {
|
|
669
|
+
display: flex;
|
|
670
|
+
align-items: center;
|
|
671
|
+
gap: 8px;
|
|
672
|
+
padding: 10px;
|
|
673
|
+
color: var(--dsw-alias-label-secondary);
|
|
674
|
+
font-size: 12px;
|
|
675
|
+
line-height: 18px;
|
|
676
|
+
}
|
|
677
|
+
.dsh-cj-select-spin {
|
|
678
|
+
width: 14px;
|
|
679
|
+
height: 14px;
|
|
680
|
+
flex: none;
|
|
681
|
+
border-radius: 50%;
|
|
682
|
+
border: 2px solid var(--dsh-cj-border);
|
|
683
|
+
border-top-color: var(--dsw-alias-brand-primary, #1677ff);
|
|
684
|
+
animation: dsh-cj-spin 0.7s linear infinite;
|
|
685
|
+
}
|
|
686
|
+
@keyframes dsh-cj-spin { to { transform: rotate(360deg); } }
|
|
687
|
+
.dsh-cj-select-option {
|
|
688
|
+
appearance: none;
|
|
689
|
+
display: block;
|
|
690
|
+
width: 100%;
|
|
691
|
+
border: 0;
|
|
692
|
+
background: transparent;
|
|
693
|
+
color: var(--dsw-alias-label-primary);
|
|
694
|
+
text-align: left;
|
|
695
|
+
border-radius: 6px;
|
|
696
|
+
padding: 8px 10px;
|
|
697
|
+
font-size: 14px;
|
|
698
|
+
line-height: 22px;
|
|
699
|
+
cursor: pointer;
|
|
700
|
+
}
|
|
701
|
+
.dsh-cj-select-option:hover,
|
|
702
|
+
.dsh-cj-select-option[data-active="1"] {
|
|
703
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
704
|
+
}
|
|
705
|
+
.dsh-cj-select-option[data-selected="1"] {
|
|
706
|
+
color: var(--dsw-alias-brand-primary);
|
|
707
|
+
font-weight: 600;
|
|
708
|
+
}
|
|
709
|
+
.dsh-cj-select-option:disabled {
|
|
710
|
+
opacity: 0.45;
|
|
711
|
+
cursor: not-allowed;
|
|
712
|
+
}
|
|
713
|
+
.dsh-cj-textarea {
|
|
714
|
+
display: block;
|
|
715
|
+
width: 100%;
|
|
716
|
+
max-width: 100%;
|
|
717
|
+
min-width: 0;
|
|
718
|
+
padding: 8px 10px;
|
|
719
|
+
margin: 0;
|
|
720
|
+
font-size: 12px;
|
|
721
|
+
line-height: 18px;
|
|
722
|
+
font-family: inherit;
|
|
723
|
+
min-height: 72px;
|
|
724
|
+
resize: vertical;
|
|
725
|
+
outline: none;
|
|
726
|
+
}
|
|
727
|
+
/* dimmed 太浅;用 secondary 并取消 Firefox 默认降低透明度 */
|
|
728
|
+
.dsh-cj-textarea::placeholder,
|
|
729
|
+
.dsh-cj-input::placeholder {
|
|
730
|
+
color: var(--dsw-alias-label-secondary, #737373);
|
|
731
|
+
opacity: 1;
|
|
732
|
+
}
|
|
733
|
+
/* Official Input wrapper also lands at 32px */
|
|
734
|
+
.dsh-cj-row > span {
|
|
735
|
+
vertical-align: middle;
|
|
736
|
+
}
|
|
737
|
+
.dsh-cj-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
|
|
738
|
+
.dsh-cj-account-form {
|
|
739
|
+
width: min(640px, calc(100vw - 48px));
|
|
740
|
+
max-width: 100%;
|
|
741
|
+
}
|
|
742
|
+
.dsh-cj-form-row {
|
|
743
|
+
display: grid;
|
|
744
|
+
grid-template-columns: 1fr 1fr;
|
|
745
|
+
gap: 0 12px;
|
|
746
|
+
align-items: start;
|
|
747
|
+
}
|
|
748
|
+
.dsh-cj-form-span {
|
|
749
|
+
grid-column: 1 / -1;
|
|
750
|
+
}
|
|
751
|
+
.dsh-cj-field-check {
|
|
752
|
+
margin-top: 2px;
|
|
753
|
+
}
|
|
754
|
+
.dsh-cj-field-check .dsh-cj-label {
|
|
755
|
+
display: flex;
|
|
756
|
+
align-items: center;
|
|
757
|
+
gap: 8px;
|
|
758
|
+
font-weight: 400;
|
|
759
|
+
cursor: pointer;
|
|
760
|
+
user-select: none;
|
|
761
|
+
}
|
|
762
|
+
@media (max-width: 560px) {
|
|
763
|
+
.dsh-cj-form-row { grid-template-columns: 1fr; }
|
|
764
|
+
.dsh-cj-account-form { width: 100%; }
|
|
765
|
+
}
|
|
766
|
+
/* 官方 Input 外层是 inline-flex + align-items:center;拉满宽度时不能改成 block,否则 placeholder 不垂直居中 */
|
|
767
|
+
.dsh-cj-field > span {
|
|
768
|
+
display: inline-flex;
|
|
769
|
+
align-items: center;
|
|
770
|
+
box-sizing: border-box;
|
|
771
|
+
width: 100%;
|
|
772
|
+
max-width: 100%;
|
|
773
|
+
min-width: 0;
|
|
774
|
+
}
|
|
775
|
+
.dsh-cj-field .dsh-cj-input {
|
|
776
|
+
box-sizing: border-box;
|
|
777
|
+
width: 100%;
|
|
778
|
+
max-width: 100%;
|
|
779
|
+
min-width: 0;
|
|
780
|
+
}
|
|
781
|
+
.dsh-cj-label { color: var(--dsw-alias-label-secondary); font-size: 12px; }
|
|
782
|
+
.dsh-cj-muted { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 1.45; }
|
|
783
|
+
.dsh-cj-page-head { margin-bottom: 14px; }
|
|
784
|
+
.dsh-cj-page-title {
|
|
785
|
+
margin: 0 0 6px;
|
|
786
|
+
font-size: 16px;
|
|
787
|
+
font-weight: 650;
|
|
788
|
+
color: var(--dsw-alias-label-primary);
|
|
789
|
+
}
|
|
790
|
+
.dsh-cj-page-desc {
|
|
791
|
+
margin: 0;
|
|
792
|
+
color: var(--dsw-alias-label-secondary);
|
|
793
|
+
font-size: 12px;
|
|
794
|
+
line-height: 1.55;
|
|
795
|
+
}
|
|
796
|
+
.dsh-cj-footnote {
|
|
797
|
+
margin: 12px 0 0;
|
|
798
|
+
color: var(--dsw-alias-label-secondary);
|
|
799
|
+
font-size: 12px;
|
|
800
|
+
line-height: 1.55;
|
|
801
|
+
}
|
|
802
|
+
.dsh-cj-error { color: var(--dsw-alias-state-error-primary); font-size: 12px; margin: 0 0 10px; }
|
|
803
|
+
/* 表头固定在滚动区外;滚动条只出现在表体 */
|
|
804
|
+
.dsh-cj-table-wrap {
|
|
805
|
+
flex: 1;
|
|
806
|
+
min-height: 0;
|
|
807
|
+
border: 1px solid var(--dsh-cj-border);
|
|
808
|
+
border-radius: 12px;
|
|
809
|
+
overflow: hidden;
|
|
810
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
811
|
+
display: flex;
|
|
812
|
+
flex-direction: column;
|
|
813
|
+
}
|
|
814
|
+
.dsh-cj-page-scroll > .dsh-cj-table-wrap {
|
|
815
|
+
flex: initial;
|
|
816
|
+
min-height: auto;
|
|
817
|
+
max-height: none;
|
|
818
|
+
}
|
|
819
|
+
.dsh-cj-table-head {
|
|
820
|
+
flex: none;
|
|
821
|
+
overflow: hidden;
|
|
822
|
+
position: relative;
|
|
823
|
+
z-index: 5;
|
|
824
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
825
|
+
border-bottom: 1px solid var(--dsh-cj-border);
|
|
826
|
+
}
|
|
827
|
+
.dsh-cj-table-body {
|
|
828
|
+
flex: 1 1 auto;
|
|
829
|
+
min-height: 0;
|
|
830
|
+
overflow: auto;
|
|
831
|
+
position: relative;
|
|
832
|
+
z-index: 1;
|
|
833
|
+
}
|
|
834
|
+
/* 账号页整页滚动,表格随内容增高,不单独出滚动条 */
|
|
835
|
+
.dsh-cj-page-scroll .dsh-cj-table-body {
|
|
836
|
+
flex: none;
|
|
837
|
+
min-height: auto;
|
|
838
|
+
overflow: visible;
|
|
839
|
+
}
|
|
840
|
+
.dsh-cj-table { width: 100%; border-collapse: collapse; }
|
|
841
|
+
.dsh-cj-table th, .dsh-cj-table td {
|
|
842
|
+
padding: 10px 12px;
|
|
843
|
+
text-align: left;
|
|
844
|
+
border-bottom: 1px solid var(--dsh-cj-border);
|
|
845
|
+
vertical-align: top;
|
|
846
|
+
overflow-wrap: anywhere;
|
|
847
|
+
}
|
|
848
|
+
.dsh-cj-table th {
|
|
849
|
+
font-weight: 600;
|
|
850
|
+
color: var(--dsw-alias-label-secondary);
|
|
851
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
852
|
+
border-bottom: 0;
|
|
853
|
+
}
|
|
854
|
+
.dsh-cj-table tr:last-child td { border-bottom: 0; }
|
|
855
|
+
.dsh-cj-table-wrap .dsh-cj-td-clip { max-width: none; }
|
|
856
|
+
.dsh-cj-table .dsh-cj-td-actions { overflow-wrap: normal; }
|
|
857
|
+
/* Fallback Tag tones (match official Tag.module.css) */
|
|
858
|
+
.dsh-cj-tag {
|
|
859
|
+
display: inline-flex;
|
|
860
|
+
align-items: center;
|
|
861
|
+
border-radius: 999px;
|
|
862
|
+
padding: 1px 8px;
|
|
863
|
+
font-size: 11px;
|
|
864
|
+
line-height: 17px;
|
|
865
|
+
font-weight: 500;
|
|
866
|
+
white-space: nowrap;
|
|
867
|
+
}
|
|
868
|
+
.dsh-cj-tag[data-tone="outline"] {
|
|
869
|
+
border: 0.5px solid var(--dsw-alias-border-l4, var(--dsh-cj-border));
|
|
870
|
+
color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary));
|
|
871
|
+
}
|
|
872
|
+
.dsh-cj-tag[data-tone="solid"] {
|
|
873
|
+
background: var(--dsw-alias-label-primary);
|
|
874
|
+
color: var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-layer-1));
|
|
875
|
+
}
|
|
876
|
+
.dsh-cj-tag[data-tone="neutral"] {
|
|
877
|
+
background: var(--dsw-alias-bg-module-platform, var(--dsw-alias-bg-layer-2));
|
|
878
|
+
color: var(--dsw-alias-label-secondary);
|
|
879
|
+
}
|
|
880
|
+
.dsh-cj-tag[data-tone="success"] {
|
|
881
|
+
background: color-mix(in srgb, var(--dsw-alias-state-success-primary, #16a34a) 10%, transparent);
|
|
882
|
+
color: var(--dsw-alias-state-success-primary, #16a34a);
|
|
883
|
+
}
|
|
884
|
+
.dsh-cj-tag[data-tone="info"] {
|
|
885
|
+
background: color-mix(in srgb, var(--dsw-alias-state-business-primary, #2563eb) 10%, transparent);
|
|
886
|
+
color: var(--dsw-alias-state-business-primary, #2563eb);
|
|
887
|
+
}
|
|
888
|
+
.dsh-cj-tag[data-tone="warning"] {
|
|
889
|
+
background: color-mix(in srgb, var(--dsw-alias-state-warn-primary, #d97706) 12%, transparent);
|
|
890
|
+
color: var(--dsw-alias-state-warn-primary, #d97706);
|
|
891
|
+
}
|
|
892
|
+
.dsh-cj-tag[data-tone="danger"] {
|
|
893
|
+
background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent);
|
|
894
|
+
color: var(--dsw-alias-state-error-primary);
|
|
895
|
+
}
|
|
896
|
+
/* Fallback modal: paint below native caption so top-right DSH controls stay usable */
|
|
897
|
+
.dsh-cj-modal-mask {
|
|
898
|
+
position: fixed;
|
|
899
|
+
inset: var(--dsh-frame-chrome-top, 0px) 0 0;
|
|
900
|
+
background: var(--dsw-alias-bg-mask-1, color-mix(in srgb, #000 40%, transparent));
|
|
901
|
+
display: flex; align-items: center; justify-content: center; z-index: 40;
|
|
902
|
+
padding: max(24px, var(--dsh-frame-overlay-top, 24px)) 24px;
|
|
903
|
+
}
|
|
904
|
+
.dsh-cj-modal {
|
|
905
|
+
width: min(480px, 100%);
|
|
906
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1));
|
|
907
|
+
border: 1px solid var(--dsh-cj-border);
|
|
908
|
+
border-radius: var(--dsw-radius-panel, 14px);
|
|
909
|
+
padding: 16px;
|
|
910
|
+
max-height: 100%;
|
|
911
|
+
overflow: auto;
|
|
912
|
+
box-shadow: var(--dsw-elevation-prominent, none);
|
|
913
|
+
}
|
|
914
|
+
.dsh-cj-modal-wide {
|
|
915
|
+
width: min(680px, 100%);
|
|
916
|
+
}
|
|
917
|
+
.dsh-cj-modal h3 { margin: 0 0 12px; font-size: 15px; }
|
|
918
|
+
.dsh-cj-stats {
|
|
919
|
+
display: grid;
|
|
920
|
+
grid-template-columns: repeat(5, minmax(0, 1fr));
|
|
921
|
+
gap: 10px;
|
|
922
|
+
margin: 4px 0 16px;
|
|
923
|
+
}
|
|
924
|
+
.dsh-cj-add {
|
|
925
|
+
color: var(--dsh-cj-add);
|
|
926
|
+
font-variant-numeric: tabular-nums;
|
|
927
|
+
}
|
|
928
|
+
.dsh-cj-del {
|
|
929
|
+
color: var(--dsh-cj-del);
|
|
930
|
+
font-variant-numeric: tabular-nums;
|
|
931
|
+
}
|
|
932
|
+
.dsh-cj-diff {
|
|
933
|
+
display: inline;
|
|
934
|
+
font-variant-numeric: tabular-nums;
|
|
935
|
+
white-space: nowrap;
|
|
936
|
+
}
|
|
937
|
+
.dsh-cj-diff .dsh-cj-diff-sep {
|
|
938
|
+
color: var(--dsw-alias-label-secondary);
|
|
939
|
+
}
|
|
940
|
+
.dsh-cj-stat {
|
|
941
|
+
position: relative;
|
|
942
|
+
overflow: hidden;
|
|
943
|
+
display: flex;
|
|
944
|
+
flex-direction: column;
|
|
945
|
+
min-height: 92px;
|
|
946
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
947
|
+
border: 1px solid var(--dsh-cj-border);
|
|
948
|
+
border-radius: 12px;
|
|
949
|
+
padding: 12px 14px 13px;
|
|
950
|
+
}
|
|
951
|
+
.dsh-cj-stat .l {
|
|
952
|
+
position: relative;
|
|
953
|
+
z-index: 1;
|
|
954
|
+
color: var(--dsw-alias-label-secondary);
|
|
955
|
+
font-size: 12px;
|
|
956
|
+
letter-spacing: 0.04em;
|
|
957
|
+
}
|
|
958
|
+
.dsh-cj-stat .v {
|
|
959
|
+
position: relative;
|
|
960
|
+
z-index: 1;
|
|
961
|
+
margin-top: 4px;
|
|
962
|
+
font-size: 26px;
|
|
963
|
+
font-weight: 700;
|
|
964
|
+
line-height: 32px;
|
|
965
|
+
min-height: 32px;
|
|
966
|
+
color: var(--dsh-cj-heat-3);
|
|
967
|
+
font-variant-numeric: tabular-nums;
|
|
968
|
+
}
|
|
969
|
+
/* 须写在 .v 之后;与其它卡共用行高,底栏才能对齐 */
|
|
970
|
+
.dsh-cj-stat .v.v-diff {
|
|
971
|
+
font-size: 22px;
|
|
972
|
+
letter-spacing: -0.02em;
|
|
973
|
+
line-height: 32px;
|
|
974
|
+
min-height: 32px;
|
|
975
|
+
color: var(--dsw-alias-label-secondary);
|
|
976
|
+
min-width: 0;
|
|
977
|
+
white-space: nowrap;
|
|
978
|
+
overflow: hidden;
|
|
979
|
+
text-overflow: ellipsis;
|
|
980
|
+
}
|
|
981
|
+
.dsh-cj-stat .v small {
|
|
982
|
+
margin-left: 4px;
|
|
983
|
+
font-size: 12px;
|
|
984
|
+
font-weight: 500;
|
|
985
|
+
color: var(--dsw-alias-label-secondary);
|
|
986
|
+
}
|
|
987
|
+
.dsh-cj-stat .n {
|
|
988
|
+
position: relative;
|
|
989
|
+
z-index: 1;
|
|
990
|
+
margin-top: auto;
|
|
991
|
+
padding-top: 0;
|
|
992
|
+
font-size: 12px;
|
|
993
|
+
line-height: 16px;
|
|
994
|
+
color: var(--dsw-alias-label-secondary);
|
|
995
|
+
min-height: 16px;
|
|
996
|
+
}
|
|
997
|
+
.dsh-cj-heat {
|
|
998
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
999
|
+
border: 1px solid var(--dsh-cj-border);
|
|
1000
|
+
border-radius: 12px;
|
|
1001
|
+
padding: 14px 16px 12px;
|
|
1002
|
+
overflow-x: hidden;
|
|
1003
|
+
container-type: inline-size;
|
|
1004
|
+
}
|
|
1005
|
+
.dsh-cj-heat-body {
|
|
1006
|
+
--dsh-cj-cell: clamp(9px, calc((100cqw - 48px) / 53), 13px);
|
|
1007
|
+
--dsh-cj-gap: 3px;
|
|
1008
|
+
display: flex;
|
|
1009
|
+
align-items: flex-start;
|
|
1010
|
+
gap: 8px;
|
|
1011
|
+
width: 100%;
|
|
1012
|
+
}
|
|
1013
|
+
.dsh-cj-heat-main { min-width: 0; }
|
|
1014
|
+
.dsh-cj-months {
|
|
1015
|
+
display: grid;
|
|
1016
|
+
grid-auto-flow: column;
|
|
1017
|
+
grid-auto-columns: calc(var(--dsh-cj-cell) + var(--dsh-cj-gap));
|
|
1018
|
+
height: 16px;
|
|
1019
|
+
margin-bottom: 4px;
|
|
1020
|
+
color: var(--dsw-alias-label-secondary);
|
|
1021
|
+
font-size: 11px;
|
|
1022
|
+
line-height: 16px;
|
|
1023
|
+
user-select: none;
|
|
1024
|
+
}
|
|
1025
|
+
.dsh-cj-months .dsh-cj-month {
|
|
1026
|
+
white-space: nowrap;
|
|
1027
|
+
}
|
|
1028
|
+
.dsh-cj-weekdays {
|
|
1029
|
+
display: grid;
|
|
1030
|
+
grid-template-rows: repeat(7, var(--dsh-cj-cell));
|
|
1031
|
+
gap: var(--dsh-cj-gap);
|
|
1032
|
+
padding-top: 20px;
|
|
1033
|
+
color: var(--dsw-alias-label-secondary);
|
|
1034
|
+
font-size: 10px;
|
|
1035
|
+
line-height: var(--dsh-cj-cell);
|
|
1036
|
+
user-select: none;
|
|
1037
|
+
width: 14px;
|
|
1038
|
+
flex: none;
|
|
1039
|
+
}
|
|
1040
|
+
.dsh-cj-weekdays span {
|
|
1041
|
+
height: var(--dsh-cj-cell);
|
|
1042
|
+
display: flex;
|
|
1043
|
+
align-items: center;
|
|
1044
|
+
justify-content: flex-end;
|
|
1045
|
+
}
|
|
1046
|
+
.dsh-cj-grid {
|
|
1047
|
+
display: grid;
|
|
1048
|
+
grid-auto-flow: column;
|
|
1049
|
+
grid-template-rows: repeat(7, var(--dsh-cj-cell));
|
|
1050
|
+
grid-auto-columns: var(--dsh-cj-cell);
|
|
1051
|
+
gap: var(--dsh-cj-gap);
|
|
1052
|
+
}
|
|
1053
|
+
.dsh-cj-cell {
|
|
1054
|
+
width: var(--dsh-cj-cell);
|
|
1055
|
+
height: var(--dsh-cj-cell);
|
|
1056
|
+
border-radius: max(3px, calc(var(--dsh-cj-cell) * 0.2));
|
|
1057
|
+
border: 0;
|
|
1058
|
+
padding: 0;
|
|
1059
|
+
background: var(--dsh-cj-heat-0);
|
|
1060
|
+
}
|
|
1061
|
+
.dsh-cj-cell.lv1 { background: var(--dsh-cj-heat-1); }
|
|
1062
|
+
.dsh-cj-cell.lv2 { background: var(--dsh-cj-heat-2); }
|
|
1063
|
+
.dsh-cj-cell.lv3 { background: var(--dsh-cj-heat-3); }
|
|
1064
|
+
.dsh-cj-cell.lv4 { background: var(--dsh-cj-heat-4); }
|
|
1065
|
+
.dsh-cj-cell.is-blank {
|
|
1066
|
+
opacity: .45;
|
|
1067
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsh-cj-border) 80%, transparent);
|
|
1068
|
+
}
|
|
1069
|
+
.dsh-cj-cell.has-commits { cursor: pointer; }
|
|
1070
|
+
.dsh-cj-cell.has-commits:hover {
|
|
1071
|
+
transform: scale(1.2);
|
|
1072
|
+
position: relative;
|
|
1073
|
+
z-index: 2;
|
|
1074
|
+
}
|
|
1075
|
+
.dsh-cj-cell.is-today { outline: 1px solid var(--dsh-cj-heat-3); outline-offset: 1px; }
|
|
1076
|
+
.dsh-cj-heat-foot {
|
|
1077
|
+
display: flex;
|
|
1078
|
+
align-items: center;
|
|
1079
|
+
justify-content: space-between;
|
|
1080
|
+
flex-wrap: wrap;
|
|
1081
|
+
gap: 10px;
|
|
1082
|
+
margin-top: 14px;
|
|
1083
|
+
font-size: 12px;
|
|
1084
|
+
color: var(--dsw-alias-label-secondary);
|
|
1085
|
+
}
|
|
1086
|
+
.dsh-cj-heat-legend {
|
|
1087
|
+
display: flex; align-items: center; gap: 5px;
|
|
1088
|
+
}
|
|
1089
|
+
.dsh-cj-heat-legend .swatch {
|
|
1090
|
+
width: 12px; height: 12px; border-radius: 3px; display: inline-block;
|
|
1091
|
+
background: var(--dsh-cj-heat-0);
|
|
1092
|
+
}
|
|
1093
|
+
.dsh-cj-heat-legend .swatch.lv1 { background: var(--dsh-cj-heat-1); }
|
|
1094
|
+
.dsh-cj-heat-legend .swatch.lv2 { background: var(--dsh-cj-heat-2); }
|
|
1095
|
+
.dsh-cj-heat-legend .swatch.lv3 { background: var(--dsh-cj-heat-3); }
|
|
1096
|
+
.dsh-cj-heat-legend .swatch.lv4 { background: var(--dsh-cj-heat-4); }
|
|
1097
|
+
.dsh-cj-insights {
|
|
1098
|
+
display: grid;
|
|
1099
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1100
|
+
gap: 12px;
|
|
1101
|
+
margin-top: 14px;
|
|
1102
|
+
}
|
|
1103
|
+
.dsh-cj-insight {
|
|
1104
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
1105
|
+
border: 1px solid var(--dsh-cj-border);
|
|
1106
|
+
border-radius: 12px;
|
|
1107
|
+
padding: 12px 14px;
|
|
1108
|
+
}
|
|
1109
|
+
.dsh-cj-insight h4 {
|
|
1110
|
+
margin: 0 0 10px;
|
|
1111
|
+
font-size: 12px;
|
|
1112
|
+
font-weight: 600;
|
|
1113
|
+
color: var(--dsw-alias-label-secondary);
|
|
1114
|
+
}
|
|
1115
|
+
.dsh-cj-wd {
|
|
1116
|
+
display: grid;
|
|
1117
|
+
grid-template-columns: 18px 1fr 28px;
|
|
1118
|
+
gap: 8px;
|
|
1119
|
+
align-items: center;
|
|
1120
|
+
margin-bottom: 6px;
|
|
1121
|
+
font-size: 11px;
|
|
1122
|
+
color: var(--dsw-alias-label-secondary);
|
|
1123
|
+
}
|
|
1124
|
+
.dsh-cj-wd:last-child { margin-bottom: 0; }
|
|
1125
|
+
.dsh-cj-wd-bar {
|
|
1126
|
+
height: 6px;
|
|
1127
|
+
border-radius: 999px;
|
|
1128
|
+
background: color-mix(in srgb, var(--dsh-cj-border) 70%, transparent);
|
|
1129
|
+
overflow: hidden;
|
|
1130
|
+
}
|
|
1131
|
+
.dsh-cj-wd-bar > i {
|
|
1132
|
+
display: block;
|
|
1133
|
+
height: 100%;
|
|
1134
|
+
border-radius: 999px;
|
|
1135
|
+
background: var(--dsh-cj-heat-3);
|
|
1136
|
+
}
|
|
1137
|
+
.dsh-cj-meta-list {
|
|
1138
|
+
display: flex;
|
|
1139
|
+
flex-direction: column;
|
|
1140
|
+
gap: 8px;
|
|
1141
|
+
font-size: 12px;
|
|
1142
|
+
}
|
|
1143
|
+
.dsh-cj-meta-list div { display: flex; justify-content: space-between; gap: 12px; }
|
|
1144
|
+
.dsh-cj-meta-list strong { color: var(--dsw-alias-label-primary); font-weight: 600; }
|
|
1145
|
+
@media (max-width: 720px) {
|
|
1146
|
+
.dsh-cj-insights { grid-template-columns: 1fr; }
|
|
1147
|
+
}
|
|
1148
|
+
.dsh-cj-drawer {
|
|
1149
|
+
position: absolute;
|
|
1150
|
+
top: 0;
|
|
1151
|
+
right: 0;
|
|
1152
|
+
bottom: 0;
|
|
1153
|
+
z-index: 20;
|
|
1154
|
+
width: min(400px, 94%);
|
|
1155
|
+
display: flex;
|
|
1156
|
+
flex-direction: column;
|
|
1157
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1));
|
|
1158
|
+
border-left: 1px solid var(--dsh-cj-border);
|
|
1159
|
+
box-shadow: var(--dsw-elevation-prominent, none);
|
|
1160
|
+
padding: 14px 16px 16px;
|
|
1161
|
+
}
|
|
1162
|
+
.dsh-cj-drawer-head {
|
|
1163
|
+
display: flex;
|
|
1164
|
+
align-items: center;
|
|
1165
|
+
justify-content: space-between;
|
|
1166
|
+
gap: 8px;
|
|
1167
|
+
margin-bottom: 12px;
|
|
1168
|
+
flex-shrink: 0;
|
|
1169
|
+
}
|
|
1170
|
+
.dsh-cj-drawer-body {
|
|
1171
|
+
flex: 1;
|
|
1172
|
+
min-height: 0;
|
|
1173
|
+
overflow: auto;
|
|
1174
|
+
}
|
|
1175
|
+
.dsh-cj-drawer-title {
|
|
1176
|
+
display: flex;
|
|
1177
|
+
flex-direction: column;
|
|
1178
|
+
gap: 2px;
|
|
1179
|
+
min-width: 0;
|
|
1180
|
+
}
|
|
1181
|
+
.dsh-cj-drawer-title strong { font-size: 15px; font-weight: 600; }
|
|
1182
|
+
.dsh-cj-drawer-title span {
|
|
1183
|
+
font-size: 12px;
|
|
1184
|
+
font-weight: 400;
|
|
1185
|
+
color: var(--dsw-alias-label-secondary);
|
|
1186
|
+
}
|
|
1187
|
+
.dsh-cj-commit {
|
|
1188
|
+
padding: 11px 13px 12px;
|
|
1189
|
+
margin-bottom: 10px;
|
|
1190
|
+
border-radius: 12px;
|
|
1191
|
+
border: 1px solid var(--dsh-cj-border);
|
|
1192
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
1193
|
+
}
|
|
1194
|
+
.dsh-cj-commit:last-child { margin-bottom: 0; }
|
|
1195
|
+
.dsh-cj-commit-head {
|
|
1196
|
+
display: flex;
|
|
1197
|
+
align-items: center;
|
|
1198
|
+
justify-content: space-between;
|
|
1199
|
+
gap: 10px;
|
|
1200
|
+
font-size: 12px;
|
|
1201
|
+
color: var(--dsw-alias-label-secondary);
|
|
1202
|
+
}
|
|
1203
|
+
.dsh-cj-commit-repo {
|
|
1204
|
+
overflow: hidden;
|
|
1205
|
+
text-overflow: ellipsis;
|
|
1206
|
+
white-space: nowrap;
|
|
1207
|
+
}
|
|
1208
|
+
.dsh-cj-commit-title {
|
|
1209
|
+
margin-top: 5px;
|
|
1210
|
+
font-size: 13px;
|
|
1211
|
+
line-height: 1.55;
|
|
1212
|
+
word-break: break-word;
|
|
1213
|
+
}
|
|
1214
|
+
.dsh-cj-commit-meta {
|
|
1215
|
+
display: flex;
|
|
1216
|
+
align-items: center;
|
|
1217
|
+
gap: 8px;
|
|
1218
|
+
margin-top: 6px;
|
|
1219
|
+
font-size: 12px;
|
|
1220
|
+
color: var(--dsw-alias-label-secondary);
|
|
1221
|
+
}
|
|
1222
|
+
.dsh-cj-commit-sha {
|
|
1223
|
+
padding: 1px 6px;
|
|
1224
|
+
border-radius: 5px;
|
|
1225
|
+
border: 1px solid var(--dsh-cj-border);
|
|
1226
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1));
|
|
1227
|
+
font-size: 11px;
|
|
1228
|
+
}
|
|
1229
|
+
.dsh-cj-pager {
|
|
1230
|
+
flex-shrink: 0;
|
|
1231
|
+
display: flex;
|
|
1232
|
+
justify-content: flex-end;
|
|
1233
|
+
gap: 6px;
|
|
1234
|
+
align-items: center;
|
|
1235
|
+
margin-top: 4px;
|
|
1236
|
+
padding: 12px 0 2px;
|
|
1237
|
+
border-top: 1px solid var(--dsh-cj-border);
|
|
1238
|
+
}
|
|
1239
|
+
.dsh-cj-pager-info {
|
|
1240
|
+
margin-right: auto;
|
|
1241
|
+
color: var(--dsw-alias-label-secondary);
|
|
1242
|
+
font-size: 12px;
|
|
1243
|
+
}
|
|
1244
|
+
.dsh-cj-pager-size {
|
|
1245
|
+
display: inline-flex;
|
|
1246
|
+
align-items: center;
|
|
1247
|
+
gap: 6px;
|
|
1248
|
+
color: var(--dsw-alias-label-secondary);
|
|
1249
|
+
font-size: 12px;
|
|
1250
|
+
}
|
|
1251
|
+
.dsh-cj-pager-size .dsh-cj-select-trigger {
|
|
1252
|
+
min-width: 72px;
|
|
1253
|
+
}
|
|
1254
|
+
.dsh-cj-link {
|
|
1255
|
+
color: var(--dsw-alias-brand-primary);
|
|
1256
|
+
text-decoration: none;
|
|
1257
|
+
}
|
|
1258
|
+
.dsh-cj-toast-fallback {
|
|
1259
|
+
position: fixed;
|
|
1260
|
+
top: 16px;
|
|
1261
|
+
left: 50%;
|
|
1262
|
+
transform: translateX(-50%);
|
|
1263
|
+
z-index: 10000;
|
|
1264
|
+
max-width: min(520px, calc(100vw - 24px));
|
|
1265
|
+
padding: 10px 14px;
|
|
1266
|
+
border-radius: 10px;
|
|
1267
|
+
font-size: 12px;
|
|
1268
|
+
line-height: 1.45;
|
|
1269
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1));
|
|
1270
|
+
border: 1px solid var(--dsh-cj-border);
|
|
1271
|
+
color: var(--dsw-alias-label-primary);
|
|
1272
|
+
box-shadow: var(--dsw-elevation-prominent, 0 8px 24px rgba(0,0,0,.18));
|
|
1273
|
+
pointer-events: none;
|
|
1274
|
+
}
|
|
1275
|
+
.dsh-cj-toast-fallback[data-tone="success"] {
|
|
1276
|
+
background: color-mix(in srgb, var(--dsh-cj-heat-2) 18%, var(--dsw-alias-bg-layer-1));
|
|
1277
|
+
border-color: color-mix(in srgb, var(--dsh-cj-heat-3) 35%, var(--dsh-cj-border));
|
|
1278
|
+
}
|
|
1279
|
+
.dsh-cj-toast-fallback[data-tone="error"] {
|
|
1280
|
+
background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, var(--dsw-alias-bg-layer-1));
|
|
1281
|
+
border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 35%, var(--dsh-cj-border));
|
|
1282
|
+
color: var(--dsw-alias-state-error-primary);
|
|
1283
|
+
}
|
|
1284
|
+
.dsh-cj-seg {
|
|
1285
|
+
display: inline-flex;
|
|
1286
|
+
gap: 2px;
|
|
1287
|
+
padding: 2px;
|
|
1288
|
+
border-radius: 8px;
|
|
1289
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
1290
|
+
border: 1px solid var(--dsh-cj-border);
|
|
1291
|
+
}
|
|
1292
|
+
.dsh-cj-seg button {
|
|
1293
|
+
appearance: none;
|
|
1294
|
+
border: 0;
|
|
1295
|
+
background: transparent;
|
|
1296
|
+
color: var(--dsw-alias-label-secondary);
|
|
1297
|
+
border-radius: 6px;
|
|
1298
|
+
padding: 5px 10px;
|
|
1299
|
+
font-size: 12px;
|
|
1300
|
+
cursor: pointer;
|
|
1301
|
+
}
|
|
1302
|
+
.dsh-cj-seg button[data-active="1"] {
|
|
1303
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
1304
|
+
color: var(--dsw-alias-label-primary);
|
|
1305
|
+
font-weight: 600;
|
|
1306
|
+
box-shadow: var(--dsw-elevation-subtle, none);
|
|
1307
|
+
}
|
|
1308
|
+
@media (max-width: 720px) {
|
|
1309
|
+
.dsh-cj-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1310
|
+
}
|
|
1311
|
+
`
|
|
1312
|
+
|
|
1313
|
+
// Strip Codeup 24-char org id prefix from path_with_namespace for UI labels
|
|
1314
|
+
function shortRepoLabel(path) {
|
|
1315
|
+
const raw = String(path || '').trim()
|
|
1316
|
+
if (!raw) return ''
|
|
1317
|
+
const parts = raw.split('/').filter(Boolean)
|
|
1318
|
+
if (parts.length <= 1) return raw
|
|
1319
|
+
if (/^[a-f0-9]{24}$/i.test(parts[0])) return parts.slice(1).join('/') || raw
|
|
1320
|
+
return raw
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
// 大数压缩显示,避免窄卡溢出(活跃卡优先短格式,减少省略号)
|
|
1324
|
+
function formatCompactNum(n) {
|
|
1325
|
+
const num = Number(n) || 0
|
|
1326
|
+
const abs = Math.abs(num)
|
|
1327
|
+
if (abs >= 1e6) {
|
|
1328
|
+
const v = num / 1e6
|
|
1329
|
+
return (abs >= 1e7 ? v.toFixed(0) : v.toFixed(1).replace(/\.0$/, '')) + 'M'
|
|
1330
|
+
}
|
|
1331
|
+
if (abs >= 10000) return Math.round(num / 1000) + 'k'
|
|
1332
|
+
if (abs >= 1000) {
|
|
1333
|
+
return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'k'
|
|
1334
|
+
}
|
|
1335
|
+
return String(num)
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// 提交增删行汇总文案(tooltip 等);无数据返回空
|
|
1339
|
+
function formatDiffStats(c) {
|
|
1340
|
+
if (!c || (c.additions == null && c.deletions == null)) return ''
|
|
1341
|
+
const a = c.additions != null ? c.additions : 0
|
|
1342
|
+
const d = c.deletions != null ? c.deletions : 0
|
|
1343
|
+
let s = '+' + a + ' −' + d
|
|
1344
|
+
if (c.filesChanged != null) s += ' · ' + c.filesChanged + ' files'
|
|
1345
|
+
return s
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// 增删分色节点;无数据返回 null。opts: files / compact
|
|
1349
|
+
function renderDiffStats(c, opts) {
|
|
1350
|
+
if (!c || (c.additions == null && c.deletions == null)) return null
|
|
1351
|
+
const a = c.additions != null ? c.additions : 0
|
|
1352
|
+
const d = c.deletions != null ? c.deletions : 0
|
|
1353
|
+
const compact = Boolean(opts && opts.compact)
|
|
1354
|
+
const showFiles = opts && opts.files !== false && c.filesChanged != null
|
|
1355
|
+
const aText = '+' + (compact ? formatCompactNum(a) : a)
|
|
1356
|
+
const dText = '−' + (compact ? formatCompactNum(d) : d)
|
|
1357
|
+
const full = formatDiffStats(c)
|
|
1358
|
+
return h('span', { className: 'dsh-cj-diff', title: full },
|
|
1359
|
+
h('span', { className: 'dsh-cj-add' }, aText),
|
|
1360
|
+
h('span', { className: 'dsh-cj-diff-sep' }, ' '),
|
|
1361
|
+
h('span', { className: 'dsh-cj-del' }, dText),
|
|
1362
|
+
showFiles
|
|
1363
|
+
? h('span', { className: 'dsh-cj-muted' }, ' · ' + c.filesChanged + ' files')
|
|
1364
|
+
: null
|
|
1365
|
+
)
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
function fillMsg(tpl, vars) {
|
|
1369
|
+
return String(tpl || '').replace(/\{(\w+)\}/g, (_, k) => String(vars[k] ?? ''))
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
function syncToastText(t, result) {
|
|
1373
|
+
const inserted = result && result.inserted != null ? result.inserted : 0
|
|
1374
|
+
const fetched = result && result.fetched != null ? result.fetched : 0
|
|
1375
|
+
const errN = result && result.errors ? result.errors.length : 0
|
|
1376
|
+
if (errN) return fillMsg(t('syncPartial'), { n: inserted, e: errN })
|
|
1377
|
+
return fillMsg(t('syncOk'), { n: inserted, f: fetched })
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
async function api(path, options) {
|
|
1381
|
+
const res = await fetch(API + path, {
|
|
1382
|
+
headers: { 'Content-Type': 'application/json', ...(options && options.headers) },
|
|
1383
|
+
...options
|
|
1384
|
+
})
|
|
1385
|
+
const text = await res.text()
|
|
1386
|
+
let data = null
|
|
1387
|
+
try { data = text ? JSON.parse(text) : null } catch { data = { error: text } }
|
|
1388
|
+
if (!res.ok) throw new Error((data && data.error) || res.statusText || 'request failed')
|
|
1389
|
+
return data
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
function PageHead({ desc }) {
|
|
1393
|
+
if (!desc) return null
|
|
1394
|
+
return h('div', { className: 'dsh-cj-page-head' },
|
|
1395
|
+
h('p', { className: 'dsh-cj-page-desc' }, desc)
|
|
1396
|
+
)
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
const PAGE_SIZE_OPTIONS = [10, 20, 50, 100]
|
|
1400
|
+
|
|
1401
|
+
function StatusTag({ tone, children }) {
|
|
1402
|
+
if (UiTag) return h(UiTag, { tone: tone || 'outline' }, children)
|
|
1403
|
+
return h('span', { className: 'dsh-cj-tag', 'data-tone': tone || 'outline' }, children)
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* 自定义下拉:弹出层挂到 portal / fixed,避免原生 select 撑出 App 容器
|
|
1408
|
+
*/
|
|
1409
|
+
function SelectField({
|
|
1410
|
+
value,
|
|
1411
|
+
options,
|
|
1412
|
+
onChange,
|
|
1413
|
+
disabled,
|
|
1414
|
+
style,
|
|
1415
|
+
className,
|
|
1416
|
+
placeholder,
|
|
1417
|
+
onOpen,
|
|
1418
|
+
boundScroll,
|
|
1419
|
+
filterable,
|
|
1420
|
+
filterPlaceholder,
|
|
1421
|
+
loading,
|
|
1422
|
+
loadingLabel,
|
|
1423
|
+
emptyLabel,
|
|
1424
|
+
'aria-label': ariaLabel,
|
|
1425
|
+
title
|
|
1426
|
+
}) {
|
|
1427
|
+
const [open, setOpen] = useState(false)
|
|
1428
|
+
const [query, setQuery] = useState('')
|
|
1429
|
+
const anchorRef = useRef(null)
|
|
1430
|
+
const menuRef = useRef(null)
|
|
1431
|
+
const filterRef = useRef(null)
|
|
1432
|
+
const [menuStyle, setMenuStyle] = useState(null)
|
|
1433
|
+
const list = options || []
|
|
1434
|
+
const q = filterable ? query.trim().toLowerCase() : ''
|
|
1435
|
+
const shown = q
|
|
1436
|
+
? list.filter((o) => String(o.label || '').toLowerCase().includes(q) || String(o.value || '').toLowerCase().includes(q))
|
|
1437
|
+
: list
|
|
1438
|
+
const selected = list.find((o) => String(o.value) === String(value))
|
|
1439
|
+
const label = selected ? selected.label : (placeholder || '')
|
|
1440
|
+
|
|
1441
|
+
const close = useCallback(() => setOpen(false), [])
|
|
1442
|
+
|
|
1443
|
+
const openMenu = useCallback(() => {
|
|
1444
|
+
if (disabled) return
|
|
1445
|
+
setOpen(true)
|
|
1446
|
+
if (onOpen) onOpen()
|
|
1447
|
+
}, [disabled, onOpen])
|
|
1448
|
+
|
|
1449
|
+
const pick = useCallback((next) => {
|
|
1450
|
+
onChange(next)
|
|
1451
|
+
setOpen(false)
|
|
1452
|
+
}, [onChange])
|
|
1453
|
+
|
|
1454
|
+
useEffect(() => {
|
|
1455
|
+
if (!open) setQuery('')
|
|
1456
|
+
}, [open])
|
|
1457
|
+
|
|
1458
|
+
const filterFocused = useRef(false)
|
|
1459
|
+
useEffect(() => {
|
|
1460
|
+
if (!open) {
|
|
1461
|
+
filterFocused.current = false
|
|
1462
|
+
return undefined
|
|
1463
|
+
}
|
|
1464
|
+
if (!filterable || !menuStyle || filterFocused.current) return undefined
|
|
1465
|
+
const id = requestAnimationFrame(() => {
|
|
1466
|
+
const input = filterRef.current
|
|
1467
|
+
if (!input) return
|
|
1468
|
+
input.focus({ preventScroll: true })
|
|
1469
|
+
filterFocused.current = true
|
|
1470
|
+
})
|
|
1471
|
+
return () => cancelAnimationFrame(id)
|
|
1472
|
+
}, [open, filterable, menuStyle])
|
|
1473
|
+
|
|
1474
|
+
useEffect(() => {
|
|
1475
|
+
if (!open || (UiMenu && !boundScroll)) return undefined
|
|
1476
|
+
const place = () => {
|
|
1477
|
+
const el = anchorRef.current
|
|
1478
|
+
if (!el) return
|
|
1479
|
+
const scrollBody = boundScroll ? el.closest('.dsh-cj-table-body') : null
|
|
1480
|
+
const a = el.getBoundingClientRect()
|
|
1481
|
+
if (scrollBody) {
|
|
1482
|
+
const b = scrollBody.getBoundingClientRect()
|
|
1483
|
+
if (a.bottom <= b.top || a.top >= b.bottom) {
|
|
1484
|
+
close()
|
|
1485
|
+
return
|
|
1486
|
+
}
|
|
1487
|
+
const width = Math.max(a.width, filterable ? 220 : 120)
|
|
1488
|
+
const rows = loading ? 1 : list.length
|
|
1489
|
+
const chrome = filterable ? 44 : 0
|
|
1490
|
+
const estimate = Math.min(280, Math.max(rows * 38 + 8 + chrome, 40 + chrome))
|
|
1491
|
+
const spaceBelow = Math.max(0, b.bottom - a.bottom - 8)
|
|
1492
|
+
const spaceAbove = Math.max(0, a.top - b.top - 8)
|
|
1493
|
+
let topVp = a.bottom + 4
|
|
1494
|
+
let height = Math.min(estimate, Math.max(spaceBelow, 40))
|
|
1495
|
+
if (spaceBelow < Math.min(estimate, 120) && spaceAbove > spaceBelow) {
|
|
1496
|
+
height = Math.min(estimate, Math.max(spaceAbove, 40))
|
|
1497
|
+
topVp = a.top - 4 - height
|
|
1498
|
+
}
|
|
1499
|
+
// 不把弹出层钉在可视区顶部:它跟行一起滚,越过表头时由表头盖住
|
|
1500
|
+
const leftVp = Math.min(Math.max(a.left, b.left), Math.max(b.left, b.right - width))
|
|
1501
|
+
setMenuStyle({
|
|
1502
|
+
position: 'absolute',
|
|
1503
|
+
left: Math.round(leftVp - b.left + scrollBody.scrollLeft) + 'px',
|
|
1504
|
+
top: Math.round(topVp - b.top + scrollBody.scrollTop) + 'px',
|
|
1505
|
+
width: Math.round(width) + 'px',
|
|
1506
|
+
maxHeight: Math.round(height) + 'px'
|
|
1507
|
+
})
|
|
1508
|
+
return
|
|
1509
|
+
}
|
|
1510
|
+
const root = el.closest('.dsh-cj-root') || document.body
|
|
1511
|
+
const bound = root.getBoundingClientRect()
|
|
1512
|
+
const width = Math.max(a.width, 120)
|
|
1513
|
+
const maxH = Math.min(280, Math.max(120, bound.height - 16))
|
|
1514
|
+
let left = Math.min(Math.max(a.left, bound.left + 8), bound.right - width - 8)
|
|
1515
|
+
let top = a.bottom + 4
|
|
1516
|
+
if (top + Math.min(maxH, list.length * 32 + 12) > bound.bottom - 8) {
|
|
1517
|
+
top = Math.max(bound.top + 8, a.top - 4 - Math.min(maxH, list.length * 32 + 12))
|
|
1518
|
+
}
|
|
1519
|
+
setMenuStyle({
|
|
1520
|
+
position: 'fixed',
|
|
1521
|
+
left: Math.round(left) + 'px',
|
|
1522
|
+
top: Math.round(top) + 'px',
|
|
1523
|
+
width: Math.round(width) + 'px',
|
|
1524
|
+
maxHeight: Math.round(maxH) + 'px'
|
|
1525
|
+
})
|
|
1526
|
+
}
|
|
1527
|
+
place()
|
|
1528
|
+
const onDoc = (e) => {
|
|
1529
|
+
const t = e.target
|
|
1530
|
+
if (anchorRef.current && anchorRef.current.contains(t)) return
|
|
1531
|
+
if (menuRef.current && menuRef.current.contains(t)) return
|
|
1532
|
+
close()
|
|
1533
|
+
}
|
|
1534
|
+
const onKey = (e) => { if (e.key === 'Escape') close() }
|
|
1535
|
+
window.addEventListener('resize', place)
|
|
1536
|
+
window.addEventListener('scroll', place, true)
|
|
1537
|
+
document.addEventListener('mousedown', onDoc, true)
|
|
1538
|
+
document.addEventListener('keydown', onKey, true)
|
|
1539
|
+
return () => {
|
|
1540
|
+
window.removeEventListener('resize', place)
|
|
1541
|
+
window.removeEventListener('scroll', place, true)
|
|
1542
|
+
document.removeEventListener('mousedown', onDoc, true)
|
|
1543
|
+
document.removeEventListener('keydown', onKey, true)
|
|
1544
|
+
}
|
|
1545
|
+
}, [boundScroll, close, filterable, list.length, loading, open])
|
|
1546
|
+
|
|
1547
|
+
const trigger = h('button', {
|
|
1548
|
+
ref: anchorRef,
|
|
1549
|
+
type: 'button',
|
|
1550
|
+
className: ['dsh-cj-btn', 'dsh-cj-btn-sized', 'dsh-cj-control', 'dsh-cj-select-trigger', className].filter(Boolean).join(' '),
|
|
1551
|
+
style,
|
|
1552
|
+
disabled: !!disabled,
|
|
1553
|
+
title: title || ariaLabel || undefined,
|
|
1554
|
+
'aria-label': ariaLabel,
|
|
1555
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
1556
|
+
'aria-haspopup': 'listbox',
|
|
1557
|
+
onClick: () => { if (open) close(); else openMenu() }
|
|
1558
|
+
},
|
|
1559
|
+
h('span', { className: 'dsh-cj-select-label' }, label || '—'),
|
|
1560
|
+
h('span', { className: 'dsh-cj-select-caret', 'aria-hidden': true },
|
|
1561
|
+
IconChevronDown ? h(IconChevronDown) : '▾'
|
|
1562
|
+
)
|
|
1563
|
+
)
|
|
1564
|
+
|
|
1565
|
+
if (UiMenu && !boundScroll) {
|
|
1566
|
+
const emptyId = '__dsh_cj_empty__'
|
|
1567
|
+
const toId = (v) => (v == null || v === '' ? emptyId : String(v))
|
|
1568
|
+
const fromId = (id) => {
|
|
1569
|
+
if (id === emptyId) {
|
|
1570
|
+
const hit = list.find((o) => o.value == null || o.value === '')
|
|
1571
|
+
return hit ? hit.value : ''
|
|
1572
|
+
}
|
|
1573
|
+
const hit = list.find((o) => String(o.value) === id)
|
|
1574
|
+
return hit ? hit.value : id
|
|
1575
|
+
}
|
|
1576
|
+
return h(UiMenu, {
|
|
1577
|
+
open,
|
|
1578
|
+
onClose: close,
|
|
1579
|
+
portal: true,
|
|
1580
|
+
minWidthFromAnchor: true,
|
|
1581
|
+
selection: 'check',
|
|
1582
|
+
selectedId: toId(value),
|
|
1583
|
+
items: list.map((o) => ({
|
|
1584
|
+
id: toId(o.value),
|
|
1585
|
+
label: o.label,
|
|
1586
|
+
disabled: !!o.disabled
|
|
1587
|
+
})),
|
|
1588
|
+
onSelect: (id) => { pick(fromId(id)) },
|
|
1589
|
+
anchor: h('span', {
|
|
1590
|
+
ref: anchorRef,
|
|
1591
|
+
className: 'dsh-cj-select-anchor',
|
|
1592
|
+
style: style && style.width === '100%'
|
|
1593
|
+
? { display: 'block', width: '100%', maxWidth: '100%' }
|
|
1594
|
+
: { display: 'inline-flex', maxWidth: '100%' },
|
|
1595
|
+
onClick: (e) => {
|
|
1596
|
+
if (disabled) return
|
|
1597
|
+
e.preventDefault()
|
|
1598
|
+
if (open) close()
|
|
1599
|
+
else openMenu()
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
h('button', {
|
|
1603
|
+
type: 'button',
|
|
1604
|
+
className: ['dsh-cj-btn', 'dsh-cj-btn-sized', 'dsh-cj-control', 'dsh-cj-select-trigger', className].filter(Boolean).join(' '),
|
|
1605
|
+
style,
|
|
1606
|
+
disabled: !!disabled,
|
|
1607
|
+
title: title || ariaLabel || undefined,
|
|
1608
|
+
'aria-label': ariaLabel,
|
|
1609
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
1610
|
+
'aria-haspopup': 'listbox'
|
|
1611
|
+
},
|
|
1612
|
+
h('span', { className: 'dsh-cj-select-label' }, label || '—'),
|
|
1613
|
+
h('span', { className: 'dsh-cj-select-caret', 'aria-hidden': true },
|
|
1614
|
+
IconChevronDown ? h(IconChevronDown) : '▾'
|
|
1615
|
+
)
|
|
1616
|
+
)
|
|
1617
|
+
)
|
|
1618
|
+
})
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
const scrollBody = boundScroll && anchorRef.current
|
|
1622
|
+
? anchorRef.current.closest('.dsh-cj-table-body')
|
|
1623
|
+
: null
|
|
1624
|
+
const optionNodes = shown.map((o) =>
|
|
1625
|
+
h('button', {
|
|
1626
|
+
key: String(o.value),
|
|
1627
|
+
type: 'button',
|
|
1628
|
+
role: 'option',
|
|
1629
|
+
className: 'dsh-cj-select-option',
|
|
1630
|
+
disabled: !!o.disabled,
|
|
1631
|
+
'data-selected': String(o.value) === String(value) ? '1' : '0',
|
|
1632
|
+
'aria-selected': String(o.value) === String(value),
|
|
1633
|
+
onClick: () => pick(o.value)
|
|
1634
|
+
}, o.label)
|
|
1635
|
+
)
|
|
1636
|
+
const menuBody = loading
|
|
1637
|
+
? h('div', { className: 'dsh-cj-select-status', role: 'status' },
|
|
1638
|
+
h('span', { className: 'dsh-cj-select-spin', 'aria-hidden': true }),
|
|
1639
|
+
loadingLabel || '…'
|
|
1640
|
+
)
|
|
1641
|
+
: (optionNodes.length
|
|
1642
|
+
? optionNodes
|
|
1643
|
+
: (filterable
|
|
1644
|
+
? h('div', { className: 'dsh-cj-select-status' }, emptyLabel || '—')
|
|
1645
|
+
: null))
|
|
1646
|
+
const menu = open && menuStyle
|
|
1647
|
+
? h('div', {
|
|
1648
|
+
ref: menuRef,
|
|
1649
|
+
className: [
|
|
1650
|
+
'dsh-cj-select-menu',
|
|
1651
|
+
scrollBody ? 'is-bound' : '',
|
|
1652
|
+
filterable ? 'is-filterable' : ''
|
|
1653
|
+
].filter(Boolean).join(' '),
|
|
1654
|
+
role: 'listbox',
|
|
1655
|
+
style: menuStyle,
|
|
1656
|
+
onWheel: scrollBody ? (e) => e.stopPropagation() : undefined
|
|
1657
|
+
},
|
|
1658
|
+
filterable
|
|
1659
|
+
? h('div', { className: 'dsh-cj-select-filter' },
|
|
1660
|
+
h('input', {
|
|
1661
|
+
ref: filterRef,
|
|
1662
|
+
className: 'dsh-cj-input',
|
|
1663
|
+
type: 'text',
|
|
1664
|
+
value: query,
|
|
1665
|
+
placeholder: filterPlaceholder || '',
|
|
1666
|
+
'aria-label': filterPlaceholder || ariaLabel,
|
|
1667
|
+
onChange: (e) => setQuery(e.target.value)
|
|
1668
|
+
})
|
|
1669
|
+
)
|
|
1670
|
+
: null,
|
|
1671
|
+
filterable
|
|
1672
|
+
? h('div', { className: 'dsh-cj-select-list' }, menuBody)
|
|
1673
|
+
: menuBody
|
|
1674
|
+
)
|
|
1675
|
+
: null
|
|
1676
|
+
|
|
1677
|
+
const portalNode = scrollBody || document.body
|
|
1678
|
+
return h(React.Fragment, null,
|
|
1679
|
+
trigger,
|
|
1680
|
+
menu && ReactDOM && ReactDOM.createPortal
|
|
1681
|
+
? ReactDOM.createPortal(menu, portalNode)
|
|
1682
|
+
: menu
|
|
1683
|
+
)
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* 表格底部分页:总数、每页条数、左右翻页
|
|
1688
|
+
*/
|
|
1689
|
+
function TablePager({ t, total, page, pageSize, busy, onPageChange, onPageSizeChange }) {
|
|
1690
|
+
const totalPages = Math.max(1, Math.ceil((total || 0) / pageSize))
|
|
1691
|
+
const safePage = Math.min(Math.max(1, page || 1), totalPages)
|
|
1692
|
+
return h('div', { className: 'dsh-cj-pager' },
|
|
1693
|
+
h('span', { className: 'dsh-cj-pager-info' },
|
|
1694
|
+
fillMsg(t('totalItems'), { n: total || 0 }) + ' · ' + safePage + ' / ' + totalPages
|
|
1695
|
+
),
|
|
1696
|
+
h('label', { className: 'dsh-cj-pager-size' },
|
|
1697
|
+
h(SelectField, {
|
|
1698
|
+
value: pageSize,
|
|
1699
|
+
disabled: busy,
|
|
1700
|
+
'aria-label': t('pageSizeLabel'),
|
|
1701
|
+
style: { minWidth: 72 },
|
|
1702
|
+
options: PAGE_SIZE_OPTIONS.map((n) => ({ value: n, label: String(n) })),
|
|
1703
|
+
onChange: (n) => onPageSizeChange(Number(n))
|
|
1704
|
+
}),
|
|
1705
|
+
h('span', null, t('pageSizeLabel'))
|
|
1706
|
+
),
|
|
1707
|
+
h(Btn, {
|
|
1708
|
+
disabled: busy || safePage <= 1,
|
|
1709
|
+
icon: IconChevronLeft ? h(IconChevronLeft) : null,
|
|
1710
|
+
onClick: () => onPageChange(safePage - 1)
|
|
1711
|
+
}, IconChevronLeft ? null : '‹'),
|
|
1712
|
+
h(Btn, {
|
|
1713
|
+
disabled: busy || safePage >= totalPages,
|
|
1714
|
+
icon: IconChevronRight ? h(IconChevronRight) : null,
|
|
1715
|
+
onClick: () => onPageChange(safePage + 1)
|
|
1716
|
+
}, IconChevronRight ? null : '›')
|
|
1717
|
+
)
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
function logLevelTag(t, level) {
|
|
1721
|
+
const key = String(level || '').toLowerCase()
|
|
1722
|
+
if (key === 'error') return h(StatusTag, { tone: 'danger' }, t('levelError'))
|
|
1723
|
+
if (key === 'warn' || key === 'warning') return h(StatusTag, { tone: 'warning' }, t('levelWarn'))
|
|
1724
|
+
return h(StatusTag, { tone: 'info' }, t('levelInfo'))
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
function Btn(props) {
|
|
1728
|
+
const { primary, danger, icon, children, className, ...rest } = props
|
|
1729
|
+
if (UiButton) {
|
|
1730
|
+
return h(UiButton, {
|
|
1731
|
+
type: 'button',
|
|
1732
|
+
variant: primary ? 'primary' : 'outline',
|
|
1733
|
+
size: 'sm',
|
|
1734
|
+
icon: icon || undefined,
|
|
1735
|
+
className: ['dsh-cj-btn-sized', danger ? 'dsh-cj-btn-danger' : '', className].filter(Boolean).join(' ') || undefined,
|
|
1736
|
+
...rest
|
|
1737
|
+
}, children)
|
|
1738
|
+
}
|
|
1739
|
+
return h('button', {
|
|
1740
|
+
type: 'button',
|
|
1741
|
+
className: ['dsh-cj-btn', className].filter(Boolean).join(' '),
|
|
1742
|
+
'data-primary': primary ? '1' : undefined,
|
|
1743
|
+
'data-danger': danger ? '1' : undefined,
|
|
1744
|
+
...rest
|
|
1745
|
+
}, icon || null, children)
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
function FieldInput(props) {
|
|
1749
|
+
const { className, ...rest } = props
|
|
1750
|
+
// 不用官方 Input:其默认 border-l4 比侧栏「新会话」浅,且内部样式会盖过 className
|
|
1751
|
+
const merged = ['dsh-cj-input', 'dsh-cj-control', className].filter(Boolean).join(' ')
|
|
1752
|
+
return h('input', { className: merged, ...rest })
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
function editionLabel(t, edition) {
|
|
1756
|
+
return edition === 'region' ? t('editionRegion') : t('editionCentral')
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
function accountModeLabel(t, mode) {
|
|
1760
|
+
return mode === 'local' ? t('modeLocalShort') : t('modeRemoteShort')
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
function providerLabel(t, provider) {
|
|
1764
|
+
if (provider === 'gitlab') return t('providerGitlab')
|
|
1765
|
+
if (provider === 'github') return t('providerGithub')
|
|
1766
|
+
if (provider === 'local') return t('modeLocalShort')
|
|
1767
|
+
return t('providerCodeup')
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
function accountOrgCell(a) {
|
|
1771
|
+
if (a.mode === 'local') {
|
|
1772
|
+
const roots = a.localRoots || []
|
|
1773
|
+
if (!roots.length) return '-'
|
|
1774
|
+
return roots.length === 1 ? roots[0] : roots[0] + ' (+' + (roots.length - 1) + ')'
|
|
1775
|
+
}
|
|
1776
|
+
return a.organizationId || a.apiBaseUrl || '-'
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
function remoteProviderFields(form, setForm, t, mode) {
|
|
1780
|
+
const provider = form.provider || 'codeup'
|
|
1781
|
+
const tokenPh =
|
|
1782
|
+
mode === 'edit'
|
|
1783
|
+
? t('tokenPhEdit')
|
|
1784
|
+
: provider === 'github'
|
|
1785
|
+
? t('tokenPhGithub')
|
|
1786
|
+
: provider === 'gitlab'
|
|
1787
|
+
? t('tokenPhGitlab')
|
|
1788
|
+
: t('tokenPh')
|
|
1789
|
+
|
|
1790
|
+
const providerField = h('div', { className: 'dsh-cj-field' },
|
|
1791
|
+
h('label', { className: 'dsh-cj-label' }, t('provider')),
|
|
1792
|
+
h(SelectField, {
|
|
1793
|
+
value: provider,
|
|
1794
|
+
style: { width: '100%' },
|
|
1795
|
+
'aria-label': t('provider'),
|
|
1796
|
+
options: [
|
|
1797
|
+
{ value: 'codeup', label: t('providerCodeup') },
|
|
1798
|
+
{ value: 'gitlab', label: t('providerGitlab') },
|
|
1799
|
+
{ value: 'github', label: t('providerGithub') }
|
|
1800
|
+
],
|
|
1801
|
+
onChange: (v) => setForm({ ...form, provider: v })
|
|
1802
|
+
})
|
|
1803
|
+
)
|
|
1804
|
+
|
|
1805
|
+
const tokenRow = h(React.Fragment, null,
|
|
1806
|
+
h('div', { className: 'dsh-cj-field dsh-cj-form-span' },
|
|
1807
|
+
h('label', { className: 'dsh-cj-label' }, t('token')),
|
|
1808
|
+
h(FieldInput, {
|
|
1809
|
+
type: 'password',
|
|
1810
|
+
value: form.token,
|
|
1811
|
+
placeholder: tokenPh,
|
|
1812
|
+
title: tokenPh,
|
|
1813
|
+
onChange: (e) => setForm({ ...form, token: e.target.value })
|
|
1814
|
+
})
|
|
1815
|
+
),
|
|
1816
|
+
h('div', { className: 'dsh-cj-field dsh-cj-field-check dsh-cj-form-span' },
|
|
1817
|
+
h('label', { className: 'dsh-cj-label', title: t('insecureSslHint') },
|
|
1818
|
+
h('input', {
|
|
1819
|
+
type: 'checkbox',
|
|
1820
|
+
checked: !!form.insecureSsl,
|
|
1821
|
+
onChange: (e) => setForm({ ...form, insecureSsl: e.target.checked })
|
|
1822
|
+
}),
|
|
1823
|
+
t('insecureSsl')
|
|
1824
|
+
)
|
|
1825
|
+
)
|
|
1826
|
+
)
|
|
1827
|
+
|
|
1828
|
+
if (provider === 'gitlab' || provider === 'github') {
|
|
1829
|
+
return h(React.Fragment, null,
|
|
1830
|
+
h('div', { className: 'dsh-cj-form-row' },
|
|
1831
|
+
providerField,
|
|
1832
|
+
h('div', { className: 'dsh-cj-field' },
|
|
1833
|
+
h('label', { className: 'dsh-cj-label' },
|
|
1834
|
+
provider === 'github' ? t('orgIdLabelGithub') : t('orgIdLabelGitlab')
|
|
1835
|
+
),
|
|
1836
|
+
h(FieldInput, {
|
|
1837
|
+
value: form.organizationId,
|
|
1838
|
+
placeholder: provider === 'github' ? t('orgIdPhGithub') : t('orgIdPhGitlab'),
|
|
1839
|
+
title: provider === 'github' ? t('orgIdPhGithub') : t('orgIdPhGitlab'),
|
|
1840
|
+
onChange: (e) => setForm({ ...form, organizationId: e.target.value })
|
|
1841
|
+
})
|
|
1842
|
+
)
|
|
1843
|
+
),
|
|
1844
|
+
h('div', { className: 'dsh-cj-form-row' },
|
|
1845
|
+
h('div', { className: 'dsh-cj-field dsh-cj-form-span' },
|
|
1846
|
+
h('label', { className: 'dsh-cj-label' }, t('apiBase')),
|
|
1847
|
+
h(FieldInput, {
|
|
1848
|
+
value: form.apiBaseUrl,
|
|
1849
|
+
placeholder: provider === 'github' ? t('apiBasePhGithub') : t('apiBasePhGitlab'),
|
|
1850
|
+
title: provider === 'github' ? t('apiBaseHintGithub') : t('apiBaseHintGitlab'),
|
|
1851
|
+
onChange: (e) => setForm({ ...form, apiBaseUrl: e.target.value })
|
|
1852
|
+
})
|
|
1853
|
+
)
|
|
1854
|
+
),
|
|
1855
|
+
h('div', { className: 'dsh-cj-form-row' }, tokenRow)
|
|
1856
|
+
)
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
return h(React.Fragment, null,
|
|
1860
|
+
h('div', { className: 'dsh-cj-form-row' },
|
|
1861
|
+
providerField,
|
|
1862
|
+
h('div', { className: 'dsh-cj-field' },
|
|
1863
|
+
h('label', { className: 'dsh-cj-label' }, t('edition')),
|
|
1864
|
+
h(SelectField, {
|
|
1865
|
+
value: form.edition,
|
|
1866
|
+
style: { width: '100%' },
|
|
1867
|
+
'aria-label': t('edition'),
|
|
1868
|
+
options: [
|
|
1869
|
+
{ value: 'central', label: t('editionCentral') },
|
|
1870
|
+
{ value: 'region', label: t('editionRegion') }
|
|
1871
|
+
],
|
|
1872
|
+
onChange: (v) => setForm({ ...form, edition: v })
|
|
1873
|
+
})
|
|
1874
|
+
)
|
|
1875
|
+
),
|
|
1876
|
+
h('div', { className: 'dsh-cj-form-row' },
|
|
1877
|
+
form.edition === 'central'
|
|
1878
|
+
? h('div', { className: 'dsh-cj-field dsh-cj-form-span' },
|
|
1879
|
+
h('label', { className: 'dsh-cj-label' }, t('orgId')),
|
|
1880
|
+
h(FieldInput, {
|
|
1881
|
+
value: form.organizationId,
|
|
1882
|
+
placeholder: t('orgIdPh'),
|
|
1883
|
+
title: t('editionHintCentral'),
|
|
1884
|
+
onChange: (e) => setForm({ ...form, organizationId: e.target.value })
|
|
1885
|
+
})
|
|
1886
|
+
)
|
|
1887
|
+
: h('div', { className: 'dsh-cj-field dsh-cj-form-span' },
|
|
1888
|
+
h('label', { className: 'dsh-cj-label' }, t('apiBase')),
|
|
1889
|
+
h(FieldInput, {
|
|
1890
|
+
value: form.apiBaseUrl,
|
|
1891
|
+
placeholder: t('apiBasePh'),
|
|
1892
|
+
title: t('editionHintRegion'),
|
|
1893
|
+
onChange: (e) => setForm({ ...form, apiBaseUrl: e.target.value })
|
|
1894
|
+
})
|
|
1895
|
+
)
|
|
1896
|
+
),
|
|
1897
|
+
h('div', { className: 'dsh-cj-form-row' }, tokenRow)
|
|
1898
|
+
)
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
function AccountModal({ open, title, form, setForm, busy, onClose, onSave, t, mode }) {
|
|
1902
|
+
const isLocal = form.accountMode === 'local'
|
|
1903
|
+
const body = h('div', { className: 'dsh-cj-account-form' },
|
|
1904
|
+
h('div', { className: 'dsh-cj-form-row' },
|
|
1905
|
+
h('div', { className: 'dsh-cj-field' },
|
|
1906
|
+
h('label', { className: 'dsh-cj-label' }, t('name')),
|
|
1907
|
+
h(FieldInput, {
|
|
1908
|
+
value: form.name,
|
|
1909
|
+
placeholder: t('namePh'),
|
|
1910
|
+
onChange: (e) => setForm({ ...form, name: e.target.value }),
|
|
1911
|
+
'data-modal-autofocus': true
|
|
1912
|
+
})
|
|
1913
|
+
),
|
|
1914
|
+
h('div', { className: 'dsh-cj-field' },
|
|
1915
|
+
h('label', { className: 'dsh-cj-label' }, t('accountMode')),
|
|
1916
|
+
h(SelectField, {
|
|
1917
|
+
value: form.accountMode || 'remote',
|
|
1918
|
+
style: { width: '100%' },
|
|
1919
|
+
'aria-label': t('accountMode'),
|
|
1920
|
+
title: isLocal ? t('modeHintLocal') : t('modeHintRemote'),
|
|
1921
|
+
options: [
|
|
1922
|
+
{ value: 'remote', label: t('modeRemote') },
|
|
1923
|
+
{ value: 'local', label: t('modeLocal') }
|
|
1924
|
+
],
|
|
1925
|
+
onChange: (v) => setForm({ ...form, accountMode: v })
|
|
1926
|
+
})
|
|
1927
|
+
)
|
|
1928
|
+
),
|
|
1929
|
+
isLocal
|
|
1930
|
+
? h('div', { className: 'dsh-cj-form-row' },
|
|
1931
|
+
h('div', { className: 'dsh-cj-field dsh-cj-form-span' },
|
|
1932
|
+
h('label', { className: 'dsh-cj-label' }, t('localRoots')),
|
|
1933
|
+
h('textarea', {
|
|
1934
|
+
className: 'dsh-cj-textarea',
|
|
1935
|
+
rows: 3,
|
|
1936
|
+
value: form.localRootsText || '',
|
|
1937
|
+
placeholder: t('localRootsPh'),
|
|
1938
|
+
title: t('localRootsHint'),
|
|
1939
|
+
onChange: (e) => setForm({ ...form, localRootsText: e.target.value })
|
|
1940
|
+
})
|
|
1941
|
+
)
|
|
1942
|
+
)
|
|
1943
|
+
: remoteProviderFields(form, setForm, t, mode),
|
|
1944
|
+
h('div', { className: 'dsh-cj-form-row' },
|
|
1945
|
+
h('div', { className: 'dsh-cj-field' },
|
|
1946
|
+
h('label', { className: 'dsh-cj-label' }, t('authors')),
|
|
1947
|
+
h(FieldInput, {
|
|
1948
|
+
value: form.authorFilters,
|
|
1949
|
+
placeholder: t('authorsPh'),
|
|
1950
|
+
title: t('authorsHint'),
|
|
1951
|
+
onChange: (e) => setForm({ ...form, authorFilters: e.target.value })
|
|
1952
|
+
})
|
|
1953
|
+
),
|
|
1954
|
+
h('div', { className: 'dsh-cj-field' },
|
|
1955
|
+
h('label', { className: 'dsh-cj-label' }, t('defaultBranch')),
|
|
1956
|
+
h(FieldInput, {
|
|
1957
|
+
value: form.defaultBranch,
|
|
1958
|
+
placeholder: t('defaultBranchPh'),
|
|
1959
|
+
onChange: (e) => setForm({ ...form, defaultBranch: e.target.value })
|
|
1960
|
+
})
|
|
1961
|
+
)
|
|
1962
|
+
)
|
|
1963
|
+
)
|
|
1964
|
+
|
|
1965
|
+
const footer = h(React.Fragment, null,
|
|
1966
|
+
h(Btn, { icon: IconClose ? h(IconClose) : null, onClick: onClose }, t('cancel')),
|
|
1967
|
+
h(Btn, { primary: true, disabled: busy, icon: IconSave ? h(IconSave) : null, onClick: onSave }, t('save'))
|
|
1968
|
+
)
|
|
1969
|
+
|
|
1970
|
+
if (UiModal) {
|
|
1971
|
+
return h(UiModal, {
|
|
1972
|
+
open: !!open,
|
|
1973
|
+
onClose,
|
|
1974
|
+
title,
|
|
1975
|
+
closeLabel: t('cancel'),
|
|
1976
|
+
footer,
|
|
1977
|
+
backdropBlur: true,
|
|
1978
|
+
className: 'dsh-cj-modal-wide'
|
|
1979
|
+
}, body)
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
if (!open) return null
|
|
1983
|
+
return h('div', { className: 'dsh-cj-modal-mask', onClick: onClose },
|
|
1984
|
+
h('div', { className: 'dsh-cj-modal dsh-cj-modal-wide', onClick: (e) => e.stopPropagation() },
|
|
1985
|
+
h('h3', null, title),
|
|
1986
|
+
body,
|
|
1987
|
+
h('div', { className: 'dsh-cj-actions' }, footer)
|
|
1988
|
+
)
|
|
1989
|
+
)
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
function PanelIcon(props) {
|
|
1993
|
+
return h('svg', {
|
|
1994
|
+
width: 18, height: 18, viewBox: '0 0 16 16', fill: 'currentColor', 'aria-hidden': true, ...props
|
|
1995
|
+
},
|
|
1996
|
+
h('rect', { x: 1, y: 1, width: 3, height: 3, rx: 0.5, opacity: 0.35 }),
|
|
1997
|
+
h('rect', { x: 5, y: 1, width: 3, height: 3, rx: 0.5, opacity: 0.55 }),
|
|
1998
|
+
h('rect', { x: 9, y: 1, width: 3, height: 3, rx: 0.5, opacity: 0.75 }),
|
|
1999
|
+
h('rect', { x: 13, y: 1, width: 2, height: 3, rx: 0.5, opacity: 1 }),
|
|
2000
|
+
h('rect', { x: 1, y: 5, width: 3, height: 3, rx: 0.5, opacity: 0.55 }),
|
|
2001
|
+
h('rect', { x: 5, y: 5, width: 3, height: 3, rx: 0.5, opacity: 1 }),
|
|
2002
|
+
h('rect', { x: 9, y: 5, width: 3, height: 3, rx: 0.5, opacity: 0.35 }),
|
|
2003
|
+
h('rect', { x: 13, y: 5, width: 2, height: 3, rx: 0.5, opacity: 0.75 }),
|
|
2004
|
+
h('rect', { x: 1, y: 9, width: 3, height: 3, rx: 0.5, opacity: 0.75 }),
|
|
2005
|
+
h('rect', { x: 5, y: 9, width: 3, height: 3, rx: 0.5, opacity: 0.35 }),
|
|
2006
|
+
h('rect', { x: 9, y: 9, width: 3, height: 3, rx: 0.5, opacity: 1 }),
|
|
2007
|
+
h('rect', { x: 13, y: 9, width: 2, height: 3, rx: 0.5, opacity: 0.55 })
|
|
2008
|
+
)
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
function emptyForm() {
|
|
2012
|
+
return {
|
|
2013
|
+
name: '',
|
|
2014
|
+
accountMode: 'local',
|
|
2015
|
+
provider: 'codeup',
|
|
2016
|
+
edition: 'central',
|
|
2017
|
+
organizationId: '',
|
|
2018
|
+
apiBaseUrl: '',
|
|
2019
|
+
insecureSsl: false,
|
|
2020
|
+
localRootsText: '',
|
|
2021
|
+
token: '',
|
|
2022
|
+
authorFilters: '',
|
|
2023
|
+
defaultBranch: 'master'
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* 表头固定、仅表体滚动的表格
|
|
2029
|
+
*/
|
|
2030
|
+
function TableScroll({ head, children }) {
|
|
2031
|
+
const headRef = useRef(null)
|
|
2032
|
+
const bodyRef = useRef(null)
|
|
2033
|
+
|
|
2034
|
+
useLayoutEffect(() => {
|
|
2035
|
+
const headEl = headRef.current
|
|
2036
|
+
const bodyEl = bodyRef.current
|
|
2037
|
+
if (!headEl || !bodyEl) return undefined
|
|
2038
|
+
|
|
2039
|
+
const measureRow = (table) => {
|
|
2040
|
+
table.style.tableLayout = 'auto'
|
|
2041
|
+
table.style.width = 'max-content'
|
|
2042
|
+
table.querySelectorAll('th,td').forEach((cell) => { cell.style.width = '' })
|
|
2043
|
+
const row = (table.tHead && table.tHead.rows[0]) || table.rows[0]
|
|
2044
|
+
if (!row) return []
|
|
2045
|
+
return Array.from(row.cells).map((cell) => cell.getBoundingClientRect().width)
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
const fitColumns = (cols, target) => {
|
|
2049
|
+
const n = cols.length
|
|
2050
|
+
if (!n || target <= 0) return cols
|
|
2051
|
+
const lock = cols.map((w, i) => i === n - 1 || w < 200)
|
|
2052
|
+
let locked = 0
|
|
2053
|
+
let flexSum = 0
|
|
2054
|
+
cols.forEach((w, i) => {
|
|
2055
|
+
if (lock[i]) locked += w
|
|
2056
|
+
else flexSum += w
|
|
2057
|
+
})
|
|
2058
|
+
if (locked >= target || flexSum <= 0) {
|
|
2059
|
+
const sum = cols.reduce((a, b) => a + b, 0) || 1
|
|
2060
|
+
const out = cols.map((w) => Math.floor((target * w) / sum))
|
|
2061
|
+
out[n - 1] = target - out.slice(0, -1).reduce((a, b) => a + b, 0)
|
|
2062
|
+
return out
|
|
2063
|
+
}
|
|
2064
|
+
const remain = target - locked
|
|
2065
|
+
const out = cols.slice()
|
|
2066
|
+
let used = 0
|
|
2067
|
+
const flexIdx = []
|
|
2068
|
+
cols.forEach((w, i) => { if (!lock[i]) flexIdx.push(i) })
|
|
2069
|
+
flexIdx.forEach((i, k) => {
|
|
2070
|
+
const next = k === flexIdx.length - 1
|
|
2071
|
+
? remain - used
|
|
2072
|
+
: Math.floor((remain * cols[i]) / flexSum)
|
|
2073
|
+
out[i] = next
|
|
2074
|
+
used += next
|
|
2075
|
+
})
|
|
2076
|
+
return out
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
const apply = (table, cols) => {
|
|
2080
|
+
table.style.tableLayout = 'fixed'
|
|
2081
|
+
table.style.width = '100%'
|
|
2082
|
+
const row = (table.tHead && table.tHead.rows[0]) || table.rows[0]
|
|
2083
|
+
if (!row) return
|
|
2084
|
+
Array.from(row.cells).forEach((cell, i) => {
|
|
2085
|
+
if (cols[i] > 0) cell.style.width = cols[i] + 'px'
|
|
2086
|
+
})
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
let running = false
|
|
2090
|
+
const sync = () => {
|
|
2091
|
+
if (running) return
|
|
2092
|
+
running = true
|
|
2093
|
+
try {
|
|
2094
|
+
const headTable = headEl.querySelector('table')
|
|
2095
|
+
const bodyTable = bodyEl.querySelector('table')
|
|
2096
|
+
if (!headTable || !bodyTable) return
|
|
2097
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
2098
|
+
const sb = bodyEl.offsetWidth - bodyEl.clientWidth
|
|
2099
|
+
headEl.style.paddingRight = sb > 0 ? sb + 'px' : ''
|
|
2100
|
+
const target = bodyEl.clientWidth
|
|
2101
|
+
if (!target) return
|
|
2102
|
+
const headW = measureRow(headTable)
|
|
2103
|
+
const bodyW = measureRow(bodyTable)
|
|
2104
|
+
const n = Math.max(headW.length, bodyW.length)
|
|
2105
|
+
if (!n) return
|
|
2106
|
+
const natural = []
|
|
2107
|
+
for (let i = 0; i < n; i++) natural.push(Math.ceil(Math.max(headW[i] || 0, bodyW[i] || 0)))
|
|
2108
|
+
const cols = fitColumns(natural, target)
|
|
2109
|
+
apply(headTable, cols)
|
|
2110
|
+
apply(bodyTable, cols)
|
|
2111
|
+
if (bodyEl.offsetWidth - bodyEl.clientWidth === sb) break
|
|
2112
|
+
}
|
|
2113
|
+
if (headEl.scrollLeft !== bodyEl.scrollLeft) headEl.scrollLeft = bodyEl.scrollLeft
|
|
2114
|
+
} finally {
|
|
2115
|
+
running = false
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
sync()
|
|
2120
|
+
const ro = new ResizeObserver(sync)
|
|
2121
|
+
ro.observe(bodyEl)
|
|
2122
|
+
const onScroll = () => {
|
|
2123
|
+
if (headEl.scrollLeft !== bodyEl.scrollLeft) headEl.scrollLeft = bodyEl.scrollLeft
|
|
2124
|
+
}
|
|
2125
|
+
bodyEl.addEventListener('scroll', onScroll, { passive: true })
|
|
2126
|
+
return () => {
|
|
2127
|
+
ro.disconnect()
|
|
2128
|
+
bodyEl.removeEventListener('scroll', onScroll)
|
|
2129
|
+
}
|
|
2130
|
+
}, [head, children])
|
|
2131
|
+
|
|
2132
|
+
return h('div', { className: 'dsh-cj-table-wrap' },
|
|
2133
|
+
h('div', { className: 'dsh-cj-table-head', ref: headRef },
|
|
2134
|
+
h('table', { className: 'dsh-cj-table' }, head)
|
|
2135
|
+
),
|
|
2136
|
+
h('div', { className: 'dsh-cj-table-body', ref: bodyRef },
|
|
2137
|
+
h('table', { className: 'dsh-cj-table' }, children)
|
|
2138
|
+
)
|
|
2139
|
+
)
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
function AccountsPage({ t, accounts, activeId, onChanged, busy, setBusy, notify }) {
|
|
2143
|
+
const [modal, setModal] = useState(null)
|
|
2144
|
+
const [form, setForm] = useState(emptyForm())
|
|
2145
|
+
|
|
2146
|
+
const openNew = () => { setForm(emptyForm()); setModal('new') }
|
|
2147
|
+
const openEdit = (a) => {
|
|
2148
|
+
setForm({
|
|
2149
|
+
id: a.id,
|
|
2150
|
+
name: a.name || '',
|
|
2151
|
+
accountMode: a.mode === 'local' ? 'local' : 'remote',
|
|
2152
|
+
provider: a.mode === 'local' ? 'local' : (a.provider || 'codeup'),
|
|
2153
|
+
edition: a.edition || 'central',
|
|
2154
|
+
organizationId: a.organizationId || '',
|
|
2155
|
+
apiBaseUrl: a.apiBaseUrl || '',
|
|
2156
|
+
insecureSsl: !!a.insecureSsl,
|
|
2157
|
+
localRootsText: (a.localRoots || []).join('\n'),
|
|
2158
|
+
token: '',
|
|
2159
|
+
authorFilters: (a.authorFilters || []).join(', '),
|
|
2160
|
+
defaultBranch: a.defaultBranch || 'master'
|
|
2161
|
+
})
|
|
2162
|
+
setModal('edit')
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
const switchAccount = async (id) => {
|
|
2166
|
+
if (!id || id === activeId) return
|
|
2167
|
+
setBusy(true)
|
|
2168
|
+
try {
|
|
2169
|
+
await api('/api/accounts/' + encodeURIComponent(id) + '/activate', { method: 'POST', body: '{}' })
|
|
2170
|
+
await onChanged()
|
|
2171
|
+
notify(t('activateOk'), 'success')
|
|
2172
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2173
|
+
finally { setBusy(false) }
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
const save = async () => {
|
|
2177
|
+
setBusy(true)
|
|
2178
|
+
try {
|
|
2179
|
+
const isLocal = form.accountMode === 'local'
|
|
2180
|
+
const provider = isLocal ? 'local' : (form.provider || 'codeup')
|
|
2181
|
+
const payload = {
|
|
2182
|
+
name: form.name,
|
|
2183
|
+
mode: isLocal ? 'local' : 'remote',
|
|
2184
|
+
provider,
|
|
2185
|
+
edition: !isLocal && provider === 'codeup' ? form.edition : undefined,
|
|
2186
|
+
organizationId: isLocal ? undefined : form.organizationId,
|
|
2187
|
+
apiBaseUrl: isLocal ? undefined : form.apiBaseUrl,
|
|
2188
|
+
insecureSsl: isLocal ? undefined : !!form.insecureSsl,
|
|
2189
|
+
localRoots: isLocal
|
|
2190
|
+
? String(form.localRootsText || '').split(/\r?\n/).map((s) => s.trim()).filter(Boolean)
|
|
2191
|
+
: undefined,
|
|
2192
|
+
token: isLocal ? undefined : (form.token || undefined),
|
|
2193
|
+
authorFilters: form.authorFilters.split(/[,,]/).map((s) => s.trim()).filter(Boolean),
|
|
2194
|
+
defaultBranch: form.defaultBranch,
|
|
2195
|
+
setActive: true,
|
|
2196
|
+
test: true
|
|
2197
|
+
}
|
|
2198
|
+
if (modal === 'edit') {
|
|
2199
|
+
await api('/api/accounts/' + encodeURIComponent(form.id), {
|
|
2200
|
+
method: 'PATCH',
|
|
2201
|
+
body: JSON.stringify(payload)
|
|
2202
|
+
})
|
|
2203
|
+
} else {
|
|
2204
|
+
await api('/api/accounts', { method: 'POST', body: JSON.stringify(payload) })
|
|
2205
|
+
}
|
|
2206
|
+
setModal(null)
|
|
2207
|
+
await onChanged()
|
|
2208
|
+
notify(t('saveOk'), 'success')
|
|
2209
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2210
|
+
finally { setBusy(false) }
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
return h('div', { className: 'dsh-cj-page-scroll' },
|
|
2214
|
+
h(PageHead, { desc: t('descAccounts') }),
|
|
2215
|
+
h('div', { className: 'dsh-cj-row dsh-cj-row-end' },
|
|
2216
|
+
accounts.length
|
|
2217
|
+
? h('div', { className: 'dsh-cj-actions' },
|
|
2218
|
+
h('span', { className: 'dsh-cj-muted' }, t('currentAccount')),
|
|
2219
|
+
h(SelectField, {
|
|
2220
|
+
style: { minWidth: 180 },
|
|
2221
|
+
value: activeId || '',
|
|
2222
|
+
disabled: busy || accounts.length < 2,
|
|
2223
|
+
'aria-label': t('switchAccount'),
|
|
2224
|
+
placeholder: t('switchAccount'),
|
|
2225
|
+
options: accounts.map((a) => ({
|
|
2226
|
+
value: a.id,
|
|
2227
|
+
label: (a.name || a.id) + ' · ' + accountModeLabel(t, a.mode)
|
|
2228
|
+
})),
|
|
2229
|
+
onChange: (id) => { void switchAccount(id) }
|
|
2230
|
+
})
|
|
2231
|
+
)
|
|
2232
|
+
: h('div', { className: 'dsh-cj-muted' }, t('emptyAccount')),
|
|
2233
|
+
h(Btn, { primary: true, icon: IconPlus ? h(IconPlus) : null, onClick: openNew }, t('newAccount'))
|
|
2234
|
+
),
|
|
2235
|
+
h(TableScroll, {
|
|
2236
|
+
head: h('thead', null, h('tr', null,
|
|
2237
|
+
h('th', null, t('name')),
|
|
2238
|
+
h('th', null, t('accountMode')),
|
|
2239
|
+
h('th', null, t('provider')),
|
|
2240
|
+
h('th', null, t('org')),
|
|
2241
|
+
h('th', null, t('authors')),
|
|
2242
|
+
h('th', null, '')
|
|
2243
|
+
)),
|
|
2244
|
+
children: h('tbody', null, accounts.map((a) =>
|
|
2245
|
+
h('tr', { key: a.id },
|
|
2246
|
+
h('td', null,
|
|
2247
|
+
a.name, ' ',
|
|
2248
|
+
a.active ? h(StatusTag, { tone: 'solid' }, t('active')) : null
|
|
2249
|
+
),
|
|
2250
|
+
h('td', null, accountModeLabel(t, a.mode)),
|
|
2251
|
+
h('td', { className: 'dsh-cj-td-clip', title: a.mode === 'local' ? undefined : providerLabel(t, a.provider) },
|
|
2252
|
+
a.mode === 'local' ? '-' : providerLabel(t, a.provider)
|
|
2253
|
+
),
|
|
2254
|
+
h('td', {
|
|
2255
|
+
className: 'dsh-cj-td-clip',
|
|
2256
|
+
title: a.mode === 'local' ? (a.localRoots || []).join('\n') : (a.organizationId || a.apiBaseUrl || '')
|
|
2257
|
+
}, accountOrgCell(a)),
|
|
2258
|
+
h('td', {
|
|
2259
|
+
className: 'dsh-cj-td-clip',
|
|
2260
|
+
title: (a.authorFilters || []).join(', ') || undefined
|
|
2261
|
+
}, (a.authorFilters || []).join(', ') || '-'),
|
|
2262
|
+
h('td', { className: 'dsh-cj-td-actions' },
|
|
2263
|
+
h('div', { className: 'dsh-cj-actions' },
|
|
2264
|
+
!a.active && h(Btn, {
|
|
2265
|
+
className: 'dsh-cj-btn-icon',
|
|
2266
|
+
disabled: busy,
|
|
2267
|
+
title: t('activate'),
|
|
2268
|
+
'aria-label': t('activate'),
|
|
2269
|
+
icon: IconCheck ? h(IconCheck) : null,
|
|
2270
|
+
onClick: () => { void switchAccount(a.id) }
|
|
2271
|
+
}, IconCheck ? null : t('activate')),
|
|
2272
|
+
h(Btn, {
|
|
2273
|
+
className: 'dsh-cj-btn-icon',
|
|
2274
|
+
disabled: busy,
|
|
2275
|
+
title: a.mode === 'local' ? t('testScan') : t('test'),
|
|
2276
|
+
'aria-label': a.mode === 'local' ? t('testScan') : t('test'),
|
|
2277
|
+
// 远程测连用地球;本地扫描用搜索,避免纯图标时语义混淆
|
|
2278
|
+
icon: a.mode === 'local'
|
|
2279
|
+
? (IconSearch ? h(IconSearch) : null)
|
|
2280
|
+
: (IconGlobe ? h(IconGlobe) : null),
|
|
2281
|
+
onClick: async () => {
|
|
2282
|
+
setBusy(true)
|
|
2283
|
+
try {
|
|
2284
|
+
const res = await api(
|
|
2285
|
+
'/api/accounts/' + encodeURIComponent(a.id) + '/test',
|
|
2286
|
+
{ method: 'POST', body: '{}' }
|
|
2287
|
+
)
|
|
2288
|
+
if (a.mode === 'local') {
|
|
2289
|
+
notify(fillMsg(t('testScanOk'), { n: res.repoCount || 0 }), 'success')
|
|
2290
|
+
} else {
|
|
2291
|
+
notify(t('testOk'), 'success')
|
|
2292
|
+
}
|
|
2293
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2294
|
+
finally { setBusy(false) }
|
|
2295
|
+
}
|
|
2296
|
+
}, (a.mode === 'local' ? IconSearch : IconGlobe)
|
|
2297
|
+
? null
|
|
2298
|
+
: (a.mode === 'local' ? t('testScan') : t('test'))),
|
|
2299
|
+
h(Btn, {
|
|
2300
|
+
className: 'dsh-cj-btn-icon',
|
|
2301
|
+
title: t('edit'),
|
|
2302
|
+
'aria-label': t('edit'),
|
|
2303
|
+
icon: IconEdit ? h(IconEdit) : null,
|
|
2304
|
+
onClick: () => openEdit(a)
|
|
2305
|
+
}, IconEdit ? null : t('edit')),
|
|
2306
|
+
h(Btn, {
|
|
2307
|
+
className: 'dsh-cj-btn-icon',
|
|
2308
|
+
danger: true, disabled: busy,
|
|
2309
|
+
title: t('remove'),
|
|
2310
|
+
'aria-label': t('remove'),
|
|
2311
|
+
icon: IconTrash ? h(IconTrash) : null,
|
|
2312
|
+
onClick: async () => {
|
|
2313
|
+
if (!confirm(t('confirmDelete'))) return
|
|
2314
|
+
setBusy(true)
|
|
2315
|
+
try {
|
|
2316
|
+
await api('/api/accounts/' + encodeURIComponent(a.id), { method: 'DELETE' })
|
|
2317
|
+
await onChanged()
|
|
2318
|
+
notify(t('clearOk'), 'success')
|
|
2319
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2320
|
+
finally { setBusy(false) }
|
|
2321
|
+
}
|
|
2322
|
+
}, IconTrash ? null : t('remove'))
|
|
2323
|
+
)
|
|
2324
|
+
)
|
|
2325
|
+
)
|
|
2326
|
+
))
|
|
2327
|
+
}),
|
|
2328
|
+
h(AccountModal, {
|
|
2329
|
+
open: !!modal,
|
|
2330
|
+
mode: modal,
|
|
2331
|
+
title: modal === 'edit' ? t('edit') : t('newAccount'),
|
|
2332
|
+
form, setForm, busy, t,
|
|
2333
|
+
onClose: () => setModal(null),
|
|
2334
|
+
onSave: save
|
|
2335
|
+
})
|
|
2336
|
+
)
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
function BranchSelect({ accountId, repo, value, onChange, notify, t }) {
|
|
2340
|
+
const [options, setOptions] = useState([])
|
|
2341
|
+
const [loading, setLoading] = useState(false)
|
|
2342
|
+
const loaded = React.useRef(false)
|
|
2343
|
+
const fallback = repo.defaultBranch || 'master'
|
|
2344
|
+
|
|
2345
|
+
const ensureLoaded = async () => {
|
|
2346
|
+
if (loaded.current || loading) return
|
|
2347
|
+
setLoading(true)
|
|
2348
|
+
try {
|
|
2349
|
+
const data = await api(
|
|
2350
|
+
'/api/repo-branches?accountId=' +
|
|
2351
|
+
encodeURIComponent(accountId) +
|
|
2352
|
+
'&repoId=' +
|
|
2353
|
+
encodeURIComponent(repo.id)
|
|
2354
|
+
)
|
|
2355
|
+
const names = (data.branches || []).map((b) => b.name).filter(Boolean)
|
|
2356
|
+
if (fallback && !names.includes(fallback)) names.unshift(fallback)
|
|
2357
|
+
setOptions(names)
|
|
2358
|
+
loaded.current = true
|
|
2359
|
+
} catch (e) {
|
|
2360
|
+
if (!options.length) setOptions(fallback ? [fallback] : [])
|
|
2361
|
+
notify(e.message || String(e), 'error')
|
|
2362
|
+
} finally { setLoading(false) }
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
useEffect(() => {
|
|
2366
|
+
loaded.current = false
|
|
2367
|
+
setOptions(fallback ? [fallback] : [])
|
|
2368
|
+
}, [repo.id, fallback])
|
|
2369
|
+
|
|
2370
|
+
const current = value || fallback
|
|
2371
|
+
const list = options.includes(current) ? options : (current ? [current].concat(options) : options)
|
|
2372
|
+
|
|
2373
|
+
return h(SelectField, {
|
|
2374
|
+
style: { width: 160 },
|
|
2375
|
+
value: current,
|
|
2376
|
+
title: t('branch'),
|
|
2377
|
+
'aria-label': t('branch'),
|
|
2378
|
+
boundScroll: true,
|
|
2379
|
+
filterable: true,
|
|
2380
|
+
filterPlaceholder: t('branchFilterPh'),
|
|
2381
|
+
loading,
|
|
2382
|
+
loadingLabel: t('branchLoading'),
|
|
2383
|
+
emptyLabel: t('branchNoMatch'),
|
|
2384
|
+
onOpen: () => { ensureLoaded().catch(() => {}) },
|
|
2385
|
+
options: list.map((name) => ({
|
|
2386
|
+
value: name,
|
|
2387
|
+
label: name === fallback ? (name + ' (' + t('defaultBranch') + ')') : name
|
|
2388
|
+
})),
|
|
2389
|
+
onChange: (v) => onChange(v === fallback ? '' : v)
|
|
2390
|
+
})
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
function WatchFilter({ t, value, onChange }) {
|
|
2394
|
+
const options = [
|
|
2395
|
+
{ value: 'watched', label: t('filterWatched') },
|
|
2396
|
+
{ value: 'unwatched', label: t('filterUnwatched') },
|
|
2397
|
+
{ value: 'all', label: t('filterAll') }
|
|
2398
|
+
]
|
|
2399
|
+
if (UiSeg) {
|
|
2400
|
+
return h(UiSeg, {
|
|
2401
|
+
id: 'dsh-cj-watch-filter',
|
|
2402
|
+
label: t('watched'),
|
|
2403
|
+
value,
|
|
2404
|
+
options,
|
|
2405
|
+
onChange
|
|
2406
|
+
})
|
|
2407
|
+
}
|
|
2408
|
+
return h('div', { className: 'dsh-cj-seg', role: 'tablist' },
|
|
2409
|
+
options.map((o) =>
|
|
2410
|
+
h('button', {
|
|
2411
|
+
key: o.value,
|
|
2412
|
+
type: 'button',
|
|
2413
|
+
'data-active': value === o.value ? '1' : '0',
|
|
2414
|
+
onClick: () => { if (value !== o.value) onChange(o.value) }
|
|
2415
|
+
}, o.label)
|
|
2416
|
+
)
|
|
2417
|
+
)
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
function ReposPage({ t, accountId, accountMode, busy, setBusy, notify }) {
|
|
2421
|
+
const [repos, setRepos] = useState([])
|
|
2422
|
+
const [watched, setWatched] = useState([])
|
|
2423
|
+
const [branches, setBranches] = useState({})
|
|
2424
|
+
const [keyword, setKeyword] = useState('')
|
|
2425
|
+
const [watchFilter, setWatchFilter] = useState('watched')
|
|
2426
|
+
const [page, setPage] = useState(1)
|
|
2427
|
+
const [pageSize, setPageSize] = useState(10)
|
|
2428
|
+
const isLocal = accountMode === 'local'
|
|
2429
|
+
|
|
2430
|
+
const load = useCallback(async () => {
|
|
2431
|
+
if (!accountId) return
|
|
2432
|
+
const data = await api('/api/repos?accountId=' + encodeURIComponent(accountId))
|
|
2433
|
+
setRepos(data.repos || [])
|
|
2434
|
+
setWatched(data.watchedRepoIds || [])
|
|
2435
|
+
setBranches(data.repoBranches || {})
|
|
2436
|
+
}, [accountId])
|
|
2437
|
+
|
|
2438
|
+
useEffect(() => { load().catch((e) => notify(e.message || String(e), 'error')) }, [load, notify])
|
|
2439
|
+
useEffect(() => { setPage(1) }, [keyword, watchFilter, accountId, pageSize])
|
|
2440
|
+
|
|
2441
|
+
const allMode = watched.length === 0
|
|
2442
|
+
const isWatched = useCallback((id) => allMode || watched.includes(id), [allMode, watched])
|
|
2443
|
+
|
|
2444
|
+
const filtered = useMemo(() => {
|
|
2445
|
+
const q = keyword.trim().toLowerCase()
|
|
2446
|
+
return repos.filter((r) => {
|
|
2447
|
+
const watchedNow = isWatched(r.id)
|
|
2448
|
+
if (watchFilter === 'watched' && !watchedNow) return false
|
|
2449
|
+
if (watchFilter === 'unwatched' && watchedNow) return false
|
|
2450
|
+
if (!q) return true
|
|
2451
|
+
const label = shortRepoLabel(r.displayName || r.fullName || r.name).toLowerCase()
|
|
2452
|
+
return label.includes(q) || String(r.name || '').toLowerCase().includes(q)
|
|
2453
|
+
})
|
|
2454
|
+
}, [repos, keyword, watchFilter, isWatched])
|
|
2455
|
+
|
|
2456
|
+
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize))
|
|
2457
|
+
const safePage = Math.min(page, totalPages)
|
|
2458
|
+
const pageRepos = filtered.slice((safePage - 1) * pageSize, safePage * pageSize)
|
|
2459
|
+
|
|
2460
|
+
if (!accountId) {
|
|
2461
|
+
return h('div', { className: 'dsh-cj-page-fill' },
|
|
2462
|
+
h(PageHead, { desc: t('descRepos') }),
|
|
2463
|
+
h('p', { className: 'dsh-cj-muted' }, t('emptyAccount'))
|
|
2464
|
+
)
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
return h('div', { className: 'dsh-cj-page-fill' },
|
|
2468
|
+
h(PageHead, { desc: isLocal ? t('descReposLocal') : t('descRepos') }),
|
|
2469
|
+
h('div', { className: 'dsh-cj-row' },
|
|
2470
|
+
h(WatchFilter, { t, value: watchFilter, onChange: setWatchFilter }),
|
|
2471
|
+
h(FieldInput, {
|
|
2472
|
+
style: { width: 180 },
|
|
2473
|
+
icon: IconSearch ? h(IconSearch) : undefined,
|
|
2474
|
+
placeholder: t('repoKeyword'),
|
|
2475
|
+
value: keyword,
|
|
2476
|
+
onChange: (e) => setKeyword(e.target.value)
|
|
2477
|
+
}),
|
|
2478
|
+
h('div', { className: 'dsh-cj-actions' },
|
|
2479
|
+
h(Btn, {
|
|
2480
|
+
disabled: busy,
|
|
2481
|
+
icon: IconRefresh ? h(IconRefresh) : null,
|
|
2482
|
+
onClick: async () => {
|
|
2483
|
+
setBusy(true)
|
|
2484
|
+
try {
|
|
2485
|
+
await api('/api/repos/refresh', { method: 'POST', body: JSON.stringify({ accountId }) })
|
|
2486
|
+
await load()
|
|
2487
|
+
notify(isLocal ? t('refreshScanOk') : t('refreshOk'), 'success')
|
|
2488
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2489
|
+
finally { setBusy(false) }
|
|
2490
|
+
}
|
|
2491
|
+
}, isLocal ? t('refreshScan') : t('refresh')),
|
|
2492
|
+
h(Btn, {
|
|
2493
|
+
disabled: busy,
|
|
2494
|
+
icon: IconSave ? h(IconSave) : null,
|
|
2495
|
+
onClick: async () => {
|
|
2496
|
+
setBusy(true)
|
|
2497
|
+
try {
|
|
2498
|
+
await api('/api/repos/watch', {
|
|
2499
|
+
method: 'PUT',
|
|
2500
|
+
body: JSON.stringify({ accountId, watchedRepoIds: watched, repoBranches: branches })
|
|
2501
|
+
})
|
|
2502
|
+
await load()
|
|
2503
|
+
notify(t('saveWatchOk'), 'success')
|
|
2504
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2505
|
+
finally { setBusy(false) }
|
|
2506
|
+
}
|
|
2507
|
+
}, t('saveWatch')),
|
|
2508
|
+
h(Btn, {
|
|
2509
|
+
primary: true, disabled: busy,
|
|
2510
|
+
icon: IconDownload ? h(IconDownload) : null,
|
|
2511
|
+
onClick: async () => {
|
|
2512
|
+
setBusy(true)
|
|
2513
|
+
try {
|
|
2514
|
+
const result = await api('/api/sync', { method: 'POST', body: JSON.stringify({ accountId }) })
|
|
2515
|
+
notify(syncToastText(t, result), (result.errors && result.errors.length) ? 'error' : 'success')
|
|
2516
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2517
|
+
finally { setBusy(false) }
|
|
2518
|
+
}
|
|
2519
|
+
}, isLocal ? t('syncWatchedLocal') : t('syncWatched'))
|
|
2520
|
+
)
|
|
2521
|
+
),
|
|
2522
|
+
h(TableScroll, {
|
|
2523
|
+
head: h('thead', null, h('tr', null,
|
|
2524
|
+
h('th', null, t('watched')),
|
|
2525
|
+
h('th', null, t('repo')),
|
|
2526
|
+
h('th', null, t('branch')),
|
|
2527
|
+
h('th', null, '')
|
|
2528
|
+
)),
|
|
2529
|
+
children: h('tbody', null, pageRepos.map((r) => {
|
|
2530
|
+
const checked = isWatched(r.id)
|
|
2531
|
+
return h('tr', { key: r.id },
|
|
2532
|
+
h('td', null,
|
|
2533
|
+
h('input', {
|
|
2534
|
+
type: 'checkbox',
|
|
2535
|
+
checked,
|
|
2536
|
+
onChange: (e) => {
|
|
2537
|
+
if (allMode) {
|
|
2538
|
+
if (!e.target.checked) setWatched(repos.map((x) => x.id).filter((id) => id !== r.id))
|
|
2539
|
+
} else if (e.target.checked) setWatched(watched.concat([r.id]))
|
|
2540
|
+
else setWatched(watched.filter((id) => id !== r.id))
|
|
2541
|
+
}
|
|
2542
|
+
})
|
|
2543
|
+
),
|
|
2544
|
+
h('td', null, shortRepoLabel(r.displayName || r.fullName || r.name)),
|
|
2545
|
+
h('td', null,
|
|
2546
|
+
h(BranchSelect, {
|
|
2547
|
+
accountId,
|
|
2548
|
+
repo: r,
|
|
2549
|
+
t,
|
|
2550
|
+
notify,
|
|
2551
|
+
value: branches[r.id] || '',
|
|
2552
|
+
onChange: (next) => {
|
|
2553
|
+
const nextMap = { ...branches }
|
|
2554
|
+
if (!next) delete nextMap[r.id]
|
|
2555
|
+
else nextMap[r.id] = next
|
|
2556
|
+
setBranches(nextMap)
|
|
2557
|
+
}
|
|
2558
|
+
})
|
|
2559
|
+
),
|
|
2560
|
+
h('td', null,
|
|
2561
|
+
h('div', { className: 'dsh-cj-actions' },
|
|
2562
|
+
h(Btn, {
|
|
2563
|
+
disabled: busy,
|
|
2564
|
+
icon: IconDownload ? h(IconDownload) : null,
|
|
2565
|
+
onClick: async () => {
|
|
2566
|
+
setBusy(true)
|
|
2567
|
+
try {
|
|
2568
|
+
const result = await api('/api/sync', {
|
|
2569
|
+
method: 'POST',
|
|
2570
|
+
body: JSON.stringify({ accountId, repoIds: [r.id] })
|
|
2571
|
+
})
|
|
2572
|
+
notify(syncToastText(t, result), (result.errors && result.errors.length) ? 'error' : 'success')
|
|
2573
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2574
|
+
finally { setBusy(false) }
|
|
2575
|
+
}
|
|
2576
|
+
}, t('sync')),
|
|
2577
|
+
r.webUrl
|
|
2578
|
+
? h(Btn, {
|
|
2579
|
+
icon: IconLink ? h(IconLink) : null,
|
|
2580
|
+
onClick: () => {
|
|
2581
|
+
try { window.open(r.webUrl, '_blank', 'noopener,noreferrer') } catch { /* ignore */ }
|
|
2582
|
+
}
|
|
2583
|
+
}, t('openRepo'))
|
|
2584
|
+
: null
|
|
2585
|
+
)
|
|
2586
|
+
)
|
|
2587
|
+
)
|
|
2588
|
+
}))
|
|
2589
|
+
}),
|
|
2590
|
+
h(TablePager, {
|
|
2591
|
+
t,
|
|
2592
|
+
total: filtered.length,
|
|
2593
|
+
page: safePage,
|
|
2594
|
+
pageSize,
|
|
2595
|
+
busy,
|
|
2596
|
+
onPageChange: setPage,
|
|
2597
|
+
onPageSizeChange: (size) => { setPageSize(size); setPage(1) }
|
|
2598
|
+
})
|
|
2599
|
+
)
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
function CommitsPage({ t, accountId, busy, setBusy, notify }) {
|
|
2603
|
+
const [repos, setRepos] = useState([])
|
|
2604
|
+
const [items, setItems] = useState([])
|
|
2605
|
+
const [total, setTotal] = useState(0)
|
|
2606
|
+
const [repoId, setRepoId] = useState('')
|
|
2607
|
+
const [from, setFrom] = useState('')
|
|
2608
|
+
const [to, setTo] = useState('')
|
|
2609
|
+
const [keyword, setKeyword] = useState('')
|
|
2610
|
+
const [page, setPage] = useState(1)
|
|
2611
|
+
const [pageSize, setPageSize] = useState(10)
|
|
2612
|
+
|
|
2613
|
+
const load = useCallback(async (nextPage, nextSize) => {
|
|
2614
|
+
if (!accountId) return
|
|
2615
|
+
const size = nextSize || pageSize
|
|
2616
|
+
const p = nextPage || page
|
|
2617
|
+
const q = new URLSearchParams({
|
|
2618
|
+
accountId,
|
|
2619
|
+
limit: String(size),
|
|
2620
|
+
offset: String((p - 1) * size)
|
|
2621
|
+
})
|
|
2622
|
+
if (repoId) q.set('repoId', repoId)
|
|
2623
|
+
if (from) q.set('from', from + 'T00:00:00.000Z')
|
|
2624
|
+
if (to) q.set('to', to + 'T23:59:59.999Z')
|
|
2625
|
+
if (keyword.trim()) q.set('keyword', keyword.trim())
|
|
2626
|
+
const [commits, repoData] = await Promise.all([
|
|
2627
|
+
api('/api/commits?' + q.toString()),
|
|
2628
|
+
api('/api/repos?accountId=' + encodeURIComponent(accountId) + '&withCommitsOnly=1')
|
|
2629
|
+
])
|
|
2630
|
+
setItems(commits.items || [])
|
|
2631
|
+
setTotal(commits.total || 0)
|
|
2632
|
+
setRepos(repoData.repos || [])
|
|
2633
|
+
setPage(p)
|
|
2634
|
+
if (nextSize) setPageSize(size)
|
|
2635
|
+
}, [accountId, from, keyword, page, pageSize, repoId, to])
|
|
2636
|
+
|
|
2637
|
+
useEffect(() => {
|
|
2638
|
+
if (!accountId) return
|
|
2639
|
+
load(1).catch((e) => notify(e.message || String(e), 'error'))
|
|
2640
|
+
}, [accountId]) // eslint-disable-line
|
|
2641
|
+
|
|
2642
|
+
if (!accountId) {
|
|
2643
|
+
return h('div', { className: 'dsh-cj-page-fill' },
|
|
2644
|
+
h(PageHead, { desc: t('descCommits') }),
|
|
2645
|
+
h('p', { className: 'dsh-cj-muted' }, t('emptyAccount'))
|
|
2646
|
+
)
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
return h('div', { className: 'dsh-cj-page-fill' },
|
|
2650
|
+
h(PageHead, { desc: t('descCommits') }),
|
|
2651
|
+
h('div', { className: 'dsh-cj-row' },
|
|
2652
|
+
h(SelectField, {
|
|
2653
|
+
value: repoId,
|
|
2654
|
+
style: { minWidth: 180 },
|
|
2655
|
+
'aria-label': t('repo'),
|
|
2656
|
+
options: [{ value: '', label: t('allRepos') }].concat(
|
|
2657
|
+
repos.map((r) => ({
|
|
2658
|
+
value: r.id,
|
|
2659
|
+
label: shortRepoLabel(r.displayName || r.fullName || r.name)
|
|
2660
|
+
}))
|
|
2661
|
+
),
|
|
2662
|
+
onChange: setRepoId
|
|
2663
|
+
}),
|
|
2664
|
+
h(FieldInput, {
|
|
2665
|
+
type: 'date',
|
|
2666
|
+
style: { minWidth: 140 },
|
|
2667
|
+
value: from,
|
|
2668
|
+
onChange: (e) => setFrom(e.target.value),
|
|
2669
|
+
title: t('from'),
|
|
2670
|
+
'aria-label': t('from')
|
|
2671
|
+
}),
|
|
2672
|
+
h(FieldInput, {
|
|
2673
|
+
type: 'date',
|
|
2674
|
+
style: { minWidth: 140 },
|
|
2675
|
+
value: to,
|
|
2676
|
+
onChange: (e) => setTo(e.target.value),
|
|
2677
|
+
title: t('to'),
|
|
2678
|
+
'aria-label': t('to')
|
|
2679
|
+
}),
|
|
2680
|
+
h(FieldInput, {
|
|
2681
|
+
style: { minWidth: 160 },
|
|
2682
|
+
placeholder: t('keyword'),
|
|
2683
|
+
value: keyword,
|
|
2684
|
+
onChange: (e) => setKeyword(e.target.value),
|
|
2685
|
+
'aria-label': t('keyword')
|
|
2686
|
+
}),
|
|
2687
|
+
h(Btn, {
|
|
2688
|
+
primary: true, disabled: busy,
|
|
2689
|
+
icon: IconSearch ? h(IconSearch) : null,
|
|
2690
|
+
onClick: () => {
|
|
2691
|
+
setBusy(true)
|
|
2692
|
+
load(1)
|
|
2693
|
+
.then(() => notify(t('queryOk'), 'success'))
|
|
2694
|
+
.catch((e) => notify(e.message || String(e), 'error'))
|
|
2695
|
+
.finally(() => setBusy(false))
|
|
2696
|
+
}
|
|
2697
|
+
}, t('query')),
|
|
2698
|
+
h(Btn, {
|
|
2699
|
+
danger: true, disabled: busy,
|
|
2700
|
+
icon: IconTrash ? h(IconTrash) : null,
|
|
2701
|
+
onClick: async () => {
|
|
2702
|
+
if (!confirm(t('confirmClearCommits'))) return
|
|
2703
|
+
setBusy(true)
|
|
2704
|
+
try {
|
|
2705
|
+
await api('/api/commits/clear', { method: 'POST', body: JSON.stringify({ accountId }) })
|
|
2706
|
+
await load(1)
|
|
2707
|
+
notify(t('clearOk'), 'success')
|
|
2708
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
2709
|
+
finally { setBusy(false) }
|
|
2710
|
+
}
|
|
2711
|
+
}, t('clearCommits'))
|
|
2712
|
+
),
|
|
2713
|
+
h(TableScroll, {
|
|
2714
|
+
head: h('thead', null, h('tr', null,
|
|
2715
|
+
h('th', null, t('time')), h('th', null, t('repo')), h('th', null, t('title')),
|
|
2716
|
+
h('th', null, t('diff')), h('th', null, t('author')), h('th', null, t('sha'))
|
|
2717
|
+
)),
|
|
2718
|
+
children: h('tbody', null, items.map((c) =>
|
|
2719
|
+
h('tr', { key: c.id },
|
|
2720
|
+
h('td', null, (c.committedAt || '').slice(0, 16).replace('T', ' ')),
|
|
2721
|
+
h('td', null, shortRepoLabel(c.repoName)),
|
|
2722
|
+
h('td', null, c.title),
|
|
2723
|
+
h('td', null, renderDiffStats(c, { compact: true }) || h('span', { className: 'dsh-cj-muted' }, '—')),
|
|
2724
|
+
h('td', null, c.authorName),
|
|
2725
|
+
h('td', null,
|
|
2726
|
+
c.webUrl
|
|
2727
|
+
? h('a', { className: 'dsh-cj-link', href: c.webUrl, target: '_blank', rel: 'noreferrer' }, c.shortId)
|
|
2728
|
+
: c.shortId
|
|
2729
|
+
)
|
|
2730
|
+
)
|
|
2731
|
+
))
|
|
2732
|
+
}),
|
|
2733
|
+
h(TablePager, {
|
|
2734
|
+
t,
|
|
2735
|
+
total,
|
|
2736
|
+
page,
|
|
2737
|
+
pageSize,
|
|
2738
|
+
busy,
|
|
2739
|
+
onPageChange: (p) => {
|
|
2740
|
+
setBusy(true)
|
|
2741
|
+
load(p).catch((e) => notify(e.message || String(e), 'error')).finally(() => setBusy(false))
|
|
2742
|
+
},
|
|
2743
|
+
onPageSizeChange: (size) => {
|
|
2744
|
+
setBusy(true)
|
|
2745
|
+
load(1, size).catch((e) => notify(e.message || String(e), 'error')).finally(() => setBusy(false))
|
|
2746
|
+
}
|
|
2747
|
+
})
|
|
2748
|
+
)
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
function formatDayTitle(iso) {
|
|
2752
|
+
const d = new Date(iso + 'T12:00:00')
|
|
2753
|
+
if (Number.isNaN(d.getTime())) return iso
|
|
2754
|
+
const wd = ['日', '一', '二', '三', '四', '五', '六'][d.getDay()]
|
|
2755
|
+
return (d.getMonth() + 1) + ' 月 ' + d.getDate() + ' 日 周' + wd
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
function ActivityPage({ t, accountId, notify }) {
|
|
2759
|
+
const [year, setYear] = useState(0)
|
|
2760
|
+
const [years, setYears] = useState([])
|
|
2761
|
+
const [data, setData] = useState(null)
|
|
2762
|
+
const [day, setDay] = useState(null)
|
|
2763
|
+
const [dayItems, setDayItems] = useState([])
|
|
2764
|
+
const [dayLoading, setDayLoading] = useState(false)
|
|
2765
|
+
const weekLabels = ['一', '二', '三', '四', '五', '六', '日']
|
|
2766
|
+
const dayReq = React.useRef(0)
|
|
2767
|
+
|
|
2768
|
+
useEffect(() => {
|
|
2769
|
+
setYear(0)
|
|
2770
|
+
setData(null)
|
|
2771
|
+
setYears([])
|
|
2772
|
+
setDay(null)
|
|
2773
|
+
setDayItems([])
|
|
2774
|
+
}, [accountId])
|
|
2775
|
+
|
|
2776
|
+
useEffect(() => {
|
|
2777
|
+
if (!accountId) return
|
|
2778
|
+
const q = new URLSearchParams({ accountId })
|
|
2779
|
+
if (year) q.set('year', String(year))
|
|
2780
|
+
api('/api/activity?' + q.toString())
|
|
2781
|
+
.then((d) => {
|
|
2782
|
+
setData(d)
|
|
2783
|
+
setYears(d.years || [])
|
|
2784
|
+
setDay(null)
|
|
2785
|
+
setDayItems([])
|
|
2786
|
+
})
|
|
2787
|
+
.catch((e) => notify(e.message || String(e), 'error'))
|
|
2788
|
+
}, [accountId, year, notify])
|
|
2789
|
+
|
|
2790
|
+
const openDay = async (date) => {
|
|
2791
|
+
const reqId = ++dayReq.current
|
|
2792
|
+
setDay(date)
|
|
2793
|
+
setDayItems([])
|
|
2794
|
+
setDayLoading(true)
|
|
2795
|
+
try {
|
|
2796
|
+
const r = await api('/api/activity/day?accountId=' + encodeURIComponent(accountId) + '&date=' + encodeURIComponent(date))
|
|
2797
|
+
if (dayReq.current === reqId) setDayItems(r.commits || [])
|
|
2798
|
+
} catch (e) {
|
|
2799
|
+
if (dayReq.current === reqId) {
|
|
2800
|
+
setDayItems([])
|
|
2801
|
+
notify(e.message || String(e), 'error')
|
|
2802
|
+
}
|
|
2803
|
+
} finally {
|
|
2804
|
+
if (dayReq.current === reqId) setDayLoading(false)
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
const heatmap = useMemo(() => {
|
|
2809
|
+
if (!data) return null
|
|
2810
|
+
const fromDay = new Date(data.from + 'T00:00:00')
|
|
2811
|
+
const toDay = new Date(data.to + 'T00:00:00')
|
|
2812
|
+
const mondayOffset = (fromDay.getDay() + 6) % 7
|
|
2813
|
+
const gridStart = new Date(fromDay); gridStart.setDate(fromDay.getDate() - mondayOffset)
|
|
2814
|
+
const endPad = (7 - ((toDay.getDay() + 6) % 7) - 1 + 7) % 7
|
|
2815
|
+
const gridEnd = new Date(toDay); gridEnd.setDate(toDay.getDate() + endPad)
|
|
2816
|
+
const totalDays = Math.round((gridEnd - gridStart) / 86400000) + 1
|
|
2817
|
+
const weeks = Math.ceil(totalDays / 7)
|
|
2818
|
+
const dayByKey = new Map((data.days || []).map((d) => [d.date, d]))
|
|
2819
|
+
const step = Math.max(1, Math.ceil((data.stats.maxDayCount || 1) / 4))
|
|
2820
|
+
const now = new Date()
|
|
2821
|
+
const todayKey = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0')
|
|
2822
|
+
const cells = []
|
|
2823
|
+
const weekdayCounts = [0, 0, 0, 0, 0, 0, 0]
|
|
2824
|
+
for (let i = 0; i < weeks * 7; i++) {
|
|
2825
|
+
const d = new Date(gridStart); d.setDate(gridStart.getDate() + i)
|
|
2826
|
+
const key = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0')
|
|
2827
|
+
const inRange = d >= fromDay && d <= toDay
|
|
2828
|
+
const dayInfo = inRange ? dayByKey.get(key) : null
|
|
2829
|
+
const count = dayInfo ? (dayInfo.count || 0) : 0
|
|
2830
|
+
const level = count <= 0 ? 0 : Math.min(4, Math.ceil(count / step))
|
|
2831
|
+
if (inRange && count > 0) weekdayCounts[(d.getDay() + 6) % 7] += count
|
|
2832
|
+
cells.push({
|
|
2833
|
+
key,
|
|
2834
|
+
count,
|
|
2835
|
+
inRange,
|
|
2836
|
+
level,
|
|
2837
|
+
isToday: key === todayKey,
|
|
2838
|
+
additions: dayInfo && dayInfo.additions != null ? dayInfo.additions : null,
|
|
2839
|
+
deletions: dayInfo && dayInfo.deletions != null ? dayInfo.deletions : null,
|
|
2840
|
+
filesChanged: dayInfo && dayInfo.filesChanged != null ? dayInfo.filesChanged : null
|
|
2841
|
+
})
|
|
2842
|
+
}
|
|
2843
|
+
// Sparse month labels like the desktop reference (avoid crowding near the end)
|
|
2844
|
+
const monthLabels = []
|
|
2845
|
+
let lastLabelWeek = -4
|
|
2846
|
+
let prevMonth = -1
|
|
2847
|
+
for (let w = 0; w < weeks; w++) {
|
|
2848
|
+
const d = new Date(gridStart); d.setDate(gridStart.getDate() + w * 7)
|
|
2849
|
+
if (d < fromDay) continue
|
|
2850
|
+
if (d.getMonth() === prevMonth) continue
|
|
2851
|
+
prevMonth = d.getMonth()
|
|
2852
|
+
if (w - lastLabelWeek < 3 || w > weeks - 4) continue
|
|
2853
|
+
monthLabels.push({ column: w + 1, text: (d.getMonth() + 1) + '月' })
|
|
2854
|
+
lastLabelWeek = w
|
|
2855
|
+
}
|
|
2856
|
+
let currentStreak = 0
|
|
2857
|
+
for (let cur = new Date(Math.min(toDay.getTime(), Date.now())); cur >= fromDay; cur.setDate(cur.getDate() - 1)) {
|
|
2858
|
+
const key = cur.getFullYear() + '-' + String(cur.getMonth() + 1).padStart(2, '0') + '-' + String(cur.getDate()).padStart(2, '0')
|
|
2859
|
+
if ((dayByKey.get(key) || {}).count > 0) currentStreak++
|
|
2860
|
+
else break
|
|
2861
|
+
}
|
|
2862
|
+
const avg = data.stats.activeDays
|
|
2863
|
+
? Math.round((data.stats.totalCommits / data.stats.activeDays) * 10) / 10
|
|
2864
|
+
: 0
|
|
2865
|
+
const wdMax = Math.max(1, ...weekdayCounts)
|
|
2866
|
+
return { weeks, cells, monthLabels, weekdayCounts, wdMax, currentStreak, avg }
|
|
2867
|
+
}, [data])
|
|
2868
|
+
|
|
2869
|
+
if (!accountId) {
|
|
2870
|
+
return h('div', { className: 'dsh-cj-page-scroll' },
|
|
2871
|
+
h(PageHead, { desc: t('descActivity') }),
|
|
2872
|
+
h('p', { className: 'dsh-cj-muted' }, t('emptyAccount'))
|
|
2873
|
+
)
|
|
2874
|
+
}
|
|
2875
|
+
if (!data) {
|
|
2876
|
+
return h('div', { className: 'dsh-cj-page-scroll' },
|
|
2877
|
+
h(PageHead, { desc: t('descActivity') }),
|
|
2878
|
+
h('p', { className: 'dsh-cj-muted' }, '…')
|
|
2879
|
+
)
|
|
2880
|
+
}
|
|
2881
|
+
if (!data.stats.totalCommits) {
|
|
2882
|
+
return h('div', { className: 'dsh-cj-page-scroll' },
|
|
2883
|
+
h(PageHead, { desc: t('descActivity') }),
|
|
2884
|
+
h('div', { className: 'dsh-cj-row dsh-cj-row-end' },
|
|
2885
|
+
h('span'),
|
|
2886
|
+
h(SelectField, {
|
|
2887
|
+
value: year,
|
|
2888
|
+
'aria-label': t('recentYear'),
|
|
2889
|
+
options: [{ value: 0, label: t('recentYear') }].concat(
|
|
2890
|
+
years.map((y) => ({ value: y, label: y + ' 年' }))
|
|
2891
|
+
),
|
|
2892
|
+
onChange: (v) => { setData(null); setYear(Number(v)) }
|
|
2893
|
+
})
|
|
2894
|
+
),
|
|
2895
|
+
h('p', { className: 'dsh-cj-muted' }, t('noData')),
|
|
2896
|
+
h('p', { className: 'dsh-cj-footnote' }, t('activityFootnote'))
|
|
2897
|
+
)
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
const stats = data.stats
|
|
2901
|
+
|
|
2902
|
+
return h('div', { className: 'dsh-cj-page-scroll' },
|
|
2903
|
+
// h(PageHead, {
|
|
2904
|
+
// desc: (year ? (year + ' 年提交活跃度') : t('descActivity')) + ' · ' + data.from + ' ~ ' + data.to
|
|
2905
|
+
// }),
|
|
2906
|
+
h('div', { className: 'dsh-cj-row dsh-cj-row-end' },
|
|
2907
|
+
h('span', { className: 'dsh-cj-muted' }, t('heatHint')),
|
|
2908
|
+
h(SelectField, {
|
|
2909
|
+
value: year,
|
|
2910
|
+
'aria-label': t('recentYear'),
|
|
2911
|
+
options: [{ value: 0, label: t('recentYear') }].concat(
|
|
2912
|
+
years.map((y) => ({ value: y, label: y + ' 年' }))
|
|
2913
|
+
),
|
|
2914
|
+
onChange: (v) => { setData(null); setYear(Number(v)) }
|
|
2915
|
+
})
|
|
2916
|
+
),
|
|
2917
|
+
h('div', { className: 'dsh-cj-stats' },
|
|
2918
|
+
h('div', { className: 'dsh-cj-stat' },
|
|
2919
|
+
h('div', { className: 'l' }, t('totalCommits')),
|
|
2920
|
+
h('div', { className: 'v' }, stats.totalCommits),
|
|
2921
|
+
h('div', { className: 'n' }, t('noteTotal'))
|
|
2922
|
+
),
|
|
2923
|
+
h('div', { className: 'dsh-cj-stat' },
|
|
2924
|
+
h('div', { className: 'l' }, t('activeDays')),
|
|
2925
|
+
h('div', { className: 'v' }, stats.activeDays, h('small', null, t('unitDay'))),
|
|
2926
|
+
h('div', { className: 'n' }, t('noteActiveDays'))
|
|
2927
|
+
),
|
|
2928
|
+
h('div', { className: 'dsh-cj-stat' },
|
|
2929
|
+
h('div', { className: 'l' }, t('longestStreak')),
|
|
2930
|
+
h('div', { className: 'v' }, stats.longestStreak, h('small', null, t('unitDay'))),
|
|
2931
|
+
h('div', { className: 'n' }, t('noteStreak'))
|
|
2932
|
+
),
|
|
2933
|
+
h('div', { className: 'dsh-cj-stat' },
|
|
2934
|
+
h('div', { className: 'l' }, t('maxDay')),
|
|
2935
|
+
h('div', { className: 'v' }, stats.maxDayCount, h('small', null, t('unitCommit'))),
|
|
2936
|
+
h('div', { className: 'n' }, stats.maxDayDate || t('notePeak'))
|
|
2937
|
+
),
|
|
2938
|
+
h('div', { className: 'dsh-cj-stat' },
|
|
2939
|
+
h('div', { className: 'l' }, t('diffTotal')),
|
|
2940
|
+
h('div', { className: 'v v-diff' },
|
|
2941
|
+
stats.commitsWithStats
|
|
2942
|
+
? renderDiffStats({
|
|
2943
|
+
additions: stats.totalAdditions || 0,
|
|
2944
|
+
deletions: stats.totalDeletions || 0
|
|
2945
|
+
}, { files: false, compact: true })
|
|
2946
|
+
: h('span', { className: 'dsh-cj-muted' }, '—')
|
|
2947
|
+
),
|
|
2948
|
+
h('div', { className: 'n' },
|
|
2949
|
+
stats.commitsWithStats
|
|
2950
|
+
? fillMsg(t('noteDiff'), { n: stats.commitsWithStats })
|
|
2951
|
+
: t('noteDiffEmpty')
|
|
2952
|
+
)
|
|
2953
|
+
)
|
|
2954
|
+
),
|
|
2955
|
+
heatmap && h('div', { className: 'dsh-cj-heat' },
|
|
2956
|
+
h('div', { className: 'dsh-cj-heat-body' },
|
|
2957
|
+
h('div', { className: 'dsh-cj-weekdays', 'aria-hidden': true },
|
|
2958
|
+
weekLabels.map((x) => h('span', { key: x }, x))
|
|
2959
|
+
),
|
|
2960
|
+
h('div', { className: 'dsh-cj-heat-main' },
|
|
2961
|
+
h('div', {
|
|
2962
|
+
className: 'dsh-cj-months',
|
|
2963
|
+
'aria-hidden': true,
|
|
2964
|
+
style: { gridTemplateColumns: 'repeat(' + heatmap.weeks + ', calc(var(--dsh-cj-cell) + var(--dsh-cj-gap)))' }
|
|
2965
|
+
},
|
|
2966
|
+
heatmap.monthLabels.map((m) =>
|
|
2967
|
+
h('span', {
|
|
2968
|
+
key: m.column + '-' + m.text,
|
|
2969
|
+
className: 'dsh-cj-month',
|
|
2970
|
+
style: { gridColumn: m.column }
|
|
2971
|
+
}, m.text)
|
|
2972
|
+
)
|
|
2973
|
+
),
|
|
2974
|
+
h('div', {
|
|
2975
|
+
className: 'dsh-cj-grid',
|
|
2976
|
+
role: 'group',
|
|
2977
|
+
'aria-label': data.from + ' ~ ' + data.to
|
|
2978
|
+
},
|
|
2979
|
+
heatmap.cells.map((c) => {
|
|
2980
|
+
const clickable = c.inRange && c.count > 0
|
|
2981
|
+
let tip = c.inRange ? (c.key + ' · ' + c.count + ' ' + t('unitCommit')) : c.key
|
|
2982
|
+
if (clickable && (c.additions != null || c.deletions != null)) {
|
|
2983
|
+
tip += ' · +' + (c.additions || 0) + ' −' + (c.deletions || 0)
|
|
2984
|
+
if (c.filesChanged != null) tip += ' · ' + c.filesChanged + ' files'
|
|
2985
|
+
}
|
|
2986
|
+
return h('button', {
|
|
2987
|
+
key: c.key,
|
|
2988
|
+
type: 'button',
|
|
2989
|
+
className: [
|
|
2990
|
+
'dsh-cj-cell',
|
|
2991
|
+
c.inRange ? 'lv' + c.level : 'is-blank',
|
|
2992
|
+
clickable ? 'has-commits' : '',
|
|
2993
|
+
c.isToday ? 'is-today' : '',
|
|
2994
|
+
day === c.key ? 'is-today' : ''
|
|
2995
|
+
].filter(Boolean).join(' '),
|
|
2996
|
+
title: clickable ? tip + '(点击查看)' : tip,
|
|
2997
|
+
disabled: !clickable,
|
|
2998
|
+
onClick: () => openDay(c.key)
|
|
2999
|
+
})
|
|
3000
|
+
})
|
|
3001
|
+
)
|
|
3002
|
+
)
|
|
3003
|
+
),
|
|
3004
|
+
h('div', { className: 'dsh-cj-heat-foot' },
|
|
3005
|
+
h('span', null, fillMsg(t('heatSummary'), {
|
|
3006
|
+
w: heatmap.weeks,
|
|
3007
|
+
a: stats.activeDays,
|
|
3008
|
+
c: stats.totalCommits
|
|
3009
|
+
})),
|
|
3010
|
+
h('span', { className: 'dsh-cj-heat-legend' },
|
|
3011
|
+
h('span', null, t('less')),
|
|
3012
|
+
[0, 1, 2, 3, 4].map((lv) =>
|
|
3013
|
+
h('span', { key: lv, className: 'swatch' + (lv ? ' lv' + lv : '') })
|
|
3014
|
+
),
|
|
3015
|
+
h('span', null, t('more'))
|
|
3016
|
+
)
|
|
3017
|
+
)
|
|
3018
|
+
),
|
|
3019
|
+
heatmap && h('div', { className: 'dsh-cj-insights' },
|
|
3020
|
+
h('div', { className: 'dsh-cj-insight' },
|
|
3021
|
+
h('h4', null, t('weekdayDist')),
|
|
3022
|
+
heatmap.weekdayCounts.map((n, i) =>
|
|
3023
|
+
h('div', { className: 'dsh-cj-wd', key: weekLabels[i] },
|
|
3024
|
+
h('span', null, weekLabels[i]),
|
|
3025
|
+
h('div', { className: 'dsh-cj-wd-bar' },
|
|
3026
|
+
h('i', { style: { width: Math.round((n / heatmap.wdMax) * 100) + '%' } })
|
|
3027
|
+
),
|
|
3028
|
+
h('span', null, n)
|
|
3029
|
+
)
|
|
3030
|
+
)
|
|
3031
|
+
),
|
|
3032
|
+
h('div', { className: 'dsh-cj-insight' },
|
|
3033
|
+
h('h4', null, t('activity')),
|
|
3034
|
+
h('div', { className: 'dsh-cj-meta-list' },
|
|
3035
|
+
h('div', null, h('span', null, t('currentStreak')), h('strong', null, heatmap.currentStreak)),
|
|
3036
|
+
h('div', null, h('span', null, t('avgPerDay')), h('strong', null, heatmap.avg)),
|
|
3037
|
+
h('div', null,
|
|
3038
|
+
h('span', null, t('peakOn')),
|
|
3039
|
+
h('strong', null, data.stats.maxDayDate || '—')
|
|
3040
|
+
),
|
|
3041
|
+
h('div', null,
|
|
3042
|
+
h('span', null, t('maxDay')),
|
|
3043
|
+
h('strong', null, data.stats.maxDayCount)
|
|
3044
|
+
),
|
|
3045
|
+
h('div', null,
|
|
3046
|
+
h('span', null, t('diffTotal')),
|
|
3047
|
+
h('strong', null,
|
|
3048
|
+
stats.commitsWithStats
|
|
3049
|
+
? renderDiffStats({
|
|
3050
|
+
additions: stats.totalAdditions || 0,
|
|
3051
|
+
deletions: stats.totalDeletions || 0
|
|
3052
|
+
}, { files: false, compact: true })
|
|
3053
|
+
: '—'
|
|
3054
|
+
)
|
|
3055
|
+
)
|
|
3056
|
+
)
|
|
3057
|
+
)
|
|
3058
|
+
),
|
|
3059
|
+
h('p', { className: 'dsh-cj-footnote' }, t('activityFootnote')),
|
|
3060
|
+
day && h('aside', {
|
|
3061
|
+
className: 'dsh-cj-drawer',
|
|
3062
|
+
role: 'complementary',
|
|
3063
|
+
'aria-label': day
|
|
3064
|
+
},
|
|
3065
|
+
h('div', { className: 'dsh-cj-drawer-head' },
|
|
3066
|
+
h('div', { className: 'dsh-cj-drawer-title' },
|
|
3067
|
+
h('strong', null, formatDayTitle(day)),
|
|
3068
|
+
h('span', null,
|
|
3069
|
+
day + ' · ' + (dayLoading ? t('dayLoading') : fillMsg(t('dayCommits'), { n: dayItems.length }))
|
|
3070
|
+
)
|
|
3071
|
+
),
|
|
3072
|
+
h(Btn, {
|
|
3073
|
+
icon: IconClose ? h(IconClose) : null,
|
|
3074
|
+
onClick: () => setDay(null)
|
|
3075
|
+
}, IconClose ? null : '×')
|
|
3076
|
+
),
|
|
3077
|
+
h('div', { className: 'dsh-cj-drawer-body' },
|
|
3078
|
+
dayLoading
|
|
3079
|
+
? h('p', { className: 'dsh-cj-muted' }, '…')
|
|
3080
|
+
: (dayItems.length
|
|
3081
|
+
? dayItems.map((c, i) =>
|
|
3082
|
+
h('div', { className: 'dsh-cj-commit', key: c.id || i },
|
|
3083
|
+
h('div', { className: 'dsh-cj-commit-head' },
|
|
3084
|
+
h('span', null, (c.time || '').slice(11, 16) || '—'),
|
|
3085
|
+
h('span', { className: 'dsh-cj-commit-repo', title: c.repo }, shortRepoLabel(c.repo))
|
|
3086
|
+
),
|
|
3087
|
+
h('div', { className: 'dsh-cj-commit-title' }, c.title),
|
|
3088
|
+
h('div', { className: 'dsh-cj-commit-meta' },
|
|
3089
|
+
h('span', { className: 'dsh-cj-commit-sha' }, c.sha),
|
|
3090
|
+
renderDiffStats(c, { compact: true }),
|
|
3091
|
+
h('span', null, c.authorName || ''),
|
|
3092
|
+
c.webUrl
|
|
3093
|
+
? h(Btn, {
|
|
3094
|
+
icon: IconLink ? h(IconLink) : null,
|
|
3095
|
+
onClick: () => {
|
|
3096
|
+
try { window.open(c.webUrl, '_blank', 'noopener,noreferrer') } catch { /* ignore */ }
|
|
3097
|
+
}
|
|
3098
|
+
}, t('openRepo'))
|
|
3099
|
+
: null
|
|
3100
|
+
)
|
|
3101
|
+
)
|
|
3102
|
+
)
|
|
3103
|
+
: h('p', { className: 'dsh-cj-muted' }, t('dayEmpty')))
|
|
3104
|
+
)
|
|
3105
|
+
)
|
|
3106
|
+
)
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
function LogsPage({ t, accountId, busy, setBusy, notify }) {
|
|
3110
|
+
const [items, setItems] = useState([])
|
|
3111
|
+
const [total, setTotal] = useState(0)
|
|
3112
|
+
const [page, setPage] = useState(1)
|
|
3113
|
+
const [pageSize, setPageSize] = useState(10)
|
|
3114
|
+
|
|
3115
|
+
const load = useCallback(async (nextPage, nextSize) => {
|
|
3116
|
+
if (!accountId) return
|
|
3117
|
+
const size = nextSize || pageSize
|
|
3118
|
+
const p = nextPage || page
|
|
3119
|
+
const q = new URLSearchParams({
|
|
3120
|
+
accountId,
|
|
3121
|
+
limit: String(size),
|
|
3122
|
+
offset: String((p - 1) * size)
|
|
3123
|
+
})
|
|
3124
|
+
const data = await api('/api/logs?' + q.toString())
|
|
3125
|
+
setItems(data.items || [])
|
|
3126
|
+
setTotal(data.total || 0)
|
|
3127
|
+
setPage(p)
|
|
3128
|
+
if (nextSize) setPageSize(size)
|
|
3129
|
+
}, [accountId, page, pageSize])
|
|
3130
|
+
|
|
3131
|
+
useEffect(() => {
|
|
3132
|
+
if (!accountId) return
|
|
3133
|
+
load(1).catch((e) => notify(e.message || String(e), 'error'))
|
|
3134
|
+
}, [accountId]) // eslint-disable-line
|
|
3135
|
+
|
|
3136
|
+
if (!accountId) {
|
|
3137
|
+
return h('div', { className: 'dsh-cj-page-fill' },
|
|
3138
|
+
h(PageHead, { desc: t('descLogs') }),
|
|
3139
|
+
h('p', { className: 'dsh-cj-muted' }, t('emptyAccount'))
|
|
3140
|
+
)
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
return h('div', { className: 'dsh-cj-page-fill' },
|
|
3144
|
+
h(PageHead, { desc: t('descLogs') }),
|
|
3145
|
+
h('div', { className: 'dsh-cj-row' },
|
|
3146
|
+
h(Btn, {
|
|
3147
|
+
disabled: busy,
|
|
3148
|
+
icon: IconRefresh ? h(IconRefresh) : null,
|
|
3149
|
+
onClick: () => {
|
|
3150
|
+
setBusy(true)
|
|
3151
|
+
load(1)
|
|
3152
|
+
.then(() => notify(t('refreshOk'), 'success'))
|
|
3153
|
+
.catch((e) => notify(e.message || String(e), 'error'))
|
|
3154
|
+
.finally(() => setBusy(false))
|
|
3155
|
+
}
|
|
3156
|
+
}, t('refresh')),
|
|
3157
|
+
h(Btn, {
|
|
3158
|
+
danger: true, disabled: busy,
|
|
3159
|
+
icon: IconTrash ? h(IconTrash) : null,
|
|
3160
|
+
onClick: async () => {
|
|
3161
|
+
if (!confirm(t('confirmClearLogs'))) return
|
|
3162
|
+
setBusy(true)
|
|
3163
|
+
try {
|
|
3164
|
+
await api('/api/logs?accountId=' + encodeURIComponent(accountId), { method: 'DELETE' })
|
|
3165
|
+
await load(1)
|
|
3166
|
+
notify(t('clearOk'), 'success')
|
|
3167
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
3168
|
+
finally { setBusy(false) }
|
|
3169
|
+
}
|
|
3170
|
+
}, t('clearLogs'))
|
|
3171
|
+
),
|
|
3172
|
+
h(TableScroll, {
|
|
3173
|
+
head: h('thead', null, h('tr', null,
|
|
3174
|
+
h('th', null, t('level')), h('th', null, t('time')), h('th', null, t('message'))
|
|
3175
|
+
)),
|
|
3176
|
+
children: h('tbody', null, items.map((l) =>
|
|
3177
|
+
h('tr', { key: l.id },
|
|
3178
|
+
h('td', null, logLevelTag(t, l.level)),
|
|
3179
|
+
h('td', null, (l.at || '').replace('T', ' ').slice(0, 19)),
|
|
3180
|
+
h('td', null, l.message)
|
|
3181
|
+
)
|
|
3182
|
+
))
|
|
3183
|
+
}),
|
|
3184
|
+
h(TablePager, {
|
|
3185
|
+
t,
|
|
3186
|
+
total,
|
|
3187
|
+
page,
|
|
3188
|
+
pageSize,
|
|
3189
|
+
busy,
|
|
3190
|
+
onPageChange: (p) => {
|
|
3191
|
+
setBusy(true)
|
|
3192
|
+
load(p).catch((e) => notify(e.message || String(e), 'error')).finally(() => setBusy(false))
|
|
3193
|
+
},
|
|
3194
|
+
onPageSizeChange: (size) => {
|
|
3195
|
+
setBusy(true)
|
|
3196
|
+
load(1, size).catch((e) => notify(e.message || String(e), 'error')).finally(() => setBusy(false))
|
|
3197
|
+
}
|
|
3198
|
+
})
|
|
3199
|
+
)
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
function SettingsPage({ t, busy, setBusy, notify }) {
|
|
3203
|
+
const [form, setForm] = useState({
|
|
3204
|
+
syncIntervalMinutes: 30,
|
|
3205
|
+
syncLookbackDays: 90,
|
|
3206
|
+
exportsPath: ''
|
|
3207
|
+
})
|
|
3208
|
+
|
|
3209
|
+
useEffect(() => {
|
|
3210
|
+
api('/api/settings').then((s) => setForm({
|
|
3211
|
+
syncIntervalMinutes: s.syncIntervalMinutes,
|
|
3212
|
+
syncLookbackDays: s.syncLookbackDays,
|
|
3213
|
+
exportsPath: s.exportsPath || ''
|
|
3214
|
+
})).catch((e) => notify(e.message || String(e), 'error'))
|
|
3215
|
+
}, [notify])
|
|
3216
|
+
|
|
3217
|
+
return h('div', { className: 'dsh-cj-page-scroll' },
|
|
3218
|
+
h(PageHead, { desc: t('descSettings') }),
|
|
3219
|
+
h('h3', {
|
|
3220
|
+
className: 'dsh-cj-page-title',
|
|
3221
|
+
style: { fontSize: 14, marginBottom: 10 }
|
|
3222
|
+
}, t('syncSettingsTitle')),
|
|
3223
|
+
h('div', { className: 'dsh-cj-field' },
|
|
3224
|
+
h('label', { className: 'dsh-cj-label' }, t('syncInterval')),
|
|
3225
|
+
h(FieldInput, {
|
|
3226
|
+
type: 'number', min: 5,
|
|
3227
|
+
value: form.syncIntervalMinutes,
|
|
3228
|
+
onChange: (e) => setForm({ ...form, syncIntervalMinutes: Number(e.target.value) })
|
|
3229
|
+
})
|
|
3230
|
+
),
|
|
3231
|
+
h('div', { className: 'dsh-cj-field' },
|
|
3232
|
+
h('label', { className: 'dsh-cj-label' }, t('lookback')),
|
|
3233
|
+
h(FieldInput, {
|
|
3234
|
+
type: 'number', min: 1,
|
|
3235
|
+
value: form.syncLookbackDays,
|
|
3236
|
+
onChange: (e) => setForm({ ...form, syncLookbackDays: Number(e.target.value) })
|
|
3237
|
+
})
|
|
3238
|
+
),
|
|
3239
|
+
h('div', { className: 'dsh-cj-field' },
|
|
3240
|
+
h('label', { className: 'dsh-cj-label' }, t('exportsPath')),
|
|
3241
|
+
h(FieldInput, {
|
|
3242
|
+
value: form.exportsPath,
|
|
3243
|
+
placeholder: '~/.dsh-commit-journal/exports',
|
|
3244
|
+
onChange: (e) => setForm({ ...form, exportsPath: e.target.value })
|
|
3245
|
+
}),
|
|
3246
|
+
h('div', { className: 'dsh-cj-muted' }, t('exportsPathHint'))
|
|
3247
|
+
),
|
|
3248
|
+
h(Btn, {
|
|
3249
|
+
primary: true, disabled: busy,
|
|
3250
|
+
icon: IconSave ? h(IconSave) : null,
|
|
3251
|
+
onClick: async () => {
|
|
3252
|
+
setBusy(true)
|
|
3253
|
+
try {
|
|
3254
|
+
await api('/api/settings', { method: 'PUT', body: JSON.stringify(form) })
|
|
3255
|
+
notify(t('saveOk'), 'success')
|
|
3256
|
+
} catch (e) { notify(e.message || String(e), 'error') }
|
|
3257
|
+
finally { setBusy(false) }
|
|
3258
|
+
}
|
|
3259
|
+
}, t('save'))
|
|
3260
|
+
)
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
function detectScheme() {
|
|
3264
|
+
const el = document.documentElement
|
|
3265
|
+
const attr = (el.getAttribute('data-theme') || el.getAttribute('data-color-scheme') || el.className || '').toLowerCase()
|
|
3266
|
+
if (attr.includes('dark')) return 'dark'
|
|
3267
|
+
if (attr.includes('light')) return 'light'
|
|
3268
|
+
const bg = getComputedStyle(el).getPropertyValue('--dsw-alias-bg-base').trim()
|
|
3269
|
+
const hex = bg.match(/#([0-9a-f]{6})/i)
|
|
3270
|
+
if (hex) {
|
|
3271
|
+
const n = parseInt(hex[1], 16)
|
|
3272
|
+
const r = (n >> 16) & 255, g = (n >> 8) & 255, b = n & 255
|
|
3273
|
+
return (r * 299 + g * 587 + b * 114) / 1000 < 128 ? 'dark' : 'light'
|
|
3274
|
+
}
|
|
3275
|
+
const rgb = bg.match(/rgba?\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i)
|
|
3276
|
+
if (rgb) {
|
|
3277
|
+
const r = Number(rgb[1]), g = Number(rgb[2]), b = Number(rgb[3])
|
|
3278
|
+
return (r * 299 + g * 587 + b * 114) / 1000 < 128 ? 'dark' : 'light'
|
|
3279
|
+
}
|
|
3280
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
function App({ t }) {
|
|
3284
|
+
const [tab, setTab] = useState('accounts')
|
|
3285
|
+
const [accounts, setAccounts] = useState([])
|
|
3286
|
+
const [activeId, setActiveId] = useState(null)
|
|
3287
|
+
const [busy, setBusy] = useState(false)
|
|
3288
|
+
const [scheme, setScheme] = useState('light')
|
|
3289
|
+
const [toast, setToast] = useState(null)
|
|
3290
|
+
const toastSeq = React.useRef(0)
|
|
3291
|
+
|
|
3292
|
+
const notify = useCallback((text, tone) => {
|
|
3293
|
+
toastSeq.current += 1
|
|
3294
|
+
setToast({
|
|
3295
|
+
id: toastSeq.current,
|
|
3296
|
+
text: String(text || ''),
|
|
3297
|
+
tone: tone === 'success' ? 'success' : 'error',
|
|
3298
|
+
holdMs: tone === 'success' ? 3000 : 6000
|
|
3299
|
+
})
|
|
3300
|
+
}, [])
|
|
3301
|
+
|
|
3302
|
+
const clearToast = useCallback(() => setToast(null), [])
|
|
3303
|
+
|
|
3304
|
+
const refreshAccounts = useCallback(async () => {
|
|
3305
|
+
const data = await api('/api/accounts')
|
|
3306
|
+
setAccounts(data.accounts || [])
|
|
3307
|
+
setActiveId(data.activeAccountId || null)
|
|
3308
|
+
}, [])
|
|
3309
|
+
|
|
3310
|
+
useEffect(() => {
|
|
3311
|
+
refreshAccounts().catch((e) => notify(e.message || String(e), 'error'))
|
|
3312
|
+
}, [refreshAccounts, notify])
|
|
3313
|
+
|
|
3314
|
+
useEffect(() => {
|
|
3315
|
+
const sync = () => setScheme(detectScheme())
|
|
3316
|
+
sync()
|
|
3317
|
+
const mo = new MutationObserver(sync)
|
|
3318
|
+
mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'data-color-scheme', 'class'] })
|
|
3319
|
+
const mq = window.matchMedia('(prefers-color-scheme: dark)')
|
|
3320
|
+
if (mq.addEventListener) mq.addEventListener('change', sync)
|
|
3321
|
+
else if (mq.addListener) mq.addListener(sync)
|
|
3322
|
+
return () => {
|
|
3323
|
+
mo.disconnect()
|
|
3324
|
+
if (mq.removeEventListener) mq.removeEventListener('change', sync)
|
|
3325
|
+
else if (mq.removeListener) mq.removeListener(sync)
|
|
3326
|
+
}
|
|
3327
|
+
}, [])
|
|
3328
|
+
|
|
3329
|
+
// 无官方 Toast 时的兜底:固定顶栏 + 定时关闭
|
|
3330
|
+
useEffect(() => {
|
|
3331
|
+
if (!toast || UiToast) return undefined
|
|
3332
|
+
const timer = setTimeout(clearToast, toast.holdMs || 4000)
|
|
3333
|
+
return () => clearTimeout(timer)
|
|
3334
|
+
}, [toast, clearToast])
|
|
3335
|
+
|
|
3336
|
+
const activeAccount = accounts.find((a) => a.id === activeId) || null
|
|
3337
|
+
const activeMode = activeAccount && activeAccount.mode === 'local' ? 'local' : 'remote'
|
|
3338
|
+
|
|
3339
|
+
const toastNode = toast
|
|
3340
|
+
? (UiToast
|
|
3341
|
+
? h(UiToast, {
|
|
3342
|
+
key: toast.id,
|
|
3343
|
+
text: toast.text,
|
|
3344
|
+
tone: toast.tone === 'success' ? 'success' : undefined,
|
|
3345
|
+
holdMs: toast.holdMs,
|
|
3346
|
+
onDone: clearToast
|
|
3347
|
+
})
|
|
3348
|
+
: (ReactDOM && ReactDOM.createPortal
|
|
3349
|
+
? ReactDOM.createPortal(
|
|
3350
|
+
h('div', {
|
|
3351
|
+
key: toast.id,
|
|
3352
|
+
className: 'dsh-cj-toast-fallback',
|
|
3353
|
+
'data-tone': toast.tone,
|
|
3354
|
+
role: 'status'
|
|
3355
|
+
}, toast.text),
|
|
3356
|
+
document.body
|
|
3357
|
+
)
|
|
3358
|
+
: h('div', {
|
|
3359
|
+
key: toast.id,
|
|
3360
|
+
className: 'dsh-cj-toast-fallback',
|
|
3361
|
+
'data-tone': toast.tone,
|
|
3362
|
+
role: 'status'
|
|
3363
|
+
}, toast.text)))
|
|
3364
|
+
: null
|
|
3365
|
+
|
|
3366
|
+
return h('div', { className: 'dsh-cj-root', 'data-scheme': scheme },
|
|
3367
|
+
h('style', null, CSS),
|
|
3368
|
+
toastNode,
|
|
3369
|
+
h('div', { className: 'dsh-cj-tabs', role: 'tablist' },
|
|
3370
|
+
TABS.map((item) =>
|
|
3371
|
+
h('button', {
|
|
3372
|
+
key: item.id,
|
|
3373
|
+
type: 'button',
|
|
3374
|
+
role: 'tab',
|
|
3375
|
+
className: 'dsh-cj-tab',
|
|
3376
|
+
'data-active': tab === item.id ? '1' : '0',
|
|
3377
|
+
'aria-selected': tab === item.id,
|
|
3378
|
+
onClick: () => setTab(item.id)
|
|
3379
|
+
}, t(item.id))
|
|
3380
|
+
)
|
|
3381
|
+
),
|
|
3382
|
+
h('div', { className: 'dsh-cj-body' },
|
|
3383
|
+
tab === 'accounts' && h(AccountsPage, {
|
|
3384
|
+
t, accounts, activeId, busy, setBusy, notify,
|
|
3385
|
+
onChanged: refreshAccounts
|
|
3386
|
+
}),
|
|
3387
|
+
tab === 'repos' && h(ReposPage, {
|
|
3388
|
+
t, accountId: activeId, accountMode: activeMode, busy, setBusy, notify
|
|
3389
|
+
}),
|
|
3390
|
+
tab === 'commits' && h(CommitsPage, { t, accountId: activeId, busy, setBusy, notify }),
|
|
3391
|
+
tab === 'activity' && h(ActivityPage, { t, accountId: activeId, notify }),
|
|
3392
|
+
tab === 'logs' && h(LogsPage, { t, accountId: activeId, busy, setBusy, notify }),
|
|
3393
|
+
tab === 'settings' && h(SettingsPage, { t, busy, setBusy, notify })
|
|
3394
|
+
)
|
|
3395
|
+
)
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
return {
|
|
3399
|
+
inject: ['slots', 'locale'],
|
|
3400
|
+
apply(ctx) {
|
|
3401
|
+
ctx.effect(() => ctx.locale.register(NS, DICTIONARIES), 'commit-journal: dictionaries')
|
|
3402
|
+
const translate = ctx.locale.bind(NS)
|
|
3403
|
+
// Tab labels come from TABS zh/en via locale keys if present; fallback zh in render
|
|
3404
|
+
const t = (key) => {
|
|
3405
|
+
try { return translate(key) } catch { return DICTIONARIES.zh[key] || key }
|
|
3406
|
+
}
|
|
3407
|
+
|
|
3408
|
+
ctx.slots.inject('sidebar.panellist', () =>
|
|
3409
|
+
ctx.slots.register(
|
|
3410
|
+
{
|
|
3411
|
+
name: 'sidebar.panellist',
|
|
3412
|
+
id: PANEL_ID,
|
|
3413
|
+
order: 25,
|
|
3414
|
+
label: () => translate('panelLabel'),
|
|
3415
|
+
locale: NS
|
|
3416
|
+
},
|
|
3417
|
+
PanelIcon
|
|
3418
|
+
)
|
|
3419
|
+
)
|
|
3420
|
+
|
|
3421
|
+
ctx.slots.inject('main', () =>
|
|
3422
|
+
ctx.slots.register(
|
|
3423
|
+
{ name: 'main', key: PANEL_ID, locale: NS },
|
|
3424
|
+
function CommitJournalMain() {
|
|
3425
|
+
return h(App, { t })
|
|
3426
|
+
}
|
|
3427
|
+
)
|
|
3428
|
+
)
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
})
|