go 中使用 electron go ui

 

JVM运行时的原型写的差不多了,但还是有很多体力活儿要做,思考着未来给PHP,JS,TS,JAVA提供桌面UI的,找了下,还真有!

https://github.com/asticode/go-astilectron

这个项目已经用封装好对electron的调用了

拿出demo 一跑就报错,一直没办法下载,,asticode会自动改下载的包的名字,但是又改名字失败。。。

starting astilectron failed: executing failed: executing cmd failed: executer failed:

 

 

 

解决办法:

直接复制出下载地址,下载好 放到对应的目录里面 我这儿是

C:\Users\mike\AppData\Roaming\Test\vendor

没什么问题的话 ,下载的包是这样的

electron-v11.4.3-win32-x64.zip 

改成

electron-windows-amd64-v11.4.3.zip

然后手动解压

解压后目录名字改为  electron-windows-amd64  当然 我这是这个版本,如果你的版本不一样,最好看报错提示的路径是什么,照着改就行了

 

 

从新运行项目即可

 

-----------------------------------------补充一下-----------------------------------------------------------

上面的DEMO是个很简单的,另外还有这个demo项目

go-astilectron-demo 

https://github.com/asticode/go-astilectron-demo

 

过程中一直报错

running bootstrap failed: restoring resources failed: restoring resources failed: creating C:\Users\mike\AppData\Roaming\resources\checksums.json failed: open C:\Users\mike\AppData\Roaming\resources\checksums.json: The system cannot find the path specified.

官方我也发问了

https://github.com/asticode/go-astilectron-demo/issues/68

但是别人来不及解答,自己琢磨着解决了

解决办法:

照着官方文档

$ go get -u github.com/asticode/go-astilectron-bundler/...
$ go install github.com/asticode/go-astilectron-bundler/astilectron-bundler

 

下载后,得到两个exe,

astilectron-bundler.exe

go-astilectron-demo.exe  这个应该是没用的

 

要想跑起来go-astilectron-demo 这个项目

需要在go-astilectron-demo 目录中 打开控制台 运行astilectron-bundler  不带任何参数。。 这个时候 其实就是在下载刚才上面的东西

如果下载不成功,单独复制地址去下载,下载后,根据报错的信息,复制到对应的目录

再执行 astilectron-bundler.exe

另外还需要注意 源码中有个bind.go 需要删除它

再执行 astilectron-bundler.exe

会在项目的output\windows-amd64 中生成一个可执行的exe拉。。。

windows-amd64是我电脑的硬件环境,根据自己的环境找生成的目录

至于调式,直接debugu 打断点就行了。。。

 -------------------------------------------------------其他的UI推荐---------------------

这两个都不错的!!

https://github.com/webview/webview

gotk: https://github.com/gotk3/gotk3

gotk3代码演示

https://github.com/GrayNerd/gotk3-samples

 

一个容易理解的库

https://github.com/zserge/lorca

但是官方说 局限性比较多

 

posted @ 2021-08-03 00:07  方东信  阅读(2230)  评论(0编辑  收藏  举报