Skip to content

Commit 60152d1

Browse files
committed
docs: Rework documentation structure, update SDK and REST API content, and add new guides and blog posts.
1 parent 6bbf587 commit 60152d1

1,550 files changed

Lines changed: 133330 additions & 137852 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/auto-assign-issue.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
- name: Assign the issue
1818
run: |
19-
export LETASE_MILESTONES=$(curl 'https://api.github.com/repos/$OWNER/$PEPO/milestones' | jq -r 'last(.[]).title')
19+
export LETASE_MILESTONES=$(curl 'https://api.github.com/repos/$OWNER/$REPO/milestones' | jq -r 'last(.[]).title')
2020
gh issue edit ${{ github.event.issue.number }} --add-assignee "${{ github.event.comment.user.login }}"
2121
gh issue edit ${{ github.event.issue.number }} --add-label "accepted"
2222
gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you. I set the milestones for this issue to [$LETASE_MILESTONES](https://github.com/$OWNER/$PEPO/milestones), We are looking forward to your PR!"

.github/workflows/build-ci.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,34 @@ name: Documentation Deployment
33
on:
44
push:
55
branches:
6-
- main # Trigger the action on push events to the main branch
7-
6+
- main
87

98
jobs:
109
build_and_deploy:
1110
runs-on: ubuntu-latest
1211

1312
steps:
1413
- name: Checkout repository
15-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1615

1716
- name: Setup Node.js
18-
uses: actions/setup-node@v2
17+
uses: actions/setup-node@v4
1918
with:
2019
node-version: '18'
2120

21+
- name: Install pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 9
25+
2226
- name: Install dependencies
23-
run: npm install
27+
run: pnpm install --frozen-lockfile
2428

2529
- name: Build documentation
26-
run: npm run build
30+
run: pnpm build
2731

2832
- name: Deploy to GitHub Pages
29-
uses: peaceiris/actions-gh-pages@v3
33+
uses: peaceiris/actions-gh-pages@v4
3034
with:
3135
github_token: ${{ secrets.GITHUB_TOKEN }}
3236
publish_dir: ./build

.github/workflows/main-ci.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Pull Request Checks
33
on:
44
pull_request:
55
branches:
6-
- main # Trigger the action on pull requests to the main branch
6+
- main
77

88
jobs:
99
test:
@@ -16,18 +16,23 @@ jobs:
1616
- name: Setup Node.js
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: 'latest'
19+
node-version: '18'
20+
21+
- name: Install pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 9
2025

2126
- name: Install dependencies
22-
run: npm install
27+
run: pnpm install --frozen-lockfile
2328

2429
- name: Build documentation
25-
run: npm run build
30+
run: pnpm build
2631

2732
- name: Lint check
28-
run: npm run lint
33+
run: pnpm lint
2934
continue-on-error: true
3035

3136
- name: Type checking
32-
run: npm run typecheck
37+
run: pnpm typecheck
3338
continue-on-error: true

.github/workflows/release.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

AGENTS.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# OpenIM Docs - Codex Agent Instructions
2+
3+
## Project Overview
4+
5+
This is the OpenIM documentation site built with Docusaurus. It supports two locales:
6+
- **zh-Hans** (Chinese, default): Source files in `docs/`
7+
- **en** (English): Translated files in `i18n/en/`
8+
9+
## Translation Task
10+
11+
When asked to translate documentation, follow the rules below.
12+
13+
### Path Mapping
14+
15+
| Source (Chinese) | Target (English) |
16+
|-----------------|------------------|
17+
| `docs/sdks/` | `i18n/en/docusaurus-plugin-content-docs-sdks/current/` |
18+
| `docs/guides/` | `i18n/en/docusaurus-plugin-content-docs-guides/current/` |
19+
| `docs/restapi/` | `i18n/en/docusaurus-plugin-content-docs-restapi/current/` |
20+
| `docs/blog/` | `i18n/en/docusaurus-plugin-content-docs-blog/current/` |
21+
22+
### Translation Rules
23+
24+
1. **Keep unchanged**:
25+
- All code blocks (` ``` `) content
26+
- Frontmatter keys (only translate Chinese values like `title`, `description`)
27+
- JSX/MDX component tags (`<Tabs>`, `<TabItem>`, etc.)
28+
- Markdown link paths and URLs
29+
- Variable names, function names, class names
30+
- Import statements
31+
32+
2. **Translate**:
33+
- All Chinese text content to natural English
34+
- Table headers and cell content (Chinese → English)
35+
- Section headings (e.g., `## 功能介绍``## Description`)
36+
- Inline comments in code examples (Chinese → English)
37+
38+
3. **Common translations** (keep consistent across all files):
39+
- 功能介绍 → Description
40+
- 返回原型 → Return Prototype
41+
- 返回结果 → Return Results
42+
- 调用示例 → Call Example
43+
- 名称 → Name
44+
- 类型 → Type
45+
- 描述 → Description
46+
47+
### Sidebar Labels
48+
49+
Sidebar category labels for each docs plugin are translated in **two places**:
50+
51+
1. **`_category_.json`** files in the corresponding `i18n/en/` directory
52+
2. **`current.json`** files at `i18n/en/docusaurus-plugin-content-docs-*/current.json`
53+
54+
For `current.json`:
55+
- The **key** stays the same (may contain Chinese category name as identifier)
56+
- Only the **`message`** field should be translated to English
57+
- The **`description`** field should also be updated to reflect the English label
58+
59+
Example:
60+
```json
61+
{
62+
"sidebar.tutorialSidebar.category.用户管理": {
63+
"message": "User Management",
64+
"description": "The label for category 'User Management' in sidebar 'tutorialSidebar'"
65+
}
66+
}
67+
```
68+
69+
### New Category Handling
70+
71+
If a new `_category_.json` is added in the source `docs/` directory:
72+
1. Create the corresponding `_category_.json` in `i18n/en/` with translated `label`
73+
2. Run `npx docusaurus write-translations --locale en` to regenerate `current.json`
74+
3. Translate any new Chinese entries in `current.json`
75+
76+
## Verification
77+
78+
After translating, verify:
79+
1. No Chinese characters remain in translated `message` values
80+
2. Build succeeds: `pnpm build`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"key": "architectural-browser",
3+
"label": "Browser"
4+
}

docs/blog/client/architectural/Browser/wasm-client-sdk-introduction.mdx renamed to docs/blog/client/architectural/Browser/wasm-client-sdk-introduction.md

File renamed without changes.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
title: Electron Demo 的快速编译与启动
3+
hide_title: false
4+
sidebar_position: 1
5+
---
6+
7+
## 前言
8+
9+
本文将带你从零开始,快速搭建并运行一个基于 OpenIMSDK 的 Electron 应用。本项目以 OpenIMSDK 开源版为基础,借助 [`@openim/electron-client-sdk`](https://www.npmjs.com/package/@openim/electron-client-sdk)[`@openim/wasm-client-sdk`](https://www.npmjs.com/package/@openim/wasm-client-sdk),能够同时构建 Web 端及桌面端(Windows、macOS、Linux)的即时通讯应用。如果你想要替换 Twilio 或 Sendbird 等第三方云通信服务,借助 OpenIMSDK 可大幅减少部署成本,完全掌握数据安全与隐私。
10+
11+
## 1. 背景介绍
12+
13+
OpenIMSDK 是一款开源的即时通讯 SDK,与市面上一些收费的云通信服务(如 Twilio、Sendbird)不同,OpenIMSDK 让开发者能够自行掌控服务端部署与数据,适合对安全性、可控性有较高要求的业务场景。基于 OpenIMSDK,可以轻松开发微信、Slack、Zoom 类似的即时通讯、语音视频通话等应用。
14+
15+
import demo_preview from './assets/demo_preview.png'
16+
17+
<p align="center">
18+
<img src={demo_preview} alt="预览图" width="80%"/>
19+
</p>
20+
21+
## 2. 环境准备
22+
23+
系统要求:
24+
- Windows 10 及以上
25+
- macOS 10.15 及以上
26+
- Linux 22.04 及以上
27+
28+
开发依赖:
29+
- Node.js ≥ 16.x([官网下载](https://nodejs.org)[nvm](https://github.com/nvm-sh/nvm)
30+
- npm ≥ 6.x(随 Node.js 一起安装)
31+
- Git(代码版本管理)
32+
33+
[提前部署](https://docs.openim.io/zh-Hans/guides/gettingStarted/dockerCompose)好最新版本的 **OpenIM Server**,确保本地可正常与服务端通信。
34+
35+
## 3. 获取示例项目
36+
37+
首先,使用 Git 拉取示例项目代码:
38+
39+
```bash
40+
git clone https://github.com/openimsdk/openim-electron-demo.git
41+
cd openim-electron-demo
42+
```
43+
44+
## 4. 安装依赖
45+
46+
在项目根目录执行:
47+
48+
```bash
49+
npm install
50+
```
51+
52+
> 等待所有依赖安装完成。
53+
54+
## 5. 配置环境变量
55+
56+
打开项目根目录下的 .env 文件,按需修改其中的主机地址或域名配置。
57+
58+
例如,如果你的服务器 IP 为 123.45.67.89 且没有修改过服务端端口,可以这样配置:
59+
60+
```bash
61+
VITE_BASE_HOST=123.45.67.89
62+
63+
VITE_WS_URL=ws://$VITE_BASE_HOST:10001
64+
VITE_API_URL=http://$VITE_BASE_HOST:10002
65+
VITE_CHAT_URL=http://$VITE_BASE_HOST:10008
66+
67+
# VITE_BASE_DOMAIN=your-server-domain
68+
69+
# VITE_WS_URL=wss://$VITE_BASE_DOMAIN/msg_gateway
70+
# VITE_API_URL=https://$VITE_BASE_DOMAIN/api
71+
# VITE_CHAT_URL=https://$VITE_BASE_DOMAIN/chat
72+
```
73+
74+
> 如果你使用域名和 HTTPS(需要 nginx 配置),则取消注释带有 VITE_BASE_DOMAIN 的部分,并将 VITE_BASE_DOMAIN 修改为你的域名。同时,根据部署情况,配置正确的 wss:// 和 https:// 地址。
75+
76+
## 6. 本地启动
77+
78+
执行以下命令即可启动开发服务器和 Electron 应用:
79+
80+
```bash
81+
npm run dev
82+
```
83+
84+
> 如果你仅需要在浏览器访问,则可以在控制台看到本地服务地址(例如 <http://localhost:5173>)。
85+
> 同时,Electron 打包的桌面应用也会自动运行,方便你在桌面环境下进行调试。
86+
87+
## 7. 音视频通话
88+
89+
开源版 OpenIM 默认支持一对一的音视频通话功能。要使用此功能,需要在服务端安装并配置音视频服务,详情可参考[官方文档](https://github.com/openimsdk/chat/blob/main/HOW_TO_SETUP_LIVEKIT_SERVER.md)。如果你有多人音视频和视频会议需求,可以联系官方邮箱 `contact@openim.io` 获取更多支持。
90+
91+
> **注意 ⚠️**:如果要在 Web 端调用音视频功能,需在 localhost 或 HTTPS 环境下进行,以确保满足浏览器安全策略的限制要求。
92+
93+
## 8. 生产环境构建
94+
95+
### 8.1 构建 Web 版本
96+
97+
如需将 Web 版本部署到服务器,请执行:
98+
99+
```bash
100+
npm run build
101+
```
102+
103+
生成后的静态文件会位于 dist 目录下,然后将其上传到你的 Web 服务器或使用 nginx 等服务进行托管即可。
104+
105+
### 8.2 构建 Electron 版本
106+
107+
1. 将 package_electron.json 文件内容替换到 package.json,这样可以去掉仅在 Web 环境需要的依赖包,减少桌面版本应用的体积。
108+
2. 执行以下命令进行对应平台的打包:
109+
110+
• macOS:
111+
112+
```bash
113+
npm run build:mac
114+
```
115+
116+
• Windows:
117+
118+
```bash
119+
npm run build:win
120+
```
121+
122+
• Linux:
123+
124+
```bash
125+
npm run build:linux
126+
```
127+
128+
> **注意 ⚠️**:在 macOS 上可以打包 Windows 和 Linux 版本应用程序,但在 Windows 和 Linux系统下只能打包对应系统的应用程序。
129+
130+
3. 打包完成后,生成的安装包/可执行文件会位于 release 目录下。
131+
132+
## 9. 常见问题与解决方案
133+
134+
Q1:正式部署发布到 Web 端时,出现报错:WASM: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'
135+
A:参考官方 [nginx配置](https://docs.openim.io/zh-hans/guides/gettingstarted/nginxdomainconfig#2-%E5%9F%9F%E5%90%8D%E9%85%8D%E7%BD%AE%E6%A8%A1%E6%9D%BF-)文件,重点在于`default_type application/wasm`
136+
137+
Q2:正式部署发布到 Web 端时,wasm 加载过慢怎么办?
138+
A:建议采用 gzip 或其他压缩方式优化 wasm 文件的体积,同时可以将其托管至 CDN,以获得更快的加载速度。
139+
140+
Q3:CKEditorError: ckeditor-duplicated-modules
141+
A:通常是依赖冲突导致,可尝试运行 npm dedupe 整理依赖后再次启动或构建。
142+
143+
## 10. 结语
144+
145+
通过本篇博客的指引,你应该已经能够在本地快速运行 OpenIMSDK 的 Electron 示例项目,并且对 Web 与 Electron 两种构建方式都能有一定认识。OpenIMSDK 为你提供了灵活度与可控性,希望能为你的项目带来更安全、可靠和低成本的实时通信解决方案。
146+
147+
如果你在使用或部署的过程中遇到问题,欢迎在 [GitHub Issues](https://github.com/openimsdk/openim-electron-demo/issues) 中与社区交流,或者直接联系官方获取更多支持。
148+
149+
更多资源
150+
• [OpenIMSDK 官网](https://www.openim.io)
151+
• [OpenIMSDK 官方文档](https://docs.openim.io)
152+
• [GitHub 仓库](https://github.com/openimsdk)

0 commit comments

Comments
 (0)