Skip to content

Commit 0744981

Browse files
committed
fix: render update notes as plain text
1 parent de37c69 commit 0744981

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kmysql",
3-
"version": "1.0.49",
3+
"version": "1.0.50",
44
"description": "kMysql",
55
"author": {
66
"name": "KK1181958464",

src/renderer/src/components/AppUpdater.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ function formatBytes(value: number): string {
2525
return `${amount.toFixed(index === 0 ? 0 : 1)} ${units[index]}`
2626
}
2727

28+
function formatReleaseNotes(value?: string): string {
29+
if (!value) return ''
30+
const document = new DOMParser().parseFromString(value, 'text/html')
31+
const text = document.body.textContent?.replace(/\s+/g, ' ').trim() || ''
32+
return text.replace(/^Full Changelog\s*:/i, '完整更新记录:')
33+
}
34+
2835
export default function AppUpdater() {
2936
const [state, setState] = useState<AppUpdateState>(initialState)
3037
const [open, setOpen] = useState(false)
@@ -61,6 +68,7 @@ export default function AppUpdater() {
6168

6269
const hasUpdate = state.status === 'available' || state.status === 'downloading' || state.status === 'downloaded'
6370
const progress = Math.max(0, Math.min(100, state.progress?.percent || 0))
71+
const releaseNotes = formatReleaseNotes(state.releaseNotes)
6472

6573
const renderContent = () => {
6674
if (state.status === 'checking' || state.status === 'idle') {
@@ -83,7 +91,7 @@ export default function AppUpdater() {
8391
<span>当前版本 {state.currentVersion}</span>
8492
</div>
8593
</div>
86-
{state.releaseNotes && <div className="app-update-notes">{state.releaseNotes}</div>}
94+
{releaseNotes && <div className="app-update-notes">{releaseNotes}</div>}
8795
</div>
8896
)
8997
}
@@ -152,6 +160,7 @@ export default function AppUpdater() {
152160
if (state.status === 'available') {
153161
return (
154162
<>
163+
<Button onClick={() => void api.updater.openRelease()}>查看 Release</Button>
155164
<Button onClick={() => setOpen(false)}>稍后提醒</Button>
156165
<Button variant="primary" icon={<DownloadOutlined />} onClick={() => void api.updater.download()}>下载更新</Button>
157166
</>

0 commit comments

Comments
 (0)