From 59ad7ba6452b2028fd7faca000c626a148256620 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期二, 01 九月 2020 23:29:50 +0800
Subject: [PATCH] fix: do not allow empty data to be saved. for area manager

---
 src/pages/desktop/index/App.vue |   74 ++++++++++++++++++------------------
 1 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/src/pages/desktop/index/App.vue b/src/pages/desktop/index/App.vue
index 38d0b0e..a89ad1d 100644
--- a/src/pages/desktop/index/App.vue
+++ b/src/pages/desktop/index/App.vue
@@ -1,15 +1,15 @@
 <template>
-  <div id="app">
+  <div id="app" @contextmenu.prevent="">
     <tools></tools>
     <desktop></desktop>
     <tools-entry ref="dock_model"></tools-entry>
-    <!-- <dock ref="dock_model"></dock> -->
     <notice-tip ref="notice_tip_model"></notice-tip>
     <notification-center></notification-center>
   </div>
 </template>
 
 <script>
+import html2canvas from 'html2canvas';
 import Desktop from './components/Desktop';
 import NotificationCenter from './components/NotificationCenter';
 import NoticeTip from './components/NoticeTip';
@@ -22,6 +22,7 @@
   components: {
     Desktop, NotificationCenter, NoticeTip, Tools, ToolsEntry
   },
+  
   mounted() {
     document.getElementById('app').style.backgroundImage = process.env.VUE_APP_MAIN_URL;
     let _that = this;
@@ -32,65 +33,64 @@
       });
     }
 
-    // setTimeout(function () {
-    //   _that.$refs.dock_model.initDockItem();
-    // }, 100);
-    // axios.get(process.env.VUE_APP_USER_DATA_URL).then(function (res) {
-
-    // });
-
     let msgResp = require("./mock/messages.json")
     if (msgResp.success) {
       msgResp.data.forEach(function (item) {
         _that.addMessage(item);
       })
     }
-    // axios.get(process.env.VUE_APP_MESSAGE_URL).then(function (res) {
-
-    // });
 
     let weather = require("./mock/weather.json")
     if (weather.success) {
       _that.addWeather(weather.data.data);
     }
-    // axios.get(process.env.VUE_APP_WEATHER_URL).then(function (res) {
-
-    // });
-
-    setTimeout(function () {
-      _that.addMessage({
-        id: 'N1',
-        icon: 'images/frost.png',
-        tip: '鍒嗗竷寮忎换鍔¤皟搴�',
-        title: '榛樿璐﹀彿',
-        body: '璐﹀彿锛歠rost 瀵嗙爜锛歠rost',
-        time: new Date()
-      }, true);
-    }, 3000);
-
     setTimeout(function () {
       _that.addMessage({
         id: 'N2',
-        icon: 'images/message.png',
+        icon: '/images/desktop/message.png',
         tip: '娑堟伅',
-        title: '瀹樻柟QQ',
-        body: '1106088328',
+        title: 'SmartAi',
+        body: 'v1.0.0',
         time: new Date()
       }, true);
-    }, 6000);
-
-    console.log(this.$store.state.desktop)
+    }, 1000);
   },
   methods: {
     addMessage: function (message, ding) {
       this.$store.dispatch('desktop/addMessage', message);
-      if (ding) {
-        new Audio('sounds/ping.mp3').play();
-      }
+      // if (ding) {
+      //   new Audio('sounds/ping.mp3').play();
+      // }
       this.$refs.notice_tip_model.showTip(message);
     },
     addWeather: function (weather) {
       this.$store.commit('desktop/addWeather', weather);
+    },
+    screenShot(dock){
+      //鎵惧埌褰撳墠鐨刬frame
+      let curIframe = Array.from(document.querySelectorAll('iframe')).find(iframe => iframe.src.indexOf(dock.url) >= 0);
+      //淇濆瓨褰撳墠搴旂敤蹇収
+      html2canvas(curIframe.contentWindow.document.body, {
+        dpi: window.devicePixelRatio * 4,
+        logging: true, //鏌ョ湅html2canvas鍐呴儴鎵ц娴佺▼
+        removeContainer: true,
+        imageTimeout: 0,
+        useCORS: true, //寮�鍚法鍩熼厤缃�
+        //allowTaint: true
+      }).then(canvas => {
+        let shotSrc = canvas.toDataURL();
+        // this.$store.commit('desktop/addMinDock', {
+        //   id: dock.id,
+        //   src: dock.icon,
+        //   alt: dock.title,
+        //   type: "3",
+        //   screenshot: shotSrc
+        // });
+        this.$store.commit('desktop/shotscreen', {id:dock.id, src:shotSrc});
+        
+      }).catch(e => {
+        this.$store.commit('desktop/shotscreen', {id:dock.id, src:''});
+      });
     }
   }
 }
@@ -112,7 +112,7 @@
   width: 100%;
   height: 100%;
   background-size: 100% 100%;
-  background-image: url("../../../assets/img/desktop/desktop.png");
+  background-image: url("/images/desktop/background.png");
   background-attachment: fixed;
 }
 

--
Gitblit v1.8.0