Skip to content

Commit

Permalink
feat: 添加语雀账号密码模式
Browse files Browse the repository at this point in the history
  • Loading branch information
LetTTGACO committed Nov 22, 2023
1 parent 8ef7c84 commit b8ef8d6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 35 deletions.
6 changes: 6 additions & 0 deletions .elog-example.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 语雀(Token方式)
YUQUE_TOKEN=

#语雀账号密码模式
YUQUE_USERNAME=
YUQUE_PASSWORD=

# 语雀公共参数
YUQUE_LOGIN=
YUQUE_REPO=

Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

## 前言

> 注意:2023/11/18更新:由于语雀官方更新了账号密码登录规则,加上了人机校验,账号密码模式已无法通过 Elog 登录!目前只能使用
> Token 方式同步文档(需要语雀超级会员)
> 如果你不是语雀超级会员,可以使用 Notion 进行部署文档站点,[参考示例](https://github.com/LetTTGACO/elog-docs)
> 当前支持语雀 Token 模式(需要语雀超级会员)和账号密码模式(不需要任何会员)
> VitePress 要求 Node 18及以上版本
Expand Down Expand Up @@ -38,9 +36,18 @@ npm install
参考[示例知识库](https://www.yuque.com/1874w/yuque-vitepress-template)
,选择或新建语雀文档知识库,并按照[文档提示](https://elog.1874.cool/notion/gvnxobqogetukays#login)
配置语雀并获取 `token login repo`。并在本地`.elog.env`中写入
> Token 模式或者账号密码模式二选一即可,默认为账号密码模式,如果需要切换为 Token 模式,则修改`elog.config.js`中的`platform`
> `yuque`
```text
# 语雀(Token方式)
YUQUE_TOKEN=获取的Token
#语雀(账号密码模式)
YUQUE_USERNAME=一般是手机号
YUQUE_PASSWORD=登录密码
# 语雀公共参数
YUQUE_LOGIN=获取的login
YUQUE_REPO=获取的repo
```
Expand Down Expand Up @@ -85,6 +92,9 @@ npm run docs:dev

## 自动化同步&部署

> 注意:在非国内CI/CD环境中使用账号密码模式登录语雀,例如Github
> Workflow,会导致语雀后台登录设备中出现大量美国IP,目前尚不清楚语雀是否会有安全限制措施,请谨慎使用。推荐本地同步时使用。
### 检查 Github Actions 权限

在 Github 仓库的设置中找到 `Actions-General`,打开流水线写入权限`Workflow permissions`
Expand Down Expand Up @@ -114,6 +124,8 @@ https://serverless-api-elog.vercel.app/api/github?user=xxx&repo=xxx&event_type=d

#### 自动触发-语雀 webhooks

> 需要语雀超级会员
在语雀知识库 - 更多设置 - 消息推送中可配置语雀 webhooks,填写上面的 Vercel Serverless API。当文档更新时,语雀会调用这个API进行推送,进而触发
Github Actions
> 注意:语雀是国内文档平台,调用国外Vercel 的服务可能会失败,可自行部署 API
Expand Down
62 changes: 31 additions & 31 deletions elog.cache.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
{
"docs": [
{
"id": 147390855,
"doc_id": "xpoghpkl22q6hkie",
"updated": 1700412848000,
"properties": {
"title": "写作注意事项",
"urlname": "xpoghpkl22q6hkie",
"date": "2023-11-18 23:53:13",
"updated": "2023-11-20 00:54:08",
"author": "1874"
},
"catalog": [
{
"title": "配置详情",
"doc_id": "xpoghpkl22q6hkie"
}
],
"realName": "写作注意事项",
"relativePath": "/配置详情/写作注意事项.md",
"docPath": "docs/docs/配置详情"
},
{
"id": 147392043,
"doc_id": "yeanygk42ggzdy3y",
Expand Down Expand Up @@ -64,24 +43,24 @@
"docPath": "docs/docs/关于"
},
{
"id": 147362998,
"doc_id": "bg32rx8afe5cfu4f",
"updated": 1700366259000,
"id": 147390855,
"doc_id": "xpoghpkl22q6hkie",
"updated": 1700412848000,
"properties": {
"title": "Elog配置详解",
"urlname": "bg32rx8afe5cfu4f",
"date": "2023-11-18 15:42:00",
"updated": "2023-11-19 11:57:39",
"title": "写作注意事项",
"urlname": "xpoghpkl22q6hkie",
"date": "2023-11-18 23:53:13",
"updated": "2023-11-20 00:54:08",
"author": "1874"
},
"catalog": [
{
"title": "配置详情",
"doc_id": "bg32rx8afe5cfu4f"
"doc_id": "xpoghpkl22q6hkie"
}
],
"realName": "Elog配置详解",
"relativePath": "/配置详情/Elog配置详解.md",
"realName": "写作注意事项",
"relativePath": "/配置详情/写作注意事项.md",
"docPath": "docs/docs/配置详情"
},
{
Expand All @@ -105,6 +84,27 @@
"relativePath": "/进阶配置/自定义Elog配置.md",
"docPath": "docs/docs/进阶配置"
},
{
"id": 147362998,
"doc_id": "bg32rx8afe5cfu4f",
"updated": 1700366259000,
"properties": {
"title": "Elog配置详解",
"urlname": "bg32rx8afe5cfu4f",
"date": "2023-11-18 15:42:00",
"updated": "2023-11-19 11:57:39",
"author": "1874"
},
"catalog": [
{
"title": "配置详情",
"doc_id": "bg32rx8afe5cfu4f"
}
],
"realName": "Elog配置详解",
"relativePath": "/配置详情/Elog配置详解.md",
"docPath": "docs/docs/配置详情"
},
{
"id": 147362979,
"doc_id": "ssuhngw0yb3dgkkg",
Expand Down
7 changes: 7 additions & 0 deletions elog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module.exports = {
repo: process.env.YUQUE_REPO,
onlyPublic: false,
onlyPublished: true,
},
"yuque-pwd": {
username: process.env.YUQUE_USERNAME,
password: process.env.YUQUE_PASSWORD,
login: process.env.YUQUE_LOGIN,
repo: process.env.YUQUE_REPO,
linebreak: false
}
},
deploy: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/LetTTGACO/yuque-vitepress#readme",
"dependencies": {
"@elog/cli": "^0.12.0",
"@elog/cli": "^0.12.1",
"vitepress": "^1.0.0-rc.27"
}
}

0 comments on commit b8ef8d6

Please sign in to comment.