Skip to content

Commit d0f24dd

Browse files
authored
i18n(zh-cn): update outdated page (#3245)
1 parent cfbce68 commit d0f24dd

File tree

6 files changed

+93
-85
lines changed

6 files changed

+93
-85
lines changed

src/content/docs/zh-cn/plugin/stronghold.mdx

+43-59
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Compatibility from '@components/plugins/Compatibility.astro';
99

1010
import { Steps, Tabs, TabItem } from '@astrojs/starlight/components';
1111
import CommandTabs from '@components/CommandTabs.astro';
12+
import PluginPermissions from '@components/PluginPermissions.astro';
1213

1314
<PluginLinks plugin={frontmatter.plugin} />
1415

@@ -33,6 +34,7 @@ import CommandTabs from '@components/CommandTabs.astro';
3334
yarn="yarn run tauri add stronghold"
3435
pnpm="pnpm tauri add stronghold"
3536
bun="bun tauri add stronghold"
37+
deno="deno task tauri add stronghold"
3638
cargo="cargo tauri add stronghold"
3739
/>
3840
</TabItem>
@@ -66,6 +68,7 @@ import CommandTabs from '@components/CommandTabs.astro';
6668
npm="npm install @tauri-apps/plugin-stronghold"
6769
yarn="yarn add @tauri-apps/plugin-stronghold"
6870
pnpm="pnpm add @tauri-apps/plugin-stronghold"
71+
deno="deno add npm:@tauri-apps/plugin-stronghold"
6972
bun="bun add @tauri-apps/plugin-stronghold"
7073
/>
7174

@@ -76,8 +79,39 @@ import CommandTabs from '@components/CommandTabs.astro';
7679

7780
## 用法
7881

82+
该插件必须使用密码哈希函数进行初始化,该函数接收密码字符串,并必须返回由其派生的 32 字节哈希值。
83+
84+
### 使用 argon2 密码散列函数初始化
85+
86+
Stronghold 插件提供了一个默认的哈希函数,使用的是 [argon2] 算法。
87+
88+
```rust title="src-tauri/src/lib.rs"
89+
use tauri::Manager;
90+
91+
pub fn run() {
92+
tauri::Builder::default()
93+
.setup(|app| {
94+
let salt_path = app
95+
.path()
96+
.app_local_data_dir()
97+
.expect("could not resolve app local data path")
98+
.join("salt.txt");
99+
app.handle().plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?;
100+
Ok(())
101+
})
102+
.run(tauri::generate_context!())
103+
.expect("error while running tauri application");
104+
}
105+
```
106+
79107
### 使用自定义密码散列函数初始化
80108

109+
或者,您也可以通过使用 `tauri_plugin_stronghold::Builder::new` 构造函数来提供您自己的哈希算法。
110+
111+
:::note
112+
密码哈希值必须恰好包含 32 个字节。这是 Stronghold 的要求。
113+
:::
114+
81115
```rust title="src-tauri/src/lib.rs"
82116
pub fn run() {
83117
tauri::Builder::default()
@@ -108,34 +142,17 @@ pub fn run() {
108142
}
109143
```
110144

111-
### 使用 argon2 密码散列函数初始化
112-
113-
```rust title="src-tauri/src/lib.rs"
114-
use tauri::Manager;
115-
116-
pub fn run() {
117-
tauri::Builder::default()
118-
.setup(|app| {
119-
let salt_path = app
120-
.path()
121-
.app_local_data_dir()
122-
.expect("could not resolve app local data path")
123-
.join("salt.txt");
124-
app.handle().plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?;
125-
Ok(())
126-
})
127-
.run(tauri::generate_context!())
128-
.expect("error while running tauri application");
129-
}
130-
```
131-
132145
### 在 JavaScript 使用
133146

134147
Stronghold 插件可以在 JavaScript 中使用。
135148

136149
```javascript
137150
import { Client, Stronghold } from '@tauri-apps/plugin-stronghold';
151+
// 当设置 `"withGlobalTauri": true` 时,你可以用
152+
// const { Client, Stronghold } = window.__TAURI__.stronghold;
138153
import { appDataDir } from '@tauri-apps/api/path';
154+
// 当设置 `"withGlobalTauri": true` 时,你可以用
155+
// const { appDataDir } = window.__TAURI__.path;
139156

140157
const initStronghold = async () => {
141158
const vaultPath = `${await appDataDir()}/vault.hold`;
@@ -189,50 +206,17 @@ await store.remove(key);
189206

190207
## 权限
191208

192-
默认情况下,所有插件命令都被阻止,无法访问。你必须在你的 `capabilities` 配置中定义一个权限列表
209+
默认情况下,所有具有潜在危险的插件命令和范围都会被阻止且无法访问。您必须修改 `capabilities` 文件夹中的配置来启用它们
193210

194-
更多信息请参见[访问控制列表](/zh-cn/reference/acl/)
211+
参见[能力概览](/zh-cn/security/capabilities/)以获取更多信息,以及插件的[分步导览](/zh-cn/learn/security/using-plugin-permissions/)来调整插件权限
195212

196213
```json title="src-tauri/capabilities/default.json" ins={8-14}
197214
{
198-
"$schema": "../gen/schemas/desktop-schema.json",
199-
"identifier": "main-capability",
200-
"description": "Capability for the main window",
201-
"windows": ["main"],
215+
...,
202216
"permissions": [
203-
"path:default",
204-
"stronghold:allow-initialize",
205-
"stronghold:allow-create-client",
206-
"stronghold:allow-load-client",
207-
"stronghold:allow-save",
208-
"stronghold:allow-save-store-record"
209-
"stronghold:allow-get-store-record",
210-
"stronghold:allow-remove-store-record",
217+
"stronghold:default",
211218
]
212219
}
213220
```
214221

215-
| 权限 | 描述 |
216-
| -------------------------------------- | ------------------------------------------------------------- |
217-
| `stronghold:allow-create-client` | 在没有预先配置的作用域的情况下启用 create_client 命令。 |
218-
| `stronghold:deny-create-client` | 拒绝没有任何预配置范围的 create_client 命令。 |
219-
| `stronghold:allow-destroy` | 在没有预先配置的作用域的情况下启用 destroy 命令。 |
220-
| `stronghold:deny-destroy` | 拒绝没有任何预配置范围的 destroy 命令。 |
221-
| `stronghold:allow-execute-procedure` | 在没有预先配置的作用域的情况下启用 execute_procedure 命令。 |
222-
| `stronghold:deny-execute-procedure` | 拒绝没有任何预配置范围的 execute_procedure 命令。 |
223-
| `stronghold:allow-get-store-record` | 在没有预先配置的作用域的情况下启用 get_store_record 命令。 |
224-
| `stronghold:deny-get-store-record` | 拒绝没有任何预配置范围的 get_store_record 命令。 |
225-
| `stronghold:allow-initialize` | 在没有预先配置的作用域的情况下启用 initialize 命令。 |
226-
| `stronghold:deny-initialize` | 拒绝没有任何预配置范围的 initialize 命令。 |
227-
| `stronghold:allow-load-client` | 在没有预先配置的作用域的情况下启用 load_client 命令。 |
228-
| `stronghold:deny-load-client` | 拒绝没有任何预配置范围的 load_client 命令。 |
229-
| `stronghold:allow-remove-secret` | 在没有预先配置的作用域的情况下启用 remove_secret 命令。 |
230-
| `stronghold:deny-remove-secret` | 拒绝没有任何预配置范围的 remove_secret 命令。 |
231-
| `stronghold:allow-remove-store-record` | 在没有预先配置的作用域的情况下启用 remove_store_record 命令。 |
232-
| `stronghold:deny-remove-store-record` | 拒绝没有任何预配置范围的 remove_store_record 命令。 |
233-
| `stronghold:allow-save` | 在没有预先配置的作用域的情况下启用 save 命令。 |
234-
| `stronghold:deny-save` | 拒绝没有任何预配置范围的 save 命令。 |
235-
| `stronghold:allow-save-secret` | 在没有预先配置的作用域的情况下启用 save_secret 命令。 |
236-
| `stronghold:deny-save-secret` | 拒绝没有任何预配置范围的 save_secret 命令。 |
237-
| `stronghold:allow-save-store-record` | 在没有预先配置的作用域的情况下启用 save_store_record 命令。 |
238-
| `stronghold:deny-save-store-record` | 拒绝没有任何预配置范围的 save_store_record 命令。 |
222+
<PluginPermissions plugin={frontmatter.plugin} />

src/content/docs/zh-cn/plugin/upload.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import CommandTabs from '@components/CommandTabs.astro';
2929
npm="npm run tauri add upload"
3030
yarn="yarn run tauri add upload"
3131
pnpm="pnpm tauri add upload"
32+
deno="deno task tauri add upload"
3233
bun="bun tauri add upload"
3334
cargo="cargo tauri add upload"
3435
/>
@@ -59,6 +60,7 @@ import CommandTabs from '@components/CommandTabs.astro';
5960
npm="npm install @tauri-apps/plugin-upload"
6061
yarn="yarn add @tauri-apps/plugin-upload"
6162
pnpm="pnpm add @tauri-apps/plugin-upload"
63+
deno="deno add npm:@tauri-apps/plugin-upload"
6264
bun="bun add @tauri-apps/plugin-upload"
6365
/>
6466

src/content/docs/zh-cn/plugin/websocket.mdx

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Compatibility from '@components/plugins/Compatibility.astro';
99

1010
import { Steps, Tabs, TabItem } from '@astrojs/starlight/components';
1111
import CommandTabs from '@components/CommandTabs.astro';
12+
import PluginPermissions from '@components/PluginPermissions.astro';
1213

1314
<PluginLinks plugin={frontmatter.plugin} />
1415

@@ -33,6 +34,7 @@ import CommandTabs from '@components/CommandTabs.astro';
3334
yarn="yarn run tauri add websocket"
3435
pnpm="pnpm tauri add websocket"
3536
bun="bun tauri add websocket"
37+
deno="deno task tauri add websocket"
3638
cargo="cargo tauri add websocket"
3739
/>
3840
</TabItem>
@@ -66,6 +68,7 @@ import CommandTabs from '@components/CommandTabs.astro';
6668
npm = "npm install @tauri-apps/plugin-websocket"
6769
yarn = "yarn add @tauri-apps/plugin-websocket"
6870
pnpm = "pnpm add @tauri-apps/plugin-websocket"
71+
deno = "deno add npm:@tauri-apps/plugin-websocket"
6972
bun="bun add @tauri-apps/plugin-websocket"
7073
/>
7174

@@ -94,9 +97,9 @@ await ws.disconnect();
9497

9598
## 权限
9699

97-
默认情况下,所有插件命令都被阻止,无法访问。你必须在你的 `capabilities` 配置中定义一个权限列表
100+
默认情况下,所有具有潜在危险的插件命令和范围都会被阻止且无法访问。您必须修改 `capabilities` 文件夹中的配置来启用它们
98101

99-
更多信息请参见[访问控制列表](/zh-cn/reference/acl/)
102+
参见[能力概览](/zh-cn/security/capabilities/)以获取更多信息,以及插件的[分步导览](/zh-cn/learn/security/using-plugin-permissions/)来调整插件权限
100103

101104
```json title="src-tauri/capabilities/default.json" ins={6}
102105
{
@@ -108,10 +111,4 @@ await ws.disconnect();
108111
}
109112
```
110113

111-
| 权限 | 描述 |
112-
| ------------------------- | ------------------------------------------------- |
113-
| `websocket:default` | 允许连接和发送数据到 WebSocket 服务器 |
114-
| `websocket:allow-connect` | 在没有预先配置的作用域的情况下启用 connect 命令。 |
115-
| `websocket:deny-connect` | 拒绝没有任何预配置范围的 connect 命令。 |
116-
| `websocket:allow-send` | 在没有预先配置的作用域的情况下启用 send 命令。 |
117-
| `websocket:deny-send` | 拒绝没有任何预配置范围的 send 命令。 |
114+
<PluginPermissions plugin={frontmatter.plugin} />

src/content/docs/zh-cn/plugin/window-state.mdx

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Compatibility from '@components/plugins/Compatibility.astro';
99

1010
import { Tabs, TabItem } from '@astrojs/starlight/components';
1111
import CommandTabs from '@components/CommandTabs.astro';
12+
import PluginPermissions from '@components/PluginPermissions.astro';
1213

1314
<PluginLinks plugin={frontmatter.plugin} />
1415

@@ -33,6 +34,7 @@ import CommandTabs from '@components/CommandTabs.astro';
3334
npm="npm run tauri add window-state"
3435
yarn="yarn run tauri add window-state"
3536
pnpm="pnpm tauri add window-state"
37+
deno="deno task tauri add window-state"
3638
bun="bun tauri add window-state"
3739
cargo="cargo tauri add window-state"
3840
/>
@@ -66,14 +68,15 @@ fn main() {
6668
npm="npm install @tauri-apps/plugin-window-state"
6769
yarn="yarn add @tauri-apps/plugin-window-state"
6870
pnpm="pnpm add @tauri-apps/plugin-window-state"
71+
deno="deno add npm:@tauri-apps/plugin-window-state"
6972
bun="bun add @tauri-apps/plugin-window-state"
7073
/>
7174
</TabItem>
7275
</Tabs>
7376

7477
## 用法
7578

76-
添加后,当应用程序被关闭时,将记住所有窗口的状态,并在下一次启动时恢复到之前的状态
79+
添加窗口状态插件后,应用程序关闭时所有窗口的状态都会被记住,并且在下次启动时会恢复到之前的状态
7780

7881
你也可以在 JavaScript 和 Rust 中访问窗口状态插件。
7982

@@ -120,24 +123,17 @@ window.restore_state(StateFlags::all()); // 将从磁盘恢复窗口的状态
120123

121124
## 权限
122125

123-
默认情况下,所有插件命令都被阻止,无法访问。
124-
你必须在你的 `capabilities` 配置中定义一个权限列表。
126+
默认情况下,所有具有潜在危险的插件命令和范围都会被阻止且无法访问。您必须修改 `capabilities` 文件夹中的配置来启用它们。
125127

126-
更多信息请参见[访问控制列表](/zh-cn/reference/acl/)
128+
参见[能力概览](/zh-cn/security/capabilities/)以获取更多信息,以及插件的[分步导览](/zh-cn/learn/security/using-plugin-permissions/)来调整插件权限
127129

128130
```json title="src-tauri/capabilities/default.json" ins={4-5}
129131
{
130132
"permissions": [
131133
...,
132-
"window-state:allow-restore-window-state",
133-
"window-state:allow-save-window-state",
134+
"window-state:default",
134135
]
135136
}
136137
```
137138

138-
| 权限 | 描述 |
139-
| ----------------------------------------- | ------------------------------------------------------------ |
140-
| `window-state:allow-restore-window-state` | 启用 restore_window_state 命令,不需要任何预先配置的作用域。 |
141-
| `window-state:deny-restore-window-state` | 拒绝没有任何预配置范围的 restore_window_state 命令。 |
142-
| `window-state:allow-save-window-state` | 启用 save_window_state 命令,不需要预先配置作用域。 |
143-
| `window-state:deny-save-window-state` | 拒绝没有任何预先配置的作用域的 save_window_state 命令。 |
139+
<PluginPermissions plugin={frontmatter.plugin} />

src/content/docs/zh-cn/start/frontend/vite.mdx

+33-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Vite 是为提供更快速,更简洁的现代 Web 项目开发体验而诞生
1212

1313
## 检查清单
1414

15-
-`tauri.conf.json` 中使用 `dist/` 作为 `frontendDist`
15+
-`tauri.conf.json` 中使用 `../dist/` 作为 `frontendDist`
1616
- 在真实 iOS 设备上调试时,使用 `process.env.TAURI_DEV_HOST` 环境变量作为开发服务器的 IP 地址。
1717

1818
## 示例配置
@@ -26,8 +26,10 @@ Vite 是为提供更快速,更简洁的现代 Web 项目开发体验而诞生
2626
```json
2727
{
2828
"scripts": {
29-
"dev": "vite dev",
30-
"build": "vite build"
29+
"dev": "vite",
30+
"build": "tsc && vite build",
31+
"preview": "vite preview",
32+
"tauri": "tauri"
3133
}
3234
}
3335
```
@@ -84,6 +86,22 @@ Vite 是为提供更快速,更简洁的现代 Web 项目开发体验而诞生
8486

8587
</TabItem>
8688

89+
<TabItem label="deno">
90+
91+
```json
92+
// tauri.conf.json
93+
{
94+
"build": {
95+
"beforeDevCommand": "deno task dev",
96+
"beforeBuildCommand": "deno task build",
97+
"devUrl": "http://localhost:5173",
98+
"frontendDist": "../dist"
99+
}
100+
}
101+
```
102+
103+
</TabItem>
104+
87105
</Tabs>
88106

89107
1. ##### 更新 Vite 配置:
@@ -95,11 +113,22 @@ Vite 是为提供更快速,更简洁的现代 Web 项目开发体验而诞生
95113
// 防止 Vite 清除 Rust 显示的错误
96114
clearScreen: false,
97115
server: {
116+
port: 1420,
98117
// Tauri 工作于固定端口,如果端口不可用则报错
99118
strictPort: true,
100119
// 如果设置了 host,Tauri 则会使用
101120
host: host || false,
102-
port: 5173,
121+
hmr: host
122+
? {
123+
protocol: 'ws',
124+
host,
125+
port: 1421,
126+
}
127+
: undefined,
128+
watch: {
129+
// 告诉 Vite 忽略监听 `src-tauri` 目录
130+
ignored: ['**/src-tauri/**'],
131+
},
103132
},
104133
// 添加有关当前构建目标的额外前缀,使这些 CLI 设置的 Tauri 环境变量可以在客户端代码中访问
105134
envPrefix: ['VITE_', 'TAURI_ENV_*'],

src/content/docs/zh-cn/start/prerequisites.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ WebView 2 已安装在 Windows 10(从版本 1803 开始)和更高版本的 W
203203

204204
Tauri 使用 Microsoft Edge WebView2 在 Windows 上呈现内容。
205205

206-
通过访问 [下载 WebView2 运行时](https://developer.microsoft.com/zh-cn/microsoft-edge/webview2/#download) 安装 WebView2。下载并安装“常青独立安装程序(Evergreen Bootstrapper)”。
206+
通过访问[下载 WebView2 运行时](https://developer.microsoft.com/zh-cn/microsoft-edge/webview2/#download)安装 WebView2。下载并安装“常青独立安装程序(Evergreen Bootstrapper)”。
207207

208208
下一步:[下载并安装 Rust](#rust)
209209

0 commit comments

Comments
 (0)