2023-08-28 22:36:38 +08:00
|
|
|
import { createForm } from '@felte/solid'
|
|
|
|
import { validator } from '@felte/validator-zod'
|
2023-09-05 20:53:00 +08:00
|
|
|
import { useNavigate } from '@solidjs/router'
|
2023-09-16 02:50:21 +08:00
|
|
|
import {
|
2023-10-16 20:26:16 +08:00
|
|
|
Accessor,
|
|
|
|
Component,
|
2023-09-16 02:50:21 +08:00
|
|
|
For,
|
|
|
|
Show,
|
|
|
|
createEffect,
|
|
|
|
createResource,
|
|
|
|
createSignal,
|
|
|
|
onMount,
|
|
|
|
} from 'solid-js'
|
2023-10-04 18:16:37 +08:00
|
|
|
import { toast } from 'solid-toast'
|
2023-08-28 22:13:48 +08:00
|
|
|
import { z } from 'zod'
|
2023-09-12 21:33:16 +08:00
|
|
|
import {
|
|
|
|
fetchBackendConfigAPI,
|
|
|
|
fetchBackendVersionAPI,
|
2023-09-16 02:50:21 +08:00
|
|
|
flushFakeIPDataAPI,
|
|
|
|
flushingFakeIPData,
|
2023-09-23 03:57:08 +08:00
|
|
|
isUpdateAvailableAPI,
|
2023-09-16 02:50:21 +08:00
|
|
|
reloadConfigFileAPI,
|
|
|
|
reloadingConfigFile,
|
2023-09-12 21:33:16 +08:00
|
|
|
restartBackendAPI,
|
|
|
|
restartingBackend,
|
|
|
|
updateBackendConfigAPI,
|
|
|
|
updateGEODatabasesAPI,
|
|
|
|
updatingGEODatabases,
|
|
|
|
upgradeBackendAPI,
|
|
|
|
upgradingBackend,
|
|
|
|
} from '~/apis'
|
2023-09-15 23:43:55 +08:00
|
|
|
import { Button, ConfigTitle } from '~/components'
|
2023-09-23 02:06:57 +08:00
|
|
|
import { LANG, MODE_OPTIONS, ROUTES, themes } from '~/constants'
|
2023-10-16 20:26:16 +08:00
|
|
|
import { isSingBox } from '~/helpers'
|
2023-09-23 02:06:57 +08:00
|
|
|
import { locale, setLocale, useI18n } from '~/i18n'
|
2023-09-02 15:55:38 +08:00
|
|
|
import {
|
2023-09-02 19:06:02 +08:00
|
|
|
autoSwitchTheme,
|
|
|
|
favDayTheme,
|
|
|
|
favNightTheme,
|
|
|
|
setAutoSwitchTheme,
|
|
|
|
setFavDayTheme,
|
|
|
|
setFavNightTheme,
|
2023-09-05 20:53:00 +08:00
|
|
|
setSelectedEndpoint,
|
2023-09-16 23:55:42 +08:00
|
|
|
setUseTwemoji,
|
2023-09-03 03:26:29 +08:00
|
|
|
useRequest,
|
2023-09-05 11:40:00 +08:00
|
|
|
useTwemoji,
|
2023-09-03 03:26:29 +08:00
|
|
|
} from '~/signals'
|
2023-09-12 21:33:16 +08:00
|
|
|
import type { DNSQuery } from '~/types'
|
2023-08-28 22:13:48 +08:00
|
|
|
|
2023-09-02 13:54:59 +08:00
|
|
|
const dnsQueryFormSchema = z.object({
|
|
|
|
name: z.string(),
|
|
|
|
type: z.string(),
|
|
|
|
})
|
|
|
|
|
|
|
|
const DNSQueryForm = () => {
|
2023-09-23 01:38:36 +08:00
|
|
|
const [t] = useI18n()
|
2023-09-02 13:54:59 +08:00
|
|
|
const request = useRequest()
|
|
|
|
|
2023-09-03 02:22:38 +08:00
|
|
|
const { form, isSubmitting } = createForm<z.infer<typeof dnsQueryFormSchema>>(
|
|
|
|
{
|
|
|
|
extend: validator({ schema: dnsQueryFormSchema }),
|
2023-10-04 18:16:37 +08:00
|
|
|
onSubmit: (values) =>
|
2023-09-03 02:22:38 +08:00
|
|
|
request
|
|
|
|
.get('dns/query', {
|
|
|
|
searchParams: { name: values.name, type: values.type },
|
|
|
|
})
|
|
|
|
.json<DNSQuery>()
|
|
|
|
.then(({ Answer }) =>
|
|
|
|
setDNSQueryResult(Answer?.map(({ data }) => data) || []),
|
|
|
|
)
|
2023-10-04 18:16:37 +08:00
|
|
|
.catch((err) => toast.error(err.message)),
|
2023-09-02 13:54:59 +08:00
|
|
|
},
|
2023-09-03 02:22:38 +08:00
|
|
|
)
|
2023-09-02 13:54:59 +08:00
|
|
|
|
|
|
|
const [DNSQueryResult, setDNSQueryResult] = createSignal<string[]>([])
|
|
|
|
|
|
|
|
return (
|
2023-09-02 14:02:25 +08:00
|
|
|
<div class="flex flex-col">
|
2023-09-16 23:46:22 +08:00
|
|
|
<form use:form={form} class="flex gap-2 sm:flex-row">
|
2023-09-10 16:42:00 +08:00
|
|
|
<input
|
|
|
|
type="search"
|
|
|
|
name="name"
|
2023-09-16 23:46:22 +08:00
|
|
|
class="input input-bordered min-w-0 flex-1"
|
2023-09-23 02:16:17 +08:00
|
|
|
placeholder="google.com"
|
2023-09-10 16:42:00 +08:00
|
|
|
/>
|
2023-09-05 22:32:47 +08:00
|
|
|
|
2023-09-02 18:04:57 +08:00
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
<select name="type" class="select select-bordered">
|
|
|
|
<option>A</option>
|
|
|
|
<option>AAAA</option>
|
|
|
|
<option>MX</option>
|
|
|
|
</select>
|
2023-09-03 02:22:38 +08:00
|
|
|
|
|
|
|
<Button type="submit" class="btn-primary" loading={isSubmitting()}>
|
2023-09-02 18:04:57 +08:00
|
|
|
{t('dnsQuery')}
|
2023-09-03 02:22:38 +08:00
|
|
|
</Button>
|
2023-09-02 18:04:57 +08:00
|
|
|
</div>
|
2023-09-02 13:54:59 +08:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<Show when={DNSQueryResult().length > 0}>
|
|
|
|
<div class="flex flex-col p-4">
|
|
|
|
<For each={DNSQueryResult()}>
|
|
|
|
{(item) => <div class="py-2">{item}</div>}
|
|
|
|
</For>
|
|
|
|
</div>
|
|
|
|
</Show>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const configFormSchema = z.object({
|
2023-08-28 22:13:48 +08:00
|
|
|
port: z.number(),
|
|
|
|
'socks-port': z.number(),
|
|
|
|
'redir-port': z.number(),
|
|
|
|
'tproxy-port': z.number(),
|
|
|
|
'mixed-port': z.number(),
|
|
|
|
})
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|
|
|
backendVersion,
|
|
|
|
}) => {
|
2023-09-23 01:38:36 +08:00
|
|
|
const [t] = useI18n()
|
2023-09-16 02:50:21 +08:00
|
|
|
const navigate = useNavigate()
|
2023-09-01 14:06:21 +08:00
|
|
|
|
2023-09-16 23:46:22 +08:00
|
|
|
const portList = [
|
2023-08-28 22:13:48 +08:00
|
|
|
{
|
2023-09-23 02:13:17 +08:00
|
|
|
label: () => t('port', { name: 'HTTP' }),
|
2023-08-28 22:13:48 +08:00
|
|
|
key: 'port',
|
2023-09-16 02:50:21 +08:00
|
|
|
onChange: (e: Event & { target: HTMLInputElement }) =>
|
|
|
|
void updateBackendConfigAPI('port', Number(e.target.value), refetch),
|
2023-08-28 22:13:48 +08:00
|
|
|
},
|
|
|
|
{
|
2023-09-23 02:13:17 +08:00
|
|
|
label: () => t('port', { name: 'Socks' }),
|
2023-08-28 22:13:48 +08:00
|
|
|
key: 'socks-port',
|
2023-09-16 02:50:21 +08:00
|
|
|
onChange: (e: Event & { target: HTMLInputElement }) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'socks-port',
|
|
|
|
Number(e.target.value),
|
|
|
|
refetch,
|
|
|
|
),
|
2023-08-28 22:13:48 +08:00
|
|
|
},
|
|
|
|
{
|
2023-09-23 02:13:17 +08:00
|
|
|
label: () => t('port', { name: 'Redir' }),
|
2023-08-28 22:13:48 +08:00
|
|
|
key: 'redir-port',
|
2023-09-16 02:50:21 +08:00
|
|
|
onChange: (e: Event & { target: HTMLInputElement }) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'redir-port',
|
|
|
|
Number(e.target.value),
|
|
|
|
refetch,
|
|
|
|
),
|
2023-08-28 22:13:48 +08:00
|
|
|
},
|
|
|
|
{
|
2023-09-23 02:13:17 +08:00
|
|
|
label: () => t('port', { name: 'TProxy' }),
|
2023-08-28 22:13:48 +08:00
|
|
|
key: 'tproxy-port',
|
2023-09-16 02:50:21 +08:00
|
|
|
onChange: (e: Event & { target: HTMLInputElement }) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'tproxy-port',
|
|
|
|
Number(e.target.value),
|
|
|
|
refetch,
|
|
|
|
),
|
2023-08-28 22:13:48 +08:00
|
|
|
},
|
|
|
|
{
|
2023-09-23 02:13:17 +08:00
|
|
|
label: () => t('port', { name: 'Mixed' }),
|
2023-08-28 22:13:48 +08:00
|
|
|
key: 'mixed-port',
|
2023-09-16 02:50:21 +08:00
|
|
|
onChange: (e: Event & { target: HTMLInputElement }) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'mixed-port',
|
|
|
|
Number(e.target.value),
|
|
|
|
refetch,
|
|
|
|
),
|
2023-08-28 22:13:48 +08:00
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2023-09-02 13:54:59 +08:00
|
|
|
const { form, setInitialValues, reset } = createForm<
|
|
|
|
z.infer<typeof configFormSchema>
|
|
|
|
>({ extend: validator({ schema: configFormSchema }) })
|
2023-09-01 14:06:21 +08:00
|
|
|
|
2023-09-16 02:50:21 +08:00
|
|
|
const [configsData, { refetch }] = createResource(fetchBackendConfigAPI)
|
|
|
|
|
|
|
|
createEffect(() => {
|
|
|
|
const configs = configsData()
|
|
|
|
|
|
|
|
if (configs) {
|
|
|
|
setInitialValues(configs)
|
|
|
|
reset()
|
|
|
|
}
|
2023-08-28 22:13:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
2023-09-05 20:53:00 +08:00
|
|
|
<div class="flex flex-col gap-4">
|
2023-09-12 20:50:52 +08:00
|
|
|
<select
|
|
|
|
class="select select-bordered"
|
2023-09-16 02:50:21 +08:00
|
|
|
value={configsData()?.mode}
|
|
|
|
onChange={(e) =>
|
|
|
|
void updateBackendConfigAPI('mode', e.target.value, refetch)
|
|
|
|
}
|
2023-09-12 20:50:52 +08:00
|
|
|
>
|
|
|
|
<option value={MODE_OPTIONS.Global}>{t('global')}</option>
|
|
|
|
<option value={MODE_OPTIONS.Rule}>{t('rule')}</option>
|
|
|
|
<option value={MODE_OPTIONS.Direct}>{t('direct')}</option>
|
|
|
|
</select>
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<Show when={!isSingBox(backendVersion())}>
|
|
|
|
<form class="grid grid-cols-3 gap-2 sm:grid-cols-5" use:form={form}>
|
|
|
|
<For each={portList}>
|
|
|
|
{(item) => (
|
|
|
|
<div class="form-control">
|
|
|
|
<label for={item.key} class="label">
|
|
|
|
<span class="label-text">{item.label()}</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<input
|
|
|
|
id={item.key}
|
|
|
|
name={item.key}
|
|
|
|
type="number"
|
|
|
|
class="input input-bordered"
|
|
|
|
placeholder={item.label()}
|
|
|
|
onChange={item.onChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div class="grid grid-cols-2 gap-2 sm:grid-cols-4">
|
2023-12-03 22:09:09 +08:00
|
|
|
<div class="form-control">
|
|
|
|
<label for="enable-allow-lan" class="label gap-2">
|
|
|
|
<span class="label-text">{t('allowLan')}</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<input
|
|
|
|
id="enable-allow-lan"
|
|
|
|
type="checkbox"
|
|
|
|
class="toggle"
|
|
|
|
checked={configsData()?.['allow-lan']}
|
|
|
|
onChange={(e) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'allow-lan',
|
|
|
|
e.target.checked,
|
|
|
|
refetch,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<div class="form-control">
|
|
|
|
<label for="enable-tun-device" class="label gap-2">
|
|
|
|
<span class="label-text">{t('enableTunDevice')}</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<input
|
|
|
|
id="enable-tun-device"
|
|
|
|
type="checkbox"
|
|
|
|
class="toggle"
|
|
|
|
checked={configsData()?.tun.enable}
|
|
|
|
onChange={(e) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'tun',
|
|
|
|
{ enable: e.target.checked },
|
|
|
|
refetch,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-09-22 22:03:22 +08:00
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<div class="form-control">
|
|
|
|
<label for="tun-ip-stack" class="label gap-2">
|
|
|
|
<span class="label-text">{t('tunModeStack')}</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<select
|
|
|
|
id="tun-ip-stack"
|
|
|
|
class="select select-bordered flex-1"
|
|
|
|
value={configsData()?.tun.stack}
|
|
|
|
onChange={(e) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'tun',
|
|
|
|
{ stack: e.target.value },
|
|
|
|
refetch,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
>
|
2023-10-29 19:15:25 +08:00
|
|
|
<option>Mixed</option>
|
2023-10-16 20:26:16 +08:00
|
|
|
<option>gVisor</option>
|
|
|
|
<option>System</option>
|
|
|
|
<option>LWIP</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2023-09-22 22:03:22 +08:00
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<div class="form-control">
|
|
|
|
<label for="device-name" class="label gap-2">
|
|
|
|
<span class="label-text">{t('tunDeviceName')}</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<input
|
|
|
|
id="device-name"
|
|
|
|
class="input input-bordered min-w-0"
|
|
|
|
value={configsData()?.tun.device}
|
|
|
|
onChange={(e) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'tun',
|
|
|
|
{ device: e.target.value },
|
|
|
|
refetch,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-09-22 22:03:22 +08:00
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<div class="form-control">
|
|
|
|
<label for="interface-name" class="label gap-2">
|
|
|
|
<span class="label-text">{t('interfaceName')}</span>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<input
|
|
|
|
id="interface-name"
|
|
|
|
class="input input-bordered min-w-0"
|
|
|
|
value={configsData()?.['interface-name']}
|
|
|
|
onChange={(e) =>
|
|
|
|
void updateBackendConfigAPI(
|
|
|
|
'interface-name',
|
|
|
|
e.target.value,
|
|
|
|
refetch,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-09-22 22:03:22 +08:00
|
|
|
</div>
|
2023-10-16 20:26:16 +08:00
|
|
|
</Show>
|
2023-09-22 22:03:22 +08:00
|
|
|
|
2023-09-22 16:05:36 +08:00
|
|
|
<div class="grid grid-cols-2 gap-2 sm:grid-cols-3">
|
2023-09-22 14:25:34 +08:00
|
|
|
<Button
|
|
|
|
class="btn-primary"
|
|
|
|
loading={reloadingConfigFile()}
|
|
|
|
onClick={reloadConfigFileAPI}
|
|
|
|
>
|
|
|
|
{t('reloadConfig')}
|
2023-09-16 02:50:21 +08:00
|
|
|
</Button>
|
|
|
|
|
2023-09-12 21:33:16 +08:00
|
|
|
<Button
|
2023-09-22 14:25:34 +08:00
|
|
|
class="btn-secondary"
|
2023-09-12 21:33:16 +08:00
|
|
|
loading={updatingGEODatabases()}
|
|
|
|
onClick={updateGEODatabasesAPI}
|
|
|
|
>
|
2023-09-03 02:18:05 +08:00
|
|
|
{t('updateGEODatabases')}
|
|
|
|
</Button>
|
|
|
|
|
2023-09-22 14:25:34 +08:00
|
|
|
<Button
|
|
|
|
class="btn-accent"
|
|
|
|
loading={flushingFakeIPData()}
|
|
|
|
onClick={flushFakeIPDataAPI}
|
|
|
|
>
|
|
|
|
{t('flushFakeIP')}
|
|
|
|
</Button>
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<Show when={!isSingBox(backendVersion())}>
|
|
|
|
<Button
|
|
|
|
class="btn-error"
|
|
|
|
loading={upgradingBackend()}
|
|
|
|
onClick={upgradeBackendAPI}
|
|
|
|
>
|
|
|
|
{t('upgradeCore')}
|
|
|
|
</Button>
|
|
|
|
</Show>
|
2023-09-04 23:35:40 +08:00
|
|
|
|
2023-09-22 14:25:34 +08:00
|
|
|
<Button
|
|
|
|
class="btn-warning"
|
|
|
|
loading={restartingBackend()}
|
|
|
|
onClick={restartBackendAPI}
|
|
|
|
>
|
2023-09-04 23:35:40 +08:00
|
|
|
{t('restartCore')}
|
|
|
|
</Button>
|
2023-09-16 02:50:21 +08:00
|
|
|
|
2023-09-22 22:03:22 +08:00
|
|
|
<Button
|
|
|
|
class="btn-info"
|
|
|
|
onClick={() => {
|
|
|
|
setSelectedEndpoint('')
|
|
|
|
navigate(ROUTES.Setup)
|
|
|
|
}}
|
|
|
|
>
|
2023-09-22 14:25:34 +08:00
|
|
|
{t('switchEndpoint')}
|
|
|
|
</Button>
|
2023-09-03 02:18:05 +08:00
|
|
|
</div>
|
2023-09-02 13:54:59 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2023-09-01 14:06:21 +08:00
|
|
|
|
2023-09-02 15:08:35 +08:00
|
|
|
const ConfigForXd = () => {
|
2023-09-23 01:38:36 +08:00
|
|
|
const [t] = useI18n()
|
2023-09-02 14:25:22 +08:00
|
|
|
|
2023-09-23 02:06:57 +08:00
|
|
|
const languages = [
|
|
|
|
{
|
|
|
|
label: () => t('en'),
|
|
|
|
value: LANG.EN,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: () => t('zh'),
|
|
|
|
value: LANG.ZH,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2023-09-16 23:55:42 +08:00
|
|
|
return (
|
2023-09-22 22:03:22 +08:00
|
|
|
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
2023-11-03 01:23:34 +08:00
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
<div class="flex flex-col items-center">
|
|
|
|
<ConfigTitle>{t('useTwemoji')}</ConfigTitle>
|
|
|
|
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
class="toggle"
|
|
|
|
checked={useTwemoji()}
|
|
|
|
onChange={(e) => setUseTwemoji(e.target.checked)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-col">
|
|
|
|
<ConfigTitle>{t('switchLanguage')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered"
|
|
|
|
onChange={(e) => setLocale(e.target.value as LANG)}
|
|
|
|
>
|
|
|
|
<For each={languages}>
|
|
|
|
{(lang) => (
|
|
|
|
<option selected={locale() === lang.value} value={lang.value}>
|
|
|
|
{lang.label()}
|
|
|
|
</option>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-09-22 22:03:22 +08:00
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
<div class="flex flex-col items-center">
|
2023-09-16 23:55:42 +08:00
|
|
|
<ConfigTitle>{t('autoSwitchTheme')}</ConfigTitle>
|
|
|
|
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
class="toggle"
|
|
|
|
checked={autoSwitchTheme()}
|
|
|
|
onChange={(e) => setAutoSwitchTheme(e.target.checked)}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-09-05 22:32:47 +08:00
|
|
|
|
2023-09-16 23:55:42 +08:00
|
|
|
<Show when={autoSwitchTheme()}>
|
2023-09-22 22:03:22 +08:00
|
|
|
<div class="flex flex-col gap-2">
|
2023-09-16 23:55:42 +08:00
|
|
|
<div class="flex flex-col">
|
|
|
|
<ConfigTitle>{t('favDayTheme')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered"
|
2023-09-23 02:06:57 +08:00
|
|
|
value={favDayTheme()}
|
2023-09-25 23:00:06 +08:00
|
|
|
onChange={(e) =>
|
|
|
|
setFavDayTheme(e.target.value as (typeof themes)[number])
|
|
|
|
}
|
2023-09-16 23:55:42 +08:00
|
|
|
>
|
|
|
|
<For each={themes}>
|
2023-09-23 02:06:57 +08:00
|
|
|
{(theme) => <option value={theme}>{theme}</option>}
|
2023-09-16 23:55:42 +08:00
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
2023-09-05 22:32:47 +08:00
|
|
|
|
2023-09-16 23:55:42 +08:00
|
|
|
<div class="flex flex-col">
|
|
|
|
<ConfigTitle>{t('favNightTheme')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered"
|
2023-09-23 02:06:57 +08:00
|
|
|
value={favNightTheme()}
|
2023-09-25 23:00:06 +08:00
|
|
|
onChange={(e) =>
|
|
|
|
setFavNightTheme(e.target.value as (typeof themes)[number])
|
|
|
|
}
|
2023-09-16 23:55:42 +08:00
|
|
|
>
|
|
|
|
<For each={themes}>
|
2023-09-23 02:06:57 +08:00
|
|
|
{(theme) => <option value={theme}>{theme}</option>}
|
2023-09-16 23:55:42 +08:00
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Show>
|
2023-09-02 19:06:02 +08:00
|
|
|
</div>
|
2023-09-02 15:55:38 +08:00
|
|
|
</div>
|
2023-09-02 15:08:35 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
const Versions: Component<{ backendVersion: Accessor<string> }> = ({
|
|
|
|
backendVersion,
|
|
|
|
}) => {
|
2023-09-23 03:57:08 +08:00
|
|
|
const [isUpdateAvailable, setIsUpdateAvailable] = createSignal(false)
|
2023-09-10 16:42:00 +08:00
|
|
|
|
2023-10-16 20:33:41 +08:00
|
|
|
createEffect(async () => {
|
|
|
|
const version = backendVersion()
|
|
|
|
|
|
|
|
if (!version) return
|
|
|
|
|
|
|
|
setIsUpdateAvailable(await isUpdateAvailableAPI(version))
|
2023-09-10 16:42:00 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
2023-11-03 01:23:34 +08:00
|
|
|
<div class="grid grid-cols-2 gap-4">
|
2024-02-01 18:21:09 +08:00
|
|
|
<kbd class="kbd">{import.meta.env.VITE_APP_VERSION}</kbd>
|
2023-11-03 01:23:34 +08:00
|
|
|
|
|
|
|
<div class="relative">
|
|
|
|
<Show when={isUpdateAvailable()}>
|
|
|
|
<span class="absolute -right-1 -top-1 flex h-3 w-3">
|
|
|
|
<span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-info opacity-75" />
|
|
|
|
<span class="inline-flex h-3 w-3 rounded-full bg-info" />
|
|
|
|
</span>
|
|
|
|
</Show>
|
2023-10-02 19:09:17 +08:00
|
|
|
|
2023-11-03 01:23:34 +08:00
|
|
|
<kbd class="kbd w-full">{backendVersion()}</kbd>
|
|
|
|
</div>
|
2023-09-10 16:42:00 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-09-02 15:08:35 +08:00
|
|
|
export default () => {
|
2023-10-16 20:33:41 +08:00
|
|
|
const [t] = useI18n()
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
const [backendVersion, setBackendVersion] = createSignal('')
|
|
|
|
|
|
|
|
onMount(async () => {
|
2023-10-16 20:33:41 +08:00
|
|
|
setBackendVersion(await fetchBackendVersionAPI())
|
2023-10-16 20:26:16 +08:00
|
|
|
})
|
|
|
|
|
2023-09-02 13:54:59 +08:00
|
|
|
return (
|
2023-09-16 23:55:42 +08:00
|
|
|
<div class="mx-auto flex max-w-screen-md flex-col gap-4">
|
2023-10-16 20:26:16 +08:00
|
|
|
<Show when={!isSingBox(backendVersion())}>
|
|
|
|
<ConfigTitle withDivider>{t('dnsQuery')}</ConfigTitle>
|
2023-09-17 00:05:15 +08:00
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<DNSQueryForm />
|
|
|
|
</Show>
|
2023-09-17 00:05:15 +08:00
|
|
|
|
|
|
|
<ConfigTitle withDivider>{t('coreConfig')}</ConfigTitle>
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<ConfigForm backendVersion={backendVersion} />
|
2023-09-17 00:05:15 +08:00
|
|
|
|
|
|
|
<ConfigTitle withDivider>{t('xdConfig')}</ConfigTitle>
|
|
|
|
|
2023-09-02 15:08:35 +08:00
|
|
|
<ConfigForXd />
|
2023-09-03 18:16:09 +08:00
|
|
|
|
2023-09-17 00:05:15 +08:00
|
|
|
<ConfigTitle withDivider>{t('version')}</ConfigTitle>
|
|
|
|
|
2023-10-16 20:26:16 +08:00
|
|
|
<Versions backendVersion={backendVersion} />
|
2023-08-28 22:13:48 +08:00
|
|
|
</div>
|
|
|
|
)
|
2023-08-24 04:20:53 +08:00
|
|
|
}
|