dsh-aupdate 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/client.js +161 -3
- package/index.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,6 +149,19 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
149
149
|
- 「全选 / 清空」只作用于当前筛选出来的行——搜完再点全选,意思是把搜到的都勾上
|
|
150
150
|
- 这个 profile 里装着的插件都会列出来,列表本身就是「能勾什么」的全部答案
|
|
151
151
|
|
|
152
|
+
### 提示不重复
|
|
153
|
+
|
|
154
|
+
「上一次」卡片里,本轮结果的原因只出现一次:点「立刻检查」后的反馈只是一句
|
|
155
|
+
「检查完成」,6 秒后自动收掉——不再把 reason 和状态词(还是英文 done)拼一遍贴在下面。
|
|
156
|
+
状态词只在没有已渲染原因时作为兜底,且按当前语言显示。
|
|
157
|
+
|
|
158
|
+
### 关于 aupdate
|
|
159
|
+
|
|
160
|
+
设置页底部有「关于 aupdate」信息组(照 Bloom 的「关于 Bloom」做):版本号(从 package.json
|
|
161
|
+
读取,发版不用改前端)、查看更新日志、源码仓库、提交问题,另有「点个星」(打开 GitHub
|
|
162
|
+
stargazers)与「分享」(复制项目地址到剪贴板,任何环境都能用;失败时地址本身也可点开复制)。
|
|
163
|
+
外链一律 `target=_blank` + `rel=noopener noreferrer`。
|
|
164
|
+
|
|
152
165
|
### 「上一次」不会再被重启清空
|
|
153
166
|
|
|
154
167
|
最近一轮的结果(时间、查了多少个、几个可更新、装成几个、失败原因)现在落在
|
|
@@ -400,6 +413,19 @@ their installed versions, instead of a textarea you had to type package names in
|
|
|
400
413
|
Search narrows the list; Select all / Clear only touch the rows currently shown, so
|
|
401
414
|
"search, then select all" means what you expect.
|
|
402
415
|
|
|
416
|
+
### No duplicated hints
|
|
417
|
+
|
|
418
|
+
The Last run card states the outcome once. Clicking Check now only adds a short
|
|
419
|
+
"Check finished" acknowledgment that clears itself after six seconds — it no longer echoes
|
|
420
|
+
the same reason plus a raw status word underneath. Status words are a localized fallback
|
|
421
|
+
used only when no rendered reason exists.
|
|
422
|
+
|
|
423
|
+
An **About aupdate** group sits at the bottom of the page (modeled on Bloom's About section):
|
|
424
|
+
the version (read from package.json, so releases need no front-end edit), a changelog link,
|
|
425
|
+
source repository, issue tracker, plus Star and Share (copies the project URL; the URL is
|
|
426
|
+
also selectable if the copy fails). External links use target=_blank with
|
|
427
|
+
rel=noopener noreferrer.
|
|
428
|
+
|
|
403
429
|
The last run's outcome (when, how many checked, how many updatable, how many installed,
|
|
404
430
|
why it failed) is persisted to `~/.dsh/aupdate-lastrun.json` and survives a restart. It
|
|
405
431
|
used to live in memory only, so every restart reset the card to "never run" and looked
|
package/client.js
CHANGED
|
@@ -8,6 +8,41 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
const NS = 'dsh-aupdate'
|
|
9
9
|
const API = 'api/dsh-aupdate'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* 「关于 aupdate」用到的项目链接集中一处。
|
|
13
|
+
*
|
|
14
|
+
* 外链一律 target=_blank + rel=noopener noreferrer:设置页可能跑在受限
|
|
15
|
+
* webview 里,noopener 防止新页反向控制本页。
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* 状态词本地化。
|
|
19
|
+
*
|
|
20
|
+
* 后端存的是数据(done / failed / blocked…),不该直接显示在界面上。
|
|
21
|
+
* 只有拿不到已渲染的 reason 时的兜底路径会用到它,所以表不用很大。
|
|
22
|
+
*/
|
|
23
|
+
const STATUS_LABELS = {
|
|
24
|
+
zh: {
|
|
25
|
+
done: '完成', failed: '失败', blocked: '已让开', partial: '部分完成', busy: '正在跑',
|
|
26
|
+
skipped: '已跳过', none: '无', ok: '成功', cancelled: '已取消', restart: '需重启',
|
|
27
|
+
applying: '生效中', unavailable: '不可用',
|
|
28
|
+
},
|
|
29
|
+
en: {
|
|
30
|
+
done: 'done', failed: 'failed', blocked: 'held off', partial: 'partly done', busy: 'busy',
|
|
31
|
+
skipped: 'skipped', none: 'none', ok: 'ok', cancelled: 'cancelled', restart: 'restart needed',
|
|
32
|
+
applying: 'applying', unavailable: 'unavailable',
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function statusLabel(value) {
|
|
37
|
+
const table = STATUS_LABELS[LANG] ?? STATUS_LABELS.zh
|
|
38
|
+
return table[String(value ?? '')] ?? String(value ?? '')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const REPO_URL = 'https://github.com/CalmSun/dsh-aupdate'
|
|
42
|
+
const CHANGELOG_URL = REPO_URL + '/releases'
|
|
43
|
+
const ISSUES_URL = REPO_URL + '/issues/new'
|
|
44
|
+
const STARS_URL = REPO_URL + '/stargazers'
|
|
45
|
+
|
|
11
46
|
const COPY = {
|
|
12
47
|
zh: {
|
|
13
48
|
title: '插件自动更新',
|
|
@@ -26,6 +61,7 @@ window.__ModuleLoader__.load({
|
|
|
26
61
|
progressApply: '正在就地生效…',
|
|
27
62
|
runDone: '检查完成',
|
|
28
63
|
runFailed: '检查没能完成',
|
|
64
|
+
off: '已关闭',
|
|
29
65
|
lastRun: '上一次',
|
|
30
66
|
never: '还没跑过',
|
|
31
67
|
checked: '检查了',
|
|
@@ -127,6 +163,20 @@ window.__ModuleLoader__.load({
|
|
|
127
163
|
policy: '更新策略',
|
|
128
164
|
minutes: '分钟',
|
|
129
165
|
scope: '这些设置只影响本机这个 profile',
|
|
166
|
+
about: '关于 aupdate',
|
|
167
|
+
aboutVersion: '版本',
|
|
168
|
+
aboutChangelog: '更新日志',
|
|
169
|
+
aboutChangelogLink: '查看更新日志',
|
|
170
|
+
aboutRepo: '源码仓库',
|
|
171
|
+
aboutFeedback: '反馈问题',
|
|
172
|
+
aboutFeedbackLink: '提交问题',
|
|
173
|
+
aboutStar: '点个星',
|
|
174
|
+
aboutStarHint: '在 GitHub 上点 Star,让更多人看到',
|
|
175
|
+
aboutShare: '分享',
|
|
176
|
+
aboutShareHint: '复制项目地址,分享给朋友',
|
|
177
|
+
aboutShareDone: '项目地址已复制',
|
|
178
|
+
aboutShareFail: '复制失败,请手动复制项目地址',
|
|
179
|
+
aboutProject: '项目地址',
|
|
130
180
|
},
|
|
131
181
|
en: {
|
|
132
182
|
title: 'Plugin auto-update',
|
|
@@ -145,6 +195,7 @@ window.__ModuleLoader__.load({
|
|
|
145
195
|
progressApply: 'Applying in place…',
|
|
146
196
|
runDone: 'Check finished',
|
|
147
197
|
runFailed: 'Check could not finish',
|
|
198
|
+
off: 'off',
|
|
148
199
|
lastRun: 'Last run',
|
|
149
200
|
never: 'never',
|
|
150
201
|
checked: 'checked',
|
|
@@ -246,6 +297,20 @@ window.__ModuleLoader__.load({
|
|
|
246
297
|
policy: 'Update policy',
|
|
247
298
|
min: 'min',
|
|
248
299
|
scope: 'These settings apply to this profile only',
|
|
300
|
+
about: 'About aupdate',
|
|
301
|
+
aboutVersion: 'Version',
|
|
302
|
+
aboutChangelog: 'Changelog',
|
|
303
|
+
aboutChangelogLink: 'View changelog',
|
|
304
|
+
aboutRepo: 'Source code',
|
|
305
|
+
aboutFeedback: 'Report an issue',
|
|
306
|
+
aboutFeedbackLink: 'Open an issue',
|
|
307
|
+
aboutStar: 'Star',
|
|
308
|
+
aboutStarHint: 'Star on GitHub to help others find it',
|
|
309
|
+
aboutShare: 'Share',
|
|
310
|
+
aboutShareHint: 'Copy the project link to share',
|
|
311
|
+
aboutShareDone: 'Project link copied',
|
|
312
|
+
aboutShareFail: 'Could not copy; please copy the link manually',
|
|
313
|
+
aboutProject: 'Project URL',
|
|
249
314
|
},
|
|
250
315
|
}
|
|
251
316
|
|
|
@@ -464,6 +529,10 @@ window.__ModuleLoader__.load({
|
|
|
464
529
|
pkgName: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
465
530
|
pkgVer: { opacity: 0.5, fontSize: '11px', marginLeft: 'auto', flexShrink: 0 },
|
|
466
531
|
search: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '12.5px' },
|
|
532
|
+
// 「关于」组:外链靠右等宽、↗ 与文字同色但更淡,避免整行像按钮。
|
|
533
|
+
link: { color: 'inherit', textDecoration: 'none', borderBottom: '1px solid rgba(128,128,128,0.4)', paddingBottom: '1px' },
|
|
534
|
+
linkExt: { opacity: 0.5, marginLeft: '3px' },
|
|
535
|
+
ver: { fontVariantNumeric: 'tabular-nums', opacity: 0.8 },
|
|
467
536
|
}
|
|
468
537
|
|
|
469
538
|
function Toggle(props) {
|
|
@@ -645,6 +714,81 @@ window.__ModuleLoader__.load({
|
|
|
645
714
|
)
|
|
646
715
|
}
|
|
647
716
|
|
|
717
|
+
/**
|
|
718
|
+
* 「关于 aupdate」信息组。
|
|
719
|
+
*
|
|
720
|
+
* 照 Bloom 设置页的「关于 Bloom」做:版本、更新日志、仓库、反馈四行纯信息,
|
|
721
|
+
* 再加「点个星 / 分享」。版本从 /state 读(随 package.json 变),不写死。
|
|
722
|
+
*
|
|
723
|
+
* 分享用 clipboard 复制项目地址:navigator.share 在桌面 webview 里多半不可用,
|
|
724
|
+
* 而「复制地址」在任何环境都能工作;失败就让用户手动复制,不静默吞掉。
|
|
725
|
+
*/
|
|
726
|
+
function AboutCard(props) {
|
|
727
|
+
useLang()
|
|
728
|
+
const [shareHint, setShareHint] = useState('')
|
|
729
|
+
const version = props.version || ''
|
|
730
|
+
|
|
731
|
+
const extLink = (href, label) => h('a', {
|
|
732
|
+
href,
|
|
733
|
+
target: '_blank',
|
|
734
|
+
rel: 'noopener noreferrer',
|
|
735
|
+
style: S.link,
|
|
736
|
+
}, label, h('span', { style: S.linkExt, 'aria-hidden': 'true' }, '↗'))
|
|
737
|
+
|
|
738
|
+
const share = async () => {
|
|
739
|
+
try {
|
|
740
|
+
if (navigator.clipboard?.writeText) {
|
|
741
|
+
await navigator.clipboard.writeText(REPO_URL)
|
|
742
|
+
setShareHint(T.aboutShareDone)
|
|
743
|
+
return
|
|
744
|
+
}
|
|
745
|
+
setShareHint(T.aboutShareFail)
|
|
746
|
+
} catch {
|
|
747
|
+
setShareHint(T.aboutShareFail)
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
return h('div', { style: S.card },
|
|
752
|
+
h('span', { style: S.label }, T.about),
|
|
753
|
+
h('div', { style: S.row },
|
|
754
|
+
h('span', { style: S.label }, T.aboutVersion),
|
|
755
|
+
h('span', { style: S.ver }, version === '' ? '…' : 'v' + version),
|
|
756
|
+
),
|
|
757
|
+
h('div', { style: S.row },
|
|
758
|
+
h('span', { style: S.label }, T.aboutChangelog),
|
|
759
|
+
extLink(CHANGELOG_URL, T.aboutChangelogLink),
|
|
760
|
+
),
|
|
761
|
+
h('div', { style: S.row },
|
|
762
|
+
h('span', { style: S.label }, T.aboutRepo),
|
|
763
|
+
extLink(REPO_URL, 'GitHub'),
|
|
764
|
+
),
|
|
765
|
+
h('div', { style: S.row },
|
|
766
|
+
h('span', { style: S.label }, T.aboutFeedback),
|
|
767
|
+
extLink(ISSUES_URL, T.aboutFeedbackLink),
|
|
768
|
+
),
|
|
769
|
+
h('div', { style: S.row },
|
|
770
|
+
h('span', { style: S.labelBox },
|
|
771
|
+
h('span', { style: S.label }, T.aboutStar),
|
|
772
|
+
h('span', { style: S.hint }, T.aboutStarHint),
|
|
773
|
+
),
|
|
774
|
+
extLink(STARS_URL, 'GitHub'),
|
|
775
|
+
),
|
|
776
|
+
h('div', { style: S.row },
|
|
777
|
+
h('span', { style: S.labelBox },
|
|
778
|
+
h('span', { style: S.label }, T.aboutShare),
|
|
779
|
+
h('span', { style: S.hint }, T.aboutShareHint),
|
|
780
|
+
),
|
|
781
|
+
h('button', { type: 'button', style: S.btn, onClick: () => void share() }, T.aboutShare),
|
|
782
|
+
),
|
|
783
|
+
// 项目地址可点开、可选中复制,失败时用户还有这一条路。
|
|
784
|
+
h('div', { style: S.row },
|
|
785
|
+
h('span', { style: S.label }, T.aboutProject),
|
|
786
|
+
extLink(REPO_URL, REPO_URL.replace('https://', '')),
|
|
787
|
+
),
|
|
788
|
+
shareHint ? h('span', { style: S.status }, shareHint) : null,
|
|
789
|
+
)
|
|
790
|
+
}
|
|
791
|
+
|
|
648
792
|
function AutoUpdateCard() {
|
|
649
793
|
useLang()
|
|
650
794
|
const [state, setState] = useState(null)
|
|
@@ -775,9 +919,12 @@ window.__ModuleLoader__.load({
|
|
|
775
919
|
// 进度由上面的常驻轮询统一负责,这里只发请求。
|
|
776
920
|
const result = await runNow('update')
|
|
777
921
|
if (result?.started === false) {
|
|
922
|
+
// 「已经有一轮在跑」这类信息在「上一次」里没有,必须显示。
|
|
778
923
|
setRunHint(result.reason || T.runFailed)
|
|
779
924
|
} else {
|
|
780
|
-
|
|
925
|
+
// 只给一句「检查完成」。原因和状态已经写进「上一次」那张卡,
|
|
926
|
+
// 这里再拼一遍 reason + status 会和它逐字重复(还有英文 done)。
|
|
927
|
+
setRunHint(T.runDone)
|
|
781
928
|
}
|
|
782
929
|
// 跑完把状态刷一遍,页面上看到的就是最新结果。
|
|
783
930
|
try {
|
|
@@ -793,6 +940,14 @@ window.__ModuleLoader__.load({
|
|
|
793
940
|
}
|
|
794
941
|
}, [running])
|
|
795
942
|
|
|
943
|
+
// 结束提示只是一次性反馈:6 秒后自己收掉,免得它一直挂在卡片里,
|
|
944
|
+
// 和下面「上一次」的原因并列成两段一样的文字。
|
|
945
|
+
useEffect(() => {
|
|
946
|
+
if (running || runHint === '') return undefined
|
|
947
|
+
const timer = setTimeout(() => setRunHint(''), 6000)
|
|
948
|
+
return () => clearTimeout(timer)
|
|
949
|
+
}, [running, runHint])
|
|
950
|
+
|
|
796
951
|
const doCleanup = useCallback(async () => {
|
|
797
952
|
if (cleaning) return
|
|
798
953
|
setCleaning(true)
|
|
@@ -981,7 +1136,9 @@ window.__ModuleLoader__.load({
|
|
|
981
1136
|
h('span', null, (last.updates?.length ?? 0) > 0
|
|
982
1137
|
? (last.updates?.length ?? 0) + ' ' + T.updates
|
|
983
1138
|
: T.upToDate),
|
|
984
|
-
|
|
1139
|
+
// reason 是后端按语言渲染好的句子;没有它才退回本地化的状态词,
|
|
1140
|
+
// 绝不要把英文 done 直接摆到界面上。
|
|
1141
|
+
h('span', null, last.reason || statusLabel(last.status) || ''),
|
|
985
1142
|
),
|
|
986
1143
|
// 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
|
|
987
1144
|
// 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
|
|
@@ -1034,6 +1191,7 @@ window.__ModuleLoader__.load({
|
|
|
1034
1191
|
// 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
|
|
1035
1192
|
saveHint ? h('span', { style: S.status }, saveHint) : null,
|
|
1036
1193
|
h('span', { style: S.hint }, T.scope),
|
|
1194
|
+
h(AboutCard, { version: state?.version }),
|
|
1037
1195
|
)
|
|
1038
1196
|
}
|
|
1039
1197
|
|
|
@@ -1134,7 +1292,7 @@ window.__ModuleLoader__.load({
|
|
|
1134
1292
|
const text = state === null
|
|
1135
1293
|
? '…'
|
|
1136
1294
|
: state.settings?.enabled === false
|
|
1137
|
-
? (T.enabled + ':' +
|
|
1295
|
+
? (T.enabled + ':' + T.off)
|
|
1138
1296
|
: last === null || last === undefined
|
|
1139
1297
|
? T.never
|
|
1140
1298
|
: (last.updates?.length ?? 0) > 0
|
package/index.js
CHANGED
|
@@ -18,6 +18,20 @@ import { AsyncLocalStorage } from 'node:async_hooks'
|
|
|
18
18
|
|
|
19
19
|
export const name = 'dsh-aupdate'
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* 当前插件版本,直接读 package.json。
|
|
23
|
+
*
|
|
24
|
+
* 设置页的「关于 aupdate」要显示版本;写死在 client 里每次发版都得改两处,
|
|
25
|
+
* 还容易忘。这里在模块加载时读一次,发版只改 package.json 就够了。
|
|
26
|
+
*/
|
|
27
|
+
let pluginVersion = '0.0.0'
|
|
28
|
+
try {
|
|
29
|
+
const manifest = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
|
|
30
|
+
if (typeof manifest.version === 'string' && manifest.version !== '') pluginVersion = manifest.version
|
|
31
|
+
} catch {
|
|
32
|
+
// 读不到就显示 0.0.0,绝不让设置页因为一个版本号加载失败。
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
const LOG_MAX_BYTES = 1_000_000
|
|
22
36
|
/** 一次查询里同时在飞的 registry 请求数。 */
|
|
23
37
|
const FETCH_CONCURRENCY = 6
|
|
@@ -2189,6 +2203,8 @@ function settingsSnapshot(config, ctxRef, lang) {
|
|
|
2189
2203
|
return {
|
|
2190
2204
|
settings,
|
|
2191
2205
|
overrides: readOverrides(),
|
|
2206
|
+
// 「关于 aupdate」显示用;随 package.json 自动更新,无需手改前端。
|
|
2207
|
+
version: pluginVersion,
|
|
2192
2208
|
// 运行中的进度:没在跑时为 null,设置页据此决定要不要显示进度条。
|
|
2193
2209
|
progress: progress === null ? null : { ...progress },
|
|
2194
2210
|
lastRun: lastRun === null ? null : {
|
package/package.json
CHANGED