Skip to content

Commit d1427dd

Browse files
authored
i18n(zh-cn): Update outdated doc (#3256)
1 parent db2e37e commit d1427dd

File tree

9 files changed

+320
-282
lines changed

9 files changed

+320
-282
lines changed

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

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ plugin: autostart
77
import PluginLinks from '@components/PluginLinks.astro';
88
import Compatibility from '@components/plugins/Compatibility.astro';
99

10-
import { Tabs, TabItem } from '@astrojs/starlight/components';
10+
import { Tabs, TabItem, Steps } 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

@@ -20,7 +21,7 @@ import CommandTabs from '@components/CommandTabs.astro';
2021

2122
## 设置
2223

23-
请安装 autostart 插件
24+
从安装 autostart 插件开始
2425

2526
<Tabs>
2627
<TabItem label="自动">
@@ -33,37 +34,47 @@ import CommandTabs from '@components/CommandTabs.astro';
3334
npm="npm run tauri add autostart"
3435
yarn="yarn run tauri add autostart"
3536
pnpm="pnpm tauri add autostart"
37+
deno="deno task tauri add autostart"
3638
bun="bun tauri add autostart"
3739
cargo="cargo tauri add autostart"
3840
/>
3941

4042
</TabItem>
4143
<TabItem label="手动">
44+
<Steps>
45+
1.`src-tauri` 文件夹中运行以下命令,将插件添加到 `Cargo.toml` 中的项目依赖项中。
46+
47+
```sh frame=none
48+
cargo add tauri-plugin-autostart --target 'cfg(any(target_os = "macos", windows, target_os = "linux"))'
49+
```
50+
51+
2. 修改 `lib.rs` 来初始化插件。
52+
53+
```rust title="src-tauri/src/lib.rs" ins={5-6}
54+
#[cfg_attr(mobile, tauri::mobile_entry_point)]
55+
pub fn run() {
56+
tauri::Builder::default()
57+
.setup(|app| {
58+
#[cfg(desktop)]
59+
app.handle().plugin(tauri_plugin_autostart::init(tauri_plugin_autostart::MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* 传递给应用程序的任意数量的参数 */));
60+
Ok(())
61+
})
62+
.run(tauri::generate_context!())
63+
.expect("error while running tauri application");
64+
}
65+
```
66+
67+
3. 你可以使用你喜欢的 JavaScript 包管理器来安装 JavaScript Guest 绑定。
68+
69+
<CommandTabs
70+
npm="npm install @tauri-apps/plugin-autostart"
71+
yarn="yarn add @tauri-apps/plugin-autostart"
72+
pnpm="pnpm add @tauri-apps/plugin-autostart"
73+
deno="deno add npm:@tauri-apps/plugin-autostart"
74+
bun="bun add @tauri-apps/plugin-autostart"
75+
/>
76+
</Steps>
4277

43-
1. 运行 `cargo add tauri-plugin-autostart` 命令,将插件添加到项目的 `Cargo.toml` 依赖中。
44-
45-
2. 修改 `lib.rs` 来初始化插件。
46-
47-
```rust title="lib.rs" ins={1, 6}
48-
use tauri_plugin_autostart::MacosLauncher;
49-
50-
#[cfg_attr(mobile, tauri::mobile_entry_point)]
51-
fn run() {
52-
tauri::Builder::default()
53-
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */))
54-
.run(tauri::generate_context!())
55-
.expect("error while running tauri application");
56-
}
57-
```
58-
59-
3. 你可以使用你喜欢的 JavaScript 包管理器来安装 JavaScript Guest 绑定。
60-
61-
<CommandTabs
62-
npm="npm install @tauri-apps/plugin-autostart"
63-
yarn="yarn add @tauri-apps/plugin-autostart"
64-
pnpm="pnpm add @tauri-apps/plugin-autostart"
65-
bun="bun add @tauri-apps/plugin-autostart"
66-
/>
6778
</TabItem>
6879
</Tabs>
6980

@@ -100,7 +111,7 @@ fn run() {
100111
Some(vec!["--flag1", "--flag2"]),
101112
))
102113
.setup(|app| {
103-
// Get the autostart manager
114+
// 获取自动启动管理器
104115
let autostart_manager = app.autolaunch();
105116
// 启用 autostart
106117
let _ = autostart_manager.enable();
@@ -120,10 +131,9 @@ fn run() {
120131

121132
## 权限
122133

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

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

128138
```json title="src-tauri/capabilities/default.json"
129139
{
@@ -136,11 +146,4 @@ fn run() {
136146
}
137147
```
138148

139-
| 权限 | 描述 |
140-
| ---------------------------- | ------------------------------------------ |
141-
| `autostart:allow-disable` | 启用 disable 命令,不需要预先配置作用域。 |
142-
| `autostart:deny-disable` | 拒绝没有预先配置作用域的 disable 命令。 |
143-
| `autostart:allow-enable` | 启用 enable 命令,不需要预先配置作用域。 |
144-
| `autostart:deny-enable` | 拒绝使用没有预先配置作用域的 enable 命令。 |
145-
| `autostart:allow-is-enabled` | 启用没有预先配置作用域的 is_enabled 命令。 |
146-
| `autostart:deny-is-enabled` | 拒绝没有预先配置作用域的 is_enabled 命令。 |
149+
<PluginPermissions plugin={frontmatter.plugin} />

src/content/docs/zh-cn/plugin/barcode-scanner.mdx

Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ plugin: barcode-scanner
1111
import PluginLinks from '@components/PluginLinks.astro';
1212
import Compatibility from '@components/plugins/Compatibility.astro';
1313

14-
import { Tabs, TabItem } from '@astrojs/starlight/components';
14+
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
1515
import CommandTabs from '@components/CommandTabs.astro';
16+
import PluginPermissions from '@components/PluginPermissions.astro';
1617

1718
<PluginLinks plugin={frontmatter.plugin} />
1819

@@ -24,12 +25,10 @@ import CommandTabs from '@components/CommandTabs.astro';
2425

2526
## 设置
2627

27-
_这个插件要求 Rust 版本至少是 **1.64**_
28-
29-
请安装条形码扫描器插件。
28+
从安装条形码扫描器插件开始。
3029

3130
<Tabs>
32-
<TabItem label="自动">
31+
<TabItem label="自动">
3332

3433
使用项目的包管理器来添加依赖。
3534

@@ -39,44 +38,75 @@ _这个插件要求 Rust 版本至少是 **1.64**_
3938
npm="npm run tauri add barcode-scanner"
4039
yarn="yarn run tauri add barcode-scanner"
4140
pnpm="pnpm tauri add barcode-scanner"
41+
deno="deno task tauri add barcode-scanner"
4242
bun="bun tauri add barcode-scanner"
4343
cargo="cargo tauri add barcode-scanner"
4444
/>
4545

46-
</TabItem>
47-
<TabItem label="手动">
46+
</TabItem>
47+
<TabItem label="手动">
48+
<Steps>
49+
1.`src-tauri` 文件夹中运行以下命令,将插件添加到 `Cargo.toml` 中的项目依赖项中。
50+
51+
```sh frame=none
52+
cargo add tauri-plugin-barcode-scanner --target 'cfg(any(target_os = "android", target_os = "ios"))'
53+
```
54+
55+
2. 修改 `lib.rs` 来初始化插件。
56+
57+
```rust title="src-tauri/src/lib.rs" ins={5-6}
58+
#[cfg_attr(mobile, tauri::mobile_entry_point)]
59+
pub fn run() {
60+
tauri::Builder::default()
61+
.setup(|app| {
62+
#[cfg(mobile)]
63+
app.handle().plugin(tauri_plugin_barcode_scanner::init());
64+
Ok(())
65+
})
66+
.run(tauri::generate_context!())
67+
.expect("error while running tauri application");
68+
}
69+
```
70+
71+
3. 使用你喜欢的 JavaScript 包管理器安装 JavaScript Guest 绑定。
72+
73+
<CommandTabs
74+
npm="npm install @tauri-apps/plugin-barcode-scanner"
75+
yarn="yarn add @tauri-apps/plugin-barcode-scanner"
76+
pnpm="pnpm add @tauri-apps/plugin-barcode-scanner"
77+
deno="deno add npm:@tauri-apps/plugin-barcode-scanner"
78+
bun="bun add @tauri-apps/plugin-barcode-scanner"
79+
/>
80+
</Steps>
81+
</TabItem>
4882

49-
1. 运行 `cargo add tauri-plugin-barcode-scanner` 以将插件添加到 `Cargo.toml` 的项目依赖中。
83+
</Tabs>
5084

51-
2. 修改 `lib.rs` 来初始化插件。
85+
## 配置
5286

53-
```rust title="lib.rs" ins={4}
54-
#[cfg_attr(mobile, tauri::mobile_entry_point)]
55-
fn run() {
56-
tauri::Builder::default()
57-
.plugin(tauri_plugin_barcode_scanner::init())
58-
.run(tauri::generate_context!())
59-
.expect("error while running tauri application");
60-
}
61-
```
87+
在 iOS 系统中,条形码扫描插件需要 `NSCameraUsageDescription` 信息属性列表值,该值应说明您的应用为何需要使用相机。
6288

63-
3. 使用你喜欢的 JavaScript 包管理器安装 JavaScript Guest 绑定。
89+
`src-tauri/Info.ios.plist` 文件中,添加以下代码片段:
6490

65-
<CommandTabs
66-
npm="npm install @tauri-apps/plugin-barcode-scanner"
67-
yarn="yarn add @tauri-apps/plugin-barcode-scanner"
68-
pnpm="pnpm add @tauri-apps/plugin-barcode-scanner"
69-
bun="bun add @tauri-apps/plugin-barcode-scanner"
70-
/>
71-
</TabItem>
72-
</Tabs>
91+
```xml title=src-tauri/Info.ios.plist
92+
<?xml version="1.0" encoding="UTF-8"?>
93+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
94+
<plist version="1.0">
95+
<dict>
96+
<key>NSCameraUsageDescription</key>
97+
<string>Read QR codes</string>
98+
</dict>
99+
</plist>
100+
```
73101

74102
## 用法
75103

76104
条形码扫描器插件在 JavaScript 中可用。
77105

78106
```javascript
79107
import { scan, Format } from '@tauri-apps/plugin-barcode-scanner';
108+
// 当设置 `"withGlobalTauri": true` 时, 你可以使用
109+
// const { scan, Format } = window.__TAURI__.barcodeScanner;
80110

81111
// `windowed: true` 实际上将 webview 设置为透明的
82112
// 而不是为相机打开一个单独的视图
@@ -86,32 +116,18 @@ scan({ windowed: true, formats: [Format.QRCode] });
86116

87117
## 权限
88118

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

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

94123
```json title="src-tauri/capabilities/mobile.json"
95124
{
96-
"$schema": "./schemas/mobile-schema.json",
125+
"$schema": "../gen/schemas/mobile-schema.json",
97126
"identifier": "mobile-capability",
98127
"windows": ["main"],
99128
"platforms": ["iOS", "android"],
100129
"permissions": ["barcode-scanner:allow-scan", "barcode-scanner:allow-cancel"]
101130
}
102131
```
103132

104-
| 权限 | 描述 |
105-
| ------------------------------------------- | ------------------------------------------------------------- |
106-
| `barcode-scanner:allow-cancel` | 在没有预先配置作用域的情况下,启用 cancel 命令。 |
107-
| `barcode-scanner:deny-cancel` | 拒绝没有任何预先配置的作用域的 cancel 命令。 |
108-
| `barcode-scanner:allow-check-permissions` | 在没有预先配置作用域的情况下,启用 check_permissions 命令。 |
109-
| `barcode-scanner:deny-check-permissions` | 拒绝没有任何预先配置的作用域的 check_permissions 命令。 |
110-
| `barcode-scanner:allow-open-app-settings` | 在没有预先配置作用域的情况下,启用 open_app_settings 命令。 |
111-
| `barcode-scanner:deny-open-app-settings` | 拒绝没有任何预先配置的作用域的 open_app_settings 命令。 |
112-
| `barcode-scanner:allow-request-permissions` | 在没有预先配置作用域的情况下,启用 request_permissions 命令。 |
113-
| `barcode-scanner:deny-request-permissions` | 拒绝没有任何预先配置的作用域的 request_permissions 命令。 |
114-
| `barcode-scanner:allow-scan` | 在没有预先配置作用域的情况下,启用 scan 命令。 |
115-
| `barcode-scanner:deny-scan` | 拒绝没有任何预先配置的作用域的 scan 命令。 |
116-
| `barcode-scanner:allow-vibrate` | 在没有预先配置作用域的情况下,启用 vibrate 命令。 |
117-
| `barcode-scanner:deny-vibrate` | 拒绝没有任何预先配置的作用域的 vibrate 命令。 |
133+
<PluginPermissions plugin={frontmatter.plugin} />

0 commit comments

Comments
 (0)