浏览代码

[Feat 0000] 为可配置首页配置表添加http站点剪切板无法访问的兼容方案

houzekong 2 月之前
父节点
当前提交
6516a1a59b
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/views/vent/deviceManager/configurationTable/index.vue

+ 7 - 1
src/views/vent/deviceManager/configurationTable/index.vue

@@ -217,7 +217,13 @@
   /** 从剪切板导入 */
   /** 从剪切板导入 */
   async function handleImport() {
   async function handleImport() {
     try {
     try {
-      const text = await window.navigator.clipboard.readText();
+      let text = '';
+      // 浏览器会阻止用户在不安全的站点使用剪切板
+      if (window.navigator.clipboard) {
+        text = await window.navigator.clipboard.readText();
+      } else {
+        text = prompt('请粘贴JSON配置') || '';
+      }
       const arr = JSON.parse(text);
       const arr = JSON.parse(text);
       if (!Array.isArray(arr)) {
       if (!Array.isArray(arr)) {
         throw '剪切板内容格式错误';
         throw '剪切板内容格式错误';