Skip to content

Commit e4c5a2e

Browse files
author
zhaoyiming
committed
First blood
0 parents  commit e4c5a2e

File tree

23,002 files changed

+2506366
-0
lines changed

Some content is hidden

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

23,002 files changed

+2506366
-0
lines changed

CONTRIBUTING.md

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Authing doc 贡献指南
2+
3+
贡献新文档或者修改时建议 Fork 项目后,提交 PR 合并到主分支。
4+
5+
## 环境准备
6+
7+
- [VS Code](https://code.visualstudio.com/)
8+
- [Source Tree](https://www.sourcetreeapp.com/) 或者 Github [桌面客户端](https://desktop.github.com/)
9+
- Node.js 16.x [长期支持版本](https://nodejs.org/)
10+
11+
本地调试,在 VS Code 终端中安装环境依赖:
12+
13+
```bash
14+
# 只需要全局安装一次
15+
npm i -g yarn
16+
# 安装依赖,可以每次更新代码时都跑一遍,如果没有新的依赖项则秒结束
17+
yarn
18+
# 运行本项目
19+
yarn docs:dev
20+
# CTRL + C 停止,重新执行再次启动,不要重复启动多个
21+
```
22+
23+
## 编译、热更新过慢
24+
25+
本地调试时,可以针对性的移动 `docs/xxx` 目录,到 `demo/xxx` 下,然后调试的时候编译就会非常快,在提交代码之前把移动的文件夹再都放回来即可。
26+
27+
docs 目录中需要一直保持的核心文件夹:
28+
29+
```bash
30+
.vuepress
31+
common
32+
images
33+
```
34+
35+
其他根据当前需要调试的章节保留一个目录即可。
36+
37+
---
38+
39+
## 使用
40+
41+
```bash
42+
# start dev server
43+
npm run docs:dev
44+
45+
# delete cache then build
46+
npm run docs:no-cache
47+
48+
# build to static HTMLs in docs/.vuepress/dist
49+
npm run docs:build
50+
```
51+
52+
## 常用组件
53+
54+
`page-ref`:
55+
56+
```bash
57+
# 普通 md: 绝对路径
58+
59+
::: page-ref /quickstart/hello-world.md
60+
:::
61+
62+
# README.md 可省略
63+
::: page-ref /scan-qrcode/wxapp-qrcode/
64+
:::
65+
66+
```
67+
68+
`embed`:
69+
70+
```bash
71+
::: embed
72+
[title](link)
73+
:::
74+
```
75+
76+
`hints`:
77+
78+
```bash
79+
::: hint-success
80+
text
81+
:::
82+
83+
::: hint-info
84+
::: hint-warning
85+
::: hint-danger
86+
```
87+
88+
`tabs`:
89+
```bash
90+
:::: tabs :options="{ useUrlFragment: false }"
91+
::: tab React
92+
93+
:::
94+
95+
::: tab Vue2
96+
97+
:::
98+
99+
::: tab Vue3
100+
101+
:::
102+
103+
::: tab Angular
104+
105+
:::
106+
::::
107+
```
108+
109+
`api-method`:
110+
111+
````markdown
112+
<!-- 组件的 prop 都可以用 slot 代替,纯字符串时可以用 prop,有 Markdown 时用 slot -->
113+
114+
<ApiMethodSpec method="get" host="https://core.authing.cn" path="/oauth/me" summary="使用 access_token 换取用户信息">
115+
<template slot="queryParams">
116+
<ApiMethodParam name="access_token" type="string" required description="access_token" />
117+
</template>
118+
<template slot="response">
119+
<ApiMethodResponse httpCode="200" description="请求结果">
120+
121+
```json
122+
{
123+
"a": "1"
124+
}
125+
```
126+
127+
</ApiMethodResponse>
128+
</template>
129+
</ApiMethodSpec>
130+
````
131+
132+
## 插值
133+
134+
按 vue 语法使用插值,可以在具体 md 文件的头部定义,也可使用全局变量(即 config 中的所有配置),常用的全局插值如下:
135+
136+
- \$localeConfig.brandName,品牌名,如 Authing
137+
- \$themeConfig.apiDomain,api 地址
138+
- \$themeConfig.sampleAppDomain,体验地址
139+
- \$themeConfig.consoleDomain,控制台地址
140+
141+
## 注意!!!
142+
143+
写好的文档发布完后要去线上看一眼,刷新页面,然后点击菜单看能否跳到其他页面。很多情况会报以下错,会导致后续 vue 代码无法执行,跳转不了页面:
144+
145+
```
146+
DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.
147+
```
148+
149+
### 加粗内容不能有中文标点符号
150+
151+
### 链接无法加粗
152+
153+
如:
154+
155+
```markdown
156+
[**百度**](https://baidu.com)
157+
**[百度](https://baidu.com)**
158+
```
159+
160+
都会导致报错,可用如下方法实现
161+
162+
```html
163+
<a class="strong" href="https://baidu.com" target="_blank">百度</a>
164+
```
165+
166+
## 更新 SDK v5 文档
167+
168+
- 1、执行文档生成 Github Actions: https://github.com/Authing/authing-docs-factory/actions
169+
- 2、执行脚本: `sh sdk-v5.sh`
170+
- 3、如有内容更新需要调整边栏,手动复制 Sidebar 配置到对应注释说明位置
171+
- 4、提交代码更新

Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# FROM node:12.14.0 as PATH_IMAGE
2+
# ENV NODE_OPTIONS=--max_old_space_size=5120
3+
# WORKDIR /app
4+
# COPY package.json .
5+
# RUN yarn --registry https://registry.npm.taobao.org/
6+
# COPY . .
7+
# RUN npm run docs:build
8+
9+
FROM nginx:alpine
10+
COPY docs/.vuepress/dist /docs
11+
COPY docs/.vuepress/dist /docs/v2
12+
COPY nginx.conf /etc/nginx/conf.d/default.conf
13+
EXPOSE 80

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Authing
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README-zh_CN.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div align=center>
2+
<img width="250" src="https://files.authing.co/authing-console/authing-logo-new-20210924.svg" />
3+
</div>
4+
5+
<div align="center">
6+
<a href="https://forum.authing.cn/" target="_blank"><img src="https://img.shields.io/badge/chat-forum-blue" /></a>
7+
<a href="javascript:;"><img src="https://img.shields.io/badge/License-MIT-success" alt="License"></a>
8+
</div>
9+
10+
[English](./README.md) | 简体中文
11+
12+
Authing 开发者文档 [docs.authing.cn](https://docs.authing.cn/v2/) 源码。
13+
14+
<div align="center">
15+
<img width="650" alt="image" src="https://user-images.githubusercontent.com/1890238/183325636-763a692d-77e1-4c41-a09f-10121ea4b006.png">
16+
</div>
17+
18+
19+
20+
## Questions
21+
22+
如果需要在线技术支持,可访问[官方论坛](https://forum.authing.cn/). 此仓库的 issue 仅用于上报 Bug 和提交新功能特性。
23+
24+
25+
## 开源共建
26+
27+
参考[贡献指南](https://github.com/Authing/.github/blob/main/CONTRIBUTING.md)
28+
29+
## 开源许可
30+
31+
[MIT](https://opensource.org/licenses/MIT)
32+
33+
Copyright (c) 2019 Authing

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div align=center>
2+
<img width="250" src="https://files.authing.co/authing-console/authing-logo-new-20210924.svg" />
3+
</div>
4+
5+
<div align="center">
6+
<a href="https://forum.authing.cn/" target="_blank"><img src="https://img.shields.io/badge/chat-forum-blue" /></a>
7+
<a href="javascript:;"><img src="https://img.shields.io/badge/License-MIT-success" alt="License"></a>
8+
</div>
9+
10+
English | [简体中文](./README-zh_CN.md)
11+
12+
Document source for Authing [docs.authing.cn](https://docs.authing.cn/v2/).
13+
14+
<div align="center">
15+
<img width="650" alt="image" src="https://user-images.githubusercontent.com/1890238/183325636-763a692d-77e1-4c41-a09f-10121ea4b006.png">
16+
</div>
17+
18+
## Questions
19+
20+
For questions and support please use the [official forum](https://forum.authing.cn/). The issue list of this repo is exclusively for bug reports and feature requests.
21+
22+
## Contribution
23+
24+
See [CONTRIBUTING Guide](https://github.com/Authing/.github/blob/main/CONTRIBUTING.md).
25+
26+
## License
27+
28+
[MIT](https://opensource.org/licenses/MIT)
29+
30+
Copyright (c) 2019 Authing
31+

build-docs-v2-prod.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# 本地 build 文档并上传 docker 仓库和 OSS
3+
./.env
4+
VERSION=$(cat version.txt)
5+
PUBLIC_URL=//cdn.authing.co/authing-docs-v2/${VERSION}/
6+
OSS_URL=authing-cdn-cn-prod
7+
OSS_REGION=oss-cn-beijing.aliyuncs.com
8+
# 构建文档
9+
PUBLIC_URL=$PUBLIC_URL yarn docs:build
10+
# 上传产物到 docker
11+
docker build -t authing:docs-new .
12+
docker login -u ${DOCKER_REPO_USERNAME} -p ${DOCKER_REPO_PASSWORD} ${DOCKER_REPO_HOST}
13+
docker tag authing:docs-new registry.cn-beijing.aliyuncs.com/authing-next/authing-docs-v2:${VERSION}
14+
docker push registry.cn-beijing.aliyuncs.com/authing-next/authing-docs-v2:${VERSION}
15+
# 上传静态文件到 OSS
16+
ossutil --access-key-id ${ALIYUN_ACCESS_KEY} --access-key-secret ${ALIYUN_ACCESS_KEY_SECRET} -e ${OSS_REGION} cp -r -f docs/.vuepress/dist oss://${OSS_URL}/authing-docs-v2/${VERSION}/
17+
echo "完成"

compress.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const cluster = require("cluster");
2+
const { cpus } = require("os");
3+
const { execSync } = require("child_process");
4+
const path = require("path");
5+
const fs = require("fs");
6+
7+
const numCPUs = 1; //cpus().length;
8+
9+
function compress(file, index) {
10+
console.log(`${index}: Compressing ${file}`);
11+
const statsOrigin = fs.statSync(file);
12+
13+
// 需要先安装 https://pngquant.org/ 命令行工具
14+
execSync(`cp "${file}" "${file}.bak"`, { encoding: "utf-8" });
15+
// execSync(`sips --resampleWidth 1920 "${file}"`, { encoding: "utf-8" });
16+
execSync(`pngquant "${file}"`, { encoding: "utf-8" });
17+
18+
const statsCompress = fs.statSync(file.replace(".png", "-fs8.png"));
19+
if (statsOrigin.size > statsCompress.size) {
20+
execSync(`rm -rf "${file}"`);
21+
execSync(`mv "${file.replace(".png", "-fs8.png")}" "${file}"`);
22+
execSync(`chmod 755 "${file}"`);
23+
execSync(`rm -rf "${file}.bak"`);
24+
} else {
25+
execSync(`rm -rf "${file.replace(".png", "-fs8.png")}"`);
26+
execSync(`rm -rf "${file}"`);
27+
execSync(`mv "${file}.bak" "${file}"`);
28+
}
29+
execSync("sleep 0.2");
30+
}
31+
32+
if (cluster.isMaster) {
33+
execSync(
34+
'find ./docs -name "*.png" -type f -size +100kb -not -path "./node_modules/*" -not -path "./docs/.vuepress/dist/*" -not -path "./.git/*" > temp.log'
35+
);
36+
for (let i = 0; i < numCPUs; i += 1) {
37+
cluster.fork();
38+
}
39+
} else {
40+
const files = fs
41+
.readFileSync("./temp.log", { encoding: "utf-8" })
42+
.split("\n");
43+
44+
files.forEach((file, i) => {
45+
if ((i % numCPUs) + 1 !== +cluster.worker.id) {
46+
return;
47+
}
48+
if (!file || file.endsWith("-fs8.png")) {
49+
return;
50+
}
51+
try {
52+
compress(file, i);
53+
} catch (e) {
54+
console.error(e);
55+
console.log(`Failed to compress ${file}`);
56+
execSync(`rm -rf "${file.replace(".png", "-fs8.png")}"`);
57+
}
58+
});
59+
}

config.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ga:
2+
enabled: true
3+
gTrackingId: G-B1XMPFE9RK

docker-compose.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "3.4"
2+
services:
3+
core:
4+
image: registry.cn-beijing.aliyuncs.com/teamory/docs:latest
5+
ports:
6+
- 3200:80

0 commit comments

Comments
 (0)