(text)
| 50 | } |
| 51 | |
| 52 | export async function copy(text) { |
| 53 | let okay = true; |
| 54 | try { |
| 55 | await navigator.clipboard.writeText(text); |
| 56 | } catch (e) { |
| 57 | try { |
| 58 | // 构建input 执行 复制命令 |
| 59 | var _input = window.document.createElement('input'); |
| 60 | _input.value = text; |
| 61 | window.document.body.appendChild(_input); |
| 62 | _input.select(); |
| 63 | window.document.execCommand('Copy'); |
| 64 | window.document.body.removeChild(_input); |
| 65 | } catch (e) { |
| 66 | okay = false; |
| 67 | console.error(e); |
| 68 | } |
| 69 | } |
| 70 | return okay; |
| 71 | } |
| 72 | |
| 73 | // isMobile 函数已移除,请改用 useIsMobile Hook |
| 74 |
no outgoing calls
no test coverage detected