}> = ({
+ isSingBox,
+}) => {
const [t] = useI18n()
const portList = [
@@ -180,9 +178,9 @@ const ConfigForm = () => {
}
})
- const modes = () => {
- return configsData()?.modes || ['rule', 'direct', 'global']
- }
+ const modes = createMemo(
+ () => configsData()?.modes || ['rule', 'direct', 'global'],
+ )
return (
@@ -538,7 +536,12 @@ export default () => {
const [t] = useI18n()
- updateBackendVersion()
+ const [backendVersion, setBackendVersion] = createSignal('')
+ const isSingBox = createMemo(() => backendVersion().includes('sing-box'))
+
+ onMount(() => {
+ fetchBackendVersionAPI().then(setBackendVersion)
+ })
return (
<>
@@ -553,7 +556,7 @@ export default () => {
{t('coreConfig')}
-
+
{t('xdConfig')}
diff --git a/src/pages/Setup.tsx b/src/pages/Setup.tsx
index 81f5d0b..044d367 100644
--- a/src/pages/Setup.tsx
+++ b/src/pages/Setup.tsx
@@ -28,7 +28,7 @@ export default () => {
const onSetupSuccess = (id: string) => {
setSelectedEndpoint(id)
- navigate('/overview')
+ navigate('/overview', { replace: true })
}
const checkEndpoint = (url: string, secret: string) =>
@@ -50,13 +50,9 @@ export default () => {
const onEndpointSelect = async (id: string) => {
const endpoint = endpointList().find((e) => e.id === id)
- if (!endpoint) {
- return
- }
+ if (!endpoint) return
- if (!(await checkEndpoint(endpoint.url, endpoint.secret))) {
- return
- }
+ if (!(await checkEndpoint(endpoint.url, endpoint.secret))) return
onSetupSuccess(id)
}
@@ -64,9 +60,7 @@ export default () => {
const onSubmit = async ({ url, secret }: { url: string; secret: string }) => {
const transformedURL = transformEndpointURL(url)
- if (!(await checkEndpoint(transformedURL, secret))) {
- return
- }
+ if (!(await checkEndpoint(transformedURL, secret))) return
const id = uuid()
const list = endpointList().slice()
diff --git a/src/signals/logs.ts b/src/signals/logs.ts
index 37eac17..e8c5e0c 100644
--- a/src/signals/logs.ts
+++ b/src/signals/logs.ts
@@ -7,26 +7,26 @@ let seq = 1
const [logs, setLogs] = createSignal([])
const [paused, setPaused] = createSignal(false)
-createEffect(
- on(logLevel, (value, oldValue) => {
- if (value === oldValue) return
-
- const logsData = useWsRequest('logs', { level: logLevel() })
-
- createEffect(() => {
- const data = logsData()
-
- if (!data || paused()) {
- return
- }
-
- setLogs((logs) => [{ ...data, seq }, ...logs].slice(0, logMaxRows()))
- seq++
- })
- }),
-)
-
export const useLogs = () => {
+ createEffect(
+ on(logLevel, (value, oldValue) => {
+ if (value === oldValue) return
+
+ const logsData = useWsRequest('logs', { level: logLevel() })
+
+ createEffect(() => {
+ const data = logsData()
+
+ if (!data || paused()) {
+ return
+ }
+
+ setLogs((logs) => [{ ...data, seq }, ...logs].slice(0, logMaxRows()))
+ seq++
+ })
+ }),
+ )
+
return {
logs,
paused,
diff --git a/src/signals/version.ts b/src/signals/version.ts
deleted file mode 100644
index d820b15..0000000
--- a/src/signals/version.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { fetchBackendVersionAPI } from '~/apis'
-
-export const [backendVersion, setBackendVersion] = createSignal('')
-export const isSingBox = createMemo(() => {
- return backendVersion().includes('sing-box')
-})
-export const updateBackendVersion = () => {
- fetchBackendVersionAPI().then(setBackendVersion)
-}