fix(EditChannelModal): enhance clipboard handling with error checks
Some checks failed
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (amd64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (arm64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Create multi-arch manifests (Docker Hub) (push) Has been cancelled

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.
This commit is contained in:
CaIon 2026-03-31 21:42:36 +08:00
parent 8bb9a42f68
commit 670abee2f0
2 changed files with 13 additions and 8 deletions

View File

@ -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",
})
}

View File

@ -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();
//