yzbtdiy

yzbtdiy

github
bilibili

Wails Project Initialization

Wails is a project that allows you to write desktop applications using Go and web technologies.

Installation#

You need to have a Go language environment, which can be downloaded from https://golang.google.cn/.

After installing Go, configure the Go module proxy to speed up module downloads.

go env -w GOPROXY=https://goproxy.cn,direct

You can quickly install the Wails command-line tool using go install.

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

Create a Project#

You can quickly create a project using the Wails command, here using the vue-ts template.

-n Project Name

-t Frontend Template Used

You can view all official templates at
https://github.com/wailsapp/wails/tree/master/v2/pkg/templates/templates.

wails init -n wailsapp -t vue-ts

image

Environment Adjustment#

Normally, you can develop using the default project template. Personally, I prefer using Bun as the JS/TS runtime instead of Node.js, so let's replace it here.

Replace npm with bun#

You need to modify two files, one is wails.json, and the other is the package.json in the frontend directory.

image

image

Replace the npm commands in wails.json with bun.

  "frontend:install": "bun install",
  "frontend:build": "bun run build",
  "frontend:dev:watcher": "bun run dev",

Replace the scripts content in the package.json in the frontend directory to use bunx to execute vite commands.

 "scripts": {
    "dev": "bunx --bun vite",
    "build": "bunx --bun vite build",
    "preview": "bunx --bun vite preview"
  }

Update Frontend Dependencies#

Use ncu -u to check for updates, which will automatically modify the package.json file, then use bun install to install.

image

Uninstall typescript and vue-tsc.

image

Everything is normal, VSCode starts.

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.