Skip to content

Commit

Permalink
chore: typo in readme [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lgou2w committed Feb 15, 2023
1 parent d5fe960 commit 9436408
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
26 changes: 13 additions & 13 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ pnpm i @l2studio/picacomic-api
import { PicaComicAPI } from '@l2studio/picacomic-api'

class PicaComicAPI {
public readonly fetch: typeof got
public readonly appOptions: Partial<PicaComicOptions>
public readonly fetch: Got
public readonly appOptions?: Partial<PicaComicOptions>
public readonly reauthorizationTokenCallback?: (self: this) => string | undefined | Promise<string | undefined>
constructor (options?: PicaComicAPIOptions)
}
```

### API Options
### API 选项

```typescript
interface PicaComicOptions {
Expand All @@ -53,7 +53,7 @@ interface PicaComicOptions {
}

interface PicaComicAPIOptions {
// Got 实例或扩展选项 (optional)
// Got 实例或扩展选项(可选)
// 请见: https://github.com/sindresorhus/got/tree/v11
fetch?: Got | ExtendOptions

Expand Down Expand Up @@ -320,9 +320,9 @@ PicaComicAPI.switchComicFavourite(payload: AuthorizationPayload & ComicIdPayload
PicaComicAPI.setUserProfileSlogan(payload: AuthorizationPayload & UserProfileSloganPayload): Promise<BaseResponse<undefined>>
```

## Client
## 客户端

服务只是对单个账户操作的封装,不需要自己去处理令牌失效的问题。
客户端只是对单个账户操作的封装,不需要自己去处理令牌失效的问题。

> 注意: 客户端类似 API,但是不提供 `register``signIn` 方法。其他方法的 `payload` 参数不需要再提供 `token` 访问令牌属性。
Expand All @@ -339,7 +339,7 @@ export class PicaComicClient {
}
```

### Client Options
### 客户端选项

```typescript
interface PicaComicClientOptions extends Omit<PicaComicAPIOptions, 'reauthorizationTokenCallback'> {
Expand Down Expand Up @@ -375,18 +375,18 @@ import fs from 'fs'

const tokenFile = path.join(__dirname, '.token') // 持久化令牌
const picacomic = new PicaComicClient({
email : 'your picacomic email',
password: 'your picacomic password',
email : '你的 PicaComic 哔咔账户邮箱',
password: '你的 PicaComic 哔咔账户密码',
token: fs.existsSync(tokenFile) ? fs.readFileSync(tokenFile, 'utf8') : undefined,
onTokenIssued (token) {
console.log('New token:', token)
console.log('新的令牌:', token)
fs.writeFileSync(tokenFile, token) // 更新持久化令牌
}
})

;(async () => {
const comics = await picacomic.fetchComics({ category: 'Cosplay' })
console.log(comics)
const response = await picacomic.fetchComics({ category: 'Cosplay' })
console.log(response)
})()
```

Expand All @@ -396,7 +396,7 @@ const picacomic = new PicaComicClient({

> 另见 Got:[agent](https://github.com/sindresorhus/got/tree/v11#agent).
请配置 `PicaComicAPIOptions``PicaComicClientOptions``fetch` 属性。
请配置 [`PicaComicAPIOptions`](#api-选项)[`PicaComicClientOptions`](#客户端选项)`fetch` 属性。

使用 [tunnel](https://github.com/koichik/node-tunnel) 的例子:

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pnpm i @l2studio/picacomic-api
import { PicaComicAPI } from '@l2studio/picacomic-api'

class PicaComicAPI {
public readonly fetch: typeof got
public readonly appOptions: Partial<PicaComicOptions>
public readonly fetch: Got
public readonly appOptions?: Partial<PicaComicOptions>
public readonly reauthorizationTokenCallback?: (self: this) => string | undefined | Promise<string | undefined>
constructor (options?: PicaComicAPIOptions)
}
Expand Down Expand Up @@ -353,6 +353,7 @@ interface PicaComicClientOptions extends Omit<PicaComicAPIOptions, 'reauthorizat
email: string // PicaComic account email
password: string // PicaComic account password
token?: string // PicaComic account access token (Optional)

// Callback function for re-authenticate and consuming a new token when the token is invalid. (Optional)
// Example:
// onTokenIssued (token) {
Expand Down Expand Up @@ -384,8 +385,8 @@ const picacomic = new PicaComicClient({
})

;(async () => {
const comics = await picacomic.fetchComics({ category: 'Cosplay' })
console.log(comics)
const response = await picacomic.fetchComics({ category: 'Cosplay' })
console.log(response)
})()
```

Expand All @@ -395,7 +396,7 @@ const picacomic = new PicaComicClient({

> See also Got [agent](https://github.com/sindresorhus/got/tree/v11#agent).
Please configure the `fetch` property of `PicaComicAPIOptions` or `PicaComicClientOptions`.
Please configure the `fetch` property of [`PicaComicAPIOptions`](#api-options) or [`PicaComicClientOptions`](#client-options).

Example using [tunnel](https://github.com/koichik/node-tunnel):

Expand Down

2 comments on commit 9436408

@Discut
Copy link

@Discut Discut commented on 9436408 Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢更新api文档,上次用这个仓库的时候好像0.2文档还没写。我用着0.2仓库看着0.1文档,写了半天才发现看错了。Hi~ o( ̄▽ ̄)ブ

@lgou2w
Copy link
Member Author

@lgou2w lgou2w commented on 9436408 Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢更新api文档,上次用这个仓库的时候好像0.2文档还没写。我用着0.2仓库看着0.1文档,写了半天才发现看错了。Hi~ o( ̄▽ ̄)ブ

Hi~ 是的,文档之前一直没有时间去写。如有什么问题欢迎贡献和PR。😄

Please sign in to comment.