From f7f1be9df244bce21ebe15d4e9559d508e10c6c2 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Sat, 21 Jun 2025 15:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20refactor:=20Refactor=20RatioSett?= =?UTF-8?q?ing:=20integrate=20Group=20Ratio=20Settings=20into=20tabs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Moved `GroupRatioSettings` component inside the existing Tabs as a new **Group Ratios** tab. * Removed the standalone `Card` that previously wrapped `GroupRatioSettings`. * Re-formatted JSX props for `ModelRatioSettings` and `GroupRatioSettings` to improve readability. * Consolidates all ratio-related settings into a single tabbed view for a cleaner and more consistent UI. --- web/src/components/settings/RatioSetting.js | 15 +- web/src/i18n/locales/en.json | 2 +- .../pages/Setting/Ratio/GroupRatioSettings.js | 242 +++++++++--------- .../pages/Setting/Ratio/ModelRatioSettings.js | 200 +++++++-------- 4 files changed, 230 insertions(+), 229 deletions(-) diff --git a/web/src/components/settings/RatioSetting.js b/web/src/components/settings/RatioSetting.js index 99a6a3cf..b0284e1d 100644 --- a/web/src/components/settings/RatioSetting.js +++ b/web/src/components/settings/RatioSetting.js @@ -84,7 +84,16 @@ const RatioSetting = () => { - + + + + { - {/* 分组倍率设置 */} - - - ); }; diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index cab7f8fb..d9cfe1d8 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -1263,7 +1263,7 @@ " 吗?": "?", "修改子渠道优先级": "Modify sub-channel priority", "确定要修改所有子渠道优先级为 ": "Confirm to modify all sub-channel priorities to ", - "分组设置": "Group settings", + "分组倍率设置": "Group ratio settings", "用户可选分组": "User selectable groups", "保存分组倍率设置": "Save group ratio settings", "模型倍率设置": "Model ratio settings", diff --git a/web/src/pages/Setting/Ratio/GroupRatioSettings.js b/web/src/pages/Setting/Ratio/GroupRatioSettings.js index 3c7c754b..12e634ba 100644 --- a/web/src/pages/Setting/Ratio/GroupRatioSettings.js +++ b/web/src/pages/Setting/Ratio/GroupRatioSettings.js @@ -96,133 +96,131 @@ export default function GroupRatioSettings(props) { getFormApi={(formAPI) => (refForm.current = formAPI)} style={{ marginBottom: 15 }} > - - - - verifyJSON(value), - message: t('不是合法的 JSON 字符串'), - }, - ]} - onChange={(value) => - setInputs({ ...inputs, GroupRatio: value }) - } - /> - - - - - verifyJSON(value), - message: t('不是合法的 JSON 字符串'), - }, - ]} - onChange={(value) => - setInputs({ ...inputs, UserUsableGroups: value }) - } - /> - - - - - verifyJSON(value), - message: t('不是合法的 JSON 字符串'), - }, - ]} - onChange={(value) => - setInputs({ ...inputs, GroupGroupRatio: value }) - } - /> - - - - - { - if (!value || value.trim() === '') { - return true; // Allow empty values - } + + + verifyJSON(value), + message: t('不是合法的 JSON 字符串'), + }, + ]} + onChange={(value) => + setInputs({ ...inputs, GroupRatio: value }) + } + /> + + + + + verifyJSON(value), + message: t('不是合法的 JSON 字符串'), + }, + ]} + onChange={(value) => + setInputs({ ...inputs, UserUsableGroups: value }) + } + /> + + + + + verifyJSON(value), + message: t('不是合法的 JSON 字符串'), + }, + ]} + onChange={(value) => + setInputs({ ...inputs, GroupGroupRatio: value }) + } + /> + + + + + { + if (!value || value.trim() === '') { + return true; // Allow empty values + } - // First check if it's valid JSON - try { - const parsed = JSON.parse(value); + // First check if it's valid JSON + try { + const parsed = JSON.parse(value); - // Check if it's an array - if (!Array.isArray(parsed)) { - return false; - } - - // Check if every element is a string - return parsed.every(item => typeof item === 'string'); - } catch (error) { + // Check if it's an array + if (!Array.isArray(parsed)) { return false; } - }, - message: t('必须是有效的 JSON 字符串数组,例如:["g1","g2"]'), + + // Check if every element is a string + return parsed.every(item => typeof item === 'string'); + } catch (error) { + return false; + } }, - ]} - onChange={(value) => - setInputs({ ...inputs, AutoGroups: value }) - } - /> - - - - - - setInputs({ ...inputs, DefaultUseAutoGroup: value }) - } - /> - - - + message: t('必须是有效的 JSON 字符串数组,例如:["g1","g2"]'), + }, + ]} + onChange={(value) => + setInputs({ ...inputs, AutoGroups: value }) + } + /> + + + + + + setInputs({ ...inputs, DefaultUseAutoGroup: value }) + } + /> + + diff --git a/web/src/pages/Setting/Ratio/ModelRatioSettings.js b/web/src/pages/Setting/Ratio/ModelRatioSettings.js index 764c6986..80238fc8 100644 --- a/web/src/pages/Setting/Ratio/ModelRatioSettings.js +++ b/web/src/pages/Setting/Ratio/ModelRatioSettings.js @@ -118,107 +118,105 @@ export default function ModelRatioSettings(props) { getFormApi={(formAPI) => (refForm.current = formAPI)} style={{ marginBottom: 15 }} > - - - - verifyJSON(value), - message: '不是合法的 JSON 字符串', - }, - ]} - onChange={(value) => - setInputs({ ...inputs, ModelPrice: value }) - } - /> - - - - - verifyJSON(value), - message: '不是合法的 JSON 字符串', - }, - ]} - onChange={(value) => - setInputs({ ...inputs, ModelRatio: value }) - } - /> - - - - - verifyJSON(value), - message: '不是合法的 JSON 字符串', - }, - ]} - onChange={(value) => - setInputs({ ...inputs, CacheRatio: value }) - } - /> - - - - - verifyJSON(value), - message: '不是合法的 JSON 字符串', - }, - ]} - onChange={(value) => - setInputs({ ...inputs, CompletionRatio: value }) - } - /> - - - - - - setInputs({ ...inputs, ExposeRatioEnabled: value }) - } - /> - - - + + + verifyJSON(value), + message: '不是合法的 JSON 字符串', + }, + ]} + onChange={(value) => + setInputs({ ...inputs, ModelPrice: value }) + } + /> + + + + + verifyJSON(value), + message: '不是合法的 JSON 字符串', + }, + ]} + onChange={(value) => + setInputs({ ...inputs, ModelRatio: value }) + } + /> + + + + + verifyJSON(value), + message: '不是合法的 JSON 字符串', + }, + ]} + onChange={(value) => + setInputs({ ...inputs, CacheRatio: value }) + } + /> + + + + + verifyJSON(value), + message: '不是合法的 JSON 字符串', + }, + ]} + onChange={(value) => + setInputs({ ...inputs, CompletionRatio: value }) + } + /> + + + + + + setInputs({ ...inputs, ExposeRatioEnabled: value }) + } + /> + +