complete auto update

This commit is contained in:
pompurin404 2024-08-18 15:39:36 +08:00
parent 5fc26d2249
commit cd3c032723
No known key found for this signature in database
4 changed files with 766 additions and 577 deletions

View File

@ -62,6 +62,7 @@
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13", "react-error-boundary": "^4.0.13",
"react-icons": "^5.2.1", "react-icons": "^5.2.1",
"react-markdown": "^9.0.1",
"react-monaco-editor": "^0.56.0", "react-monaco-editor": "^0.56.0",
"react-router-dom": "^6.26.0", "react-router-dom": "^6.26.0",
"react-virtuoso": "^4.9.0", "react-virtuoso": "^4.9.0",

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,19 @@ const UpdaterModal: React.FC<Props> = (props) => {
scrollBehavior="inside" scrollBehavior="inside"
> >
<ModalContent className="h-full w-[calc(100%-100px)]"> <ModalContent className="h-full w-[calc(100%-100px)]">
<ModalHeader className="flex">v{version} </ModalHeader> <ModalHeader className="flex justify-between">
<div>v{version} </div>
<Button
color="primary"
size="sm"
className="flex"
onPress={() => {
open(`https://github.com/pompurin404/mihomo-party/releases/tag/v${version}`)
}}
>
</Button>
</ModalHeader>
<ModalBody className="h-full"> <ModalBody className="h-full">
<ReactMarkdown <ReactMarkdown
className="markdown-body select-text" className="markdown-body select-text"

View File

@ -3,6 +3,7 @@ import BasePage from '@renderer/components/base/base-page'
import SettingCard from '@renderer/components/base/base-setting-card' import SettingCard from '@renderer/components/base/base-setting-card'
import SettingItem from '@renderer/components/base/base-setting-item' import SettingItem from '@renderer/components/base/base-setting-item'
import { useAppConfig } from '@renderer/hooks/use-app-config' import { useAppConfig } from '@renderer/hooks/use-app-config'
import UpdaterModal from '@renderer/components/updater/updater-modal'
import { import {
checkAutoRun, checkAutoRun,
enableAutoRun, enableAutoRun,
@ -45,6 +46,10 @@ const Settings: React.FC = () => {
webdavUsername, webdavUsername,
webdavPassword webdavPassword
} = appConfig || {} } = appConfig || {}
const [newVersion, setNewVersion] = useState('')
const [changelog, setChangelog] = useState('')
const [openUpdate, setOpenUpdate] = useState(false)
const [checkingUpdate, setCheckingUpdate] = useState(false)
const [backuping, setBackuping] = useState(false) const [backuping, setBackuping] = useState(false)
const [restoring, setRestoring] = useState(false) const [restoring, setRestoring] = useState(false)
const [filenames, setFilenames] = useState<string[]>([]) const [filenames, setFilenames] = useState<string[]>([])
@ -114,6 +119,13 @@ const Settings: React.FC = () => {
{restoreOpen && ( {restoreOpen && (
<WebdavRestoreModal filenames={filenames} onClose={() => setRestoreOpen(false)} /> <WebdavRestoreModal filenames={filenames} onClose={() => setRestoreOpen(false)} />
)} )}
{openUpdate && (
<UpdaterModal
onClose={() => setOpenUpdate(false)}
version={newVersion}
changelog={changelog}
/>
)}
<BasePage <BasePage
title="应用设置" title="应用设置"
@ -370,21 +382,22 @@ const Settings: React.FC = () => {
<SettingItem title="检查更新" divider> <SettingItem title="检查更新" divider>
<Button <Button
size="sm" size="sm"
isLoading={checkingUpdate}
onPress={async () => { onPress={async () => {
try { try {
setCheckingUpdate(true)
const version = await checkUpdate() const version = await checkUpdate()
if (version) { if (version) {
new window.Notification(`v${version}版本已发布`, { setNewVersion(version.version)
body: '点击前往下载' setChangelog(version.changelog)
}).onclick = (): void => { setOpenUpdate(true)
open(`https://github.com/pompurin404/mihomo-party/releases/tag/v${version}`)
}
} else { } else {
new window.Notification('当前已是最新版本', { body: '无需更新' }) new window.Notification('当前已是最新版本', { body: '无需更新' })
} }
} catch (e) { } catch (e) {
alert(e) alert(e)
} finally {
setCheckingUpdate(false)
} }
}} }}
> >