Wails 安裝初體驗

文章目錄

      • Wails 安裝說明
        • 1. 系統要求
        • 2. 安裝步驟
        • 3. 構建應用
      • 結論

Wails 安裝說明

Wails 是一個用于構建桌面應用的 Go 框架,結合了現代前端技術。以下是安裝步驟:

1. 系統要求
  • Go 1.16 或更高版本
  • Node.js 和 npm
  • 可選:適用于 Windows、macOS 或 Linux 的支持包
2. 安裝步驟
  1. 安裝 Go 和 Node.js

    確保系統上已安裝 Go 和 Node.js。可以通過以下命令檢查版本:

https://go.dev/dl/

同時記得配上PATH

PS D:\code\go\project202407\myproject> go version  
go version go1.22.4 windows/amd64PS D:\code\go\project202407\myproject> node -v
v18.20.3
  1. 安裝 Wails CLI

    使用以下命令安裝 Wails 命令行工具:

go install github.com/wailsapp/wails/v2/cmd/wails@latest

PS C:\Windows\system32> go install github.com/wailsapp/wails/v2/cmd/wails@latest
go: github.com/wailsapp/wails/v2/cmd/wails@latest: module github.com/wailsapp/wails/v2/cmd/wails: Get "https://proxy.golang.org/github.com/wailsapp/wails/v2/cmd/wails/@v/list": dial tcp 172.217.163.49:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

如果遇到網絡問題可以, 這時如果連接不到proxy.golang.org 的話可以切換國內源

go install github.com/wailsapp/wails/v2/cmd/wails@latest
go env -w GOPROXY=https://goproxy.cn
  1. 創建新項目

    創建一個新的 Wails 項目:

PS D:\code\go\project202407> wails init -n myproject1 -t vue
Wails CLI v2.9.1# Initialising Project 'myproject1'
Project Name      | myproject1
Project Directory | D:\code\go\project202407\myproject1
Template          | Vue + Vite
Template Source   | https://wails.ioInitialised project 'myproject1' in 1.272s.?   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony
PS D:\code\go\project202407>

根據提示選擇項目模板并配置項目。

  1. 運行項目

    進入項目目錄并運行:

PS D:\code\go\project202407> cd .\myproject1\
PS D:\code\go\project202407\myproject1> wails dev
Wails CLI v2.9.1Executing: go mod tidy? Generating bindings: Done.? Installing frontend dependencies: Done.? Compiling frontend: Done.> frontend@0.0.0 dev
> viteVITE v3.2.10  ready in 375 msVite Server URL: http://localhost:5173/?  Local:   http://localhost:5173/?  Network: use --host to expose
Running frontend DevWatcher command: 'npm run dev'
Building application for development...? Generating bindings: Done.? Generating application assets: Done.? Compiling application: Done.INFO  Wails is now using the new Go WebView2Loader. If you encounter any issues with it, please report them to https://github.com/wailsapp/wails/issues/2004. You could also use the old legacy loader with `-tags native_webview2loader`, but keep in mind this will be deprecated in the near future.Using DevServer URL: http://localhost:34115
Using Frontend DevServer URL: http://localhost:5173/
Using reload debounce setting of 100 milliseconds
Watching (sub)/directory: D:\code\go\project202407\myproject1
INF | Serving assets from frontend DevServer URL: http://localhost:5173/
DEB | WebView2 Runtime Version '126.0.2592.81' installed. Minimum version required: 94.0.992.31.
DEB | [DevWebServer] Serving DevServer at http://localhost:34115
DEB | [AssetHandler] Handling request '/' (file='.')
DEB | [AssetHandler] File '.' not found, serving '/' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/'
DEB | [AssetHandler] Handling request '/@vite/client' (file='@vite/client')
DEB | [AssetHandler] Handling request '/src/main.js' (file='src/main.js')
DEB | [AssetHandler] File '@vite/client' not found, serving '/@vite/client' by AssetHandler
DEB | [AssetHandler] File 'src/main.js' not found, serving '/src/main.js' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/@vite/client'
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/main.js'
DEB | [AssetHandler] Handling request '/node_modules/.vite/deps/vue.js' (file='node_modules/.vite/deps/vue.js')
DEB | [AssetHandler] File 'node_modules/.vite/deps/vue.js' not found, serving '/node_modules/.vite/deps/vue.js' by AssetHandler
DEB | [AssetHandler] Handling request '/src/App.vue' (file='src/App.vue')
DEB | [AssetHandler] File 'src/App.vue' not found, serving '/src/App.vue' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/node_modules/.vite/deps/vue.js?v=0f4440cc'
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/App.vue'
DEB | [AssetHandler] Handling request '/src/style.css' (file='src/style.css')
DEB | [AssetHandler] File 'src/style.css' not found, serving '/src/style.css' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/style.css'
DEB | [AssetHandler] Handling request '/node_modules/vite/dist/client/env.mjs' (file='node_modules/vite/dist/client/env.mjs')
DEB | [AssetHandler] File 'node_modules/vite/dist/client/env.mjs' not found, serving '/node_modules/vite/dist/client/env.mjs' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/node_modules/vite/dist/client/env.mjs'
DEB | [AssetHandler] Handling request '/src/components/HelloWorld.vue' (file='src/components/HelloWorld.vue')
DEB | [AssetHandler] File 'src/components/HelloWorld.vue' not found, serving '/src/components/HelloWorld.vue' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/components/HelloWorld.vue'
DEB | [AssetHandler] Handling request '/src/App.vue' (file='src/App.vue')
DEB | [AssetHandler] File 'src/App.vue' not found, serving '/src/App.vue' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/App.vue?vue&type=style&index=0&lang.css'
DEB | [AssetHandler] Handling request '/@id/__x00__plugin-vue:export-helper' (file='@id/__x00__plugin-vue:export-helper')
DEB | [AssetHandler] File '@id/__x00__plugin-vue:export-helper' not found, serving '/@id/__x00__plugin-vue:export-helper' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/@id/__x00__plugin-vue:export-helper'
DEB | [AssetHandler] Handling request '/wailsjs/go/main/App.js' (file='wailsjs/go/main/App.js')
DEB | [AssetHandler] File 'wailsjs/go/main/App.js' not found, serving '/wailsjs/go/main/App.js' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/wailsjs/go/main/App.js'
DEB | [AssetHandler] Handling request '/src/components/HelloWorld.vue' (file='src/components/HelloWorld.vue')
DEB | [AssetHandler] File 'src/components/HelloWorld.vue' not found, serving '/src/components/HelloWorld.vue' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/components/HelloWorld.vue?vue&type=style&index=0&scoped=e17ea971&lang.css'
DEB | [AssetHandler] Handling request '/src/assets/images/logo-universal.png' (file='src/assets/images/logo-universal.png')
DEB | [AssetHandler] File 'src/assets/images/logo-universal.png' not found, serving '/src/assets/images/logo-universal.png' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/assets/images/logo-universal.png'
DEB | [AssetHandler] Handling request '/src/assets/fonts/nunito-v16-latin-regular.woff2' (file='src/assets/fonts/nunito-v16-latin-regular.woff2')
DEB | [AssetHandler] File 'src/assets/fonts/nunito-v16-latin-regular.woff2' not found, serving '/src/assets/fonts/nunito-v16-latin-regular.woff2' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/src/assets/fonts/nunito-v16-latin-regular.woff2'
DEB | [AssetHandler] Handling request '/favicon.ico' (file='favicon.ico')
DEB | [AssetHandler] File 'favicon.ico' not found, serving '/favicon.ico' by AssetHandler
DEB | [ExternalAssetHandler] Loading 'http://localhost:5173/favicon.ico'To develop in the browser and call your bound Go methods from Javascript, navigate to: http://localhost:34115

這將啟動開發服務器并打開應用窗口。

3. 構建應用

要構建生產版本的應用,使用以下命令:

wails build

構建完成后,應用程序的可執行文件將位于 build 目錄下。

結論

通過上述步驟,你可以輕松安裝和使用 Wails 來開發跨平臺桌面應用。如果遇到問題,請查看 Wails 官方文檔以獲取更多詳細信息。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/37223.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/37223.shtml
英文地址,請注明出處:http://en.pswp.cn/web/37223.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【機器學習】機器學習的重要方法——強化學習:理論,方法與實踐

目錄 一、強化學習的核心概念 二、強化學習算法的分類與示例代碼 三.強化學習的優勢 四.強化學習的應用與挑戰 五、總結與展望 強化學習:理論,方法和實踐 在人工智能的廣闊領域中,強化學習(Reinforcement Learning, RL&…

轉自羅翔老師的畢業寄語(二)

其實我很想祝大家一帆風順,可是我覺得這不現實。 智者說人這一生至少有三件事是無法避免的,一個是苦難,一個是邪惡,還有一個是人生的終點。所以真的愿我們每時每刻都在當下存儲足夠美好的記憶去對抗人生不期而至的苦楚&#xff0c…

基于源碼詳解ThreadPoolExecutor實現原理

個人博客地址 基于源碼詳解ThreadPoolExecutor實現原理 | iwts’s blog 內容拆分 這里算是一個總集,內容太多,拆分成幾個比較重要的小的模塊: ThreadPoolExecutor基于ctl變量的聲明周期管理 | iwts’s blog ThreadPoolExecutor 工作線程…

模板方法模式在金融業務中的應用及其框架實現

引言 模板方法模式(Template Method Pattern)是一種行為設計模式,它在一個方法中定義一個算法的框架,而將一些步驟的實現延遲到子類中。模板方法允許子類在不改變算法結構的情況下重新定義算法的某些步驟。在金融業務中&#xff…

可信和可解釋的大語言模型推理-RoG

大型語言模型(LLM)在復雜任務中表現出令人印象深刻的推理能力。然而,LLM在推理過程中缺乏最新的知識和經驗,這可能導致不正確的推理過程,降低他們的表現和可信度。知識圖譜(Knowledge graphs, KGs)以結構化的形式存儲了…

基于lightgbm hyperopt的旋轉機械故障診斷(Python)

前置文章: 將一維機械振動信號構造為訓練集和測試集(Python) https://mp.weixin.qq.com/s/DTKjBo6_WAQ7bUPZEdB1TA 旋轉機械振動信號特征提取(Python) https://mp.weixin.qq.com/s/VwvzTzE-pacxqb9rs8hEVw import…

Python變量的命名規則與賦值方式

第二章:Python 基礎語法 第一節:變量的命名規則與賦值方式 2.1.1 引言 在編程中,變量是存儲數據的基本單元。變量的命名和賦值是編程語言中表達和操作數據的基礎。了解和遵循變量命名規則對于編寫清晰、可維護的代碼至關重要。 2.1.2 變量…

【linux】網絡基礎(1)

文章目錄 網絡基本概念網絡的定義網絡的類型局域網(LAN)廣域網(WAN) 網絡協議OSI七層模型TCP/IP模型TCP/IP模型的結構 網絡傳輸的基本流程計算機與計算機之間的通信計算機的信息處理封裝報頭 網絡基本概念 網絡的定義 1.網絡是指…

專題一: Spring生態初探

咱們先從整體脈絡上看下Spring有哪些模塊,重要的概念有個直觀印象。 從Spring框架的整體架構和組成對整體框架有個認知。 Spring框架基礎概念 Spring基礎 - Spring和Spring框架組成 上圖是從官網4.2.x獲取的原圖,目前我們使用最廣法的版本應該都是5.x&am…

GitHub每日最火火火項目(6.30)

項目名稱:modelscope / DiffSynth - Studio 項目介紹:該項目致力于讓用戶體驗擴散模型的神奇魅力。擴散模型是一種具有廣泛應用前景的技術,在圖像生成、音頻處理等領域展現出了強大的能力。通過DiffSynth - Studio,用戶可以深入探…

Arrays.asList 和 java.util.ArrayList 區別

理解 Java 中的 Arrays.asList 和 java.util.ArrayList 的區別 在 Java 編程中,Arrays.asList 方法和 java.util.ArrayList 是兩種常用的處理列表數據的方式。雖然它們在功能上看起來相似,但在內部實現和使用上有著本質的不同。本文將探討這兩種方式的區…

一區算法MPA|海洋捕食者算法原理及其代碼實現(Matlab/Python))

Matlab/Python: 本文KAU將介紹一個2020年發表在1區期刊ESWA上的優化算法——海洋捕食者算法 (Marine Predators Algorithm,MPA)[1] 該算法由Faramarzi等于2020年提出,其靈感來源于海洋捕食者之間不同的覓食策略、最佳相遇概率策略、海洋記…

【Linux】IO多路復用——select,poll,epoll的概念和使用,三種模型的特點和優缺點,epoll的工作模式

文章目錄 Linux多路復用1. select1.1 select的概念1.2 select的函數使用1.3 select的優缺點 2. poll2.1 poll的概念2.2 poll的函數使用2.3 poll的優缺點 3. epoll3.1 epoll的概念3.2 epoll的函數使用3.3 epoll的優點3.4 epoll工作模式 Linux多路復用 IO多路復用是一種操作系統的…

MCU復位時GPIO是什么狀態?

大家一定遇到過上電或者復位時外部的MOS電路或者芯片使能信號意外開啟,至此有經驗的工程師就會經常關心一個問題,MCU復位時GPIO是什么狀態?什么電路需要外部加上下拉? MCU從上電到啟動,實際可分為復位前和復位后、初始…

【WPF】Windows系統桌面應用程序編程開發新手入門-打造自己的小工具

電腦Windows系統上的桌面程序通常是用Visual Studio 開發工具編寫出來的,有兩種開發方式供選擇,一種是WindowForm,簡稱WinForm,另一種是Windows Presentation Foundation,簡稱WPF,這里將學習WPF項目。 文章…

大物3錯題整理

平衡位置:在O點上的位置 相位: 當N很大的時候,wxwywz。因此,平均平動動能除以3,就是能量均分定理。 W F在x上的積分 Π時無單位 180,就是單位 1rad,rad就是單位 左手定則、右手定則、安培定…

C++模板類與繼承

1)模板類繼承普通類(常見)。 2)普通類繼承模板類的實例化版本。 3)普通類繼承模板類。(常見) 4)模板類繼承模板類。 5)模板類繼承模板參數給出的基類(不能是模板類)。 示…

【抽代復習筆記】24-群(十八):循環群的兩道例題

例1:證明: (1)三次交錯群A3是循環群,它與(Z3,)同構,其中Z3 {[0],[1],[2]}; (2)G {1,i,-1,-i},G上的代數運算是數的乘法,則G是一個循環群&…

如何解決三菱軟件提示 起動MELSOFT Mediative Server失敗

前言: 注意,這篇文章僅針對如何解決 起動MELSOFT Mediative Server失敗 的問題。對于其他相關的問題,請搜索其他相應的解決辦法。 本人是在重裝三菱GX Works軟件時遇到此問題的。后來搜索發現無人能妥善的關閉這個提示。因此本文介紹如何關…

【Web3項目案例】Ethers.js極簡入門+實戰案例:實現ERC20協議代幣查詢、交易

蘇澤 大家好 這里是蘇澤 一個鐘愛區塊鏈技術的后端開發者 本篇專欄 ←持續記錄本人自學智能合約學習筆記和經驗總結 如果喜歡拜托三連支持~ 目錄 簡介 前景科普-ERC20 Ethers極簡入門教程:HelloVitalik(非小白可跳) 教程概覽 開發工具 V…