UNPKG

matedesktop

Version:

云桌面前端框架vue插件-测试版本

177 lines (154 loc) 7.48 kB
import { reactive } from "vue"; function System(){ let index = 0; let components = []; let countWindow = []; return { App:null, data: reactive({ desktopBackground : { tabIndex: 2, color: "#000", imageList: [ "https://img0.baidu.com/it/u=4283872450,1871395198&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1664557200&t=c452b32088ebdbd340a8ac912dc402fa", "https://img2.baidu.com/it/u=1489621019,851380760&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800", "https://img0.baidu.com/it/u=1330642793,527938673&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800", "https://img2.baidu.com/it/u=3694252178,3820096143&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800", "https://img2.baidu.com/it/u=2648826339,3844245919&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800", "https://img2.baidu.com/it/u=3717023900,1003887710&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500", "https://img0.baidu.com/it/u=1190877567,170658503&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500", "https://img0.baidu.com/it/u=3768248324,2029509371&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500", "https://img2.baidu.com/it/u=1202750346,2371902332&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800", "https://img0.baidu.com/it/u=939224646,2754221629&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800", "https://img2.baidu.com/it/u=3356131001,3311381934&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500", "https://img1.baidu.com/it/u=3782130620,3987760814&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=313", "https://img0.baidu.com/it/u=1127857218,766670651&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500", ], imageIndex: 0, videoList:[ require("../video/01.mp4"), require("../video/vb2-2.mp4"), require("../video/02.mp4"), require("../video/5397ead2c951342879774b72b01bb5ff_preview.mp4"), require("../video/f879922e2b8c01dd86912fc7e3576270_preview.mp4"), require("../video/97ba6b60662ab4f31ef06cdf5a5f8e94_preview.mp4"), require("../video/750c4e56cb120056c9d155b63025c564_preview.mp4"), require("../video/a03f8b79f5b344c92855592f5b016cb0_preview.mp4"), require("../video/3760b2031ff41ca0bd80bc7a8a13f7bb_preview.mp4"), require("../video/2366564fa6b83158208eb3181752a8d6_preview.mp4"), require("../video/b99b51e6c7945c9d5565861d397451cb_preview.mp4"), require("../video/b8c4da367a3c730ca2c2e1eacf422107_preview.mp4"), ], videoIndex: 0, gradientColor: "", gradientList: [], gradientAngle: 90, }, bottomBar:{ background: "rgb(46, 46, 46)", iconBackground: "rgb(128,128,128)", iconActiveBackground: "#000", }, notice:{ background: "#2e2e2e", msgBoxbackground: "#000", msgBoxbacColor: "#fff", list:[] }, windowWidth : 0, windowHeight : 0, App: null, windowList: [], activeWindowIndex: -1, }), window(mateWindow){ let name = mateWindow.component.name ?? mateWindow.title; mateWindow.componentName = name; if(!name) { console.warn("组件未配置name属性,或未配置窗口title属性,将暂停窗口生成"); return; } let findIndex = components.indexOf(mateWindow.component); if(findIndex == -1){ this.App.component(name,mateWindow.component); components.push(mateWindow.component); findIndex = components.length - 1; countWindow[findIndex] = { count: 0, list: {} }; } mateWindow.storageIndex = findIndex; if(countWindow[findIndex].count < mateWindow.maxCountWindow){ countWindow[findIndex].count++; countWindow[findIndex].list[index] = index; mateWindow.desktopIndex = index; this.data.windowList.push({ mateWindow,windowIndex: index++ }); setTimeout(()=>{ this.setIndex(index -1) },5); } else{ for (const key in countWindow[findIndex].list) { if (Object.hasOwnProperty.call(countWindow[findIndex].list, key)) { this.setIndex(key); for (let index = 0; index < this.data.windowList.length; index++) { const element = this.data.windowList[index]; if(element.windowIndex == key) { if(element.mateWindow.showWindow && key != this.data.activeWindowIndex){ if(element.mateWindow.showWindow){ setTimeout(()=>{ this.setIndex(key); }) } } else{ element.mateWindow.showWindow = !element.mateWindow.showWindow; element.mateWindow.emit("onHide",!element.mateWindow.showWindow); } break; } } } } } }, get windowInfoList(){ return this.data.windowList; }, get windowWidth(){ return this.data.windowWidth; }, get windowHeight(){ return this.data.windowHeight; }, closeWindow(key){ let mateWindow = this.data.windowList[key].mateWindow; countWindow[mateWindow.storageIndex].count--; delete countWindow[mateWindow.storageIndex].list[mateWindow.desktopIndex]; this.data.windowList.splice(key,1); mateWindow.setState(2); mateWindow.emit("onClose"); setTimeout(()=>{ if(this.data.windowList.length > 0) { this.setIndex(this.data.windowList[this.data.windowList.length-1].windowIndex); } }) }, setIndex(index){ this.data.activeWindowIndex = index; }, notice(msg){ this.data.notice.list.push({ time: (new Date()), msg: msg }) }, closeNotice(index){ this.data.notice.list.splice(index,1); }, } } export default System;