Skip to content

3.4fix

Choose a tag to compare

@onodera2007 onodera2007 released this 28 Jun 10:36
· 20 commits to main since this release
26b9d5c

[优化]
将代码进行优化
将

      document.getElementById("output").value = command;
      // 自动选择文本以便复制
      document.getElementById("output").select();
      // 尝试执行复制操作
      try {
        document.execCommand('copy');
        alert('命令已复制到剪贴板!');
      } catch (err) {
        console.error('无法自动复制:', err);
      }

修改为

 // 输出到文本框
  const output = document.getElementById("output");
  output.value = command;
  // 自动选择文本以便复制
  output.select();
  // 尝试执行复制操作
  try {
    // 使用现代 Clipboard API
    navigator.clipboard.writeText(command).then(() => {
      alert('命令已复制到剪贴板!');
    }).catch(err => {
      console.error('无法自动复制:', err);
      // 回退到旧方法
      document.execCommand('copy');
      alert('命令已复制到剪贴板!');
    });
  } catch (err) {
    console.error('无法自动复制:', err);
  }

并统合为copyCommand(command)方法
优化了格式文本