From 670abee2f03f6832f04dca7a160f03c0d51948e9 Mon Sep 17 00:00:00 2001 From: CaIon Date: Tue, 31 Mar 2026 21:42:36 +0800 Subject: [PATCH] fix(EditChannelModal): enhance clipboard handling with error checks Added checks to ensure clipboard functionality is available before attempting to read from it. Improved error handling during clipboard read operations to prevent unhandled exceptions. --- controller/pricing.go | 2 +- .../channels/modals/EditChannelModal.jsx | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/controller/pricing.go b/controller/pricing.go index b6537e4c..d0736119 100644 --- a/controller/pricing.go +++ b/controller/pricing.go @@ -46,7 +46,7 @@ func GetPricing(c *gin.Context) { "usable_group": usableGroup, "supported_endpoint": model.GetSupportedEndpointMap(), "auto_groups": service.GetUserAutoGroup(group), - "_": "a42d372ccf0b5dd13ecf71203521f9d2", + "pricing_version": "a42d372ccf0b5dd13ecf71203521f9d2", }) } diff --git a/web/src/components/table/channels/modals/EditChannelModal.jsx b/web/src/components/table/channels/modals/EditChannelModal.jsx index 8558b734..cf57aadd 100644 --- a/web/src/components/table/channels/modals/EditChannelModal.jsx +++ b/web/src/components/table/channels/modals/EditChannelModal.jsx @@ -558,6 +558,10 @@ const EditChannelModal = (props) => { }; const pasteFromClipboard = async () => { + if (!navigator?.clipboard?.readText) { + showError(t('无法读取剪贴板')); + return; + } try { const text = await navigator.clipboard.readText(); const parsed = parseChannelConnectionString(text); @@ -1302,13 +1306,14 @@ const EditChannelModal = (props) => { loadChannel(); } else { formApiRef.current?.setValues(getInitValues()); - // best-effort clipboard auto-detect for new channels - navigator.clipboard.readText().then((text) => { - const parsed = parseChannelConnectionString(text); - if (parsed) { - setClipboardConfig(parsed); - } - }).catch(() => {}); + try { + navigator?.clipboard?.readText()?.then((text) => { + const parsed = parseChannelConnectionString(text); + if (parsed) { + setClipboardConfig(parsed); + } + }).catch(() => {}); + } catch {} } fetchModelGroups(); // 重置手动输入模式状态