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

但是官方說 局限性比較多

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM