From 14bc636ee8376a2158cd158a6e7efe90d5ddd659 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sat, 11 Jul 2026 21:39:57 +0800 Subject: [PATCH] refactor(frontend): remove unused modules --- docs/CONTRIBUTING_i18n.md | 11 +-- scripts/cleanup-unused-i18n.mjs | 64 +------------ src/components/connection/connection-item.tsx | 91 ------------------- .../setting/mods/password-input.tsx | 52 ----------- src/hooks/use-current-proxy.ts | 82 ----------------- src/locales/ar/index.ts | 25 ----- src/locales/ar/settings.json | 5 - src/locales/de/index.ts | 25 ----- src/locales/de/settings.json | 5 - src/locales/en/index.ts | 25 ----- src/locales/en/settings.json | 5 - src/locales/es/index.ts | 25 ----- src/locales/es/settings.json | 5 - src/locales/fa/index.ts | 25 ----- src/locales/fa/settings.json | 5 - src/locales/id/index.ts | 25 ----- src/locales/id/settings.json | 5 - src/locales/jp/index.ts | 25 ----- src/locales/jp/settings.json | 5 - src/locales/ko/index.ts | 25 ----- src/locales/ko/settings.json | 5 - src/locales/ru/index.ts | 25 ----- src/locales/ru/settings.json | 5 - src/locales/tr/index.ts | 25 ----- src/locales/tr/settings.json | 5 - src/locales/tt/index.ts | 25 ----- src/locales/tt/settings.json | 5 - src/locales/zh/index.ts | 25 ----- src/locales/zh/settings.json | 5 - src/locales/zhtw/index.ts | 25 ----- src/locales/zhtw/settings.json | 5 - src/providers/chain-proxy-context.ts | 20 ---- src/providers/chain-proxy-provider.tsx | 32 ------- src/services/config.ts | 35 ------- src/types/generated/i18n-keys.ts | 1 - src/types/generated/i18n-resources.ts | 5 - src/utils/ignore-case.ts | 14 --- src/utils/truncate-str.ts | 6 -- 38 files changed, 6 insertions(+), 797 deletions(-) delete mode 100644 src/components/connection/connection-item.tsx delete mode 100644 src/components/setting/mods/password-input.tsx delete mode 100644 src/hooks/use-current-proxy.ts delete mode 100644 src/locales/ar/index.ts delete mode 100644 src/locales/de/index.ts delete mode 100644 src/locales/en/index.ts delete mode 100644 src/locales/es/index.ts delete mode 100644 src/locales/fa/index.ts delete mode 100644 src/locales/id/index.ts delete mode 100644 src/locales/jp/index.ts delete mode 100644 src/locales/ko/index.ts delete mode 100644 src/locales/ru/index.ts delete mode 100644 src/locales/tr/index.ts delete mode 100644 src/locales/tt/index.ts delete mode 100644 src/locales/zh/index.ts delete mode 100644 src/locales/zhtw/index.ts delete mode 100644 src/providers/chain-proxy-context.ts delete mode 100644 src/providers/chain-proxy-provider.tsx delete mode 100644 src/services/config.ts delete mode 100644 src/utils/ignore-case.ts delete mode 100644 src/utils/truncate-str.ts diff --git a/docs/CONTRIBUTING_i18n.md b/docs/CONTRIBUTING_i18n.md index ed963cf94..6a9cb702f 100644 --- a/docs/CONTRIBUTING_i18n.md +++ b/docs/CONTRIBUTING_i18n.md @@ -21,15 +21,13 @@ src/locales/ home.json shared.json ... - index.ts zh/ ... ``` - JSON files map to namespaces (for example `home.json` → `home.*`). Keep keys scoped to the file they belong to. - `shared.json` stores reusable vocabulary (buttons, validations, etc.); feature-specific wording should live in the relevant namespace. -- `index.ts` re-exports a `resources` object that aggregates the namespace JSON files. When adding or removing namespaces, mirror the pattern from `src/locales/en/index.ts`. -- Frontend bundles are lazy-loaded by `src/services/i18n.ts`. Only languages listed in `supportedLanguages` are fetched at runtime, so append new codes there when you add a locale. +- `src/services/i18n.ts` automatically discovers and lazy-loads each locale's JSON sections, so no aggregate module is required. Keep locales aligned with `src/locales/en/`, and add new codes to `supportedLanguages`. Because backend translations now live in their own directory, you no longer need to run `pnpm prebuild` just to sync locales—the frontend folder is the sole source of truth for web bundles. @@ -52,10 +50,9 @@ Native UI strings (tray menu, notifications, dialogs) use `rust-i18n` with YAML ## Adding a new language 1. Duplicate `src/locales/en/` into `src/locales//` and translate the JSON files while preserving key structure. -2. Update the locale’s `index.ts` to import every namespace. Matching the English file is the easiest way to avoid missing exports. -3. Append the language code to `supportedLanguages` in `src/services/i18n.ts`. -4. If the backend should expose the language, create `crates/clash-verge-i18n/.yml` and translate the keys used in existing YAML files. -5. Run `pnpm i18n:format`, `pnpm i18n:types`, and (optionally) `pnpm i18n:check` in dry-run mode to confirm structure. +2. Append the language code to `supportedLanguages` in `src/services/i18n.ts`. +3. If the backend should expose the language, create `crates/clash-verge-i18n/.yml` and translate the keys used in existing YAML files. +4. Run `pnpm i18n:format`, `pnpm i18n:types`, and (optionally) `pnpm i18n:check` in dry-run mode to confirm structure. ## Authoring guidelines diff --git a/scripts/cleanup-unused-i18n.mjs b/scripts/cleanup-unused-i18n.mjs index 98f9c581f..5143e03bc 100644 --- a/scripts/cleanup-unused-i18n.mjs +++ b/scripts/cleanup-unused-i18n.mjs @@ -1,5 +1,3 @@ -#!/usr/bin/env node - import fs from 'fs' import path from 'path' import { fileURLToPath } from 'url' @@ -1020,7 +1018,7 @@ function loadBackendLocales() { const localePath = path.join(BACKEND_LOCALES_DIR, entry.name) const name = entry.name.replace(/\.(ya?ml)$/i, '') const raw = fs.readFileSync(localePath, 'utf8') - let data = {} + let data try { const parsed = yaml.load(raw) data = isPlainObject(parsed) ? parsed : {} @@ -1055,6 +1053,7 @@ function ensureBackup(localePath) { } catch (error) { throw new Error( `Failed to recycle existing backup for ${path.basename(localePath)}: ${error.message}`, + { cause: error }, ) } } @@ -1086,59 +1085,6 @@ function cleanupBackups(backups) { backups.clear() } -function toModuleIdentifier(namespace, seen) { - const RESERVED = new Set([ - 'default', - 'function', - 'var', - 'let', - 'const', - 'import', - 'export', - 'class', - 'enum', - ]) - - const base = - namespace.replace(/[^a-zA-Z0-9_$]/g, '_').replace(/^[^a-zA-Z_$]+/, '') || - 'ns' - - let candidate = base - let counter = 1 - while (RESERVED.has(candidate) || seen.has(candidate)) { - candidate = `${base}_${counter}` - counter += 1 - } - seen.add(candidate) - return candidate -} - -function regenerateLocaleIndex(localeDir, namespaces) { - const seen = new Set() - const imports = [] - const mappings = [] - - for (const namespace of namespaces) { - const filePath = path.join(localeDir, `${namespace}.json`) - if (!fs.existsSync(filePath)) continue - const identifier = toModuleIdentifier(namespace, seen) - const key = namespace === identifier ? namespace : `'${namespace}'` - imports.push(`import ${identifier} from './${namespace}.json'`) - mappings.push(` ${key}: ${identifier},`) - } - - const content = `${imports.join('\n')} - -const resources = { -${mappings.join('\n')} -} - -export default resources -` - - fs.writeFileSync(path.join(localeDir, 'index.ts'), content, 'utf8') -} - function writeLocale(locale, data, options) { const backups = new Map() let success = false @@ -1163,7 +1109,6 @@ function writeLocale(locale, data, options) { } const entries = Object.entries(data) - const orderedNamespaces = entries.map(([namespace]) => namespace) const existingFiles = new Map( locale.files.map((file) => [file.namespace, file.path]), ) @@ -1187,11 +1132,6 @@ function writeLocale(locale, data, options) { } } - regenerateLocaleIndex(locale.dir, orderedNamespaces) - locale.files = orderedNamespaces.map((namespace) => ({ - namespace, - path: path.join(locale.dir, `${namespace}.json`), - })) success = true } finally { if (success) { diff --git a/src/components/connection/connection-item.tsx b/src/components/connection/connection-item.tsx deleted file mode 100644 index 4c8ac2f58..000000000 --- a/src/components/connection/connection-item.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { CloseRounded } from '@mui/icons-material' -import { - styled, - ListItem, - IconButton, - ListItemText, - Box, - alpha, -} from '@mui/material' -import { useLockFn } from 'ahooks' -import dayjs from 'dayjs' -import { useTranslation } from 'react-i18next' -import { closeConnection } from 'tauri-plugin-mihomo-api' - -import parseTraffic from '@/utils/parse-traffic' - -const Tag = styled('span')(({ theme }) => ({ - fontSize: '10px', - padding: '0 4px', - lineHeight: 1.375, - border: '1px solid', - borderRadius: 4, - borderColor: alpha(theme.palette.text.secondary, 0.35), - marginTop: '4px', - marginRight: '4px', -})) - -interface Props { - value: IConnectionsItem - closed: boolean - onShowDetail?: () => void -} - -export const ConnectionItem = (props: Props) => { - const { value, closed, onShowDetail } = props - - const { id, metadata, chains, start, curUpload, curDownload } = value - const { t } = useTranslation() - - const onDelete = useLockFn(async () => closeConnection(id)) - const showTraffic = curUpload! >= 100 || curDownload! >= 100 - - return ( - - - - ) - } - > - - - {metadata.network} - - - {metadata.type} - - {!!metadata.process && {metadata.process}} - - {chains?.length > 0 && ( - {[...chains].reverse().join(' / ')} - )} - - {dayjs(start).fromNow()} - - {showTraffic && ( - - {parseTraffic(curUpload!)} / {parseTraffic(curDownload!)} - - )} - - } - /> - - ) -} diff --git a/src/components/setting/mods/password-input.tsx b/src/components/setting/mods/password-input.tsx deleted file mode 100644 index 32a66cfaa..000000000 --- a/src/components/setting/mods/password-input.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - TextField, -} from '@mui/material' -import { useState } from 'react' -import { useTranslation } from 'react-i18next' - -interface Props { - onConfirm: (passwd: string) => Promise -} - -export const PasswordInput = (props: Props) => { - const { onConfirm } = props - - const { t } = useTranslation() - const [passwd, setPasswd] = useState('') - - return ( - - - {t('settings.modals.password.prompts.enterRoot')} - - - - e.key === 'Enter' && onConfirm(passwd)} - onChange={(e) => setPasswd(e.target.value)} - > - - - - - - - ) -} diff --git a/src/hooks/use-current-proxy.ts b/src/hooks/use-current-proxy.ts deleted file mode 100644 index 08dc905c3..000000000 --- a/src/hooks/use-current-proxy.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { useMemo } from 'react' - -import { - useAppRefreshers, - useClashConfigData, - useProxiesData, -} from '@/providers/app-data-context' - -// 定义代理组类型 -interface ProxyGroup { - name: string - now: string -} - -// 获取当前代理节点信息的自定义Hook -export const useCurrentProxy = () => { - // 从AppDataProvider获取数据 - const { proxies } = useProxiesData() - const { clashConfig } = useClashConfigData() - const { refreshProxy } = useAppRefreshers() - - // 获取当前模式 - const currentMode = clashConfig?.mode?.toLowerCase() || 'rule' - - // 获取当前代理节点信息 - const currentProxyInfo = useMemo(() => { - if (!proxies) return { currentProxy: null, primaryGroupName: null } - - const { global, groups, records } = proxies - - // 默认信息 - let primaryGroupName = 'GLOBAL' - let currentName = global?.now - - // 在规则模式下,寻找主要代理组(通常是第一个或者名字包含特定关键词的组) - if (currentMode === 'rule' && groups.length > 0) { - // 查找主要的代理组(优先级:包含关键词 > 第一个非GLOBAL组) - const primaryKeywords = [ - 'auto', - 'select', - 'proxy', - '节点选择', - '自动选择', - ] - const primaryGroup = - groups.find((group: ProxyGroup) => - primaryKeywords.some((keyword) => - group.name.toLowerCase().includes(keyword.toLowerCase()), - ), - ) || groups.filter((g: ProxyGroup) => g.name !== 'GLOBAL')[0] - - if (primaryGroup) { - primaryGroupName = primaryGroup.name - currentName = primaryGroup.now - } - } - - // 如果找不到当前节点,返回null - if (!currentName) return { currentProxy: null, primaryGroupName } - - // 获取完整的节点信息 - const currentProxy = records[currentName] || { - name: currentName, - type: 'Unknown', - udp: false, - xudp: false, - tfo: false, - mptcp: false, - smux: false, - history: [], - } - - return { currentProxy, primaryGroupName } - }, [proxies, currentMode]) - - return { - currentProxy: currentProxyInfo.currentProxy, - primaryGroupName: currentProxyInfo.primaryGroupName, - mode: currentMode, - refreshProxy, - } -} diff --git a/src/locales/ar/index.ts b/src/locales/ar/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/ar/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/ar/settings.json b/src/locales/ar/settings.json index 700aed55d..0dae64738 100644 --- a/src/locales/ar/settings.json +++ b/src/locales/ar/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "إعادة تنشيط الملفات الشخصية" } }, - "password": { - "prompts": { - "enterRoot": "يرجى إدخال كلمة مرور الرووت" - } - }, "networkInterface": { "title": "واجهة الشبكة", "fields": { diff --git a/src/locales/de/index.ts b/src/locales/de/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/de/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/de/settings.json b/src/locales/de/settings.json index b65000f04..7678bb926 100644 --- a/src/locales/de/settings.json +++ b/src/locales/de/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Abonnement erneut aktivieren" } }, - "password": { - "prompts": { - "enterRoot": "Bitte geben Sie Ihr Root-Passwort ein." - } - }, "networkInterface": { "title": "Netzwerkschnittstelle", "fields": { diff --git a/src/locales/en/index.ts b/src/locales/en/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/en/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/en/settings.json b/src/locales/en/settings.json index 1dfb91616..6853dd49a 100644 --- a/src/locales/en/settings.json +++ b/src/locales/en/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Reactivate Profiles" } }, - "password": { - "prompts": { - "enterRoot": "Please enter your root password" - } - }, "networkInterface": { "title": "Network Interface", "fields": { diff --git a/src/locales/es/index.ts b/src/locales/es/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/es/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/es/settings.json b/src/locales/es/settings.json index cbf7dd14a..d3ee17bb8 100644 --- a/src/locales/es/settings.json +++ b/src/locales/es/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Reactivar suscripciones" } }, - "password": { - "prompts": { - "enterRoot": "Ingrese su contraseña de root" - } - }, "networkInterface": { "title": "Interfaz de red", "fields": { diff --git a/src/locales/fa/index.ts b/src/locales/fa/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/fa/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/fa/settings.json b/src/locales/fa/settings.json index ff662cf98..ecf157ee4 100644 --- a/src/locales/fa/settings.json +++ b/src/locales/fa/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "فعال‌سازی مجدد پروفایل‌ها" } }, - "password": { - "prompts": { - "enterRoot": "لطفاً رمز ریشه خود را وارد کنید" - } - }, "networkInterface": { "title": "رابط شبکه", "fields": { diff --git a/src/locales/id/index.ts b/src/locales/id/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/id/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/id/settings.json b/src/locales/id/settings.json index b69edca62..5f29fb046 100644 --- a/src/locales/id/settings.json +++ b/src/locales/id/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Reaktivasi Profil" } }, - "password": { - "prompts": { - "enterRoot": "Harap masukkan kata sandi root Anda" - } - }, "networkInterface": { "title": "Antarmuka Jaringan", "fields": { diff --git a/src/locales/jp/index.ts b/src/locales/jp/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/jp/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/jp/settings.json b/src/locales/jp/settings.json index bb11efdda..363a0bc6c 100644 --- a/src/locales/jp/settings.json +++ b/src/locales/jp/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "プロファイルを再アクティブ化" } }, - "password": { - "prompts": { - "enterRoot": "ルートパスワードを入力してください。" - } - }, "networkInterface": { "title": "ネットワークインターフェース", "fields": { diff --git a/src/locales/ko/index.ts b/src/locales/ko/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/ko/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/ko/settings.json b/src/locales/ko/settings.json index d9da68b33..e82169595 100644 --- a/src/locales/ko/settings.json +++ b/src/locales/ko/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "프로필 재활성화" } }, - "password": { - "prompts": { - "enterRoot": "루트 암호를 입력하세요" - } - }, "networkInterface": { "title": "네트워크 인터페이스", "fields": { diff --git a/src/locales/ru/index.ts b/src/locales/ru/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/ru/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/ru/settings.json b/src/locales/ru/settings.json index f79898ee6..66656c2ef 100644 --- a/src/locales/ru/settings.json +++ b/src/locales/ru/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Перезапустить профиль" } }, - "password": { - "prompts": { - "enterRoot": "Пожалуйста, введите пароль root" - } - }, "networkInterface": { "title": "Сетевой интерфейс", "fields": { diff --git a/src/locales/tr/index.ts b/src/locales/tr/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/tr/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/tr/settings.json b/src/locales/tr/settings.json index 88aba16b2..32a5514e8 100644 --- a/src/locales/tr/settings.json +++ b/src/locales/tr/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Profilleri Yeniden Etkinleştir" } }, - "password": { - "prompts": { - "enterRoot": "Lütfen root şifrenizi girin" - } - }, "networkInterface": { "title": "Ağ Arayüzü", "fields": { diff --git a/src/locales/tt/index.ts b/src/locales/tt/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/tt/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/tt/settings.json b/src/locales/tt/settings.json index 9b74cc636..bfa11ebe8 100644 --- a/src/locales/tt/settings.json +++ b/src/locales/tt/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "Профильләрне янәдән активлаштыру" } }, - "password": { - "prompts": { - "enterRoot": "root паролен языгыз" - } - }, "networkInterface": { "title": "Челтәр интерфейсы", "fields": { diff --git a/src/locales/zh/index.ts b/src/locales/zh/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/zh/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/zh/settings.json b/src/locales/zh/settings.json index 5cbc959eb..4ec97f3ef 100644 --- a/src/locales/zh/settings.json +++ b/src/locales/zh/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "重新激活订阅" } }, - "password": { - "prompts": { - "enterRoot": "请输入您的 root 密码" - } - }, "networkInterface": { "title": "网络接口", "fields": { diff --git a/src/locales/zhtw/index.ts b/src/locales/zhtw/index.ts deleted file mode 100644 index 0cc99846b..000000000 --- a/src/locales/zhtw/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import connections from './connections.json' -import home from './home.json' -import layout from './layout.json' -import logs from './logs.json' -import profiles from './profiles.json' -import proxies from './proxies.json' -import rules from './rules.json' -import settings from './settings.json' -import shared from './shared.json' -import tests from './tests.json' - -const resources = { - connections: connections, - home: home, - layout: layout, - logs: logs, - profiles: profiles, - proxies: proxies, - rules: rules, - settings: settings, - shared: shared, - tests: tests, -} - -export default resources diff --git a/src/locales/zhtw/settings.json b/src/locales/zhtw/settings.json index 4757007f7..80e8f768f 100644 --- a/src/locales/zhtw/settings.json +++ b/src/locales/zhtw/settings.json @@ -609,11 +609,6 @@ "reactivateProfiles": "重新啟用訂閱" } }, - "password": { - "prompts": { - "enterRoot": "請輸入您的 root 密碼" - } - }, "networkInterface": { "title": "網路介面", "fields": { diff --git a/src/providers/chain-proxy-context.ts b/src/providers/chain-proxy-context.ts deleted file mode 100644 index 980523aa4..000000000 --- a/src/providers/chain-proxy-context.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { createContext, use } from 'react' - -export interface ChainProxyContextType { - isChainMode: boolean - setChainMode: (isChain: boolean) => void - chainConfigData: string | null - setChainConfigData: (data: string | null) => void -} - -export const ChainProxyContext = createContext( - null, -) - -export const useChainProxy = () => { - const context = use(ChainProxyContext) - if (!context) { - throw new Error('useChainProxy must be used within a ChainProxyProvider') - } - return context -} diff --git a/src/providers/chain-proxy-provider.tsx b/src/providers/chain-proxy-provider.tsx deleted file mode 100644 index 9902f9af5..000000000 --- a/src/providers/chain-proxy-provider.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React, { useCallback, useMemo, useState } from 'react' - -import { ChainProxyContext } from './chain-proxy-context' - -export const ChainProxyProvider = ({ - children, -}: { - children: React.ReactNode -}) => { - const [isChainMode, setIsChainMode] = useState(false) - const [chainConfigData, setChainConfigData] = useState(null) - - const setChainMode = useCallback((isChain: boolean) => { - setIsChainMode(isChain) - }, []) - - const setChainConfigDataCallback = useCallback((data: string | null) => { - setChainConfigData(data) - }, []) - - const contextValue = useMemo( - () => ({ - isChainMode, - setChainMode, - chainConfigData, - setChainConfigData: setChainConfigDataCallback, - }), - [isChainMode, setChainMode, chainConfigData, setChainConfigDataCallback], - ) - - return {children} -} diff --git a/src/services/config.ts b/src/services/config.ts deleted file mode 100644 index 693f154e7..000000000 --- a/src/services/config.ts +++ /dev/null @@ -1,35 +0,0 @@ -const SWR_NOT_SMART = { - revalidateOnFocus: false, - revalidateOnReconnect: false, - revalidateIfStale: false, - suspense: false, - errorRetryCount: 2, - dedupingInterval: 1500, - errorRetryInterval: 3000, -} as const - -export const SWR_DEFAULTS = { - revalidateOnFocus: false, - revalidateOnReconnect: false, - suspense: false, - errorRetryCount: 2, - dedupingInterval: 5000, -} as const - -export const SWR_SLOW_POLL = { - ...SWR_DEFAULTS, - refreshInterval: 60000, -} as const - -export const SWR_MIHOMO = { - ...SWR_NOT_SMART, - errorRetryInterval: 2000, - errorRetryCount: 3, -} - -export const SWR_EXTERNAL_API = { - ...SWR_NOT_SMART, - shouldRetryOnError: true, - errorRetryCount: 1, - errorRetryInterval: 30_000, -} as const diff --git a/src/types/generated/i18n-keys.ts b/src/types/generated/i18n-keys.ts index 679746a63..abf5da69f 100644 --- a/src/types/generated/i18n-keys.ts +++ b/src/types/generated/i18n-keys.ts @@ -672,7 +672,6 @@ export const translationKeys = [ 'settings.modals.hotkey.functions.entryLightweightMode', 'settings.modals.hotkey.functions.direct', 'settings.modals.hotkey.functions.reactivateProfiles', - 'settings.modals.password.prompts.enterRoot', 'settings.modals.networkInterface.title', 'settings.modals.networkInterface.fields.ipAddress', 'settings.modals.networkInterface.fields.macAddress', diff --git a/src/types/generated/i18n-resources.ts b/src/types/generated/i18n-resources.ts index f21634afa..bb306c510 100644 --- a/src/types/generated/i18n-resources.ts +++ b/src/types/generated/i18n-resources.ts @@ -981,11 +981,6 @@ export interface TranslationResources { } title: string } - password: { - prompts: { - enterRoot: string - } - } sysproxy: { actions: { editPac: string diff --git a/src/utils/ignore-case.ts b/src/utils/ignore-case.ts deleted file mode 100644 index 72dee4408..000000000 --- a/src/utils/ignore-case.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Deep copy and change all keys to lowercase -type TData = Record - -export default function ignoreCase(data: TData): TData { - if (!data) return {} - - const newData = {} as TData - - Object.entries(data).forEach(([key, value]) => { - newData[key.toLowerCase()] = JSON.parse(JSON.stringify(value)) - }) - - return newData -} diff --git a/src/utils/truncate-str.ts b/src/utils/truncate-str.ts deleted file mode 100644 index c29c62b83..000000000 --- a/src/utils/truncate-str.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const truncateStr = (str?: string, prefixLen = 16, maxLen = 56) => { - if (!str || str.length <= maxLen) return str - return ( - str.slice(0, prefixLen) + ' ... ' + str.slice(-(maxLen - prefixLen - 5)) - ) -}