mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 04:24:53 +00:00
Refactor copy util with Web API (#432)
This commit is contained in:
parent
aff69c057f
commit
5c92a46569
@ -16,18 +16,22 @@
|
||||
*/
|
||||
|
||||
import { ElNotification } from "element-plus";
|
||||
export default (value: string): void => {
|
||||
const input = document.createElement("input");
|
||||
input.value = value;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
if (document.execCommand("Copy")) {
|
||||
document.execCommand("Copy");
|
||||
}
|
||||
input.remove();
|
||||
ElNotification({
|
||||
title: "Success",
|
||||
message: "Copied",
|
||||
type: "success",
|
||||
});
|
||||
|
||||
export default (text: string): void => {
|
||||
navigator.clipboard
|
||||
.writeText(text)
|
||||
.then(() => {
|
||||
ElNotification({
|
||||
title: "Success",
|
||||
message: "Copied",
|
||||
type: "success",
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
ElNotification({
|
||||
title: "Error",
|
||||
message: err,
|
||||
type: "warning",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user