一个超级简单,基于 Pake 项目改造的将前端项目打包成桌面端的工具.
A super simple, based on Pake project that can package front-end projects into desktop applications.
这个项目每次打开新的页面,都会创建一个新的窗口.(如果前端逻辑是路由跳转,则不会创建新的窗口)
This project will create a new window each time it opens a new page. (If the front-end logic is route jump, it will not create a new window)
配置 tauri.conf.json, 配置为 frontendDist:"../dist"
或者线上的前端项目地址, 例如: frontendDist:"https://ai.goviewlink.com"
.
Configure tauri.conf.json, set frontendDist:"../dist"
or use the online frontend project address, for example: frontendDist:"https://ai.goviewlink.com"
.
注意: 本地运行时,你需要 devUrl:"http://localhost:8080"
运行自己的前端项目. 打包部署时,你需要将 dist
目录复制到 PakePro 项目的 根目录.
Note: When running locally, you need to run your own front-end project at http://localhost:8080
. When deploying, you need to copy the dist
directory to the root directory of the PakePro project.
# 安装依赖
# Install dependencies
npm i
# 本地开发 默认运行本地 http://localhost:8080 的前端项目.
# Local development defaults to running locally http://localhost:8080 The front-end project.
npm run dev
# 将前端项目打包到 dist 目录 , 并将 dist 目录复制到 PakePro 项目的 根目录.
# Package the front-end project into the dist directory and copy the dist directory to the root directory of the PakePro project.
npm run build
-
PakePro/src-tauri/src/app/invoke.rs
window_run_label 函数是每次创建新窗口的主要逻辑.
The window_run_label function is the main logic for creating a new window each time. -
PakePro/src-tauri/src/inject/event.js
你可以通过修改 window.open 去自定义创建新窗口的逻辑.
You can modify window.open to customize the logic for creating a new window. -
PakePro/src-tauri/src/lib.rs
项目采用的是 tauri_plugin_localhost 插件,http://localhost:9527
提供的本地服务器,tauri://
协议会导致一些服务无法使用, 你们可以根据自己的需求修改这里的逻辑.
The project uses the tauri_plugin_localhost plugin, which provides a local server athttp://localhost:9527
. Thetauri://
protocol will cause some services to not work, so you can modify the logic here according to your own needs. -
如果你是打包的本地静态文件, 需要服务端推送自动更新应用, 可以参考 main-pro-updater 分支.
If you are packaging local static files, you need to push automatic updates to the server. You can refer to the main-pro-updater branch.
PakePro/src-tauri/capabilities/default.json
为了方便使用, 安全权限采用的是最宽松的, 你可以根据自己的需求修改这里的逻辑.
To facilitate use, the security permissions are set to the most relaxed. You can modify the logic here according to your own needs.