dsh-aupdate 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/client.js +119 -0
- package/index.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,6 +149,13 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
|
|
|
149
149
|
- 「全选 / 清空」只作用于当前筛选出来的行——搜完再点全选,意思是把搜到的都勾上
|
|
150
150
|
- 这个 profile 里装着的插件都会列出来,列表本身就是「能勾什么」的全部答案
|
|
151
151
|
|
|
152
|
+
### 关于 aupdate
|
|
153
|
+
|
|
154
|
+
设置页底部有「关于 aupdate」信息组(照 Bloom 的「关于 Bloom」做):版本号(从 package.json
|
|
155
|
+
读取,发版不用改前端)、查看更新日志、源码仓库、提交问题,另有「点个星」(打开 GitHub
|
|
156
|
+
stargazers)与「分享」(复制项目地址到剪贴板,任何环境都能用;失败时地址本身也可点开复制)。
|
|
157
|
+
外链一律 `target=_blank` + `rel=noopener noreferrer`。
|
|
158
|
+
|
|
152
159
|
### 「上一次」不会再被重启清空
|
|
153
160
|
|
|
154
161
|
最近一轮的结果(时间、查了多少个、几个可更新、装成几个、失败原因)现在落在
|
|
@@ -400,6 +407,12 @@ their installed versions, instead of a textarea you had to type package names in
|
|
|
400
407
|
Search narrows the list; Select all / Clear only touch the rows currently shown, so
|
|
401
408
|
"search, then select all" means what you expect.
|
|
402
409
|
|
|
410
|
+
An **About aupdate** group sits at the bottom of the page (modeled on Bloom's About section):
|
|
411
|
+
the version (read from package.json, so releases need no front-end edit), a changelog link,
|
|
412
|
+
source repository, issue tracker, plus Star and Share (copies the project URL; the URL is
|
|
413
|
+
also selectable if the copy fails). External links use target=_blank with
|
|
414
|
+
rel=noopener noreferrer.
|
|
415
|
+
|
|
403
416
|
The last run's outcome (when, how many checked, how many updatable, how many installed,
|
|
404
417
|
why it failed) is persisted to `~/.dsh/aupdate-lastrun.json` and survives a restart. It
|
|
405
418
|
used to live in memory only, so every restart reset the card to "never run" and looked
|
package/client.js
CHANGED
|
@@ -8,6 +8,17 @@ 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
|
+
const REPO_URL = 'https://github.com/CalmSun/dsh-aupdate'
|
|
18
|
+
const CHANGELOG_URL = REPO_URL + '/releases'
|
|
19
|
+
const ISSUES_URL = REPO_URL + '/issues/new'
|
|
20
|
+
const STARS_URL = REPO_URL + '/stargazers'
|
|
21
|
+
|
|
11
22
|
const COPY = {
|
|
12
23
|
zh: {
|
|
13
24
|
title: '插件自动更新',
|
|
@@ -127,6 +138,20 @@ window.__ModuleLoader__.load({
|
|
|
127
138
|
policy: '更新策略',
|
|
128
139
|
minutes: '分钟',
|
|
129
140
|
scope: '这些设置只影响本机这个 profile',
|
|
141
|
+
about: '关于 aupdate',
|
|
142
|
+
aboutVersion: '版本',
|
|
143
|
+
aboutChangelog: '更新日志',
|
|
144
|
+
aboutChangelogLink: '查看更新日志',
|
|
145
|
+
aboutRepo: '源码仓库',
|
|
146
|
+
aboutFeedback: '反馈问题',
|
|
147
|
+
aboutFeedbackLink: '提交问题',
|
|
148
|
+
aboutStar: '点个星',
|
|
149
|
+
aboutStarHint: '在 GitHub 上点 Star,让更多人看到',
|
|
150
|
+
aboutShare: '分享',
|
|
151
|
+
aboutShareHint: '复制项目地址,分享给朋友',
|
|
152
|
+
aboutShareDone: '项目地址已复制',
|
|
153
|
+
aboutShareFail: '复制失败,请手动复制项目地址',
|
|
154
|
+
aboutProject: '项目地址',
|
|
130
155
|
},
|
|
131
156
|
en: {
|
|
132
157
|
title: 'Plugin auto-update',
|
|
@@ -246,6 +271,20 @@ window.__ModuleLoader__.load({
|
|
|
246
271
|
policy: 'Update policy',
|
|
247
272
|
min: 'min',
|
|
248
273
|
scope: 'These settings apply to this profile only',
|
|
274
|
+
about: 'About aupdate',
|
|
275
|
+
aboutVersion: 'Version',
|
|
276
|
+
aboutChangelog: 'Changelog',
|
|
277
|
+
aboutChangelogLink: 'View changelog',
|
|
278
|
+
aboutRepo: 'Source code',
|
|
279
|
+
aboutFeedback: 'Report an issue',
|
|
280
|
+
aboutFeedbackLink: 'Open an issue',
|
|
281
|
+
aboutStar: 'Star',
|
|
282
|
+
aboutStarHint: 'Star on GitHub to help others find it',
|
|
283
|
+
aboutShare: 'Share',
|
|
284
|
+
aboutShareHint: 'Copy the project link to share',
|
|
285
|
+
aboutShareDone: 'Project link copied',
|
|
286
|
+
aboutShareFail: 'Could not copy; please copy the link manually',
|
|
287
|
+
aboutProject: 'Project URL',
|
|
249
288
|
},
|
|
250
289
|
}
|
|
251
290
|
|
|
@@ -464,6 +503,10 @@ window.__ModuleLoader__.load({
|
|
|
464
503
|
pkgName: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
465
504
|
pkgVer: { opacity: 0.5, fontSize: '11px', marginLeft: 'auto', flexShrink: 0 },
|
|
466
505
|
search: { padding: '4px 8px', borderRadius: '6px', border: '1px solid rgba(128,128,128,0.32)', background: 'transparent', color: 'inherit', fontSize: '12.5px' },
|
|
506
|
+
// 「关于」组:外链靠右等宽、↗ 与文字同色但更淡,避免整行像按钮。
|
|
507
|
+
link: { color: 'inherit', textDecoration: 'none', borderBottom: '1px solid rgba(128,128,128,0.4)', paddingBottom: '1px' },
|
|
508
|
+
linkExt: { opacity: 0.5, marginLeft: '3px' },
|
|
509
|
+
ver: { fontVariantNumeric: 'tabular-nums', opacity: 0.8 },
|
|
467
510
|
}
|
|
468
511
|
|
|
469
512
|
function Toggle(props) {
|
|
@@ -645,6 +688,81 @@ window.__ModuleLoader__.load({
|
|
|
645
688
|
)
|
|
646
689
|
}
|
|
647
690
|
|
|
691
|
+
/**
|
|
692
|
+
* 「关于 aupdate」信息组。
|
|
693
|
+
*
|
|
694
|
+
* 照 Bloom 设置页的「关于 Bloom」做:版本、更新日志、仓库、反馈四行纯信息,
|
|
695
|
+
* 再加「点个星 / 分享」。版本从 /state 读(随 package.json 变),不写死。
|
|
696
|
+
*
|
|
697
|
+
* 分享用 clipboard 复制项目地址:navigator.share 在桌面 webview 里多半不可用,
|
|
698
|
+
* 而「复制地址」在任何环境都能工作;失败就让用户手动复制,不静默吞掉。
|
|
699
|
+
*/
|
|
700
|
+
function AboutCard(props) {
|
|
701
|
+
useLang()
|
|
702
|
+
const [shareHint, setShareHint] = useState('')
|
|
703
|
+
const version = props.version || ''
|
|
704
|
+
|
|
705
|
+
const extLink = (href, label) => h('a', {
|
|
706
|
+
href,
|
|
707
|
+
target: '_blank',
|
|
708
|
+
rel: 'noopener noreferrer',
|
|
709
|
+
style: S.link,
|
|
710
|
+
}, label, h('span', { style: S.linkExt, 'aria-hidden': 'true' }, '↗'))
|
|
711
|
+
|
|
712
|
+
const share = async () => {
|
|
713
|
+
try {
|
|
714
|
+
if (navigator.clipboard?.writeText) {
|
|
715
|
+
await navigator.clipboard.writeText(REPO_URL)
|
|
716
|
+
setShareHint(T.aboutShareDone)
|
|
717
|
+
return
|
|
718
|
+
}
|
|
719
|
+
setShareHint(T.aboutShareFail)
|
|
720
|
+
} catch {
|
|
721
|
+
setShareHint(T.aboutShareFail)
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
return h('div', { style: S.card },
|
|
726
|
+
h('span', { style: S.label }, T.about),
|
|
727
|
+
h('div', { style: S.row },
|
|
728
|
+
h('span', { style: S.label }, T.aboutVersion),
|
|
729
|
+
h('span', { style: S.ver }, version === '' ? '…' : 'v' + version),
|
|
730
|
+
),
|
|
731
|
+
h('div', { style: S.row },
|
|
732
|
+
h('span', { style: S.label }, T.aboutChangelog),
|
|
733
|
+
extLink(CHANGELOG_URL, T.aboutChangelogLink),
|
|
734
|
+
),
|
|
735
|
+
h('div', { style: S.row },
|
|
736
|
+
h('span', { style: S.label }, T.aboutRepo),
|
|
737
|
+
extLink(REPO_URL, 'GitHub'),
|
|
738
|
+
),
|
|
739
|
+
h('div', { style: S.row },
|
|
740
|
+
h('span', { style: S.label }, T.aboutFeedback),
|
|
741
|
+
extLink(ISSUES_URL, T.aboutFeedbackLink),
|
|
742
|
+
),
|
|
743
|
+
h('div', { style: S.row },
|
|
744
|
+
h('span', { style: S.labelBox },
|
|
745
|
+
h('span', { style: S.label }, T.aboutStar),
|
|
746
|
+
h('span', { style: S.hint }, T.aboutStarHint),
|
|
747
|
+
),
|
|
748
|
+
extLink(STARS_URL, 'GitHub'),
|
|
749
|
+
),
|
|
750
|
+
h('div', { style: S.row },
|
|
751
|
+
h('span', { style: S.labelBox },
|
|
752
|
+
h('span', { style: S.label }, T.aboutShare),
|
|
753
|
+
h('span', { style: S.hint }, T.aboutShareHint),
|
|
754
|
+
),
|
|
755
|
+
h('button', { type: 'button', style: S.btn, onClick: () => void share() }, T.aboutShare),
|
|
756
|
+
),
|
|
757
|
+
// 项目地址可点开、可选中复制,失败时用户还有这一条路。
|
|
758
|
+
h('div', { style: S.row },
|
|
759
|
+
h('span', { style: S.label }, T.aboutProject),
|
|
760
|
+
extLink(REPO_URL, REPO_URL.replace('https://', '')),
|
|
761
|
+
),
|
|
762
|
+
shareHint ? h('span', { style: S.status }, shareHint) : null,
|
|
763
|
+
)
|
|
764
|
+
}
|
|
765
|
+
|
|
648
766
|
function AutoUpdateCard() {
|
|
649
767
|
useLang()
|
|
650
768
|
const [state, setState] = useState(null)
|
|
@@ -1034,6 +1152,7 @@ window.__ModuleLoader__.load({
|
|
|
1034
1152
|
// 没有保存按钮:改动自己在 350ms 后落盘,这里只报它落没落成。
|
|
1035
1153
|
saveHint ? h('span', { style: S.status }, saveHint) : null,
|
|
1036
1154
|
h('span', { style: S.hint }, T.scope),
|
|
1155
|
+
h(AboutCard, { version: state?.version }),
|
|
1037
1156
|
)
|
|
1038
1157
|
}
|
|
1039
1158
|
|
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