Przeglądaj źródła

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

houzekong 2 miesięcy temu
rodzic
commit
6516a1a59b

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

@@ -217,7 +217,13 @@
   /** 从剪切板导入 */
   async function handleImport() {
     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);
       if (!Array.isArray(arr)) {
         throw '剪切板内容格式错误';