mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Feature: add script mode in settings (#49)
This commit is contained in:
parent
a20d7b0fed
commit
5873076fd7
@ -1,8 +1,8 @@
|
|||||||
import React, { useEffect } from 'react'
|
import React, { useEffect, useMemo } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import capitalize from 'lodash/capitalize'
|
import capitalize from 'lodash/capitalize'
|
||||||
import { Header, Card, Row, Col, Switch, ButtonSelect, ButtonSelectOptions, Input, Icon } from '@components'
|
import { Header, Card, Row, Col, Switch, ButtonSelect, ButtonSelectOptions, Input, Icon } from '@components'
|
||||||
import { useI18n, useClashXData, useAPIInfo, useGeneral, useIdentity } from '@stores'
|
import { useI18n, useClashXData, useAPIInfo, useGeneral, useIdentity, useVersion } from '@stores'
|
||||||
import { updateConfig } from '@lib/request'
|
import { updateConfig } from '@lib/request'
|
||||||
import { useObject } from '@lib/hook'
|
import { useObject } from '@lib/hook'
|
||||||
import { jsBridge } from '@lib/jsBridge'
|
import { jsBridge } from '@lib/jsBridge'
|
||||||
@ -12,6 +12,7 @@ import './style.scss'
|
|||||||
const languageOptions: ButtonSelectOptions[] = [{ label: '中文', value: 'zh_CN' }, { label: 'English', value: 'en_US' }]
|
const languageOptions: ButtonSelectOptions[] = [{ label: '中文', value: 'zh_CN' }, { label: 'English', value: 'en_US' }]
|
||||||
|
|
||||||
export default function Settings () {
|
export default function Settings () {
|
||||||
|
const { premium } = useVersion()
|
||||||
const { data: clashXData, update: fetchClashXData } = useClashXData()
|
const { data: clashXData, update: fetchClashXData } = useClashXData()
|
||||||
const { general, update: fetchGeneral } = useGeneral()
|
const { general, update: fetchGeneral } = useGeneral()
|
||||||
const { set: setIdentity } = useIdentity()
|
const { set: setIdentity } = useIdentity()
|
||||||
@ -78,11 +79,17 @@ export default function Settings () {
|
|||||||
systemProxy
|
systemProxy
|
||||||
} = clashXData
|
} = clashXData
|
||||||
|
|
||||||
const proxyModeOptions: ButtonSelectOptions[] = [
|
const proxyModeOptions = useMemo(() => {
|
||||||
{ label: t('values.global'), value: 'Global' },
|
const options = [
|
||||||
{ label: t('values.rules'), value: 'Rule' },
|
{ label: t('values.global'), value: 'Global' },
|
||||||
{ label: t('values.direct'), value: 'Direct' }
|
{ label: t('values.rules'), value: 'Rule' },
|
||||||
]
|
{ label: t('values.direct'), value: 'Direct' }
|
||||||
|
]
|
||||||
|
if (premium) {
|
||||||
|
options.push({ label: t('values.script'), value: 'Script' })
|
||||||
|
}
|
||||||
|
return options
|
||||||
|
}, [t, premium])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
|
@ -25,7 +25,8 @@ export default {
|
|||||||
en: 'English',
|
en: 'English',
|
||||||
global: 'Global',
|
global: 'Global',
|
||||||
rules: 'Rules',
|
rules: 'Rules',
|
||||||
direct: 'Direct'
|
direct: 'Direct',
|
||||||
|
script: 'Script'
|
||||||
},
|
},
|
||||||
versionString: 'Current ClashX is the latest version:{{version}}',
|
versionString: 'Current ClashX is the latest version:{{version}}',
|
||||||
checkUpdate: 'Check Update',
|
checkUpdate: 'Check Update',
|
||||||
|
@ -25,7 +25,8 @@ export default {
|
|||||||
en: 'English',
|
en: 'English',
|
||||||
global: '全局',
|
global: '全局',
|
||||||
rules: '规则',
|
rules: '规则',
|
||||||
direct: '直连'
|
direct: '直连',
|
||||||
|
script: '脚本'
|
||||||
},
|
},
|
||||||
versionString: '当前 ClashX 已是最新版本:{{version}}',
|
versionString: '当前 ClashX 已是最新版本:{{version}}',
|
||||||
checkUpdate: '检查更新',
|
checkUpdate: '检查更新',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user