From b4d2703e653bf702d705b18c20d9edb9066c7c8a Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期三, 03 十一月 2021 17:35:10 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/web/vue-smart-ai
---
src/pages/desktop/index/App.vue | 123 ++++++++++++++++++++++++++++++++++++----
1 files changed, 109 insertions(+), 14 deletions(-)
diff --git a/src/pages/desktop/index/App.vue b/src/pages/desktop/index/App.vue
index 73741ab..7babd3b 100644
--- a/src/pages/desktop/index/App.vue
+++ b/src/pages/desktop/index/App.vue
@@ -1,5 +1,5 @@
<template>
- <div id="app">
+ <div id="app" @contextmenu.prevent>
<tools></tools>
<desktop></desktop>
<tools-entry ref="dock_model"></tools-entry>
@@ -9,6 +9,7 @@
</template>
<script>
+import html2canvas from 'html2canvas';
import Desktop from './components/Desktop';
import NotificationCenter from './components/NotificationCenter';
import NoticeTip from './components/NoticeTip';
@@ -16,22 +17,40 @@
import ToolsEntry from './components/ToolsEntry';
import axios from 'axios'
+import { getApps } from '@/api/app'
+import { findAllSdk } from '@/api/taskMange'
+
+import config from '../../../../package.json'
+
export default {
name: 'app',
components: {
Desktop, NotificationCenter, NoticeTip, Tools, ToolsEntry
},
-
+ data() {
+ return {
+ buttonAuthority: sessionStorage.getItem('buttonAuthoritys') || []
+ }
+ },
+ computed: {
+ isAdmin() {
+ if (
+ sessionStorage.getItem('userInfo') &&
+ sessionStorage.getItem('userInfo') !== ''
+ ) {
+ let loginName = JSON.parse(sessionStorage.getItem('userInfo')).username
+ return (
+ loginName === 'superadmin' || loginName === 'basic'
+ )
+ }
+ return false
+ }
+ },
mounted() {
document.getElementById('app').style.backgroundImage = process.env.VUE_APP_MAIN_URL;
- let _that = this;
- let user_res = require("./mock/userData.json")
- if (user_res.success) {
- user_res.data.docks.forEach(function (item) {
- _that.$store.commit('desktop/addDock', item);
- });
- }
+ this.showApps();
+ let _that = this;
let msgResp = require("./mock/messages.json")
if (msgResp.success) {
msgResp.data.forEach(function (item) {
@@ -48,22 +67,98 @@
id: 'N2',
icon: '/images/desktop/message.png',
tip: '娑堟伅',
- title: 'SmartAi',
- body: 'v1.0.0',
+ title: 'SmartAI',
+ body: 'V' + config.version,
time: new Date()
}, true);
}, 1000);
+ window.addEventListener('message', (e) => {
+ if (e.data.msg == 'AppUpdate') {
+ this.showApps();
+ }
+ });
},
methods: {
+ showApps() {
+ let _that = this;
+
+ getApps().then(rsp => {
+ if (rsp && rsp.success) {
+ _that.$store.state.desktop.docks = [];
+ let installedApps = [];
+ rsp.data
+ rsp.data.forEach(function (item) {
+ if (item.installed) {
+ let temp = {
+ id: item.id,
+ create_by: item.create_by,
+ create_time: item.create_time,
+ height: item.height,
+ icon: item.icon,
+ src: item.iconBlob ? 'data:image/png;base64,' + item.iconBlob : item.icon,
+ installed: item.installed,
+ isDelete: item.isDelete,
+ isUpgrade: item.isUpgrade,
+ title: item.title,
+ name: item.package,
+ remoteVersion: item.remoteVersion,
+ type: item.type,
+ update_by: item.update_by,
+ update_time: item.update_time,
+ url: item.url,
+ version: item.version,
+ width: item.width,
+ isDefault: item.isDefault
+ }
+
+ // 鍒ゆ柇鏉冮檺
+ if (_that.isAdmin || _that.buttonAuthority.indexOf(item.package) >= 0) {
+ _that.$store.commit('desktop/addDock', temp);
+ }
+
+ installedApps.push(item.package);
+ }
+ });
+
+ sessionStorage.setItem("apps", installedApps.join(","));
+ }
+ })
+ },
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: '' });
+ });
}
}
}
--
Gitblit v1.8.0