Skip to content

Commit

Permalink
feat: 语雀使用思源 API 正向代理
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 5, 2023
1 parent 4f1e53a commit f7f283f
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 291 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ This plugin supports almost all devices and platforms of Siyuan Note, and the sp

**It may be migrated to the official forward proxy to achieve zero configuration in the future, but for now you must set it yourself, you can follow the progress here.**

- Progress 1: The Yuque and Notion platforms have used the built-in forward proxy and do not need to be configured.

## Platform List

Names not listed in order
Expand Down
2 changes: 2 additions & 0 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@

**后续可能会迁移到官方的正向代理实现零配置,但是目前还是必须要自己设置,可在这里关注进展。**

- 进度1:语雀、Notion平台已使用内置正向代理,无需配置。

## 平台列表

排名不分先后
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.4",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.20.8",
"zhi-blog-api": "^1.20.9",
"zhi-common": "^1.11.7",
"zhi-device": "^2.3.0",
"zhi-fetch-middleware": "^0.2.7",
"zhi-github-middleware": "^0.1.4",
"zhi-lib-base": "^0.4.3",
"zhi-siyuan-api": "^1.29.9",
"zhi-siyuan-api": "^1.29.10",
"zhi-xmlrpc-middleware": "^0.4.2"
}
}
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/adaptors/api/base/baseBlogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class BaseBlogApi extends BlogApi {
url: string,
headers: any[],
params: any = {},
method: "GET" | "POST" = "GET",
method: "GET" | "POST" | "PUT" | "DELETE" = "GET",
contentType: string = "application/json"
): Promise<any> {
if (this.isInChromeExtension) {
Expand Down
16 changes: 8 additions & 8 deletions src/adaptors/api/notion/adaptor/notionApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ class NotionApiAdaptor extends BaseBlogApi {
const result: UserBlog[] = []

// https://developers.notion.com/reference/post-search
const headers = {
Authorization: `Bearer ${this.cfg.password}`,
"Notion-Version": "2022-06-28",
}
const params = {
page_size: 10,
filter: {
value: "page",
property: "object",
},
}
const headers = {
Authorization: `Bearer ${this.cfg.password}`,
"Notion-Version": "2022-06-28",
}
const searchResp = await this.proxyFetch("/search", [headers], params, "POST", "application/json")
this.logger.debug("notion searchResp results=>", searchResp)
if (searchResp.status === 401) {
throw new Error(searchResp.message)
this.logger.debug("notion searchResp=>", searchResp)
if (searchResp?.status === 401) {
throw new Error(searchResp?.message)
}
const pages = searchResp.results as any
this.logger.debug("notion database results=>", pages)
this.logger.debug("notion pages=>", pages)

// https://stackoverflow.com/a/75537092/4037224
if (pages.length === 0) {
Expand Down
223 changes: 0 additions & 223 deletions src/adaptors/api/yuque/adaptor/yuqueApi.ts

This file was deleted.

Loading

0 comments on commit f7f283f

Please sign in to comment.