Bladeren bron

bugfix:处理已知bug

leo 1 jaar geleden
bovenliggende
commit
9662cd2fc1
3 gewijzigde bestanden met toevoegingen van 20 en 16 verwijderingen
  1. 1 1
      nuxt.config.js
  2. 10 9
      pages/claimCloudPhone/components/bargainingAssistance.vue
  3. 9 6
      plugins/plugins.js

+ 1 - 1
nuxt.config.js

@@ -276,7 +276,7 @@ export default {
     extendRoutes(routes, resolve) {
       routes.push({
         name: 'custom-route-name',
-        path: '/:type',
+        path: 'claimCloudPhone/:type',
         component: resolve(__dirname, 'pages/claimCloudPhone/_type.vue')
       });
     }

+ 10 - 9
pages/claimCloudPhone/components/bargainingAssistance.vue

@@ -746,18 +746,19 @@ export default {
                   if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
                     this.$native.share(shareInfo);
                   } else {
-                    console.log(writeToClipboard)
-                    writeToClipboard(res.data.link)
-                      .then(() => {
+                    writeToClipboard(
+                      res.data.link,
+                      () => {
                         setTimeout(() => {
                           this.$toast('链接复制成功');
                         });
-                      })
-                      .catch((err) => {
+                      },
+                      () => {
                         setTimeout(() => {
                           this.$toast('链接复制失败');
                         });
-                      });
+                      },
+                    );
                   }
                 }
               })
@@ -1438,12 +1439,12 @@ export default {
       width: 284px;
       z-index: -1;
     }
-    .exit-glory{
+    .exit-glory {
       position: absolute;
       top: 50%;
       left: 50%;
       transform: translate(-50%, -50%) scale(1.5);
-      z-index: -2
+      z-index: -2;
     }
     .exit-content {
       position: absolute;
@@ -1682,7 +1683,7 @@ export default {
   margin-bottom: 24px !important;
 }
 
-.mask{
+.mask {
   z-index: 4000;
 }
 </style>

+ 9 - 6
plugins/plugins.js

@@ -17,18 +17,21 @@ export function timeStamp(StatusMinute, userCardType, nextSendTime) {
 
 
 // 封装对剪贴板的访问为异步函数
-export function writeToClipboard(text) {
+export function writeToClipboard(text, success = () => { }, error = () => { }) {
     // 如果navigator.clipboard存在,直接使用复制功能
     if (navigator.clipboard) {
         try {
             setTimeout(() => {
-                return navigator.clipboard.writeText(text)
+                navigator.clipboard.writeText(text).then(() => {
+                    success()
+                }).catch(() => {
+                    error()
+                })
             }, 0);
         } catch (err) {
-            return Promise.reject(err)
+            error()
         }
     } else {
-        // 否则使用传统的document.execCommand('copy')方法
         const textArea = document.createElement('textarea');
         textArea.value = text;
         document.body.appendChild(textArea);
@@ -36,12 +39,12 @@ export function writeToClipboard(text) {
         try {
             const successful = document.execCommand('copy');
             if (successful) {
-                return Promise.resolve()
+                success()
             } else {
                 throw '复制失败'
             }
         } catch (err) {
-            return Promise.reject(err)
+            error()
         }
         document.body.removeChild(textArea);
     }