Browse Source

增加打开关闭交互
Signed-off-by: Caner <40012261+Canees@users.noreply.github.com>

Caner 3 years ago
parent
commit
9bb189ecbb

File diff suppressed because it is too large
+ 0 - 0
dist/assets/index-f4171c99.css


File diff suppressed because it is too large
+ 0 - 0
dist/assets/print-0c0a74d0.css


File diff suppressed because it is too large
+ 0 - 0
dist/assets/print-a182cf59.css


+ 2 - 2
dist/index.html

@@ -5,10 +5,10 @@
   <meta charset="UTF-8" />
   <meta charset="UTF-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <title>CZRock</title>
   <title>CZRock</title>
-  <script type="module" crossorigin src="./js/index-dc08ba4e.js"></script>
+  <script type="module" crossorigin src="./js/index-e84c2abc.js"></script>
   <link rel="modulepreload" href="./js/iview-e6e434cb.js">
   <link rel="modulepreload" href="./js/iview-e6e434cb.js">
   <link rel="stylesheet" href="./assets/iview-ee1eeafc.css">
   <link rel="stylesheet" href="./assets/iview-ee1eeafc.css">
-  <link rel="stylesheet" href="./assets/index-f0be57da.css">
+  <link rel="stylesheet" href="./assets/index-f4171c99.css">
 </head>
 </head>
 
 
 <body>
 <body>

+ 1 - 0
dist/js/Lithology-1c072229.js

@@ -0,0 +1 @@
+import{n as o}from"./iview-e6e434cb.js";var s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("Button",{attrs:{type:"primary"},on:{click:t.test}},[t._v(" \u6253\u5370 ")])],1)},c=[];const l={data(){return{}},methods:{test(){const t=window.$electron||null;t&&t.ipcRenderer.send("openPrint",!0)}}},r={};var i=o(l,s,c,!1,a,null,null,null);function a(t){for(let e in r)this[e]=r[e]}var u=function(){return i.exports}();export{u as default};

+ 0 - 1
dist/js/Lithology-ba217e10.js

@@ -1 +0,0 @@
-import{n as o}from"./iview-e6e434cb.js";var s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("Button",{attrs:{type:"primary"},on:{click:t.test}},[t._v(" \u6253\u5370 ")])],1)},c=[];const l={data(){return{}},methods:{test(){console.log(123);const t=window.$electron||null;t&&t.ipcRenderer.send("createBW",!0)}}},r={};var a=o(l,s,c,!1,i,null,null,null);function i(t){for(let e in r)this[e]=r[e]}var u=function(){return a.exports}();export{u as default};

File diff suppressed because it is too large
+ 0 - 0
dist/js/index-e84c2abc.js


File diff suppressed because it is too large
+ 0 - 0
dist/js/print-dbcc8280.js


+ 2 - 2
dist/print.html

@@ -5,10 +5,10 @@
   <meta charset="UTF-8" />
   <meta charset="UTF-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <title>CZRock</title>
   <title>CZRock</title>
-  <script type="module" crossorigin src="./js/print-1eb7535f.js"></script>
+  <script type="module" crossorigin src="./js/print-dbcc8280.js"></script>
   <link rel="modulepreload" href="./js/iview-e6e434cb.js">
   <link rel="modulepreload" href="./js/iview-e6e434cb.js">
   <link rel="stylesheet" href="./assets/iview-ee1eeafc.css">
   <link rel="stylesheet" href="./assets/iview-ee1eeafc.css">
-  <link rel="stylesheet" href="./assets/print-0c0a74d0.css">
+  <link rel="stylesheet" href="./assets/print-a182cf59.css">
 </head>
 </head>
 
 
 <body>
 <body>

+ 28 - 5
main.js

@@ -1,6 +1,7 @@
 const {
 const {
   app, BrowserWindow, Menu, ipcMain
   app, BrowserWindow, Menu, ipcMain
 } = require('electron')// 引入electron
 } = require('electron')// 引入electron
+// ----------------窗口init-------------
 let win = null
 let win = null
 let loadingWin = null
 let loadingWin = null
 let print = null
 let print = null
@@ -44,10 +45,17 @@ const createWindow = () => {
   win.on('close', () => {
   win.on('close', () => {
     // 回收BrowserWindow对象
     // 回收BrowserWindow对象
     win = null
     win = null
+    print = null
   })
   })
 }
 }
-// 创建打印窗口
+// 创建打印窗口=>宽高根据主窗口宽高80%定
 const createPrint = () => {
 const createPrint = () => {
+  // 获取主窗口宽高
+  // const winWH = win.getBounds()
+  // const winWidth = 0
+  // const winHeight = 0
+
+  // console.log(6666, winWH)
   print = new BrowserWindow({
   print = new BrowserWindow({
     width: 1310,
     width: 1310,
     height: 860,
     height: 860,
@@ -55,7 +63,12 @@ const createPrint = () => {
     resizable: false,
     resizable: false,
     center: true,
     center: true,
     transparent: true,
     transparent: true,
-    show: false
+    show: false,
+    webPreferences: {
+      contextIsolation: false,
+      nodeIntegration: true,
+      webSecurity: false
+    }
   })// 创建一个窗口
   })// 创建一个窗口
   print.loadFile('dist/print.html')
   print.loadFile('dist/print.html')
   // print.webContents.openDevTools()
   // print.webContents.openDevTools()
@@ -64,6 +77,8 @@ const createPrint = () => {
     print = null
     print = null
   })
   })
 }
 }
+
+//  --------------事件监听fn-------------
 // 事件监听
 // 事件监听
 app.on('ready', async () => {
 app.on('ready', async () => {
   showLoading()
   showLoading()
@@ -74,8 +89,9 @@ app.on('ready', async () => {
     loadingWin.close()
     loadingWin.close()
     win.show()
     win.show()
   })
   })
-  // 监听是否打开print
-  ipcMain.on('createBW', (state) => {
+
+  // 监听打开print
+  ipcMain.on('openPrint', (event, data) => {
     // TODO: 页面数据生成PDF
     // TODO: 页面数据生成PDF
 
 
     // TODO: 数据回传打印组件
     // TODO: 数据回传打印组件
@@ -83,7 +99,14 @@ app.on('ready', async () => {
     // 显示打印组件
     // 显示打印组件
     print.show()
     print.show()
 
 
-    console.log(123, state)
+    console.log('open', data)
+  })
+
+  // 监听关闭print
+  ipcMain.on('closePrint', (event, data) => {
+    console.log('close', data)
+    // 显示打印组件
+    print.hide()
   })
   })
 })
 })
 
 

+ 1 - 2
src/pages/index/views/Lithology.vue

@@ -17,11 +17,10 @@ export default {
   },
   },
   methods: {
   methods: {
     test() {
     test() {
-      console.log(123)
       // 通知主进程开启打印窗口
       // 通知主进程开启打印窗口
       const electron = window.$electron || null
       const electron = window.$electron || null
       if (electron) {
       if (electron) {
-        electron.ipcRenderer.send('createBW', true)
+        electron.ipcRenderer.send('openPrint', true)
       }
       }
     }
     }
   }
   }

+ 12 - 1
src/pages/print/App.vue

@@ -180,7 +180,9 @@
         <Button type="primary">
         <Button type="primary">
           打印
           打印
         </Button>
         </Button>
-        <Button>取消</Button>
+        <Button @click="close">
+          取消
+        </Button>
       </div>
       </div>
     </div>
     </div>
   </div>
   </div>
@@ -199,6 +201,15 @@ export default {
         }
         }
       ]
       ]
     }
     }
+  },
+  methods: {
+    close() {
+      const electron = window.$electron || null
+      console.log(electron)
+      if (electron) {
+        electron.ipcRenderer.send('closePrint', false)
+      }
+    }
   }
   }
 }
 }
 </script>
 </script>

Some files were not shown because too many files changed in this diff