fix(config): backend version is likely to be undefined when invoking isUpdateAvailableAPI

This commit is contained in:
kunish 2023-10-16 20:33:41 +08:00
parent 79335831cb
commit 398f05d8a5
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -467,8 +467,12 @@ const Versions: Component<{ backendVersion: Accessor<string> }> = ({
}) => { }) => {
const [isUpdateAvailable, setIsUpdateAvailable] = createSignal(false) const [isUpdateAvailable, setIsUpdateAvailable] = createSignal(false)
onMount(async () => { createEffect(async () => {
setIsUpdateAvailable(await isUpdateAvailableAPI(backendVersion())) const version = backendVersion()
if (!version) return
setIsUpdateAvailable(await isUpdateAvailableAPI(version))
}) })
return ( return (
@ -494,15 +498,14 @@ const Versions: Component<{ backendVersion: Accessor<string> }> = ({
} }
export default () => { export default () => {
const [t] = useI18n()
const [backendVersion, setBackendVersion] = createSignal('') const [backendVersion, setBackendVersion] = createSignal('')
onMount(async () => { onMount(async () => {
const version = await fetchBackendVersionAPI() setBackendVersion(await fetchBackendVersionAPI())
setBackendVersion(version)
}) })
const [t] = useI18n()
return ( return (
<div class="mx-auto flex max-w-screen-md flex-col gap-4"> <div class="mx-auto flex max-w-screen-md flex-col gap-4">
<Show when={!isSingBox(backendVersion())}> <Show when={!isSingBox(backendVersion())}>