dsh-aupdate 0.6.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/client.js +27 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -445,8 +445,8 @@ The page renders the log newest first, so whatever just happened is at the top o
|
|
|
445
445
|
box instead of at the bottom of a scroll. During installation it writes "Installing N/M:
|
|
446
446
|
<name>" for each package and, past two minutes on any one package, an explicit slow-install
|
|
447
447
|
notice — pnpm buffers network warnings until the command ends, so there needs to be an
|
|
448
|
-
anchor in the meantime. The
|
|
449
|
-
|
|
448
|
+
anchor in the meantime. The settings page polls /state every three seconds while it is open, so progress
|
|
449
|
+
from an automatically scheduled cycle shows up too — not only one started by the button.
|
|
450
450
|
|
|
451
451
|
Log lines are stored as an event code plus its arguments, not as finished sentences, so
|
|
452
452
|
switching **Display language** re-renders history too. Lines written before 0.6.2 are
|
package/client.js
CHANGED
|
@@ -680,6 +680,25 @@ window.__ModuleLoader__.load({
|
|
|
680
680
|
|
|
681
681
|
useEffect(() => { void load() }, [load])
|
|
682
682
|
|
|
683
|
+
// 进度轮询要常驻:更新多数是定时器自动触发的,若只在点「立刻检查」时轮询,
|
|
684
|
+
// 自动跑的那一轮界面上什么也看不到——上次就是这个原因以为进度功能没生效。
|
|
685
|
+
useEffect(() => {
|
|
686
|
+
let alive = true
|
|
687
|
+
const tick = async () => {
|
|
688
|
+
try {
|
|
689
|
+
const next = await getState(LANG)
|
|
690
|
+
if (alive) {
|
|
691
|
+
setProgress(next?.progress ?? null)
|
|
692
|
+
// 别人(定时器 / 另一个窗口)触发的轮次,也把 running 点亮。
|
|
693
|
+
if (next?.progress) setRunning(true)
|
|
694
|
+
}
|
|
695
|
+
} catch {}
|
|
696
|
+
}
|
|
697
|
+
void tick()
|
|
698
|
+
const timer = setInterval(() => { void tick() }, 3000)
|
|
699
|
+
return () => { alive = false; clearInterval(timer) }
|
|
700
|
+
}, [LANG])
|
|
701
|
+
|
|
683
702
|
/**
|
|
684
703
|
* 立即保存。
|
|
685
704
|
*
|
|
@@ -736,15 +755,15 @@ window.__ModuleLoader__.load({
|
|
|
736
755
|
|
|
737
756
|
/** 把后端进度翻成一行中文/英文;没进度就退回普通「正在检查」。 */
|
|
738
757
|
const runningText = (() => {
|
|
739
|
-
if (!
|
|
740
|
-
if (progress
|
|
758
|
+
if (!progress) return ''
|
|
759
|
+
if (progress.phase === 'installing' && progress.total > 0) {
|
|
741
760
|
return T.progressInstall
|
|
742
761
|
.replace('{n}', String(progress.index))
|
|
743
762
|
.replace('{m}', String(progress.total))
|
|
744
763
|
.replace('{name}', String(progress.name || ''))
|
|
745
764
|
}
|
|
746
|
-
if (progress
|
|
747
|
-
if (progress
|
|
765
|
+
if (progress.phase === 'applying') return T.progressApply
|
|
766
|
+
if (progress.phase === 'checking') return T.progressCheck
|
|
748
767
|
return T.running
|
|
749
768
|
})()
|
|
750
769
|
|
|
@@ -752,19 +771,9 @@ window.__ModuleLoader__.load({
|
|
|
752
771
|
if (running) return
|
|
753
772
|
setRunning(true)
|
|
754
773
|
setRunHint(T.running)
|
|
755
|
-
setProgress(null)
|
|
756
774
|
try {
|
|
757
|
-
//
|
|
758
|
-
const
|
|
759
|
-
try {
|
|
760
|
-
setProgress((await getState(LANG))?.progress ?? null)
|
|
761
|
-
} catch {}
|
|
762
|
-
}
|
|
763
|
-
void poll()
|
|
764
|
-
const timer = setInterval(() => { void poll() }, 2000)
|
|
765
|
-
const result = await (async () => {
|
|
766
|
-
try { return await runNow('update') } finally { clearInterval(timer) }
|
|
767
|
-
})()
|
|
775
|
+
// 进度由上面的常驻轮询统一负责,这里只发请求。
|
|
776
|
+
const result = await runNow('update')
|
|
768
777
|
if (result?.started === false) {
|
|
769
778
|
setRunHint(result.reason || T.runFailed)
|
|
770
779
|
} else {
|
|
@@ -780,7 +789,7 @@ window.__ModuleLoader__.load({
|
|
|
780
789
|
setRunHint(T.runFailed)
|
|
781
790
|
} finally {
|
|
782
791
|
setRunning(false)
|
|
783
|
-
|
|
792
|
+
// 不在这里清 progress:常驻轮询会在后端清掉后同步,手动作废会和它打架。
|
|
784
793
|
}
|
|
785
794
|
}, [running])
|
|
786
795
|
|
|
@@ -961,7 +970,7 @@ window.__ModuleLoader__.load({
|
|
|
961
970
|
h('button', { type: 'button', style: S.btn, disabled: running, onClick: () => void fire() }, running ? T.running : T.runNow),
|
|
962
971
|
),
|
|
963
972
|
// 进度单独占一行:安装要几分钟甚至更久,这里明确告诉用户在装第几个。
|
|
964
|
-
|
|
973
|
+
progress
|
|
965
974
|
? h('span', { style: { ...S.status, color: '#4c9aff', fontWeight: 500 } }, runningText)
|
|
966
975
|
: null,
|
|
967
976
|
last === null || last === undefined
|
package/package.json
CHANGED