-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #568 from hiddenblue/main
zh-CN translation add and update some translation
- Loading branch information
Showing
7 changed files
with
362 additions
and
17 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...Hans/docusaurus-plugin-content-docs/current/basics/user-interface/messagebox.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
id: messagebox | ||
title: 消息框 MessageBox | ||
--- | ||
|
||
# 消息框 | ||
|
||
目前,Avalonia 尚未提供原生的 `消息框(MessageBox)` 组件。我们正在考虑在未来开发这一功能,以不断扩展和增强我们工具包的能力。需要`消息框` 功能的开发者可以探索以下第三方解决方案。 | ||
|
||
我们邀请您参考我们在 [GitHub 仓库中的issue](https://github.com/AvaloniaUI/Avalonia/issues/670) ,以获取有关 Avalonia UI 中 MessageBox 功能的最新更新和讨论。 | ||
|
||
## 第三方 MessageBox 实现 | ||
|
||
* [Actipro Avalonia UI Controls](https://www.actiprosoftware.com/products/controls/avalonia) | ||
* [DialogHost.Avalonia](https://github.com/AvaloniaUtils/DialogHost.Avalonia) | ||
* [MessageBox.Avalonia](https://github.com/AvaloniaCommunity/MessageBox.Avalonia) |
102 changes: 102 additions & 0 deletions
102
...ocusaurus-plugin-content-docs/current/concepts/services/activatable-lifetime.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
id: activatable-lifetime | ||
title: Activatable Lifetime 可激活生命周期 | ||
--- | ||
|
||
# 可激活生命周期 <MinVersion version="11.1" /> | ||
|
||
`IActivatableLifetime` 服务定义了一组与应用程序激活和去激活生命周期相关的方法和事件。`IActivatableLifetime` 是一个全局应用程序级别的服务,可以通过 `Application` 实例使用 `TryGetService` 方法访问:`Application.Current.TryGetService<IActivatableLifetime>()`。 | ||
|
||
## 事件 | ||
|
||
### Activated | ||
|
||
当应用程序因各种原因被激活时引发的事件,这些原因由 `ActivationKind` 枚举描述。 | ||
|
||
### Deactivated | ||
|
||
当应用程序因各种原因被去激活时引发的事件,这些原因由 `ActivationKind` 枚举描述。 | ||
|
||
## 方法 | ||
|
||
### TryLeaveBackground | ||
|
||
告诉应用程序尝试离开其后台状态。如果可能并且平台支持此操作,则返回 `true`;否则返回 `false`。 | ||
|
||
:::note | ||
例如在 macOS 上是 `[NSApp unhide]`。 | ||
::: | ||
|
||
### TryEnterBackground | ||
|
||
告诉应用程序尝试进入其后台状态。如果可能并且平台支持此操作,则返回 `true`;否则返回 `false`。 | ||
|
||
:::note | ||
例如在 macOS 上是 `[NSApp hide]`。 | ||
::: | ||
|
||
## 示例 | ||
|
||
### 处理应用程序进入和退出后台状态 | ||
|
||
在某些应用程序中,您可能希望在应用程序处于后台时暂停或停止某些代码处理,比如说暂停多媒体播放或禁用周期性的 HTTP 请求。 | ||
|
||
```csharp | ||
if (Application.Current.TryGetFeature<IActivatableLifetime>() is { } activatableLifetime) | ||
{ | ||
activatableLifetime.Activated += (sender, args) => | ||
{ | ||
if (args.Kind == ActivationKind.Background) | ||
{ | ||
Console.WriteLine($"App exited background"); | ||
} | ||
}; | ||
|
||
activatableLifetime.Deactivated += (sender, args) => | ||
{ | ||
if (args.Kind == ActivationKind.Background) | ||
{ | ||
Console.WriteLine($"App entered background"); | ||
} | ||
}; | ||
} | ||
``` | ||
|
||
### 处理 URI 激活 | ||
|
||
某些应用程序可能需要支持协议激活,通常称为深度链接。注册在系统中并与应用程序关联的链接方案(协议)。一旦注册,操作系统将始终将这些链接重定向到应用程序。 | ||
|
||
应用程序可以以不同的方式处理这些链接。但典型的用例包括导航到特定页面或将其用作 [OAuth 操作中的重定向 URL](https://www.oauth.com/oauth2-servers/oauth-native-apps/redirect-urls-for-native-apps/)。 | ||
|
||
```csharp | ||
if (Application.Current.TryGetFeature<IActivatableLifetime>() is { } activatableLifetime) | ||
{ | ||
activatableLifetime.Activated += (s, a) => | ||
{ | ||
if (a is ProtocolActivatedEventArgs protocolArgs && protocolArgs.Kind == ActivationKind.OpenUri) | ||
{ | ||
Console.WriteLine($"App activated via Uri: {protocolArgs.Uri}"); | ||
} | ||
}; | ||
} | ||
``` | ||
|
||
:::note | ||
为了启用应用程序的协议处理,您需要遵循特定平台的说明更新清单。 | ||
在 macOS 和 iOS 上,您需要在 `Info.plist` 中添加带有 `CFBundleURLSchemes` 段的 `CFBundleURLTypes`。 | ||
参阅 https://rderik.com/blog/creating-app-custom-url-scheme/(跳过 Swift 部分,因为它由 `IActivatableLifetime` 处理)。 | ||
在 Android 上,您需要在 `AndroidManifest.xml` 中添加带有特定 `android:scheme` 的 `intent-filter`。参阅 https://developer.android.com/training/app-links/deep-linking 了解详细信息(跳过 Kotlin/Java 部分,因为它由 `IActivatableLifetime` 处理)。 | ||
::: | ||
|
||
## 平台兼容性: | ||
|
||
| 功能 | Windows | macOS | Linux | 浏览器 | Android | iOS | Tizen | | ||
|-----------------------|---------|-------|-------|--------|---------|-----|-------| | ||
| `ActivationKind.Background` | ✖ | ✔ | ✖ | ✔ | ✔ | ✔ | ✖ | | ||
| `ActivationKind.File` | ✖ | ✔ | ✖ | ✖ | ✔ | ✔ | ✖ | | ||
| `ActivationKind.OpenUri` | ✖ | ✔ | ✖ | ✖ | ✔ | ✔ | ✖ | | ||
| `ActivationKind.Reopen` | ✖ | ✔ | ✖ | ✖ | ✖ | ✖ | ✖ | | ||
| `TryLeaveBackground` | ✖ | ✔ | ✖ | ✖ | ✖ | ✖ | ✖ | | ||
| `TryEnterBackground` | ✖ | ✔ | ✖ | ✖ | ✔ | ✖ | ✖ | | ||
|
||
参阅 [AvaloniaUI/Avalonia#15316](https://github.com/AvaloniaUI/Avalonia/issues/15316) 以获取当前支持和不支持的平台的更多信息。 |
75 changes: 75 additions & 0 deletions
75
.../zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/input-pane.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
id: input-pane | ||
title: Input Pane 输入面板 | ||
--- | ||
|
||
# 输入面板 <MinVersion version="11.1" /> | ||
|
||
`InputPane` 允许开发者监听平台输入面板(例如,软键盘或屏幕键盘)的当前状态和边界。 | ||
|
||
`InputPane` 可以通过 `TopLevel` 或 `Window` 的实例访问,有关访问 `TopLevel` 的更多详细信息,请访问 [TopLevel](../toplevel) 页面: | ||
```cs | ||
var inputPane = TopLevel.GetTopLevel(control).InputPane; | ||
``` | ||
|
||
:::note | ||
目前Avalonia 不会根据输入面板的状态自动调整root视图和滚动位置。相反的,建议开发者使用 `IInputPane` API 并相应地调整他们的应用程序。 | ||
|
||
自动调整计划在未来的 11.* 版本中实现。 | ||
::: | ||
|
||
## 属性 | ||
|
||
### State | ||
|
||
当前输入面板状态。可能的值: | ||
- `InputPaneState.Closed` | ||
- `InputPaneState.Opened` | ||
|
||
```cs | ||
InputPaneState State { get; } | ||
``` | ||
|
||
### OccludedRect | ||
|
||
当前输入面板的边界。 | ||
|
||
```cs | ||
Rect OccludedRect { get; } | ||
``` | ||
|
||
:::note | ||
返回值是以当前顶级窗口的客户端坐标表示的。如果输入面板是浮动或分离的,并位于视图顶部,则会返回一个空矩形。 | ||
::: | ||
|
||
## 事件 | ||
|
||
### StateChanged | ||
|
||
当输入面板的状态发生变化时触发。 | ||
|
||
```cs | ||
event EventHandler<InputPaneStateEventArgs>? StateChanged; | ||
``` | ||
|
||
值得注意的是,事件参数包括几个有用的参数: | ||
- `InputPaneStateEventArgs.NewState` - 输入面板的新状态。 | ||
- `InputPaneStateEventArgs.StartRect` - 输入面板的初始边界。 | ||
- `InputPaneStateEventArgs.EndRect` - 输入面板的最终边界。 | ||
- `InputPaneStateEventArgs.AnimationDuration` - 输入面板状态变化动画的持续时间。 | ||
- `InputPaneStateEventArgs.Easing` - 输入面板状态变化动画的缓动效果。 | ||
|
||
拥有 `AnimationDuration` 和 `Easing` 允许开发者在两个状态之间创建过渡。 | ||
|
||
## 平台兼容性: | ||
|
||
| 功能 | Windows | macOS | Linux | 浏览器 | Android | iOS | Tizen | | ||
|-----------------------|---------|-------|-------|--------|---------|-----|-------| | ||
| `State` | ✔ | ✖ | ✖ | ✔* | ✔ | ✔ | ✖ | | ||
| `OccludedRect` | ✔ | ✖ | ✖ | ✔* | ✔ | ✔ | ✖ | | ||
| `StateChanged` | ✔ | ✖ | ✖ | ✔* | ✔ | ✔ | ✖ | | ||
| `StateChanged.StartRect` | ✖ | ✖ | ✖ | ✔* | ✔ | ✔ | ✖ | | ||
| `StateChanged.AnimationDuration` | ✖ | ✖ | ✖ | ✖ | ✔ | ✔ | ✖ | | ||
| `StateChanged.Easing` | ✖ | ✖ | ✖ | ✖ | ✔ | ✔ | ✖ | | ||
|
||
\* - 仅移动版 Chromium 浏览器支持 `IInputPane` API。 |
71 changes: 71 additions & 0 deletions
71
i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/services/launcher.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
id: launcher | ||
title: Launcher 启动器 | ||
--- | ||
|
||
# 启动器 <MinVersion version="11.1" /> | ||
|
||
`Launcher` 允许您在与指定参数关联的默认应用程序中打开文件或 URI 链接。 | ||
|
||
`Launcher` 可以通过 `TopLevel` 或 `Window` 的实例访问,有关访问 `TopLevel` 的更多详细信息,请访问 [TopLevel](../toplevel) 页面: | ||
```cs | ||
var launcher = TopLevel.GetTopLevel(control).Launcher; | ||
``` | ||
|
||
## 方法 | ||
|
||
### LaunchUriAsync | ||
|
||
通过指定的URI启动与URI方案(scheme)名称关联的默认应用程序。 | ||
|
||
```cs | ||
Task<bool> LaunchUriAsync(Uri uri) | ||
``` | ||
|
||
:::note | ||
输入的 URI 可以具有任何方案,也可以自定义方案。但是此启动请求被接受还是拒绝取决于操作系统。 | ||
::: | ||
|
||
### LaunchFileAsync | ||
|
||
启动与指定存储文件或文件夹关联的默认应用程序。 | ||
|
||
```cs | ||
Task<bool> LaunchFileAsync(IStorageItem storageItem); | ||
``` | ||
|
||
:::note | ||
`IStorageItem` 是从沙盒 API(如 `IStorageProvider` 或 `IClipboard`)检索的文件或文件夹。如果您只针对非沙盒桌面平台,建议使用接受 `FileInfo` 或 `DirectoryInfo` 的扩展方法。 | ||
::: | ||
|
||
## 扩展方法 | ||
|
||
### LaunchFileInfoAsync | ||
|
||
启动与指定存储文件关联的默认应用程序。 | ||
|
||
```cs | ||
Task<bool> LaunchFileInfoAsync(FileInfo fileInfo) | ||
``` | ||
|
||
### LaunchDirectoryInfoAsync | ||
|
||
启动与指定存储目录(文件夹)关联的默认应用程序。 | ||
|
||
```cs | ||
Task<bool> LaunchDirectoryInfoAsync(DirectoryInfo directoryInfo); | ||
``` | ||
|
||
:::note | ||
这些方法中的每一个都会返回一个布尔结果,指示操作系统是否可以处理请求。但这并不能保证存在可以处理启动请求的应用程序。 | ||
::: | ||
|
||
## 平台兼容性: | ||
|
||
| 功能 | Windows | macOS | Linux | 浏览器 | Android | iOS | Tizen | | ||
|-----------------------|---------|-------|-------|--------|---------|-----|-------| | ||
| `LaunchUriAsync` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | ||
| `LaunchFileAsync` | ✔ | ✔ | ✔ | ✖ | ✔ | ✔ | ✔ | | ||
| `LaunchFileInfoAsync` | ✔ | ✔ | ✔ | ✖ | ✖ | ✖ | ✖ | | ||
| `LaunchDirectoryInfoAsync` | ✔ | ✔ | ✔ | ✖ | ✖ | ✖ | ✖ | | ||
``` |
23 changes: 19 additions & 4 deletions
23
...ontent-docs/current/guides/implementation-guides/how-to-use-the-mvvm-pattern.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
--- | ||
id: how-to-use-the-mvvm-pattern | ||
title: How To Use the MVVM Pattern | ||
title: 如何使用 MVVM 模式 | ||
--- | ||
|
||
|
||
# How To Use the MVVM Pattern | ||
# 如何使用 MVVM 模式 | ||
|
||
Content in preparation. | ||
<HelpNeeded/> | ||
|
||
与此同时,请参阅以下内容: | ||
|
||
|
||
Tutorials -> | ||
<CardSection | ||
id="sections" | ||
> | ||
<Card | ||
title="MVVM 模式" | ||
to="/docs/concepts/the-mvvm-pattern/" | ||
description="对 MVVM 模式的介绍" | ||
/> | ||
<Card | ||
title="如何使用 INotifyPropertyChanged" | ||
to="/docs/guides/data-binding/inotifypropertychanged" | ||
description="查看 MVVM 当中最重要的接口" | ||
/> | ||
|
||
</CardSection> |
46 changes: 43 additions & 3 deletions
46
...ns/docusaurus-plugin-content-docs/current/guides/implementation-guides/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
--- | ||
id: index | ||
title: Implementation Guides | ||
title: 实现指南 | ||
--- | ||
|
||
|
||
# Implementation Guides | ||
# 实现指南 | ||
|
||
These guides show you how to use various implementation architectures and techniques with _Avalonia UI_. | ||
这些指南展示了如何用Avalonia UI使用各种架构实现和技术。 | ||
|
||
<CardSection | ||
id="sections" | ||
> | ||
<Card | ||
title="如何使用 MVVM 模式" | ||
to="/docs/guides/implementation-guides/how-to-use-the-mvvm-pattern" | ||
description="使用 Model, View, ViewModel 架构开发应用的指南。" | ||
/> | ||
<Card | ||
title="如何实现依赖注入" | ||
to="/docs/guides/implementation-guides/how-to-implement-dependency-injection" | ||
description="了解如何在应用中使用依赖注入 (DI) 的指南。" | ||
/> | ||
<Card | ||
title="开发者工具" | ||
to="/docs/guides/implementation-guides/developer-tools" | ||
description="学习如何调试应用的视觉效果。" | ||
/> | ||
<Card | ||
title="如何记录错误和警告" | ||
to="/docs/guides/implementation-guides/logging-errors-and-warnings" | ||
description="本指南展示了如何在 Avalonia 中记录警告和错误。" | ||
/> | ||
<Card | ||
title="如何使用实时预览" | ||
to="/docs/guides/implementation-guides/ide-support" | ||
description="本指南将展示如何使用 Avalonia UI IDE 扩展的实时预览功能。" | ||
/> | ||
<Card | ||
title="如何使用设计时数据" | ||
to="/docs/guides/implementation-guides/how-to-use-design-time-data" | ||
description="学习如何使用设计时数据,避免构建整个应用。" | ||
/> | ||
<Card | ||
title="使用ResX进行本地化" | ||
to="/docs/guides/implementation-guides/localizing" | ||
description="学习如何使用 ResX 本地化应用。" | ||
/> | ||
</CardSection> |
Oops, something went wrong.