diff --git a/.vitepress/i18n/zh/BasicSideBar.ts b/.vitepress/i18n/zh/BasicSideBar.ts index ef309ec..c068924 100644 --- a/.vitepress/i18n/zh/BasicSideBar.ts +++ b/.vitepress/i18n/zh/BasicSideBar.ts @@ -2,27 +2,27 @@ import { DefaultTheme } from "vitepress"; export const BasicSideBar: DefaultTheme.SidebarItem[] = [ { - text: "Basic", + text: "简介", link: "/docs/basic", items: [ - { text: "Quick Start", link: "/docs/basic/quick-start" }, - { text: "Simple Project", link: "/docs/basic/simple-project" }, + { text: "快速开始", link: "/docs/basic/quick-start" }, + { text: "从 0 新建项目", link: "/docs/basic/simple-project" }, ], }, { - text: "Cli", + text: "脚手架", collapsed: false, items: [ - { text: "Init", link: "/docs/cli/init" }, - { text: "Build", link: "/docs/cli/build" }, - { text: "Artifact", link: "/docs/cli/artifact" }, + { text: "init", link: "/docs/cli/init" }, + { text: "build", link: "/docs/cli/build" }, + { text: "artifact", link: "/docs/cli/artifact" }, ], }, { - text: "Usage", + text: "用法", collapsed: false, items: [ - { text: "Basic", link: "/docs/usage/basic" }, + { text: "基本用法", link: "/docs/usage/basic" }, { text: "Task", link: "/docs/usage/task" }, { text: "ThreadSafeFunction", link: "/docs/usage/tsfn" }, ], @@ -35,8 +35,8 @@ export const BasicSideBar: DefaultTheme.SidebarItem[] = [ { text: "More", items: [ - { text: "F & Q", link: "/docs/more/f&q" }, - { text: "Known issue", link: "/docs/more/known-issue" }, + { text: "常见问题", link: "/docs/more/f&q" }, + { text: "已知问题", link: "/docs/more/known-issue" }, { text: "EMU-TLS", link: "/docs/more/emu-tls" }, ], }, diff --git a/.vitepress/i18n/zh/Ecosystem.ts b/.vitepress/i18n/zh/Ecosystem.ts index 7288169..f09bcc0 100644 --- a/.vitepress/i18n/zh/Ecosystem.ts +++ b/.vitepress/i18n/zh/Ecosystem.ts @@ -16,7 +16,7 @@ export const EcosystemSideBar: DefaultTheme.SidebarItem[] = [ ], }, { - text: "Native-binding", + text: "原生模块绑定", collapsed: false, items: [ { text: "hilog", link: "/ecosystem/binding/hilog" }, @@ -31,7 +31,7 @@ export const EcosystemSideBar: DefaultTheme.SidebarItem[] = [ ], }, { - text: "Third-Party", + text: "第三方能力", collapsed: false, items: [ { text: "OpenSSL", link: "/ecosystem/third/openssl" }, diff --git a/.vitepress/i18n/zh/index.ts b/.vitepress/i18n/zh/index.ts index a395723..c498679 100644 --- a/.vitepress/i18n/zh/index.ts +++ b/.vitepress/i18n/zh/index.ts @@ -30,7 +30,7 @@ export const zh = defineConfig({ editLink: { pattern: "https://github.com/ohos-rs/ohos-rs.github.io/tree/master/src/:path", - text: "编辑本页", + text: "帮助我们改进本页面内容", }, lastUpdated: { text: "最新更新于", diff --git a/src/docs/basic.md b/src/docs/basic.md index 5a3b430..7dc973b 100644 --- a/src/docs/basic.md +++ b/src/docs/basic.md @@ -1,21 +1,21 @@ --- editLink: true --- -> [!IMPORTANT] Star -> **If you find this project helpful, we'd appreciate it if you could give us a [star](https://github.com/ohos-rs/ohos-rs). Thank you!** +> [!IMPORTANT] ✨ +> **如果该项目对您有一定的帮助,请不吝给我们点一个 [star](https://github.com/ohos-rs/ohos-rs)。非常感谢!** -## What's the `ohos-rs`? +## 什么是 `ohos-rs`? -The runtime of HarmonyOS is very similar to Node.js, but there are slight differences in some logic, so it forked the code of [napi-rs](https://github.com/napi-rs/napi-rs) and made some modifications. The overall functions are basically aligned with napi-rs. +OpenHarmony 目前底层的运行机制与 Node.js 十分相像,但是在一些小的方面有一些差异。因此我们基于 [napi-rs](https://github.com/napi-rs/napi-rs) 做了一些处理,使得基本上在鸿蒙上可用并且用法基本对齐。 ::: danger -The project is in the development stage, and some capabilities may have problems, please use with caution. +目前项目处于开发阶段,请谨慎使用! ::: -## Simple example +## 一个简单的 🌰 -We can write a simple function called `add`. +现在我们可以基于 ohos-rs 实现一个简单的函数,其名为 `add` ```rs use napi_derive_ohos::napi; @@ -27,7 +27,7 @@ pub fn add(left: u32, right: u32) -> u32 { ``` -In HarmonyOS, we can call it with some code. +在鸿蒙上层的 ArkTS 里可以像下面这样调用: ```ts import basic from 'libadd.so'; diff --git a/src/docs/basic/quick-start.md b/src/docs/basic/quick-start.md index a0a1a11..29d4a50 100644 --- a/src/docs/basic/quick-start.md +++ b/src/docs/basic/quick-start.md @@ -2,70 +2,63 @@ editLink: true --- -# Quick Start +# 快速开始 -We provide a cli tool to simplify some action. For example: `init`, `build` and so on. +我们基于 Rust 实现了一个简单的脚手架工具,提供了类似于初始化,构建等命令。 -We will now begin to introduce this capability step by step. +我们现在开始一步步介绍如何基于 ohos-rs 开发一个鸿蒙原生模块。 -## Requirement +## 环境准备 -Before all, we need to install `Rust` and `HarmonyOS NDK`. +在开始之前,我们需要安装 `Rust` 和 `HarmonyOS NDK`. ### Rust -For rust, we can use official guide to install it. +对于 Rust 来说,我们可以直接使用官方提供的安装脚本来实现安装。 ```shell curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ::: tip 🌈 -For more detail about rust, you can visit [link](https://www.rust-lang.org/learn/get-started) +1. 你需要确保你安装的 Rust 版本是 >= 1.78.0 的 +2. 更多关于 Rust 的信息和知识点,你可以访问 [link](https://www.rust-lang.org/learn/get-started) ::: -And then we need to install some toolchain and component, which will help use to build prebuild binary for HarmonyOS. +然后我们需要安装一些 Rust 的 toolchain 来帮助我们构建鸿蒙的原生模块。 -1. **nightly toolchain** - - OpenHarmony is `tier3` target for rust, so we must use custom toolchain or use source-code to build it. - Just run this command and set toolchain to `nightly` - ```shell - rustup default nightly - ``` -2. **rust-std** - - Then we need to install source code. Just run this command - ```shell - rustup component add rust-src - ``` +```shell +rustup target add aarch64-unknown-linux-ohos +rustup target add armv7-unknown-linux-ohos +rustup target add x86_64-unknown-linux-ohos +``` ### HarmonyOS NDK ::: tip -For the latest SDK Version, You need `DevEco Studio NEXT Developer Beta1 (5.0.3.100)` or later. +对于最新的 ohos-rs 版本,鸿蒙 NDK 的版本需要是 `DevEco Studio NEXT Developer Beta1 (5.0.3.100)` 或者更新. ::: -You just need to download the latest `DevEco-Studio` and download the latest SDK. You can download it with [official website](https://developer.huawei.com/consumer/cn/deveco-studio/) +你只需要下载最新的 `DevEco-Studio` 然后安装对应的 NDK 即可. 你可以在 [官方网站](https://developer.huawei.com/consumer/cn/deveco-studio/) 找到并且下载。 -## Install +## 安装 -Now, you can install cli tool with `cargo`. +现在你可以用 `cargo` 来安装脚手架工具了。 ```shell cargo install ohrs ``` -## Simple Project +## 简单的项目示例 -Using `ohrs` to init project +使用 `ohrs` 来初始化项目。 ```shell ohrs init hello ``` -And using `ohrs` to build project +之后使用 `ohrs` 来构建项目 ```shell -ohrs build.md -``` +ohrs build +``` \ No newline at end of file