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