Переглянути джерело

测试文件从主进程读入,传给渲染进程,再传给管理页面组件,最终失败

liuwei 4 роки тому
батько
коміт
a861d25dce

Різницю між файлами не показано, бо вона завелика
+ 4429 - 2399
.idea/workspace.xml


+ 4 - 0
src/index.ejs

@@ -12,5 +12,9 @@
   </head>
   <body>
     <div id="app"></div>
+
+    <script>
+      if (process.env.NODE_ENV !== 'development') window.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
+    </script>
   </body>
 </html>

+ 14 - 0
src/main/index.js

@@ -1,4 +1,6 @@
 import { app, BrowserWindow } from 'electron'
+import fs from 'fs'
+import path from 'path'
 
 /**
  * Set `__static` path to static files in production
@@ -21,10 +23,22 @@ function createWindow () {
     width: 1000,
     height: 563,
     useContentSize: true,
+    webPreferences: {
+      // 渲染进程是否使用node
+      nodeIntegration: true
+    }
   })
 
   mainWindow.loadURL(winURL)
 
+  mainWindow.webContents.openDevTools();
+
+  let fileContents = fs.readFileSync(path.join(__static, '/EnityWindow.json'), 'utf8')
+
+  mainWindow.webContents.on('did-finish-load', function(){
+    mainWindow.webContents.send('something', fileContents)
+  })
+
   mainWindow.on('closed', () => {
     mainWindow = null
   })

+ 1 - 1
src/renderer/App.vue

@@ -6,7 +6,7 @@
 
 <script>
   export default {
-    name: 'dispersedvedio_managesystem'
+    name: 'vedio_app'
   }
 </script>
 

+ 11 - 22
src/renderer/components/Admin.vue

@@ -2,6 +2,7 @@
 <template>
     <div class="containers">
         <!--主页-->
+<!--        display:windowJson[0].IsVisibility ? 'block' : 'none',-->
         <div
                 :style="{
                 position: 'relative',
@@ -14,7 +15,7 @@
                 backgroundImage:windowJson[0].BackIcon ? 'url('+require(`../../../static/images/${windowJson[0].BackIcon}`)+')' : null,
                 backgroundRepeat:'no-repeat',
                 backgroundSize:'100% 100%',
-                backgroundColor:`#${windowJson[0].BrackgroupStr.slice(3)}`,
+                backgroundColor:`#${windowJson[0].BrackgroupStr ? windowJson[0].BrackgroupStr.slice(3) : null}`,
                 margin:'0 auto',
             }"
         >
@@ -195,9 +196,11 @@
 </template>
 
 <script>
-    import '../assets/less/splitscreen.less'
     import {mapState} from 'vuex'
     import draggable from 'vuedraggable'
+    import storageUtils from "../../utils/storageUtils"
+    import '../assets/less/splitscreen.less'
+
     import labelJson from '../../../static/EnityLable'
     import bigScreenJson from '../../../static/EnityBigScreen'
     import buttonJson from '../../../static/EnityButton'
@@ -205,12 +208,12 @@
     import sliderJson from '../../../static/EnitySlider'
     import imageJson from '../../../static/EnityImage'
     import windowJson from '../../../static/EnityWindow'
-    import storageUtils from "../../utils/storageUtils"
 
     export default {
         components: {
             draggable
         },
+
         data() {
             return {
                 user: storageUtils.getUser(), // 本地存储的用户
@@ -232,10 +235,10 @@
                 count6: 0, // 其他按钮
             }
         },
+
         mounted() {
             // 获取分屏按钮数组(将分屏按钮和其他按钮区分开)
-            const arr = this.buttonJson.filter(item => (item.WindowID === '9a0dff23-8633-4e7f-89bf-cc4f68ec88e1' || item.WindowID === '08208721-41cc-4f1e-937b-3a1627389049' || item.WindowID === 'ab842585-0c91-4e65-bfed-a219bcaaeb43'))
-            this.arr = arr
+            this.arr = this.buttonJson.filter(item => (item.WindowID === '9a0dff23-8633-4e7f-89bf-cc4f68ec88e1' || item.WindowID === '08208721-41cc-4f1e-937b-3a1627389049' || item.WindowID === 'ab842585-0c91-4e65-bfed-a219bcaaeb43'))
 
             // 获取功能按钮涉及到的按钮和label
             // 1.电源管理  2.音频管理  3.视频管理  4.环境控制  5.电脑控制
@@ -248,9 +251,9 @@
             }
 
             // 获取电源管理和电脑控制按钮
-            const powerAndCompBtns = this.buttonJson.filter(item => (item.WindowID === 'd80a8b6e-9f88-41ff-b3a7-1ff8d6ee37a5' || item.WindowID === 'd9868551-b579-4258-9bc7-7c1f733773f5') && item.ID !== '19554440-98bc-4644-83a0-d9cefd69153e')
-            this.powerAndCompBtns = powerAndCompBtns
+            this.powerAndCompBtns = this.buttonJson.filter(item => (item.WindowID === 'd80a8b6e-9f88-41ff-b3a7-1ff8d6ee37a5' || item.WindowID === 'd9868551-b579-4258-9bc7-7c1f733773f5') && item.ID !== '19554440-98bc-4644-83a0-d9cefd69153e')
         },
+
         methods: {
             // 移动信号源
             onMove({relatedContext, draggedContext}) {
@@ -415,21 +418,6 @@
                     }
                 }
 
-                // 系统开关按钮
-                /*if (e.ID === 'aea34c76-4216-469b-9610-9889a2d42d06') {
-                    this.systemStatus = !this.systemStatus
-                    if (this.systemStatus) { // 开启,同时开启LCD屏和坐席电源
-                        this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.ActionIcon}`) + ')'
-                        this.$refs['f5361d60-6868-4c59-806b-22b85e7c9e3e'][0].style.backgroundImage = 'url(' + require(`../../../static/images/73.png`) + ')'
-                        this.$refs['4d3266e8-64b5-4765-a36d-7e271eb3c8e8'][0].style.backgroundImage = 'url(' + require(`../../../static/images/73.png`) + ')'
-                    } else { // 关闭
-                        this.$refs[e.ID][0].style.backgroundImage = 'url(' + require(`../../../static/images/${e.BackIcon}`) + ')'
-                        this.$refs['f5361d60-6868-4c59-806b-22b85e7c9e3e'][0].style.backgroundImage = 'url(' + require(`../../../static/images/75.png`) + ')'
-                        this.$refs['4d3266e8-64b5-4765-a36d-7e271eb3c8e8'][0].style.backgroundImage = 'url(' + require(`../../../static/images/75.png`) + ')'
-                    }
-                    return false
-                }*/
-
                 return
             },
 
@@ -461,6 +449,7 @@
                 return
             },
         },
+
         computed: {
             ...mapState(['deviceList']),
             dragOptions1() {

+ 5 - 0
src/renderer/main.js

@@ -7,6 +7,11 @@ import store from './store'
 import ElementUI from 'element-ui'
 import 'element-ui/lib/theme-chalk/index.css'
 
+require('electron').ipcRenderer.on('something',(event,message) => {
+  // console.log('msg:', message) // 主进程发送到渲染进程的数据
+  Vue.prototype.EnityWindow = message
+})
+
 Vue.use(ElementUI)
 
 if (!process.env.IS_WEB) Vue.use(require('vue-electron'))

+ 0 - 1
src/renderer/router/index.js

@@ -7,7 +7,6 @@ import Admin from '../components/Admin'
 Vue.use(Router)
 
 export default new Router({
-  mode:'hash',
   routes: [
     {
       path: '/login',