Tauri 配置 launch.json

2023-10-13 15:27 更新

創(chuàng)建一個 ?.vscode/launch.json? 文件并并將以下 JSON 內(nèi)容粘貼到其中:

.vscode/launch.json

{
// 使用 IntellliSense 來了解可能的屬性。
// 懸停以查看現(xiàn)有屬性的描述。
// 更多詳情訪問:https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Tauri Development Debug",
"cargo": {
"args": [
"build",
"--manifest-path=./src-tauri/Cargo.toml",
"--no-default-features"
]
},
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
"preLaunchTask": "ui:dev"
},
{
"type": "lldb",
"request": "launch",
"name": "Tauri Production Debug",
"cargo": {
"args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"]
},
// task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json`
"preLaunchTask": "ui:build"
}
]
}

這直接使用 cargo 來構(gòu)建Rust 應用程序,并在開發(fā)和生產(chǎn)模式中加載它。

請注意,它不使用 Tauri CLI,因此不會執(zhí)行獨占的 CLI 功能。 before DevCommand 和 preambular Build 腳本必須事先執(zhí)行或配置為 LaunchTask 任務。 下面的 .vscode/missions. son 示例文件包含兩個任務。 一個是 beforeDevCommand 用于生成開發(fā)服務器的,另一個是 beforeBuildCommand:

.vscode/tasks.json

{
// 關(guān)于 tasks.json 格式文檔,請參閱:https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"label": "ui:dev",
"type": "shell",
// `dev` keeps running in the background
// ideally you should also configure a `problemMatcher`
// see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson
"isBackground": true,
// change this to your `beforeDevCommand`:
"command": "yarn",
"args": ["dev"]
},
{
"label": "ui:build",
"type": "shell",
// change this to your `beforeBuildCommand`:
"command": "yarn",
"args": ["build"]
}
]
}

現(xiàn)在您可以在 ?src-tauri/src/main.rs? 或任何其他 Rust 文件中設置斷點,然后按 ?F5? 開始調(diào)試.


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號