mirror of
https://github.com/tauri-apps/tauri-docs.git
synced 2026-01-31 00:35:16 +01:00
fix: replace 4 backticks with 3
This commit is contained in:
@@ -17,6 +17,7 @@ Dependent on whether you use the stable or nightly Rust toolchain the options av
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Stable">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -28,11 +29,12 @@ lto = true # Enables link-time-optimizations.
|
||||
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
|
||||
panic = "abort" # Higher performance by disabling panic handlers.
|
||||
strip = true # Ensures debug symbols are removed.
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Nightly">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -47,7 +49,7 @@ panic = "abort" # Higher performance by disabling panic handlers.
|
||||
strip = true # Ensures debug symbols are removed.
|
||||
trim-paths = "all" # Removes potentially privileged information from your binaries.
|
||||
rustflags = ["-Cdebuginfo=0", "-Zthreads=8"] # Better compile performance.
|
||||
````
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -17,6 +17,7 @@ Stable 版(安定版)の Rust ツールチェーンを使用するか、Nigh
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Stable">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -28,11 +29,12 @@ lto = true # Enables link-time-optimizations.
|
||||
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
|
||||
panic = "abort" # Higher performance by disabling panic handlers.
|
||||
strip = true # Ensures debug symbols are removed.
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Nightly">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -47,7 +49,7 @@ panic = "abort" # Higher performance by disabling panic handlers.
|
||||
strip = true # Ensures debug symbols are removed.
|
||||
trim-paths = "all" # Removes potentially privileged information from your binaries.
|
||||
rustflags = ["-Cdebuginfo=0", "-Zthreads=8"] # Better compile performance.
|
||||
````
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -37,7 +37,7 @@ fn my_custom_command() {
|
||||
`lib.rs` ファイルに定義されたコマンドは、「[グルーコード](https://ja.wikipedia.org/wiki/グルーコード)生成」に対する制約のため、`pub`(パブリック/公開)として指定できません。
|
||||
「パブリック関数」として指定すると、次のようなエラーが表示されます:
|
||||
|
||||
````
|
||||
```
|
||||
error[E0255]: the name `__cmd__command_name` is defined multiple times 《`__cmd__command_name`という名称は複数定義されています》
|
||||
--> src/lib.rs:28:8
|
||||
|
|
||||
@@ -48,6 +48,7 @@ error[E0255]: the name `__cmd__command_name` is defined multiple times 《`__c
|
||||
|
|
||||
= note: `__cmd__command_name` must be defined only once in the macro namespace of this module 《注記: `__cmd__command_name` はこのモジュールのマクロ名前空間に一度だけ定義できます》
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
コマンドのリストは、次のように、「ビルダー」関数に提供する必要があります。
|
||||
@@ -60,7 +61,7 @@ pub fn run() {
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
````
|
||||
```
|
||||
|
||||
これで、JavaScript コードからコマンドを呼び出すことができます。
|
||||
|
||||
|
||||
@@ -332,8 +332,10 @@ $VERSION = Get-ChildItem -Name "$env:LocalAppData\Android\Sdk\ndk"
|
||||
PowerShell は、再起動またはログアウトするまで、新しい環境変数の設定が有効になりませんが、
|
||||
現在のセッションを更新することはできます:
|
||||
|
||||
````ps
|
||||
```ps
|
||||
[System.Environment]::GetEnvironmentVariables("User").GetEnumerator() | % { Set-Item -Path "Env:\$($_.key)" -Value $_.value }
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
@@ -344,7 +346,7 @@ PowerShell は、再起動またはログアウトするまで、新しい環境
|
||||
|
||||
```sh
|
||||
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
|
||||
````
|
||||
```
|
||||
|
||||
次のステップ: [iOS 用の設定](#ios) または [プロジェクトの作成](/ja/start/create-project/)。
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ Stable 버전(안정판)의 Rust 툴체인을 사용하는지, Nightly 버전(
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Stable">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -28,11 +29,12 @@ lto = true # 링크 타임 최적화를 활성화합니다.
|
||||
opt-level = "s" # 작은 바이너리 크기를 우선시합니다. 속도를 선호하는 경우 `3`을 사용하십시오.
|
||||
panic = "abort" # 패닉 핸들러를 비활성화하여 성능을 향상시킵니다.
|
||||
strip = true # 디버그 심볼이 제거되도록 합니다.
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Nightly">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -47,7 +49,7 @@ panic = "abort" # 패닉 핸들러를 비활성화하여 성능을 향상시킵
|
||||
strip = true # 디버그 심볼이 제거되도록 합니다.
|
||||
trim-paths = "all" # 바이너리에서 잠재적으로 권한 있는 정보를 제거합니다.
|
||||
rustflags = ["-Cdebuginfo=0", "-Zthreads=8"] # 더 나은 컴파일 성능.
|
||||
````
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -37,7 +37,7 @@ fn my_custom_command() {
|
||||
`lib.rs` 파일에 정의된 명령은 "[글루 코드](https://ko.wikipedia.org/wiki/글루_코드) 생성"에 대한 제약 때문에 `pub`(공개)으로 지정할 수 없습니다.
|
||||
"공개 함수"로 지정하면 다음과 같은 오류가 표시됩니다:
|
||||
|
||||
````
|
||||
```
|
||||
error[E0255]: the name `__cmd__command_name` is defined multiple times 《`__cmd__command_name`이라는 이름이 여러 번 정의되었습니다》
|
||||
--> src/lib.rs:28:8
|
||||
|
|
||||
@@ -48,6 +48,7 @@ error[E0255]: the name `__cmd__command_name` is defined multiple times 《`__cmd
|
||||
|
|
||||
= note: `__cmd__command_name` must be defined only once in the macro namespace of this module 《참고: `__cmd__command_name`은 이 모듈의 매크로 네임스페이스에 한 번만 정의해야 합니다》
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
명령 목록은 다음과 같이 "빌더" 함수에 제공해야 합니다.
|
||||
@@ -60,7 +61,7 @@ pub fn run() {
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
````
|
||||
```
|
||||
|
||||
이제 JavaScript 코드에서 명령을 호출할 수 있습니다.
|
||||
|
||||
|
||||
@@ -154,48 +154,51 @@ We use [sqlx](https://docs.rs/sqlx/latest/sqlx/) as the underlying library and a
|
||||
<Tabs syncKey='SQLvariant'>
|
||||
<TabItem label="SQLite">
|
||||
Use the "$#" syntax when substituting query data
|
||||
|
||||
```javascript
|
||||
const result = await db.execute(
|
||||
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
||||
[todos.id, todos.title, todos.status],
|
||||
'INSERT into todos (id, title, status) VALUES ($1, $2, $3)',
|
||||
[todos.id, todos.title, todos.status]
|
||||
);
|
||||
|
||||
const result = await db.execute(
|
||||
"UPDATE todos SET title = $1, status = $2 WHERE id = $3",
|
||||
[todos.title, todos.status, todos.id],
|
||||
'UPDATE todos SET title = $1, status = $2 WHERE id = $3',
|
||||
[todos.title, todos.status, todos.id]
|
||||
);
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
<TabItem label="MySQL">
|
||||
Use "?" when substituting query data
|
||||
|
||||
```javascript
|
||||
const result = await db.execute(
|
||||
"INSERT into todos (id, title, status) VALUES (?, ?, ?)",
|
||||
[todos.id, todos.title, todos.status],
|
||||
'INSERT into todos (id, title, status) VALUES (?, ?, ?)',
|
||||
[todos.id, todos.title, todos.status]
|
||||
);
|
||||
|
||||
const result = await db.execute(
|
||||
"UPDATE todos SET title = ?, status = ? WHERE id = ?",
|
||||
[todos.title, todos.status, todos.id],
|
||||
'UPDATE todos SET title = ?, status = ? WHERE id = ?',
|
||||
[todos.title, todos.status, todos.id]
|
||||
);
|
||||
````
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="PostgreSQL">
|
||||
Use the "$#" syntax when substituting query data
|
||||
|
||||
```javascript
|
||||
const result = await db.execute(
|
||||
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
||||
[todos.id, todos.title, todos.status],
|
||||
'INSERT into todos (id, title, status) VALUES ($1, $2, $3)',
|
||||
[todos.id, todos.title, todos.status]
|
||||
);
|
||||
|
||||
const result = await db.execute(
|
||||
"UPDATE todos SET title = $1, status = $2 WHERE id = $3",
|
||||
[todos.title, todos.status, todos.id],
|
||||
'UPDATE todos SET title = $1, status = $2 WHERE id = $3',
|
||||
[todos.title, todos.status, todos.id]
|
||||
);
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -218,7 +221,7 @@ let migration = Migration {
|
||||
sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);",
|
||||
kind: MigrationKind::Up,
|
||||
};
|
||||
````
|
||||
```
|
||||
|
||||
Or if you want to use SQL from a file, you can include it by using `include_str!`:
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components';
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Stable">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -28,11 +29,12 @@ lto = true # 启用链接时优化。
|
||||
opt-level = "s" # 优先考虑小的二进制文件大小。如果您更喜欢速度,请使用 `3`。
|
||||
panic = "abort" # 通过禁用 panic 处理程序来提高性能。
|
||||
strip = true # 确保移除调试符号。
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Nightly">
|
||||
|
||||
```toml
|
||||
# src-tauri/Cargo.toml
|
||||
[profile.dev]
|
||||
@@ -47,7 +49,7 @@ panic = "abort" # 通过禁用 panic 处理程序来提高性能。
|
||||
strip = true # 确保移除调试符号。
|
||||
trim-paths = "all" # 从您的二进制文件中移除潜在的特权信息。
|
||||
rustflags = ["-Cdebuginfo=0", "-Zthreads=8"] # 提高编译性能。
|
||||
````
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -92,22 +92,21 @@ await db.execute('INSERT INTO ...');
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="MySQL">
|
||||
```javascript
|
||||
|
||||
```javascript
|
||||
import Database from '@tauri-apps/plugin-sql';
|
||||
const db = await Database.load('mysql://user:pass@host/database');
|
||||
await db.execute('INSERT INTO ...');
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
<TabItem label="PostgreSQL">
|
||||
|
||||
```javascript
|
||||
|
||||
import Database from "@tauri-apps/plugin-sql";
|
||||
const db = await Database.load("postgres://postgres:password@localhost/test");
|
||||
await db.execute("INSERT INTO ...");
|
||||
|
||||
````
|
||||
import Database from '@tauri-apps/plugin-sql';
|
||||
const db = await Database.load('postgres://postgres:password@localhost/test');
|
||||
await db.execute('INSERT INTO ...');
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
@@ -119,48 +118,51 @@ await db.execute("INSERT INTO ...");
|
||||
<Tabs syncKey="SQLvariant">
|
||||
<TabItem label="SQLite">
|
||||
在替换查询数据时使用 "$#" 语法
|
||||
|
||||
```javascript
|
||||
const result = await db.execute(
|
||||
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
||||
[todos.id, todos.title, todos.status],
|
||||
'INSERT into todos (id, title, status) VALUES ($1, $2, $3)',
|
||||
[todos.id, todos.title, todos.status]
|
||||
);
|
||||
|
||||
const result = await db.execute(
|
||||
"UPDATE todos SET title = $1, status = $2 WHERE id = $3",
|
||||
[todos.title, todos.status, todos.id],
|
||||
'UPDATE todos SET title = $1, status = $2 WHERE id = $3',
|
||||
[todos.title, todos.status, todos.id]
|
||||
);
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
<TabItem label="MySQL">
|
||||
在替换查询数据时使用 "?" 语法
|
||||
|
||||
```javascript
|
||||
const result = await db.execute(
|
||||
"INSERT into todos (id, title, status) VALUES (?, ?, ?)",
|
||||
[todos.id, todos.title, todos.status],
|
||||
'INSERT into todos (id, title, status) VALUES (?, ?, ?)',
|
||||
[todos.id, todos.title, todos.status]
|
||||
);
|
||||
|
||||
const result = await db.execute(
|
||||
"UPDATE todos SET title = ?, status = ? WHERE id = ?",
|
||||
[todos.title, todos.status, todos.id],
|
||||
'UPDATE todos SET title = ?, status = ? WHERE id = ?',
|
||||
[todos.title, todos.status, todos.id]
|
||||
);
|
||||
````
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="PostgreSQL">
|
||||
在替换查询数据时使用 "$#" 语法
|
||||
|
||||
```javascript
|
||||
const result = await db.execute(
|
||||
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
||||
[todos.id, todos.title, todos.status],
|
||||
'INSERT into todos (id, title, status) VALUES ($1, $2, $3)',
|
||||
[todos.id, todos.title, todos.status]
|
||||
);
|
||||
|
||||
const result = await db.execute(
|
||||
"UPDATE todos SET title = $1, status = $2 WHERE id = $3",
|
||||
[todos.title, todos.status, todos.id],
|
||||
'UPDATE todos SET title = $1, status = $2 WHERE id = $3',
|
||||
[todos.title, todos.status, todos.id]
|
||||
);
|
||||
```
|
||||
|
||||
````
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -184,7 +186,7 @@ let migration = Migration {
|
||||
sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);",
|
||||
kind: MigrationKind::Up,
|
||||
};
|
||||
````
|
||||
```
|
||||
|
||||
### 向插件构建器添加迁移
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
|
||||
2. 修改 `lib.rs` 来初始化插件。
|
||||
|
||||
````rust title="src-tauri/src/lib.rs" ins={4}
|
||||
```rust title="src-tauri/src/lib.rs" ins={4}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
|
||||
Reference in New Issue
Block a user