广丰卷烟厂数采质量分析系统
zhuguifei
2026-03-04 dbfd4bc96205dd957827ee16c1149058fc2b88bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { useClipboard } from '@vueuse/core';
 
const { copy, isSupported } = useClipboard();
 
export async function handleCopy(source?: string) {
  if (!isSupported) {
    window.$message?.error('您的浏览器不支持 Clipboard API');
    return;
  }
 
  if (!source) {
    return;
  }
 
  if (navigator.clipboard && window.isSecureContext) {
    await copy(source);
  } else {
    const range = document.createRange();
    range.selectNode(document.getElementById('tokenDetailInput')!);
    const selection = window.getSelection();
    if (selection?.rangeCount) selection.removeAllRanges();
    selection?.addRange(range);
    document.execCommand('copy');
  }
  window.$message?.success('复制成功');
}