Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将电子功能连接到Vue前端_Javascript_Node.js_Vue.js_Electron - Fatal编程技术网

Javascript 将电子功能连接到Vue前端

Javascript 将电子功能连接到Vue前端,javascript,node.js,vue.js,electron,Javascript,Node.js,Vue.js,Electron,所以,我想用我自己的应用程序栏制作一个无框电子窗口(比如discord的应用程序)。但是,我在连接函数时遇到问题。。。下面是一个例子: 这是我所有电子函数所在的文件 从“electron”导入{remote} 常量getCurrentWindow=()=>remote.getCurrentWindow() 常量最小化窗口=(browserWindow=getCurrentWindow())=>{ if(浏览器窗口。可最小化){ browserWindow.minimize()文件 } } 导出{

所以,我想用我自己的应用程序栏制作一个无框电子窗口(比如discord的应用程序)。但是,我在连接函数时遇到问题。。。下面是一个例子:

这是我所有电子函数所在的文件

从“electron”导入{remote}
常量getCurrentWindow=()=>remote.getCurrentWindow()
常量最小化窗口=(browserWindow=getCurrentWindow())=>{
if(浏览器窗口。可最小化){
browserWindow.minimize()文件
}
}
导出{minimizeWindow}
我正在使用Vue 3,我尝试了两种方法:

//在组件中:
从“../app/menu”和“@/app/menu”导入{minimizeWindow}
//作为全球财产
从“../app/menu”导入{minimizeWindow}
vue.config.globalProperties.$electron.minimizeWindow=minimizeWindow()
但我得到了这个错误:

index.js?bdb9:4 Uncaught ReferenceError: __dirname is not defined
    at eval (index.js?bdb9:4)
    at Object../node_modules/electron/index.js (chunk-vendors.js:1154)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (menu.ts?c8ae:1)
    at Module../src/app/menu.ts (app.js:1228)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (main.ts:18)
    at Module../src/main.ts (app.js:1347)
如果我点击抛出错误的
index.js?bdb9:4
文件,它来自:

var fs = require('fs')
var path = require('path')


// this threw
// Uncaught ReferenceError: __dirname is not defined

var pathFile = path.join(__dirname, 'path.txt') 



function getElectronPath () {
  if (fs.existsSync(pathFile)) {
    var executablePath = fs.readFileSync(pathFile, 'utf-8')
    if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
      return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath)
    }
    return path.join(__dirname, 'dist', executablePath)
  } else {
    throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
  }
}

module.exports = getElectronPath()
是因为Vue和Electron在不同的环境中运行吗