mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-25 07:04:11 +08:00
feat: proxy type support i18n (#1135)
This commit is contained in:
parent
fd45c2e970
commit
b0f32b5e55
@ -1,22 +1,32 @@
|
||||
import { LATENCY_QUALITY_MAP_HTTP, PROXIES_ORDERING_TYPE } from '~/constants'
|
||||
import { useI18n } from '~/i18n'
|
||||
import { latencyQualityMap, useProxies } from '~/signals'
|
||||
|
||||
export const formatProxyType = (type = '') => {
|
||||
const t = type.toLowerCase()
|
||||
const [t] = useI18n()
|
||||
const lt = type.toLowerCase()
|
||||
const formatMap = new Map([
|
||||
['shadowsocks', 'SS'],
|
||||
['shadowsocksr', 'SSR'],
|
||||
['hysteria', 'HY'],
|
||||
['hysteria2', 'HY2'],
|
||||
['wireguard', 'WG'],
|
||||
['selector', t('selector')],
|
||||
['urltest', t('urltest')],
|
||||
['fallback', t('fallback')],
|
||||
['loadbalance', t('loadbalance')],
|
||||
['direct', t('direct')],
|
||||
['reject', t('reject')],
|
||||
['rejectdrop', t('rejectdrop')],
|
||||
['relay', t('relay')],
|
||||
['pass', t('pass')],
|
||||
])
|
||||
|
||||
if (t.includes('shadowsocks')) {
|
||||
return t.replace('shadowsocks', 'SS') // for both ss and ssr
|
||||
if (formatMap.has(lt)) {
|
||||
return formatMap.get(lt)
|
||||
} else {
|
||||
return lt
|
||||
}
|
||||
|
||||
if (t.includes('hysteria')) {
|
||||
return t.replace('hysteria', 'HY')
|
||||
}
|
||||
|
||||
if (t === 'wireguard') {
|
||||
return 'WG'
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
export const getLatencyClassName = (latency: LATENCY_QUALITY_MAP_HTTP) => {
|
||||
|
@ -92,6 +92,14 @@ export default {
|
||||
global: 'Global',
|
||||
rule: 'Rule',
|
||||
direct: 'Direct',
|
||||
reject: 'Reject',
|
||||
rejectdrop: 'Drop',
|
||||
selector: 'Selector',
|
||||
urltest: 'Urltest',
|
||||
loadbalance: 'Balance',
|
||||
fallback: 'Fallback',
|
||||
relay: 'Relay',
|
||||
pass: 'Pass',
|
||||
active: 'Active',
|
||||
closed: 'Closed',
|
||||
sort: 'Sort',
|
||||
|
@ -94,6 +94,14 @@ export default {
|
||||
global: '全局',
|
||||
rule: '规则',
|
||||
direct: '直连',
|
||||
reject: '拒绝',
|
||||
rejectdrop: '丢弃',
|
||||
selector: '手动选择',
|
||||
urltest: '自动选择',
|
||||
loadbalance: '负载均衡',
|
||||
fallback: '故障转移',
|
||||
relay: '链式代理',
|
||||
pass: '绕过',
|
||||
active: '活动',
|
||||
closed: '已关闭',
|
||||
sort: '排序',
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
} from '~/components'
|
||||
import {
|
||||
filterProxiesByAvailability,
|
||||
formatProxyType,
|
||||
formatTimeFromNow,
|
||||
sortProxiesByOrderingType,
|
||||
} from '~/helpers'
|
||||
@ -235,7 +236,7 @@ export default () => {
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="badge badge-primary badge-sm">
|
||||
<span class="font-bold">{proxyGroup.type}</span>
|
||||
<span class="font-bold">{formatProxyType(proxyGroup.type)}</span>
|
||||
<Show when={proxyGroup.now?.length > 0}>
|
||||
<span class="whitespace-nowrap">
|
||||
::
|
||||
|
Loading…
x
Reference in New Issue
Block a user