fix: optimize appearing the wrong prompt by pop-up for the HTTP environments in copy function (#491)

This commit is contained in:
Fine0830
2025-08-15 12:08:54 +08:00
committed by GitHub
parent 54a700bf19
commit 7a8ee92bbb
2 changed files with 99 additions and 10 deletions

View File

@@ -18,8 +18,20 @@
import { ElNotification } from "element-plus";
export default (text: string): void => {
if (location.protocol === "http:") {
ElNotification({
title: "Warning",
message: "Clipboard is not supported in HTTP environments",
type: "warning",
});
return;
}
if (!navigator.clipboard) {
console.error("Clipboard is not supported");
ElNotification({
title: "Warning",
message: "Clipboard is not supported",
type: "warning",
});
return;
}
navigator.clipboard
@@ -33,7 +45,7 @@ export default (text: string): void => {
})
.catch((err) => {
ElNotification({
title: "Error",
title: "Warning",
message: err,
type: "warning",
});