(sth: string | number)
| 6 | const { copy, copied, isSupported } = useClipboard(); |
| 7 | |
| 8 | export 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 | }; |
no test coverage detected