mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-06-29 12:27:35 +00:00
refactor copy
This commit is contained in:
parent
aff69c057f
commit
1d2031420b
@ -16,18 +16,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ElNotification } from "element-plus";
|
import { ElNotification } from "element-plus";
|
||||||
export default (value: string): void => {
|
|
||||||
const input = document.createElement("input");
|
export default (text: string): void => {
|
||||||
input.value = value;
|
navigator.clipboard
|
||||||
document.body.appendChild(input);
|
.writeText(text)
|
||||||
input.select();
|
.then(() => {
|
||||||
if (document.execCommand("Copy")) {
|
ElNotification({
|
||||||
document.execCommand("Copy");
|
title: "Success",
|
||||||
}
|
message: "Copied",
|
||||||
input.remove();
|
type: "success",
|
||||||
ElNotification({
|
});
|
||||||
title: "Success",
|
})
|
||||||
message: "Copied",
|
.catch((err) => {
|
||||||
type: "success",
|
ElNotification({
|
||||||
});
|
title: "Error",
|
||||||
|
message: err,
|
||||||
|
type: "warning",
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user