Browse Source

更新 'main.js'

Caner 3 years ago
parent
commit
06ce170bf2
1 changed files with 6 additions and 7 deletions
  1. 6 7
      main.js

+ 6 - 7
main.js

@@ -8,16 +8,16 @@ app.commandLine.appendSwitch('wm-window-animations-disabled') // 拖动闪屏
 
 
 
 
 // 截图
 // 截图
-function screenShot() {
-  return new Promise((res, rej) => {
-    const file = execFile(`${path.resolve(__dirname, 'screen/PrintScr.exe')}`)
-    file.on('exit', (e) => {
+function screenShot () {
+  return new Promise((res) => {
+    const file = execFile(join(__dirname, './screen/PrintScr.exe'))
+    file.on('exit', (e: Any) => {
       if (e === 1) {
       if (e === 1) {
         // 剪切板读buffer图片
         // 剪切板读buffer图片
         const clip = clipboard.readImage()
         const clip = clipboard.readImage()
         if (clip.isEmpty()) {
         if (clip.isEmpty()) {
           // eslint-disable-next-line prefer-promise-reject-errors
           // eslint-disable-next-line prefer-promise-reject-errors
-          rej(null)
+          res(null)
         } else {
         } else {
           // 转成buffer base64
           // 转成buffer base64
           const png = clipboard.readImage().toPNG()
           const png = clipboard.readImage().toPNG()
@@ -26,13 +26,12 @@ function screenShot() {
         }
         }
       } else {
       } else {
         // eslint-disable-next-line prefer-promise-reject-errors
         // eslint-disable-next-line prefer-promise-reject-errors
-        rej(null)
+        res(null)
       }
       }
     })
     })
   })
   })
 }
 }
 
 
-
 // 创建loading 窗口
 // 创建loading 窗口
 const showLoading = () => {
 const showLoading = () => {
   loadingWin = new BrowserWindow({
   loadingWin = new BrowserWindow({