mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-15 06:45:36 +08:00
feat(config): refresh backend version after core gets updated
This commit is contained in:
parent
1e7dcb13bc
commit
73b7e3e40a
@ -163,9 +163,10 @@ const configFormSchema = z.object({
|
|||||||
'mixed-port': z.number(),
|
'mixed-port': z.number(),
|
||||||
})
|
})
|
||||||
|
|
||||||
const ConfigForm: ParentComponent<{ isSingBox: Accessor<boolean> }> = ({
|
const ConfigForm: ParentComponent<{
|
||||||
isSingBox,
|
isSingBox: Accessor<boolean>
|
||||||
}) => {
|
fetchBackendVersion: () => Promise<void>
|
||||||
|
}> = ({ isSingBox, fetchBackendVersion }) => {
|
||||||
const [t] = useI18n()
|
const [t] = useI18n()
|
||||||
|
|
||||||
const portList = [
|
const portList = [
|
||||||
@ -408,7 +409,10 @@ const ConfigForm: ParentComponent<{ isSingBox: Accessor<boolean> }> = ({
|
|||||||
<Button
|
<Button
|
||||||
class="btn-error"
|
class="btn-error"
|
||||||
loading={upgradingBackend()}
|
loading={upgradingBackend()}
|
||||||
onClick={upgradeBackendAPI}
|
onClick={async () => {
|
||||||
|
await upgradeBackendAPI()
|
||||||
|
await fetchBackendVersion()
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{t('upgradeCore')}
|
{t('upgradeCore')}
|
||||||
</Button>
|
</Button>
|
||||||
@ -527,9 +531,12 @@ const Versions: Component<{
|
|||||||
const [isFrontendUpdateAvailable] = createResource(() =>
|
const [isFrontendUpdateAvailable] = createResource(() =>
|
||||||
isFrontendUpdateAvailableAPI(frontendVersion),
|
isFrontendUpdateAvailableAPI(frontendVersion),
|
||||||
)
|
)
|
||||||
const [isBackendUpdateAvailable] = createResource(() =>
|
const [isBackendUpdateAvailable, { refetch: fetchIsBackendUpdateAvailable }] =
|
||||||
isBackendUpdateAvailableAPI(backendVersion()),
|
createResource(() => isBackendUpdateAvailableAPI(backendVersion()))
|
||||||
)
|
|
||||||
|
createEffect(() => {
|
||||||
|
fetchIsBackendUpdateAvailable()
|
||||||
|
}, backendVersion())
|
||||||
|
|
||||||
const UpdateAvailableIndicator = () => (
|
const UpdateAvailableIndicator = () => (
|
||||||
<span class="absolute -right-1 -top-1 flex h-3 w-3">
|
<span class="absolute -right-1 -top-1 flex h-3 w-3">
|
||||||
@ -571,9 +578,10 @@ export default () => {
|
|||||||
const [t] = useI18n()
|
const [t] = useI18n()
|
||||||
|
|
||||||
const frontendVersion = `v${import.meta.env.APP_VERSION}`
|
const frontendVersion = `v${import.meta.env.APP_VERSION}`
|
||||||
const [backendVersion] = createResource(fetchBackendVersionAPI, {
|
const [backendVersion, { refetch: fetchBackendVersion }] = createResource(
|
||||||
initialValue: '',
|
fetchBackendVersionAPI,
|
||||||
})
|
{ initialValue: '' },
|
||||||
|
)
|
||||||
|
|
||||||
const isSingBox = createMemo(
|
const isSingBox = createMemo(
|
||||||
() => backendVersion()?.includes('sing-box') || false,
|
() => backendVersion()?.includes('sing-box') || false,
|
||||||
@ -592,7 +600,12 @@ export default () => {
|
|||||||
|
|
||||||
<ConfigTitle withDivider>{t('coreConfig')}</ConfigTitle>
|
<ConfigTitle withDivider>{t('coreConfig')}</ConfigTitle>
|
||||||
|
|
||||||
<ConfigForm isSingBox={isSingBox} />
|
<ConfigForm
|
||||||
|
isSingBox={isSingBox}
|
||||||
|
fetchBackendVersion={() =>
|
||||||
|
fetchBackendVersion() as unknown as Promise<void>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<ConfigTitle withDivider>{t('xdConfig')}</ConfigTitle>
|
<ConfigTitle withDivider>{t('xdConfig')}</ConfigTitle>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user