From 341a14a7bcdf6054fb3bb8f1d6bb87e78cc38db7 Mon Sep 17 00:00:00 2001 From: xireiki Date: Thu, 22 Aug 2024 16:44:30 +0800 Subject: [PATCH] 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 --- src/constants/index.ts | 6 ------ src/pages/Config.tsx | 14 ++++++++++---- src/types/index.d.ts | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/constants/index.ts b/src/constants/index.ts index a07de631..0ce391a9 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -151,12 +151,6 @@ export enum TAILWINDCSS_SIZE { LG = 'lg', } -export enum MODE_OPTIONS { - Global = 'global', - Rule = 'rule', - Direct = 'direct', -} - export enum LOG_LEVEL { Info = 'info', Error = 'error', diff --git a/src/pages/Config.tsx b/src/pages/Config.tsx index 27c2b05a..ca290e5d 100644 --- a/src/pages/Config.tsx +++ b/src/pages/Config.tsx @@ -21,7 +21,7 @@ import { upgradingUI, } from '~/apis' 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 { autoSwitchTheme, @@ -179,6 +179,10 @@ const ConfigForm = () => { } }) + const modes = () => { + return configsData()?.modes || ["rule", "direct", "global"] + } + return (
diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 32421f0a..965f4d9d 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -117,7 +117,8 @@ export type Log = { export type LogWithSeq = Log & { seq: number } export type Config = { - mode: 'global' | 'rule' | 'direct' + mode: string + modes?: string[] port: number 'socks-port': number 'redir-port': number