MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / toCopy

Function toCopy

frontend/src/tools/copy.ts:8–29  ·  view source on GitHub ↗
(sth: string | number)

Source from the content-addressed store, hash-verified

6const { copy, copied, isSupported } = useClipboard();
7
8export const toCopy = async (sth: string | number) => {
9 try {
10 if (!isSupported.value) {
11 const input = document.createElement("input");
12 input.setAttribute("value", String(sth));
13 document.body.appendChild(input);
14 input.select();
15 document.execCommand("copy");
16 document.body.removeChild(input);
17 return message.success(t("TXT_CODE_b858d78a"));
18 } else {
19 await copy(String(sth));
20 if (copied.value) return message.success(t("TXT_CODE_b858d78a"));
21 }
22 } catch (err: any) {
23 console.error(err);
24 Modal.warning({
25 title: t("TXT_CODE_ca07c84c"),
26 content: [h("span", t("TXT_CODE_2452016e")), h("br"), h("span", sth)]
27 });
28 }
29};

Callers 1

initTerminalWindowFunction · 0.90

Calls 3

errorMethod · 0.80
warningMethod · 0.80
selectMethod · 0.45

Tested by

no test coverage detected