您必须已经完成设置机器开发环境所需的所有步骤。
如果您尚未完成此操作,请查看您操作系统的 设置页面

1.安装Tauri JS 包作为依赖项:

cd project-folder # Not required if you already have a package.json: # npm init # OR # yarn init yarn add tauri # OR npm install tauri —save
您可以安装Tauri作为本地和全局依赖关系,但我们建议在本地安装它。
如果你决定使用 npm 命令下 Tauri 作为本地包,你必须定义一个script指令在你新建的package.json文件里
{ // This content is just a sample “scripts”: { “tauri”: “tauri” } }

2.初始化Tauri

此命令将在当前工作目录中创建一个新文件夹, src-tauri。
└── src-tauri ├── .gitignore ├── Cargo.toml ├── rustfmt.toml ├── tauri.conf.json ├── icons │ ├── 128x128.png │ ├── 128x128@2x.png │ ├── 32x32.png │ ├── Square107x107Logo.png │ ├── Square142x142Logo.png │ ├── Square150x150Logo.png │ ├── Square284x284Logo.png │ ├── Square30x30Logo.png │ ├── Square310x310Logo.png │ ├── Square44x44Logo.png │ ├── Square71x71Logo.png │ ├── Square89x89Logo.png │ ├── StoreLogo.png │ ├── icon.icns │ ├── icon.ico │ └── icon.png └── src ├── build.rs ├── cmd.rs └── main.rs

3.使用 tauri info 来确保你的开发环境一切正常:

执行命令后会返回如下内容:
Operating System - Darwin(16.7.0) - darwin/x64 Node.js environment Node.js - 12.14.0 tauri.js - 0.2.1 Rust environment rustc - 1.40.0 cargo - 1.40.0 tauri-cli - 0.1.2 Global packages NPM - 6.13.4 yarn - 1.21.1 App directory structure /.quasar /build-tauri /dist /node_modules /src App tauri - 0.3.0 mode - embedded-server build-type - bundle CSP - default-src data: filesystem: ws: http: https: ‘unsafe-eval’ ‘unsafe-inline’ Windows - Edge distDir - ../dist/spa devPath - http://localhost:7334
当出现问题时,这些信息会对您有所帮助。

src-tauri/tauri.conf.json

编辑 src-tauri/tauri.conf.json: 取决于您的开发设置,您可能需要更新两个重要的tauri入口:

  • 绑定资源文件 (distDir)
  • 您的开发服务器 (devPath)

查看更多关于 tauri.conf.json 的配置信息,请点击 这里
{ “build”: { “distDir”: “../dist/spa”, “devPath”: “http://localhost:7334“ } }

模式

我们还定义了预制配置,叫做“ Patterns”(模式)。
他们可以帮助你定制Tauri来满足你的需要。
查看更多关于 模式
从技术上说,你可以将 devPath 指向一个文件夹,Tauri将尝试静态地为这些资产服务。
在某些系统设置中,本地主机可能不可用。
一般规则是使用与你的 devServer 完全相同的域名。
您可以尝试在这里切换本地主机: - “127.0.0.1” - “0.0.0.0” 在窗口上,您必须在开发过程中启用loopback功能。
待办:添加链接

Vue CLI Plugin Tauri

如果您正在使用Vue CLI 3/4,推荐使用官方的 CLI 插件