feat: display current selected endpoint at the bottom of the overview page

This commit is contained in:
kunish 2023-11-03 01:23:34 +08:00
parent aaf2d0bed2
commit 3e92373166
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
3 changed files with 46 additions and 49 deletions

View File

@ -7,9 +7,7 @@ export const Latency = (props: { name?: string }) => {
const [t] = useI18n() const [t] = useI18n()
const { latencyMap } = useProxies() const { latencyMap } = useProxies()
const [textClassName, setTextClassName] = createSignal('') const [textClassName, setTextClassName] = createSignal('')
const latency = createMemo(() => { const latency = createMemo(() => latencyMap()[props.name!])
return latencyMap()[props.name!]
})
createEffect(() => { createEffect(() => {
setTextClassName('text-success') setTextClassName('text-success')

View File

@ -35,7 +35,6 @@ import { isSingBox } from '~/helpers'
import { locale, setLocale, useI18n } from '~/i18n' import { locale, setLocale, useI18n } from '~/i18n'
import { import {
autoSwitchTheme, autoSwitchTheme,
endpoint,
favDayTheme, favDayTheme,
favNightTheme, favNightTheme,
setAutoSwitchTheme, setAutoSwitchTheme,
@ -381,6 +380,36 @@ const ConfigForXd = () => {
return ( return (
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2"> <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
<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>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<ConfigTitle>{t('autoSwitchTheme')}</ConfigTitle> <ConfigTitle>{t('autoSwitchTheme')}</ConfigTitle>
@ -429,36 +458,6 @@ const ConfigForXd = () => {
</div> </div>
</Show> </Show>
</div> </div>
<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>
</div> </div>
) )
} }
@ -477,7 +476,6 @@ const Versions: Component<{ backendVersion: Accessor<string> }> = ({
}) })
return ( return (
<div class="flex flex-col gap-2">
<div class="grid grid-cols-2 gap-4"> <div class="grid grid-cols-2 gap-4">
<kbd class="kbd">{import.meta.env.version}</kbd> <kbd class="kbd">{import.meta.env.version}</kbd>
@ -492,9 +490,6 @@ const Versions: Component<{ backendVersion: Accessor<string> }> = ({
<kbd class="kbd w-full">{backendVersion()}</kbd> <kbd class="kbd w-full">{backendVersion()}</kbd>
</div> </div>
</div> </div>
<h1 class="text-center text-lg font-bold">{endpoint()?.url}</h1>
</div>
) )
} }

View File

@ -14,7 +14,7 @@ import {
} from 'solid-js' } from 'solid-js'
import { CHART_MAX_XAXIS, DEFAULT_CHART_OPTIONS } from '~/constants' import { CHART_MAX_XAXIS, DEFAULT_CHART_OPTIONS } from '~/constants'
import { useI18n } from '~/i18n' import { useI18n } from '~/i18n'
import { latestConnectionMsg, useWsRequest } from '~/signals' import { endpoint, latestConnectionMsg, useWsRequest } from '~/signals'
const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => ( const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
<div class="stat flex-1 place-items-center"> <div class="stat flex-1 place-items-center">
@ -130,6 +130,10 @@ export default () => {
/> />
</div> </div>
</div> </div>
<footer class="footer rounded-box mx-auto mt-4 block bg-neutral p-4 text-center text-lg font-bold text-neutral-content">
{endpoint()?.url}
</footer>
</div> </div>
) )
} }