Explorar o código

[FIX] autostart in dev mode

Gogs %!s(int64=7) %!d(string=hai) anos
pai
achega
91d67a25bf
Modificáronse 2 ficheiros con 19 adicións e 6 borrados
  1. 9 3
      src/index.js
  2. 10 3
      src/print.js

+ 9 - 3
src/index.js

@@ -60,16 +60,22 @@ const createWindow = async () => {
     if (isDevMode) {
         await installExtension(VUEJS_DEVTOOLS)
         win.webContents.openDevTools()
-    }
 
-    AppAutolaunch.enable()
+        AppAutolaunch.disable()
+    } else {
+        AppAutolaunch.enable()
+    }
 
     AppAutolaunch.isEnabled().then(enable => {
         if (enable) {
             return
         }
 
-        AppAutolaunch.enable()
+        if (isDevMode) {
+            AppAutolaunch.disable()
+        } else {
+            AppAutolaunch.enable()
+        }
     }).catch(e => {
         console.log(e)
     })

+ 10 - 3
src/print.js

@@ -3,6 +3,7 @@ import { printDirect, getPrinters, getDefaultPrinterName, getJob } from 'printer
 
 const REQUEST_PRINTER_NAME = 'request_printer_name'
 const SHOW_PRINT_STATUS = 'show_print_status'
+const DOWNLOAD_DATA = 'download_data'
 
 const printQueue = []
 
@@ -23,7 +24,6 @@ const removeRequestQueued = id => {
     printQueue.splice(index, 1) !== 0
 }
 
-
 /**
  * 
  * @param {*} id 
@@ -82,7 +82,7 @@ const doPrint = (socket, request) => {
 
         request.data = requestQueued.data
     }
-
+    
     if (!request.printer) {
         request.printer = getDefaultPrinterName()
     }
@@ -96,8 +96,15 @@ const doPrint = (socket, request) => {
         return
     }
 
+    const data = request.data.replace(mimeTypeRegex[0], '')
+
+    if (request.printer == 'download') {
+        socket.emit(DOWNLOAD_DATA, data)
+        return
+    }
+
     const format = getFormat(mimeTypeRegex[0])
-    const buffer = Buffer.from(request.data.replace(mimeTypeRegex[0], ''), 'base64')
+    const buffer = Buffer.from(data, 'base64')
 
     printDirect({
         data: buffer,