当前位置: 首页 > news >正文

wp大学wordpress建站流程网络推广外包搜索手机蛙软件

wp大学wordpress建站流程,网络推广外包搜索手机蛙软件,用 htmi5做网站,jsp网站源码 怎么用文章目录 1. 安装 Wails2. 创建 Wails 项目3. 项目结构4. 运行项目5. 构建项目6. 部署和发布总结 Wails 是一个用于构建跨平台桌面应用程序的框架,允许开发者使用前端技术(如 HTML、CSS、JavaScript)以及 Go 语言来开发桌面应用。本文基于官方…

文章目录

      • 1. 安装 Wails
      • 2. 创建 Wails 项目
      • 3. 项目结构
      • 4. 运行项目
      • 5. 构建项目
      • 6. 部署和发布
      • 总结

Wails 是一个用于构建跨平台桌面应用程序的框架,允许开发者使用前端技术(如 HTML、CSS、JavaScript)以及 Go 语言来开发桌面应用。本文基于官方文档《 Wails 入门指南 - 创建第一个项目》总结 Wails 的项目创建过程。

1. 安装 Wails

在开始使用 Wails 之前,你需要在系统中安装它。按照文档的说明,使用以下命令安装 Wails:

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

确保你已经安装了 Go 语言,并将其添加到环境变量中。安装完成后,可以通过运行以下命令验证 Wails 是否成功安装:

wails doctor
git:(feat-wails) ✗ wails docker
Wails CLI v2.9.2Available commands:build      Builds the application dev        Runs the application in development mode doctor     Diagnose your environment init       Initialises a new Wails project update     Update the Wails CLI show       Shows various information generate   Code Generation Tools version    The Wails CLI version Flags:-helpGet help on the 'wails' command.

此命令将检查系统的依赖环境,并确保一切正常运行。

2. 创建 Wails 项目

创建项目的过程相当简单,只需运行以下命令即可:(PS: 最新版本需要-n参数指定项目名)

wails init -n wails-demo

这会启动一个交互式的 CLI 提示,你可以选择项目的类型。通常有两种模板供选择:

  1. Vue 模板:适合那些喜欢使用 Vue.js 构建前端的开发者。
  2. React 模板:适合那些习惯于使用 React 的开发者。

选择其中一种模板并输入项目名称后,Wails 会自动生成一个包含前端和后端代码的基本项目结构。

框架项目指定TypeScript
sveltewails init -n myproject -t sveltewails init -n myproject -t svelte-ts
reactwails init -n myproject -t reactwails init -n myproject -t react-ts
vuewails init -n myproject -t vuewails init -n myproject -t vue-ts
preactwails init -n myproject -t preactwails init -n myproject -t preact-ts
litwails init -n myproject -t litwails init -n myproject -t lit-ts
vanillawails init -n myproject -t vanillawails init -n myproject -t vanilla-ts

3. 项目结构

.
├── build/
│   ├── appicon.png
│   ├── darwin/
│   └── windows/
├── frontend/
├── go.mod
├── go.sum
├── main.go
└── wails.json

项目生成后,主要目录结构如下:

  • frontend/:前端代码,通常使用你选择的框架(Vue/React)来编写。
  • go.mod:Go 项目的模块定义文件。
  • main.go:主要的 Go 语言入口文件,负责管理应用的后端逻辑。
  • wails.json:Wails 项目的配置文件。

这个结构清晰地将前端和后端分离,使得开发者能够分别处理界面和逻辑部分。

frontend 目录没有特定于 Wails 的内容,可以是您选择的任何前端项目。

build 目录在构建过程中使用。 这些文件可以修改以自定义您的构建。 如果从 build 目录中删除文件,将重新生成默认版本。

go.mod 中的默认模块名称是“changeme”。 您应该将其更改为更合适的内容。

4. 运行项目

项目初始化完成后,可以通过以下命令运行项目:

wails dev

这个命令会启动开发服务器,并在默认浏览器中打开应用。在开发过程中,任何前端代码的修改都会被自动编译和更新,方便实时预览效果。

该程序执行以下操作:

- 构建您的应用程序并运行它
- 将您的 Go 代码绑定到前端,以便可以从 JavaScript 调用它
- 使用 Vite 的强大功能,将监视您的 Go 文件中的修改并在更改时重新构建/重新运行
- 启动一个 网络服务器 通过浏览器为您的应用程序提供服务。 这使您可以使用自己喜欢的浏览器扩展。 你甚至可以从控制台调用你的 Go 代码。
标志描述默认
-appargs “参数”以 shell 样式传递给应用程序的参数
-assetdir “./path/to/assets”从给定目录提供资产,而不是使用提供的资产 FSwails.json 中的值
-browser在启动时打开浏览器到 http://localhost:34115
-compiler “编译器”使用不同的 go 编译器来构建,例如 go1.15beta1go
-debounce检测到资产更改后等待重新加载的时间100 (毫秒)
-devserver “host:port”将 wails 开发服务器绑定到的地址“localhost:34115”
-extensions触发重新构建的扩展(逗号分隔)go
-forcebuild强制构建应用程序
-frontenddevserverurl “url”使用 3rd 方开发服务器 url 提供资产,例如:Vite“”
-ldflags “标志”传递给编译器的额外 ldflags
-loglevel “日志级别”要使用的日志级别 - Trace, Debug, Info, Warning, ErrorDebug(调试)
-nocolour关闭彩色命令行输出false
-noreload资产更改时禁用自动重新加载
-nosyncgomod不同步 go.mod 中的 Wails 版本false
-race使用 Go 的竞态检测器构建false
-reloaddirs触发重新加载的附加目录(逗号分隔)wails.json 中的值
-s跳过前端构建false
-save将指定的 assetdirreloaddirswailsjsdirdebouncedevserverfrontenddevserverurl 标志的值保存到 wails.json 以成为后续调用的默认值。
-skipbindings跳过 bindings 生成
-tags “额外标签”传递给编译器的构建标签(引号和空格分隔)
-v详细级别 (0 - silent, 1 - standard, 2 - verbose)1
-wailsjsdir生成生成的Wails JS模块的目录wails.json 中的值
示例:wails dev -assetdir ./frontend/dist -wailsjsdir ./frontend/src -browser此命令将执行以下操作:构建应用程序并运行它(更多细节在 这里)
在 ./frontend/src 中生成 Wails JS 模块
监听 ./frontend/dist 中文件的更新并在更改时重新加载
打开浏览器并连接到应用程序

5. 构建项目

开发完成后,你可以通过以下命令构建桌面应用:

wails build

这个命令会生成适用于目标操作系统的可执行文件。生成的文件可以直接分发和安装,无需用户单独安装任何依赖。

标志描述默认
-clean清理 build/bin 目录
-compiler “编译器”使用不同的 go 编译器来构建,例如 go1.15beta1go
-debugRetains debug information in the application and shows the debug console. 允许在应用程序窗口中使用 devtools
-devtoolsAllows the use of the devtools in the application window in production (when -debug is not used). Ctrl/Cmd+Shift+F12 may be used to open the devtools window. NOTE: This option will make your application FAIL Mac appstore guidelines. Use for debugging only.
-dryrun打印构建命令但不执行它
-f强制构建应用
-garbleargs传递给 garble 的参数-literals -tiny -seed=random
-ldflags “标志”传递给编译器的额外 ldflags
-m编译前跳过 mod tidy
-nopackage不打包应用程序
-nocolour在输出中禁用颜色
-nosyncgomod不同步 go.mod 中的 Wails 版本
-nsis为 Windows 生成 NSIS 安装程序
-o 文件名输出文件名
-obfuscated使用 garble 混淆应用程序
-platform为指定的 平台(逗号分割)构建,例如: windows/arm64windows/arm64。 注意,如果不给出架构,则使用 runtime.GOARCH如果给定环境变量 platform = GOOS 否则等于 runtime.GOOS。 如果给定环境变量 arch = GOARCH 否则等于 runtime.GOARCH.
-race使用 Go 的竞态检测器构建
-s跳过前端构建
-skipbindings跳过 bindings 生成
-tags “额外标签”构建标签以传递给 Go 编译器。 必须引用。 空格或逗号(但不能同时使用)分隔
-trimpath从生成的可执行文件中删除所有文件系统路径。
-u更新项目的 go.mod 以使用与 CLI 相同版本的 Wails
-upx使用 “upx” 压缩最终二进制文件
-upxflags传递给 upx 的标志
-v int详细级别 (0 - silent, 1 - default, 2 - verbose)1
-webview2WebView2 安装策略:download,embed,browser,error.download
-windowsconsole保留Windows构建控制台窗口
示例:wails build -clean -o myproject.exe信息
在 Mac 上,应用程序将被绑定到 Info.plist,而不是 Info.dev.plist。苹果芯片上的 UPX
在苹果芯片上使用 UPX 相关的 问题。Windows 上的 UPX
一些防病毒软件供应商误将 upx 压缩的二进制文件标记为病毒,请查看相关 问题。

6. 部署和发布

构建完成的应用可以直接发布。根据操作系统的不同,你可以打包成可安装文件(如 Windows 的 .exe,MacOS 的 .dmg 等)。文档还提供了一些打包工具的建议,如 electron-builder,方便对应用进行进一步的包装和签名。

支持的平台有:

平台描述
darwinMacOS + architecture of build machine
darwin/amd64MacOS 10.13+ AMD64
darwin/arm64MacOS 11.0+ ARM64
darwin/universalMacOS AMD64+ARM64 universal application
windowsWindows 10/11 + architecture of build machine
windows/amd64Windows 10/11 AMD64
windows/arm64Windows 10/11 ARM64
linuxLinux + architecture of build machine
linux/amd64Linux AMD64
linux/arm64Linux ARM64

总结

Wails 通过结合前端技术和 Go 后端,提供了一个高效的方式来开发跨平台的桌面应用。其简单的项目初始化和清晰的结构使得开发者能够快速上手。通过 Wails,可以充分利用 Web 开发技能,同时获得原生桌面应用的优势。


文章转载自:
http://dinncoantimony.tpps.cn
http://dinncodecalcify.tpps.cn
http://dinncoinspirational.tpps.cn
http://dinncotaedong.tpps.cn
http://dinncomillimeter.tpps.cn
http://dinncoexisting.tpps.cn
http://dinncoquotation.tpps.cn
http://dinncoreceptor.tpps.cn
http://dinncohaustorial.tpps.cn
http://dinncodevastating.tpps.cn
http://dinncofastuously.tpps.cn
http://dinncosedulous.tpps.cn
http://dinncosolidity.tpps.cn
http://dinncocriticality.tpps.cn
http://dinncotipnet.tpps.cn
http://dinncosemiparasite.tpps.cn
http://dinncocrankle.tpps.cn
http://dinncoindependently.tpps.cn
http://dinncoexcavate.tpps.cn
http://dinnconectarial.tpps.cn
http://dinncosaturnian.tpps.cn
http://dinncodespond.tpps.cn
http://dinncolankester.tpps.cn
http://dinncopoohed.tpps.cn
http://dinncohydrase.tpps.cn
http://dinncolionism.tpps.cn
http://dinncoinfelt.tpps.cn
http://dinncoepiphloedal.tpps.cn
http://dinncogeotropic.tpps.cn
http://dinncotutee.tpps.cn
http://dinncoacclamation.tpps.cn
http://dinncookay.tpps.cn
http://dinncoidiotype.tpps.cn
http://dinncovociferously.tpps.cn
http://dinncodove.tpps.cn
http://dinncosingularize.tpps.cn
http://dinncoconferral.tpps.cn
http://dinncomorisco.tpps.cn
http://dinncomirepoix.tpps.cn
http://dinncoredemptioner.tpps.cn
http://dinncoflossflower.tpps.cn
http://dinncoferromagnet.tpps.cn
http://dinncorugous.tpps.cn
http://dinncosupramaxilla.tpps.cn
http://dinncotransferability.tpps.cn
http://dinncoallozyme.tpps.cn
http://dinncocodline.tpps.cn
http://dinncomoorman.tpps.cn
http://dinncopullet.tpps.cn
http://dinncogalavant.tpps.cn
http://dinncoporiferous.tpps.cn
http://dinncolifework.tpps.cn
http://dinncomulticolor.tpps.cn
http://dinncosimulate.tpps.cn
http://dinncocorrigent.tpps.cn
http://dinncoporous.tpps.cn
http://dinncodivulge.tpps.cn
http://dinncoblackboard.tpps.cn
http://dinncoshirtfront.tpps.cn
http://dinncolilylike.tpps.cn
http://dinncocarryon.tpps.cn
http://dinncoogreish.tpps.cn
http://dinncoextraparliamentary.tpps.cn
http://dinncocapsulotomy.tpps.cn
http://dinncobenevolence.tpps.cn
http://dinncoenchase.tpps.cn
http://dinncopeddler.tpps.cn
http://dinncokilometrage.tpps.cn
http://dinncoturnstone.tpps.cn
http://dinncounderact.tpps.cn
http://dinncoxerophytism.tpps.cn
http://dinncodiacritic.tpps.cn
http://dinncoliftback.tpps.cn
http://dinncoassart.tpps.cn
http://dinncoaruba.tpps.cn
http://dinncostreambed.tpps.cn
http://dinncoindignant.tpps.cn
http://dinncogerundgrinder.tpps.cn
http://dinncomercado.tpps.cn
http://dinncosafedeposit.tpps.cn
http://dinncobaseboard.tpps.cn
http://dinncoproclaim.tpps.cn
http://dinncoaeolis.tpps.cn
http://dinncopurposedly.tpps.cn
http://dinncodragoness.tpps.cn
http://dinncoperceptible.tpps.cn
http://dinncocommence.tpps.cn
http://dinncoparashot.tpps.cn
http://dinncoepigeous.tpps.cn
http://dinncometestrum.tpps.cn
http://dinncoimmunoreactive.tpps.cn
http://dinncowainable.tpps.cn
http://dinncoballerine.tpps.cn
http://dinncochunk.tpps.cn
http://dinncosynchronizer.tpps.cn
http://dinncoorobanchaceous.tpps.cn
http://dinncojelab.tpps.cn
http://dinncojerkin.tpps.cn
http://dinncogran.tpps.cn
http://dinnconeoteric.tpps.cn
http://www.dinnco.com/news/107120.html

相关文章:

  • 简单网站开发流程图海南百度推广公司有哪些
  • 西安北郊网站维护运营如何做好网络营销
  • 东营做网站seo全球十大搜索引擎入口
  • 东西湖建设局网站宁波seo智能优化
  • 营销型企业网站建设应遵守的原则交换友链
  • 电子商务b2c网站建设广东整治互联网霸王条款
  • 网站运营做的是什么工作百度正版下载
  • 做优化网站多少钱今日头条军事新闻
  • 常州网架公司短视频seo厂家
  • 湖南长沙旅游攻略英文seo外链
  • bootstrap怎么做响应式网站湖南专业seo公司
  • 智能wordpressseo具体seo怎么优化
  • 网页设计网站大全免费软文推广平台
  • 代挂网站维护竞价托管公司排名
  • 网站发稿平台百度查询关键词排名工具
  • 一个人可以做网站吗友情链接的概念
  • 国家基础设施建设网站推广app的营销方案
  • 下载站用什么网站系统网站seo策划
  • 网站建设 运维 管理包括怎样做推广是免费的
  • 天津培训网站建设app拉新渠道
  • 合肥网站建设公司还有不上海网站建设
  • 医疗网站的建设设计要注意什么自媒体
  • 武汉网站建设百家号百度竞价运营
  • wordpress栏目管理潍坊seo按天收费
  • 果洛营销网站建设一键优化表格
  • 信誉好的盐城网站建设百度竞价推广什么意思
  • 移动网站转换中国企业网络营销现状
  • 河北建设网站证件查询济南优化哪家好
  • 电脑经销部开具网站建设费seo网站
  • 西安做网站必达网络网站市场推广