mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
fix: disallow empty selection in Select component
(cherry picked from commit 48eef556770030d8a032fb6dd0e6888d1f0750a0)
This commit is contained in:
parent
f54ffcf42b
commit
511eb0c7fa
@ -193,6 +193,7 @@ const GeneralConfig: React.FC = () => {
|
|||||||
selectionMode="multiple"
|
selectionMode="multiple"
|
||||||
selectedKeys={new Set(envType)}
|
selectedKeys={new Set(envType)}
|
||||||
aria-label={t('settings.envType')}
|
aria-label={t('settings.envType')}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={async (v) => {
|
onSelectionChange={async (v) => {
|
||||||
try {
|
try {
|
||||||
await patchAppConfig({
|
await patchAppConfig({
|
||||||
@ -389,6 +390,7 @@ const GeneralConfig: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
selectedKeys={new Set([customTheme])}
|
selectedKeys={new Set([customTheme])}
|
||||||
aria-label={t('settings.selectTheme')}
|
aria-label={t('settings.selectTheme')}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={async (v) => {
|
onSelectionChange={async (v) => {
|
||||||
try {
|
try {
|
||||||
await patchAppConfig({ customTheme: v.currentKey as string })
|
await patchAppConfig({ customTheme: v.currentKey as string })
|
||||||
|
|||||||
@ -129,6 +129,7 @@ const MihomoConfig: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
selectedKeys={new Set([proxyCols])}
|
selectedKeys={new Set([proxyCols])}
|
||||||
aria-label={t('mihomo.proxyColumns.title')}
|
aria-label={t('mihomo.proxyColumns.title')}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={async (v) => {
|
onSelectionChange={async (v) => {
|
||||||
await patchAppConfig({ proxyCols: v.currentKey as 'auto' | '1' | '2' | '3' | '4' })
|
await patchAppConfig({ proxyCols: v.currentKey as 'auto' | '1' | '2' | '3' | '4' })
|
||||||
}}
|
}}
|
||||||
@ -147,6 +148,7 @@ const MihomoConfig: React.FC = () => {
|
|||||||
className="w-[150px]"
|
className="w-[150px]"
|
||||||
size="sm"
|
size="sm"
|
||||||
selectedKeys={new Set([mihomoCpuPriority])}
|
selectedKeys={new Set([mihomoCpuPriority])}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={async (v) => {
|
onSelectionChange={async (v) => {
|
||||||
try {
|
try {
|
||||||
await patchAppConfig({
|
await patchAppConfig({
|
||||||
|
|||||||
@ -236,6 +236,7 @@ const Connections: React.FC = () => {
|
|||||||
className="w-[180px] min-w-[131px]"
|
className="w-[180px] min-w-[131px]"
|
||||||
aria-label={t('connections.orderBy')}
|
aria-label={t('connections.orderBy')}
|
||||||
selectedKeys={new Set([connectionOrderBy])}
|
selectedKeys={new Set([connectionOrderBy])}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={async (v) => {
|
onSelectionChange={async (v) => {
|
||||||
await patchAppConfig({
|
await patchAppConfig({
|
||||||
connectionOrderBy: v.currentKey as
|
connectionOrderBy: v.currentKey as
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const CoreMap = {
|
|||||||
const Mihomo: React.FC = () => {
|
const Mihomo: React.FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { appConfig, patchAppConfig } = useAppConfig()
|
const { appConfig, patchAppConfig } = useAppConfig()
|
||||||
const {
|
const {
|
||||||
core = 'mihomo',
|
core = 'mihomo',
|
||||||
maxLogDays = 7,
|
maxLogDays = 7,
|
||||||
sysProxy,
|
sysProxy,
|
||||||
@ -136,6 +136,7 @@ const Mihomo: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
aria-label={t('mihomo.selectCoreVersion')}
|
aria-label={t('mihomo.selectCoreVersion')}
|
||||||
selectedKeys={new Set([core])}
|
selectedKeys={new Set([core])}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={async (v) => {
|
onSelectionChange={async (v) => {
|
||||||
handleConfigChangeWithRestart('core', v.currentKey as 'mihomo' | 'mihomo-alpha')
|
handleConfigChangeWithRestart('core', v.currentKey as 'mihomo' | 'mihomo-alpha')
|
||||||
}}
|
}}
|
||||||
@ -702,6 +703,7 @@ const Mihomo: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
aria-label={t('mihomo.selectLogLevel')}
|
aria-label={t('mihomo.selectLogLevel')}
|
||||||
selectedKeys={new Set([logLevel])}
|
selectedKeys={new Set([logLevel])}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={(v) => {
|
onSelectionChange={(v) => {
|
||||||
onChangeNeedRestart({ 'log-level': v.currentKey as LogLevel })
|
onChangeNeedRestart({ 'log-level': v.currentKey as LogLevel })
|
||||||
}}
|
}}
|
||||||
@ -720,6 +722,7 @@ const Mihomo: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
aria-label={t('mihomo.selectFindProcessMode')}
|
aria-label={t('mihomo.selectFindProcessMode')}
|
||||||
selectedKeys={new Set([findProcessMode])}
|
selectedKeys={new Set([findProcessMode])}
|
||||||
|
disallowEmptySelection={true}
|
||||||
onSelectionChange={(v) => {
|
onSelectionChange={(v) => {
|
||||||
onChangeNeedRestart({ 'find-process-mode': v.currentKey as FindProcessMode })
|
onChangeNeedRestart({ 'find-process-mode': v.currentKey as FindProcessMode })
|
||||||
}}
|
}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user