5

vue electron-builder linux 打包失败那些事

 3 years ago
source link: https://my.oschina.net/u/3310942/blog/4953621
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
vue electron-builder linux 打包失败那些事

electron+vue+elementui+electron-builder 在win下打包正常,在linux下打包错误,错误信息如下:

• building        target=AppImage arch=x64 file=dist_electron/BB-API-1.0.0.AppImage
  ⨯ unknown output format set
github.com/develar/app-builder/pkg/icons.convertSingleFile
        /Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:305
github.com/develar/app-builder/pkg/icons.doConvertIcon
        /Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:247
github.com/develar/app-builder/pkg/icons.ConvertIcon
        /Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:56
github.com/develar/app-builder/pkg/icons.ConfigureCommand.func1
        /Volumes/data/Documents/app-builder/pkg/icons/icon-converter.go:33
github.com/alecthomas/kingpin.(*actionMixin).applyActions 

以上问题困恼许久,最终解决方案如下,如有高手有更优解决方法请留下您的宝贵建议,谢谢!

问题解决过程

第一坑 发现问题真相

一开始错误提示,直接看到如下错误

⨯ unknown output format set

下意识的认为是打包格式设置错误,查找相关资料配置成如下是正确的,为什么还提示错误呢?

linux: {
    target: [
         "AppImage"
    ]
}

认真看报错的堆栈发现有icons的错误,这时反应过来不是打包格式错误,而是跟ico图标有关,既然跟ico有关,那问题就有针对性处理了。

第二坑 针对问题处理

既然是ico图标错误,下意识认为图标文件路径配置错误,查找相关资料肯定配置没错,可是为什么还是报错。配置如下

linux: {
    icon: path.resolve(__dirname, "bb.ico"),
    target: [
         "AppImage"
    ]
}

思考许久,突然想起来,在win下打包时,在制作ico时有系统平台格式,也就是ico是给win下使用的,linux就不行或者在mac下不行。我用的时icofx 3工具制作的。 到此问题更清晰了,原来是ico格式错误才打印⨯ unknown output format set,程序真不会骗人,这错误提示真的简单明了。

第三坑 再次被ico图标搞得人崩溃

既然ico格式错误,我把图标换成png格式,天哪,终于打包成功了。

 INFO  Building app with electron-builder:
  • electron-builder  version=22.9.1 os=5.4.70-amd64-desktop
  • description is missed in the package.json  appPackageFile=/home/loon/build/code/client-bb-api/dist_electron/bundled/package.json
  • writing effective config  file=dist_electron/builder-effective-config.yaml
  • packaging       platform=linux arch=x64 electron=9.3.5 appOutDir=dist_electron/linux-unpacked
  • building        target=AppImage arch=x64 file=dist_electron/BB-API-1.0.0.AppImage
 DONE  Build complete!

启动程序看下./BB-API-1.0.0.AppImage,程序正常启动,可是让人崩溃的问题是图标没有生效,显示的是默认的图标,千万只草泥马在挥舞奔腾...。

第四坑 浪子回头

我算是怕你了electron-builder,既然配置ico不行,我直接代码指定总可以吧,代码如下:

win = new BrowserWindow({
    width: 1000,
    height: 670,
    icon: path.join(__dirname, '/bb.png'), //这里指定图标
    webPreferences: {
      ...
    }
  })

再次启动程序,成功。此问题告一段! 接下来更精彩,请勿走开(以下是私事,不喜欢别往下看了)

好用的HTTP模拟请求工具

市面上有很多HTTP模拟请求工具,有yapi,有ApiPost,好不好用在此不做评价。这里推荐使用BB-API,功能全面,免费使用、资源无限制,自动生成接口文档,界面简洁大气。支持局域网部署,打造属于你、公司的HTTP 协议管理工具。 官网地址http://api.app-yun.com/bbapi/index.html

开源项目-web的远程控制

基于web的远程控制系统,没错,能够在web上发起远程控制,支持VNC,RDP协议,支持远程录像审计,支持企业级权限控制。关键还是免费开源、资源无限制、无广告 官网地址http://bb.app-yun.com/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK