From 5fb65ada8ccc28eabf823b284de70fbd3ca1f41e Mon Sep 17 00:00:00 2001
From: ZZJ <zzjdsg2300@163.com>
Date: 星期二, 28 九月 2021 18:29:36 +0800
Subject: [PATCH] 抓拍大图层级修复v1
---
src/pages/desktop/index/App.vue | 192 ++++++++++++++++++++++++++++++++++-------------
1 files changed, 139 insertions(+), 53 deletions(-)
diff --git a/src/pages/desktop/index/App.vue b/src/pages/desktop/index/App.vue
index b58209a..5925c0d 100644
--- a/src/pages/desktop/index/App.vue
+++ b/src/pages/desktop/index/App.vue
@@ -1,97 +1,175 @@
<template>
- <div id="app">
- <tools></tools>
- <preference></preference>
- <desktop></desktop>
- <dock ref="dock_model"></dock>
+ <div id="app" @contextmenu.prevent>
+ <tools @jumpToDock="onJumpToDock"></tools>
+ <desktop ref="desktop"></desktop>
+ <tools-entry @changeBackground="onChangeBg" ref="dock_model"></tools-entry>
<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 Dock from './components/Dock';
-import Preference from './components/Preference';
import NotificationCenter from './components/NotificationCenter';
import NoticeTip from './components/NoticeTip';
import Tools from './components/Tools';
-import axios from 'axios'
+import ToolsEntry from './components/ToolsEntry';
+
+import { getApps } from '@/api/app'
+
+import config from '../../../../package.json'
export default {
name: 'app',
components: {
- Desktop, Dock, Preference, NotificationCenter, NoticeTip, Tools
+ Desktop, NotificationCenter, NoticeTip, Tools, ToolsEntry
+ },
+ data() {
+ return {
+ buttonAuthority: sessionStorage.getItem('buttonAuthoritys') || [],
+ defaultBgUrl:"/images/desktop/background.png"
+ }
+ },
+ 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;
+ // document.getElementById('app').style.backgroundImage = process.env.VUE_APP_MAIN_URL;
+ const url = localStorage.getItem("backgroundPic")
+ document.getElementById('app').style.backgroundImage = `url(${url||this.defaultBgUrl})`
+ this.showApps();
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);
- });
- }
-
- 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: 'V' + config.version,
time: new Date()
}, true);
- }, 6000);
-
- console.log(this.$store.state.desktop)
+ }, 1000);
+ window.addEventListener('message', (e) => {
+ if (e.data.msg == 'AppUpdate') {
+ this.showApps();
+ }
+ if (e.data.msg=='checkSN') {
+ debugger
+ this.$refs.desktop.validateSn()
+ }
+ });
},
methods: {
+ onJumpToDock(name){
+ this.$refs.dock_model.onJumpToDock(name)
+ },
+ onChangeBg(v){
+ document.getElementById('app').style.backgroundImage = "url(" + v + ")"
+ this.defaultBgUrl = v
+ localStorage.setItem("backgroundPic", v)
+ },
+ 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: '' });
+ });
}
}
}
@@ -113,6 +191,14 @@
width: 100%;
height: 100%;
background-size: 100% 100%;
- background-image: url("../../../assets/img/desktop/main.jpg");
+ background-image: url("/images/desktop/background.png");
+ background-attachment: fixed;
+}
+
+.clearFix:after {
+ content: "";
+ display: block;
+ height: 0;
+ clear: both;
}
</style>
--
Gitblit v1.8.0