diff --git a/napcat.webui/src/pages/dashboard/config/index.tsx b/napcat.webui/src/pages/dashboard/config/index.tsx index 2ddd55b1..d290fb12 100644 --- a/napcat.webui/src/pages/dashboard/config/index.tsx +++ b/napcat.webui/src/pages/dashboard/config/index.tsx @@ -1,12 +1,14 @@ import { Tab, Tabs } from '@heroui/tabs' import { useLocalStorage } from '@uidotdev/usehooks' -import { useEffect } from 'react' +import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' import toast from 'react-hot-toast' import { useMediaQuery } from 'react-responsive' import key from '@/const/key' +import PageLoading from '@/components/page_loading' + import useConfig from '@/hooks/use-config' import useMusic from '@/hooks/use-music' @@ -15,6 +17,7 @@ import WebUIConfigCard from './webui' export default function ConfigPage() { const { config, saveConfigWithoutNetwork, refreshConfig } = useConfig() + const [loading, setLoading] = useState(false) const { control: onebotControl, handleSubmit: handleOnebotSubmit, @@ -82,13 +85,16 @@ export default function ConfigPage() { } }) - const onRefresh = async () => { + const onRefresh = async (shotTip = true) => { try { + setLoading(true) await refreshConfig() - toast.success('刷新成功') + if (shotTip) toast.success('刷新成功') } catch (error) { const msg = (error as Error).message toast.error(`刷新失败: ${msg}`) + } finally { + setLoading(false) } } @@ -97,6 +103,10 @@ export default function ConfigPage() { resetWebUI() }, [config]) + useEffect(() => { + onRefresh(false) + }, []) + return (
+