feat: add CheckUpdate

main
spacemeowx2 2023-03-08 22:21:25 +08:00 committed by imspace
parent 3b36a6b7d8
commit 8a913e35aa
4 changed files with 24 additions and 2 deletions

View File

@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.2", features = [] }
[dependencies]
tauri = { version = "1.2", features = ["fs-all", "path-all", "shell-execute", "shell-open", "shell-sidecar", "updater", "window-all"] }
tauri = { version = "1.2", features = ["fs-all", "path-all", "process-relaunch", "shell-execute", "shell-open", "shell-sidecar", "updater", "window-all"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.0", features = ["time"] }

View File

@ -8,7 +8,7 @@
},
"package": {
"productName": "s3si-ts",
"version": "0.3.3"
"version": "0.3.2"
},
"tauri": {
"allowlist": {
@ -47,6 +47,10 @@
},
"path": {
"all": true
},
"process": {
"all": false,
"relaunch": true
}
},
"bundle": {

View File

@ -0,0 +1,16 @@
import { ReactNode } from "react";
import { checkUpdate } from '@tauri-apps/api/updater'
export const CheckUpdate: React.FC<{ className?: string, children?: ReactNode }> = ({ className, children }) => {
const onClick = async () => {
try {
await checkUpdate()
} catch (error) {
console.log(error)
}
}
return <>
<button className={className} onClick={onClick}>{children}</button>
</>;
}

View File

@ -1,3 +1,4 @@
import { CheckUpdate } from 'components/CheckUpdate';
import { ErrorContent } from 'components/ErrorContent';
import { Loading } from 'components/Loading';
import { STAT_INK } from 'constant';
@ -33,6 +34,7 @@ export const Home: React.FC = () => {
<div className='flex flex-col gap-2'>
<Link to='/settings' className='btn btn-primary'>{t('配置')}</Link>
<a className='btn' href={STAT_INK} target='_blank' rel='noreferrer'>{t('前往 stat.ink')}</a>
<CheckUpdate className='btn'>{t('检查更新')}</CheckUpdate>
</div>
</div>
</>