✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview • Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels. • Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close. • Fixed blank-form bug when opening the same record twice. Key improvements 1. Validation • `type`, `models` always required. • `key` required only while creating (not on edit). 2. Batch key creation • Checkbox moved into `extraText`; hidden when editing or when channel type = 41. 3. Layout & UI • `Row / Col` (12 + 12) for “Priority” and “Weight”. • Placeholders revised; model selector now shows creation hint; removed obsolete banner. • Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice. • Added `showClear`, `min`, rounded card class names for consistency. 4. Reusable helpers • `batchAllowed`, `batchExtra` utilities. • `getInitValues()` + centralized `inputs`→form synchronization. 5. Token editor aligned to the same pattern (`props.visiable` watcher). Result Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
This commit is contained in:
@@ -1143,8 +1143,8 @@
|
||||
"默认测试模型": "Default Test Model",
|
||||
"不填则为模型列表第一个": "First model in list if empty",
|
||||
"是否自动禁用(仅当自动禁用开启时有效),关闭后不会自动禁用该渠道": "Auto-disable (only effective when auto-disable is enabled). When turned off, this channel will not be automatically disabled",
|
||||
"状态码复写(仅影响本地判断,不修改返回到上游的状态码)": "Status Code Override (only affects local judgment, does not modify status code returned upstream)",
|
||||
"此项可选,用于复写返回的状态码,比如将claude渠道的400错误复写为500(用于重试),请勿滥用该功能,例如:": "Optional, used to override returned status codes, e.g. rewriting Claude channel's 400 error to 500 (for retry). Do not abuse this feature. Example:",
|
||||
"状态码复写": "Status Code Override",
|
||||
"此项可选,用于复写返回的状态码,仅影响本地判断,不修改返回到上游的状态码,比如将claude渠道的400错误复写为500(用于重试),请勿滥用该功能,例如:": "Optional, used to override returned status codes, only affects local judgment, does not modify status code returned upstream, e.g. rewriting Claude channel's 400 error to 500 (for retry). Do not abuse this feature. Example:",
|
||||
"渠道标签": "Channel Tag",
|
||||
"渠道优先级": "Channel Priority",
|
||||
"渠道权重": "Channel Weight",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -139,14 +139,24 @@ const EditToken = (props) => {
|
||||
if (formApiRef.current) {
|
||||
if (!isEdit) {
|
||||
formApiRef.current.setValues(getInitValues());
|
||||
} else {
|
||||
loadToken();
|
||||
}
|
||||
}
|
||||
loadModels();
|
||||
loadGroups();
|
||||
}, [props.editingToken.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.visiable) {
|
||||
if (isEdit) {
|
||||
loadToken();
|
||||
} else {
|
||||
formApiRef.current?.setValues(getInitValues());
|
||||
}
|
||||
} else {
|
||||
formApiRef.current?.reset();
|
||||
}
|
||||
}, [props.visiable, props.editingToken.id]);
|
||||
|
||||
const generateRandomSuffix = () => {
|
||||
const characters =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
||||
Reference in New Issue
Block a user