electron打包是 直接复制文件夹到安装目录(不压缩进app.asar中)

参考博文:electron-builder打包指定资源到安装目录

使用quasar时:

electron: {
      // extendElectronMainConf (esbuildConf)
      // extendElectronPreloadConf (esbuildConf)

      inspectPort: 5858,

      bundler: 'packager', // 'packager' or 'builder'

      packager: {
        // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
        // asar: true,
        // The resources directory can be referenced in the packaged app via the process.resourcesPath value.
        extraResource: "./extraResource",  //本文件的同级目录
        // OS X / Mac App Store
        // appBundleId: '',
        // appCategoryType: '',
        // osxSign: '',
        // protocol: 'myapp://path',

        // Windows only
        // win32metadata: { ... }
      },

      builder: {
        // https://www.electron.build/configuration/configuration

        appId: 'amtf-su-ui'
      }
    },

官网参考:

https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html#extraresource

开发与发布环境,分别获取路径:

            if (process.env.DEBUGGING) {
              主路径=process.cwd()//nodejs进程的当前工作目录
              console.log(主路径);

            } else {//发布环境
              主路径=process.resourcesPath//资源文件夹路径路径
              console.log(主路径);
            }
            路径 = path.join(主路径, '/其他','关于amtf.html')
            shell.openPath(路径);

 

posted @ 2022-12-29 12:03  老小鱼  阅读(1153)  评论(0编辑  收藏  举报