Skip to content

Commit fdb7082

Browse files
committed
format
1 parent 1f7ffa3 commit fdb7082

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/content/docs/develop/calling-rust.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ error[E0255]: the name `__cmd__command_name` is defined multiple times
4747
|
4848
= note: `__cmd__command_name` must be defined only once in the macro namespace of this module
4949
```
50+
5051
:::
5152

5253
You will have to provide a list of your commands to the builder function like so:
@@ -59,7 +60,7 @@ pub fn run() {
5960
.run(tauri::generate_context!())
6061
.expect("error while running tauri application");
6162
}
62-
````
63+
```
6364

6465
Now, you can invoke the command from your JavaScript code:
6566

src/content/docs/zh-cn/develop/calling-rust.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ error[E0255]: the name `__cmd__command_name` is defined multiple times
4646
|
4747
= note: `__cmd__command_name` must be defined only once in the macro namespace of this module
4848
```
49+
4950
:::
5051

5152
您必须向构建器函数提供命令列表,如下所示:
@@ -58,7 +59,7 @@ pub fn run() {
5859
.run(tauri::generate_context!())
5960
.expect("error while running tauri application");
6061
}
61-
````
62+
```
6263

6364
现在,您可以从 JavaScript 代码调用该命令:
6465

@@ -112,7 +113,7 @@ pub fn run() {
112113

113114
注意命令列表中的 `commands::` 前缀,它表示命令函数的完整路径。
114115

115-
此示例中的命令名称是 `my_custom_command` ,因此您仍然可以通过执行
116+
此示例中的命令名称是 `my_custom_command` ,因此您仍然可以通过执行
116117
`invoke("my_custom_command")` 来调用它。在您的前端, `commands::` 前缀将被忽略。
117118

118119
#### WASM
@@ -341,7 +342,7 @@ Tauri 优先使用异步命令来执行繁重的工作,而不会导致 UI 冻
341342
:::note
342343

343344
异步命令使用 [`async_runtime::spawn`] 在单独的异步任务上执行。
344-
除非使用 *#[tauri::command(async)]* 定义,否则没有 *async* 关键字的命令将在主线程上执行。
345+
除非使用 _#[tauri::command(async)]_ 定义,否则没有 _async_ 关键字的命令将在主线程上执行。
345346

346347
:::
347348

@@ -360,7 +361,7 @@ Tauri 优先使用异步命令来执行繁重的工作,而不会导致 UI 冻
360361

361362
**选项 1**:将类型转换为非借用类型,例如 `&str` 转为 `String` 。这可能不适用于所有类型,例如 `State<'_, Data>`
362363

363-
*例子:*
364+
_例子:_
364365

365366
```rust
366367
// 在声明异步函数时使用 String 而不是 &str,因为 &str 是借用的,因此不支持
@@ -381,7 +382,7 @@ async fn my_custom_command(value: String) -> String {
381382
- `Result<(), ()>` 返回 `null`
382383
- `Result<bool, Error>` 返回一个 bool 值或一个错误,如上面的 [错误处理](#错误处理) 部分所示。
383384

384-
*例子:*
385+
_例子:_
385386

386387
```rust
387388
// 返回一个 Result<String, ()> 以绕过借用问题
@@ -516,7 +517,7 @@ fn upload(request: tauri::ipc::Request) -> Result<(), Error> {
516517
}
517518
```
518519

519-
在前端,您可以调用 `invoke()` 通过在 payload 参数上提供 ArrayBuffer
520+
在前端,您可以调用 `invoke()` 通过在 payload 参数上提供 ArrayBuffer
520521
或 Uint8Array 来发送原始请求主体,并在第三个参数中包含请求标头:
521522

522523
```js
@@ -657,7 +658,7 @@ appWebview.emitTo('editor', 'file-changed', {
657658

658659
:::note
659660
Webview 特有的事件**不会**被触发到常规的全局事件监听器中。
660-
要监听**所有**事件,您必须为 [event.listen] 函数提供 `{ target: { kind: 'Any' } }`
661+
要监听**所有**事件,您必须为 [event.listen] 函数提供 `{ target: { kind: 'Any' } }`
661662
选项,该选项将监听器定义为所有已发出事件的集合:
662663

663664
```js
@@ -677,9 +678,8 @@ listen(
677678

678679
### 监听事件
679680

680-
<FrontendListen />
681-
.
682-
要了解如何从 Rust 代码中监听事件和发出事件,请参阅 [Rust 事件系统文档]
681+
<FrontendListen />. 要了解如何从 Rust 代码中监听事件和发出事件,请参阅 [Rust
682+
事件系统文档]
683683

684684
[从 Rust 调用前端]: /develop/calling-frontend/
685685
[`async_runtime::spawn`]: https://docs.rs/tauri/2.0.0/tauri/async_runtime/fn.spawn.html

0 commit comments

Comments
 (0)