mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-27 07:34:12 +08:00
feat: Support dynamic acquisition of clash_mode (#908)
* feat: Dynamic clash_mode support * fix: Constraint modes & implement part i18n * refactor: Optimize select option generation logic & set modes default value * feat: Some clash_mode keywords are translated using i18n * refactor: Use For instead of JS map() * refactor: Remove the MODE_OPTIONS enum
This commit is contained in:
parent
bd6547873f
commit
341a14a7bc
@ -151,12 +151,6 @@ export enum TAILWINDCSS_SIZE {
|
|||||||
LG = 'lg',
|
LG = 'lg',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum MODE_OPTIONS {
|
|
||||||
Global = 'global',
|
|
||||||
Rule = 'rule',
|
|
||||||
Direct = 'direct',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum LOG_LEVEL {
|
export enum LOG_LEVEL {
|
||||||
Info = 'info',
|
Info = 'info',
|
||||||
Error = 'error',
|
Error = 'error',
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
upgradingUI,
|
upgradingUI,
|
||||||
} from '~/apis'
|
} from '~/apis'
|
||||||
import { Button, ConfigTitle } from '~/components'
|
import { Button, ConfigTitle } from '~/components'
|
||||||
import { LANG, MODE_OPTIONS, ROUTES, themes } from '~/constants'
|
import { LANG, ROUTES, themes } from '~/constants'
|
||||||
import { locale, setLocale, useI18n } from '~/i18n'
|
import { locale, setLocale, useI18n } from '~/i18n'
|
||||||
import {
|
import {
|
||||||
autoSwitchTheme,
|
autoSwitchTheme,
|
||||||
@ -179,6 +179,10 @@ const ConfigForm = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const modes = () => {
|
||||||
|
return configsData()?.modes || ["rule", "direct", "global"]
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<select
|
<select
|
||||||
@ -188,9 +192,11 @@ const ConfigForm = () => {
|
|||||||
void updateBackendConfigAPI('mode', e.target.value, refetch)
|
void updateBackendConfigAPI('mode', e.target.value, refetch)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value={MODE_OPTIONS.Global}>{t('global')}</option>
|
<For echo={modes()}>
|
||||||
<option value={MODE_OPTIONS.Rule}>{t('rule')}</option>
|
{(name) => (
|
||||||
<option value={MODE_OPTIONS.Direct}>{t('direct')}</option>
|
<option value={name}>{t(name) ?? name}</option>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<Show when={!isSingBox()}>
|
<Show when={!isSingBox()}>
|
||||||
|
3
src/types/index.d.ts
vendored
3
src/types/index.d.ts
vendored
@ -117,7 +117,8 @@ export type Log = {
|
|||||||
export type LogWithSeq = Log & { seq: number }
|
export type LogWithSeq = Log & { seq: number }
|
||||||
|
|
||||||
export type Config = {
|
export type Config = {
|
||||||
mode: 'global' | 'rule' | 'direct'
|
mode: string
|
||||||
|
modes?: string[]
|
||||||
port: number
|
port: number
|
||||||
'socks-port': number
|
'socks-port': number
|
||||||
'redir-port': number
|
'redir-port': number
|
||||||
|
Loading…
x
Reference in New Issue
Block a user