From 90c3d15616860c27c80b47e4190414a68ec395c2 Mon Sep 17 00:00:00 2001 From: kunish Date: Fri, 11 Oct 2024 00:48:50 +0800 Subject: [PATCH] feat(config): rearrange settings --- src/i18n/en.ts | 2 +- src/i18n/index.tsx | 2 + src/i18n/zh.ts | 2 +- src/pages/Config.tsx | 258 +++++++++++++++++++++++-------------------- 4 files changed, 144 insertions(+), 120 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index cc0124e..6547045 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -108,7 +108,7 @@ export default { enableTunDevice: 'Enable TUN Device', tunModeStack: 'TUN Mode Stack', tunDeviceName: 'TUN Device Name', - interfaceName: 'Interface Name', + outboundInterfaceName: 'Outbound Interface Name', en: 'English', zh: 'Chinese', port: '{{ name }} Port', diff --git a/src/i18n/index.tsx b/src/i18n/index.tsx index 9e5c78e..3975968 100644 --- a/src/i18n/index.tsx +++ b/src/i18n/index.tsx @@ -24,3 +24,5 @@ export const [I18nProvider, useMaybeI18n] = createContextProvider< ]) export const useI18n = () => useMaybeI18n()! + +export { type Dict } diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts index b58485c..b470023 100644 --- a/src/i18n/zh.ts +++ b/src/i18n/zh.ts @@ -110,7 +110,7 @@ export default { enableTunDevice: '开启 TUN 转发', tunModeStack: 'TUN 模式堆栈', tunDeviceName: 'TUN 设备名称', - interfaceName: '接口名称', + outboundInterfaceName: '出站接口名称', en: '英文', zh: '中文', port: '{{ name }} 端口', diff --git a/src/pages/Config.tsx b/src/pages/Config.tsx index 05e988f..fc5b15f 100644 --- a/src/pages/Config.tsx +++ b/src/pages/Config.tsx @@ -1,7 +1,8 @@ import { createForm } from '@felte/solid' import { validator } from '@felte/validator-zod' -import type { Accessor, Component, ParentComponent } from 'solid-js' +import type { Accessor, Component, JSX, ParentComponent } from 'solid-js' import { toast } from 'solid-toast' +import { twMerge } from 'tailwind-merge' import { z } from 'zod' import { fetchBackendConfigAPI, @@ -25,7 +26,7 @@ import { import { Button, ConfigTitle } from '~/components' import DocumentTitle from '~/components/DocumentTitle' import { LANG, ROUTES, themes } from '~/constants' -import { locale, setLocale, useI18n } from '~/i18n' +import { Dict, locale, setLocale, useI18n } from '~/i18n' import { autoSwitchTheme, endpoint, @@ -41,6 +42,55 @@ import { } from '~/signals' import type { DNSQuery } from '~/types' +const Toggle: ParentComponent> = ( + props, +) => { + const [local, others] = splitProps(props, ['class']) + + return ( + + ) +} + +const Input: ParentComponent> = ( + props, +) => { + const [local, others] = splitProps(props, ['class']) + + return ( + + ) +} + +const Select: ParentComponent> = ( + props, +) => { + const [local, others] = splitProps(props, ['class']) + + return ( + + ) +} + +const Label: ParentComponent> = ( + props, +) => { + const [local, others] = splitProps(props, ['class']) + + return ( + + ) +} + const dnsQueryFormSchema = z.object({ name: z.string(), type: z.string(), @@ -71,10 +121,10 @@ const DNSQueryForm = () => { return (
- { if (!e.target.value) setDNSQueryResult([]) @@ -82,11 +132,11 @@ const DNSQueryForm = () => { />
- - +