From 2d705a9b7bd038927a0a89e6763996490f72b55c Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Wed, 15 Jan 2025 20:12:43 +0800 Subject: [PATCH] feat(client)!: refine props --- docs/src/.vuepress/config.ts | 9 + docs/src/en/migration/v2.md | 2 +- docs/src/en/reference/api/README.md | 702 +----------------- docs/src/en/reference/client/props.md | 15 +- docs/src/migration/v2.md | 2 +- docs/src/reference/api/README.md | 702 +----------------- docs/src/reference/client/props.md | 15 +- package.json | 2 +- packages/api/src/comment.ts | 4 +- packages/api/src/login.ts | 2 +- packages/api/src/typings.ts | 12 +- packages/client/src/components/CommentBox.vue | 96 ++- .../client/src/components/CommentCard.vue | 4 +- .../client/src/components/WalineComment.vue | 60 +- packages/client/src/typings/waline.ts | 28 +- packages/client/src/utils/config.ts | 48 +- packages/client/src/utils/emoji.ts | 14 +- packages/client/src/utils/markdown.ts | 4 +- pnpm-lock.yaml | 30 +- 19 files changed, 169 insertions(+), 1582 deletions(-) diff --git a/docs/src/.vuepress/config.ts b/docs/src/.vuepress/config.ts index dcb90754184..3bc2641bbc4 100644 --- a/docs/src/.vuepress/config.ts +++ b/docs/src/.vuepress/config.ts @@ -26,6 +26,15 @@ export default defineUserConfig({ }, }), + markdown: { + importCode: { + handleImportPath: (str) => + str === '@waline/api/types' + ? path.resolve(__dirname, '../../../packages/api/dist/api.d.ts') + : str, + }, + }, + theme, alias: { diff --git a/docs/src/en/migration/v2.md b/docs/src/en/migration/v2.md index 244bd3faa87..4df1fb12215 100644 --- a/docs/src/en/migration/v2.md +++ b/docs/src/en/migration/v2.md @@ -60,7 +60,7 @@ The following options have long been marked as deprecated APIs in V1, they have - `avatarForce`: refresh by default - `anonymous`: use `login` - `mathTagSupport`: use `texRenderer` -- `copyRight`: use `copyright` +- `copyRight`: use `noCopyright` ## Other changes diff --git a/docs/src/en/reference/api/README.md b/docs/src/en/reference/api/README.md index d104b06a8d7..f84d370c119 100644 --- a/docs/src/en/reference/api/README.md +++ b/docs/src/en/reference/api/README.md @@ -7,704 +7,4 @@ Waline provides `@waline/api` package for official client, third-party client de ## API -```ts -interface BaseAPIOptions { - /** - * Waline 服务端地址 - * - * Waline serverURL - */ - serverURL: string; - /** - * 错误信息所使用的语言 - * - * Language used in error text - */ - lang: string; -} -interface ErrorStatusResponse { - /** - * 错误代码 - * - * Error number - */ - errno: number; - /** - * 错误消息 - * - * Error msg - */ - errmsg: string; -} - -interface GetArticleCounterOptions extends BaseAPIOptions { - /** - * 待获取计数器的 path - * - * Path of counters - */ - paths: string[]; - /** - * 待获取计数器的类型 - * - * Counter type to be fetched - */ - type: string[]; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -type GetArticleCounterResponse = - | Record[] - | Record - | number[] - | number; -declare const getArticleCounter: ({ - serverURL, - lang, - paths, - type, - signal, -}: GetArticleCounterOptions) => Promise; -interface UpdateArticleCounterOptions extends BaseAPIOptions { - /** - * 待更新计数器的 path - * - * Path of counter to be updated - */ - path: string; - /** - * 待更新计数器的类型 - * - * Counter type to be updated - */ - type: string; - /** - * 更新操作 - * - * Update operation - * - * @default 'inc' - */ - action?: 'inc' | 'desc'; -} -declare const updateArticleCounter: ({ - serverURL, - lang, - path, - type, - action, -}: UpdateArticleCounterOptions) => Promise; - -type WalineCommentStatus = 'approved' | 'waiting' | 'spam'; -type WalineUserType = 'administrator' | 'guest'; -interface WalineCommentData { - /** - * User Nickname - */ - nick?: string; - /** - * User email - */ - mail?: string; - /** - * User link - */ - link?: string; - /** - * Content of comment - */ - comment: string; - /** - * User Agent - */ - ua: string; - /** - * Comment page path - */ - url: string; - /** - * Parent comment id - * - * @description Only available when replying comment - */ - pid?: string; - /** - * Root comment id - * - * @description Only available when replying comment - */ - rid?: string; - /** - * User id being at - * - * @description Only available when replying comment - */ - at?: string; - /** - * Recaptcha Token - */ - recaptchaV3?: string; - /** - * Turnstile Token - */ - turnstile?: string; -} -interface BaseWalineResponseComment { - /** - * Comment object ID - */ - objectId: string; - /** - * Time ISOString when the comment is created - */ - createdAt: string; - /** - * Time ISOString when the comment is inserted - */ - insertedAt: string; - /** - * Time ISOString when the comment is updated - */ - updatedAt: string; - /** - * Content of comment - */ - comment: string; - /** - * Original comment content - * - * 原始评论内容 - */ - orig: string; - /** - * Comment like number - * - * 评论喜欢数 - */ - like: number; - /** - * User Nickname - */ - nick: string; - /** - * User link - */ - link: string; - /** - * User avatar - */ - avatar: string; - /** - * User type - * - * @description Only available with logged in user - * - * 用户类型 - * - * @description 仅在登录用户时可用 - */ - type?: WalineUserType; - /** - * User ID - * - * @description Only available with logged in user - * - * 用户 ID - * - * @description 仅在登录用户时可用 - */ - user_id?: string; - /** - * User location - * - * @description Not available with `DISABLE_REGION=true` - * - * 用户位置 - * - * @description `DISABLE_REGION=true` 时不可用 - */ - addr?: string; - /** - * User browser - * - * @description Not available with `DISABLE_USERAGENT=true` - * - * 用户浏览器 - * - * @description `DISABLE_USERAGENT=true` 时不可用 - */ - browser?: string; - /** - * User location - * - * @description Not available with `DISABLE_USERAGENT=true` - * - * 用户位置 - * - * @description `DISABLE_USERAGENT=true` 时不可用 - */ - os?: string; - /** - * User level - * - * @description Only available when `LEVELS` is set - * - * 用户等级 - * - * @description 仅在 `LEVELS` 设置时可用 - */ - level?: number; - /** - * User label - * - * 用户标签 - */ - label?: string; - /** - * Comment status - * - * @description For administrators, `approved` `spam` `waiting` can be get, for others, the only value is `approved` - * - * 评论状态 - * - * @description 管理员可获得 `approved`、`spam` 和 `waiting`,其他用户只能获得 `approved` - */ - status?: WalineCommentStatus; -} -interface WalineChildComment extends BaseWalineResponseComment { - /** - * Parent comment id - */ - pid: string; - /** - * Root comment id - */ - rid: string; - /** - * User id being at - */ - at?: string; -} -interface WalineRootComment extends BaseWalineResponseComment { - /** - * Whether the comment is sticky - * - * 是否置顶 - */ - sticky: boolean; - /** - * Child comments - * - * 子评论 - */ - children: WalineChildComment[]; -} -type WalineComment = WalineRootComment | WalineChildComment; - -interface GetCommentOptions extends BaseAPIOptions { - /** - * 待获取评论列表的 path - * - * Path of comment list - */ - path: string; - /** - * 评论分页数 - * - * Comment pagination number - */ - page: number; - /** - * 每页评论个数 - * - * Comment number per page - */ - pageSize: number; - /** - * 排序方式 - * - * Sort method - */ - sortBy: string; - /** - * 用户令牌 - * - * User token - */ - token?: string; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -interface GetCommentResponse { - /** - * 评论数量 - * - * Comment number - */ - count: number; - /** - * 评论分页数 - * - * Comment pagination number - */ - page: number; - /** - * 每页评论个数 - * - * Comment number per page - */ - pageSize: number; - /** - * 评论数据 - * - * Comment Data - */ - data: WalineRootComment[]; - /** - * 页面总数 - * - * Page number - */ - totalPages: number; -} -declare const getComment: ({ - serverURL, - lang, - path, - page, - pageSize, - sortBy, - signal, - token, -}: GetCommentOptions) => Promise; -interface AddCommentOptions extends BaseAPIOptions { - /** - * 用户令牌 - * - * User token - */ - token?: string; - /** - * 用户待提交的评论数据 - * - * Comment data being submitted by user - */ - comment: WalineCommentData; -} -interface AddCommentResponse extends ErrorStatusResponse { - /** - * 渲染好的评论数据 - * - * Comment data rendered - */ - data?: WalineComment; -} -declare const addComment: ({ - serverURL, - lang, - token, - comment, -}: AddCommentOptions) => Promise; -interface DeleteCommentOptions extends BaseAPIOptions { - /** - * Auth token - * - * 认证令牌 - */ - token: string; - /** - * Comment objectId to be deleted - * - * 待删除的评论对象 ID - */ - objectId: string | number; -} -interface DeleteCommentResponse extends ErrorStatusResponse { - data: ''; -} -declare const deleteComment: ({ - serverURL, - lang, - token, - objectId, -}: DeleteCommentOptions) => Promise; -interface UpdateWalineCommentData extends Partial { - /** - * 点赞还是取消点赞 - * - * Like or dislike - */ - like?: boolean; - /** - * 评论的状态 - * - * Comment status - */ - status?: 'approved' | 'waiting' | 'spam'; - /** - * 评论指定状态 - * - * Comment sticky status - * - * @description 0 means not sticky and 1 means sticky - */ - sticky?: 0 | 1; -} -interface UpdateCommentOptions extends BaseAPIOptions { - /** - * 用户令牌 - * - * User token - */ - token: string; - /** - * 评论的 ID - * - * Comment ID - */ - objectId: number | string; - /** - * 评论数据 - * - * Comment data - */ - comment?: UpdateWalineCommentData; -} -interface UpdateCommentResponse extends ErrorStatusResponse { - /** - * 更新后的评论数据 - * - * Comment data rendered - */ - data: WalineComment; -} -declare const updateComment: ({ - serverURL, - lang, - token, - objectId, - comment, -}: UpdateCommentOptions) => Promise; - -interface GetCommentCountOptions extends BaseAPIOptions { - /** - * 待获取评论数的 path - * - * Path of pages to be fetched - */ - paths: string[]; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -declare const fetchCommentCount: ({ - serverURL, - lang, - paths, - signal, -}: GetCommentCountOptions) => Promise; - -interface UserInfo { - /** - * 显示姓名 - * - * User name displayed - */ - display_name: string; - /** - * 用户电子邮件地址 - * - * User email - */ - email: string; - /** - * 用户网站地址 - * - * User website - */ - url: string; - /** - * 用户令牌 - * - * User token - */ - token: string; - /** - * 用户头像 - * - * User avatar - */ - avatar: string; - /** - * 用户邮箱 MD5 - * - * MD5 of User email - */ - mailMd5: string; - /** - * 用户对象 ID - * - * User object ID - */ - objectId: string | number; - /** - * 用户身份 - * - * User role - */ - type: 'administrator' | 'guest'; -} -declare const login: ({ lang, serverURL }: BaseAPIOptions) => Promise< - UserInfo & { - remember: boolean; - } ->; - -interface GetPageviewOptions extends BaseAPIOptions { - /** - * 待获取页面的 path - * - * Path of pages - */ - paths: string[]; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -declare const getPageview: ({ - serverURL, - lang, - paths, - signal, -}: GetPageviewOptions) => Promise; -interface UpdatePageviewOptions extends BaseAPIOptions { - /** - * 待更新页面的 path - * - * Path of pages - */ - path: string; -} -declare const updatePageview: ( - options: UpdatePageviewOptions, -) => Promise; - -interface GetRecentCommentOptions extends BaseAPIOptions { - /** - * 获取评论的数量 - * - * Comment number to be fetched - */ - count: number; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; - /** - * 用户令牌 - * - * User token - */ - token?: string; -} -interface RecentCommentData extends BaseWalineResponseComment { - /** - * Page url where comment locales - * - * 评论所在页面地址 - */ - url: string; -} -declare const getRecentComment: ({ - serverURL, - lang, - count, - signal, - token, -}: GetRecentCommentOptions) => Promise; - -interface GetUserListOptions extends BaseAPIOptions { - /** - * 每页个数 - * - * Number per page - */ - pageSize: number; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -interface WalineUser - extends Pick { - count: number; -} -interface GetUserListResponse extends ErrorStatusResponse { - data: WalineUser[]; -} -declare const getUserList: ({ - serverURL, - signal, - pageSize, - lang, -}: GetUserListOptions) => Promise; - -export { - type AddCommentOptions, - type AddCommentResponse, - type BaseWalineResponseComment, - type DeleteCommentOptions, - type DeleteCommentResponse, - type GetArticleCounterOptions, - type GetArticleCounterResponse, - type GetCommentCountOptions, - type GetCommentOptions, - type GetCommentResponse, - type GetRecentCommentOptions, - type GetUserListOptions, - type GetUserListResponse, - type RecentCommentData, - type UpdateArticleCounterOptions, - type UpdateCommentOptions, - type UpdateCommentResponse, - type UpdatePageviewOptions, - type UserInfo, - type WalineChildComment, - type WalineComment, - type WalineCommentData, - type WalineCommentStatus, - type WalineRootComment, - type WalineUser, - type WalineUserType, - addComment, - deleteComment, - fetchCommentCount, - getArticleCounter, - getComment, - getPageview, - getRecentComment, - getUserList, - login, - updateArticleCounter, - updateComment, - updatePageview, -}; -``` +@[code](@waline/api/types) diff --git a/docs/src/en/reference/client/props.md b/docs/src/en/reference/client/props.md index a1f60ea08df..30ff840adad 100644 --- a/docs/src/en/reference/client/props.md +++ b/docs/src/en/reference/client/props.md @@ -63,7 +63,7 @@ Waline Locales. ## emoji -- Type: `(string | WalineEmojiInfo)[] | false` +- Type: `(string | WalineEmojiInfo)[] | 'disabled'` ```ts type WalineEmojiPresets = `http://${string}` | `https://${string}`; @@ -177,7 +177,7 @@ number of comments per page. ## imageUploader -- Type: `WalineImageUploader | false` +- Type: `WalineImageUploader | 'disabled'` ```ts type WalineImageUploader = (image: File) => Promise; @@ -194,7 +194,7 @@ The function should receive an image object and return a Promise that provides t ## highlighter -- Type: `WalineHighlighter | false` +- Type: `WalineHighlighter | 'disabled'` ```ts type WalineHighlighter = (code: string, lang: string) => string; @@ -211,7 +211,7 @@ You can pass in a code highlighter of your own, or set to `false` to disable cod ## texRenderer -- Type: `WalineTeXRenderer | false` +- Type: `WalineTeXRenderer | 'disabled'` ```ts type WalineTeXRenderer = (blockMode: boolean, tex: string) => string; @@ -231,7 +231,7 @@ You can import $\TeX$ renderer to provide preview feature. We recommend you to u ## search -- Type: `WalineSearchOptions | false` +- Type: `WalineSearchOptions | 'disabled'` ```ts interface WalineSearchImageData extends Record { @@ -288,12 +288,11 @@ You can import $\TeX$ renderer to provide preview feature. We recommend you to u Customize search features, you can disable search function by setting it to `false`. -## copyright +## noCopyright - Type: `boolean` -- Default: `true` -Whether show copyright and version in footer. +Whether hide copyright and version in footer. ::: tip diff --git a/docs/src/migration/v2.md b/docs/src/migration/v2.md index 0ed97ec7490..5187612c673 100644 --- a/docs/src/migration/v2.md +++ b/docs/src/migration/v2.md @@ -60,7 +60,7 @@ icon: migration - `avatarForce`: 默认刷新 - `anonymous`: 使用 `login` - `mathTagSupport`: 不再需要 -- `copyRight`: 使用 `copyright` +- `copyRight`: 使用 `noCopyright` ## 其他变更 diff --git a/docs/src/reference/api/README.md b/docs/src/reference/api/README.md index b6a31feb6be..1e15b186052 100644 --- a/docs/src/reference/api/README.md +++ b/docs/src/reference/api/README.md @@ -7,704 +7,4 @@ Waline 官方提供 `@waline/api` 包,以供官方客户端、第三方客户 ## API -```ts -interface BaseAPIOptions { - /** - * Waline 服务端地址 - * - * Waline serverURL - */ - serverURL: string; - /** - * 错误信息所使用的语言 - * - * Language used in error text - */ - lang: string; -} -interface ErrorStatusResponse { - /** - * 错误代码 - * - * Error number - */ - errno: number; - /** - * 错误消息 - * - * Error msg - */ - errmsg: string; -} - -interface GetArticleCounterOptions extends BaseAPIOptions { - /** - * 待获取计数器的 path - * - * Path of counters - */ - paths: string[]; - /** - * 待获取计数器的类型 - * - * Counter type to be fetched - */ - type: string[]; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -type GetArticleCounterResponse = - | Record[] - | Record - | number[] - | number; -declare const getArticleCounter: ({ - serverURL, - lang, - paths, - type, - signal, -}: GetArticleCounterOptions) => Promise; -interface UpdateArticleCounterOptions extends BaseAPIOptions { - /** - * 待更新计数器的 path - * - * Path of counter to be updated - */ - path: string; - /** - * 待更新计数器的类型 - * - * Counter type to be updated - */ - type: string; - /** - * 更新操作 - * - * Update operation - * - * @default 'inc' - */ - action?: 'inc' | 'desc'; -} -declare const updateArticleCounter: ({ - serverURL, - lang, - path, - type, - action, -}: UpdateArticleCounterOptions) => Promise; - -type WalineCommentStatus = 'approved' | 'waiting' | 'spam'; -type WalineUserType = 'administrator' | 'guest'; -interface WalineCommentData { - /** - * User Nickname - */ - nick?: string; - /** - * User email - */ - mail?: string; - /** - * User link - */ - link?: string; - /** - * Content of comment - */ - comment: string; - /** - * User Agent - */ - ua: string; - /** - * Comment page path - */ - url: string; - /** - * Parent comment id - * - * @description Only available when replying comment - */ - pid?: string; - /** - * Root comment id - * - * @description Only available when replying comment - */ - rid?: string; - /** - * User id being at - * - * @description Only available when replying comment - */ - at?: string; - /** - * Recaptcha Token - */ - recaptchaV3?: string; - /** - * Turnstile Token - */ - turnstile?: string; -} -interface BaseWalineResponseComment { - /** - * Comment object ID - */ - objectId: string; - /** - * Time ISOString when the comment is created - */ - createdAt: string; - /** - * Time ISOString when the comment is inserted - */ - insertedAt: string; - /** - * Time ISOString when the comment is updated - */ - updatedAt: string; - /** - * Content of comment - */ - comment: string; - /** - * Original comment content - * - * 原始评论内容 - */ - orig: string; - /** - * Comment like number - * - * 评论喜欢数 - */ - like: number; - /** - * User Nickname - */ - nick: string; - /** - * User link - */ - link: string; - /** - * User avatar - */ - avatar: string; - /** - * User type - * - * @description Only available with logged in user - * - * 用户类型 - * - * @description 仅在登录用户时可用 - */ - type?: WalineUserType; - /** - * User ID - * - * @description Only available with logged in user - * - * 用户 ID - * - * @description 仅在登录用户时可用 - */ - user_id?: string; - /** - * User location - * - * @description Not available with `DISABLE_REGION=true` - * - * 用户位置 - * - * @description `DISABLE_REGION=true` 时不可用 - */ - addr?: string; - /** - * User browser - * - * @description Not available with `DISABLE_USERAGENT=true` - * - * 用户浏览器 - * - * @description `DISABLE_USERAGENT=true` 时不可用 - */ - browser?: string; - /** - * User location - * - * @description Not available with `DISABLE_USERAGENT=true` - * - * 用户位置 - * - * @description `DISABLE_USERAGENT=true` 时不可用 - */ - os?: string; - /** - * User level - * - * @description Only available when `LEVELS` is set - * - * 用户等级 - * - * @description 仅在 `LEVELS` 设置时可用 - */ - level?: number; - /** - * User label - * - * 用户标签 - */ - label?: string; - /** - * Comment status - * - * @description For administrators, `approved` `spam` `waiting` can be get, for others, the only value is `approved` - * - * 评论状态 - * - * @description 管理员可获得 `approved`、`spam` 和 `waiting`,其他用户只能获得 `approved` - */ - status?: WalineCommentStatus; -} -interface WalineChildComment extends BaseWalineResponseComment { - /** - * Parent comment id - */ - pid: string; - /** - * Root comment id - */ - rid: string; - /** - * User id being at - */ - at?: string; -} -interface WalineRootComment extends BaseWalineResponseComment { - /** - * Whether the comment is sticky - * - * 是否置顶 - */ - sticky: boolean; - /** - * Child comments - * - * 子评论 - */ - children: WalineChildComment[]; -} -type WalineComment = WalineRootComment | WalineChildComment; - -interface GetCommentOptions extends BaseAPIOptions { - /** - * 待获取评论列表的 path - * - * Path of comment list - */ - path: string; - /** - * 评论分页数 - * - * Comment pagination number - */ - page: number; - /** - * 每页评论个数 - * - * Comment number per page - */ - pageSize: number; - /** - * 排序方式 - * - * Sort method - */ - sortBy: string; - /** - * 用户令牌 - * - * User token - */ - token?: string; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -interface GetCommentResponse { - /** - * 评论数量 - * - * Comment number - */ - count: number; - /** - * 评论分页数 - * - * Comment pagination number - */ - page: number; - /** - * 每页评论个数 - * - * Comment number per page - */ - pageSize: number; - /** - * 评论数据 - * - * Comment Data - */ - data: WalineRootComment[]; - /** - * 页面总数 - * - * Page number - */ - totalPages: number; -} -declare const getComment: ({ - serverURL, - lang, - path, - page, - pageSize, - sortBy, - signal, - token, -}: GetCommentOptions) => Promise; -interface AddCommentOptions extends BaseAPIOptions { - /** - * 用户令牌 - * - * User token - */ - token?: string; - /** - * 用户待提交的评论数据 - * - * Comment data being submitted by user - */ - comment: WalineCommentData; -} -interface AddCommentResponse extends ErrorStatusResponse { - /** - * 渲染好的评论数据 - * - * Comment data rendered - */ - data?: WalineComment; -} -declare const addComment: ({ - serverURL, - lang, - token, - comment, -}: AddCommentOptions) => Promise; -interface DeleteCommentOptions extends BaseAPIOptions { - /** - * Auth token - * - * 认证令牌 - */ - token: string; - /** - * Comment objectId to be deleted - * - * 待删除的评论对象 ID - */ - objectId: string | number; -} -interface DeleteCommentResponse extends ErrorStatusResponse { - data: ''; -} -declare const deleteComment: ({ - serverURL, - lang, - token, - objectId, -}: DeleteCommentOptions) => Promise; -interface UpdateWalineCommentData extends Partial { - /** - * 点赞还是取消点赞 - * - * Like or dislike - */ - like?: boolean; - /** - * 评论的状态 - * - * Comment status - */ - status?: 'approved' | 'waiting' | 'spam'; - /** - * 评论指定状态 - * - * Comment sticky status - * - * @description 0 means not sticky and 1 means sticky - */ - sticky?: 0 | 1; -} -interface UpdateCommentOptions extends BaseAPIOptions { - /** - * 用户令牌 - * - * User token - */ - token: string; - /** - * 评论的 ID - * - * Comment ID - */ - objectId: number | string; - /** - * 评论数据 - * - * Comment data - */ - comment?: UpdateWalineCommentData; -} -interface UpdateCommentResponse extends ErrorStatusResponse { - /** - * 更新后的评论数据 - * - * Comment data rendered - */ - data: WalineComment; -} -declare const updateComment: ({ - serverURL, - lang, - token, - objectId, - comment, -}: UpdateCommentOptions) => Promise; - -interface GetCommentCountOptions extends BaseAPIOptions { - /** - * 待获取评论数的 path - * - * Path of pages to be fetched - */ - paths: string[]; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -declare const fetchCommentCount: ({ - serverURL, - lang, - paths, - signal, -}: GetCommentCountOptions) => Promise; - -interface UserInfo { - /** - * 显示姓名 - * - * User name displayed - */ - display_name: string; - /** - * 用户电子邮件地址 - * - * User email - */ - email: string; - /** - * 用户网站地址 - * - * User website - */ - url: string; - /** - * 用户令牌 - * - * User token - */ - token: string; - /** - * 用户头像 - * - * User avatar - */ - avatar: string; - /** - * 用户邮箱 MD5 - * - * MD5 of User email - */ - mailMd5: string; - /** - * 用户对象 ID - * - * User object ID - */ - objectId: string | number; - /** - * 用户身份 - * - * User role - */ - type: 'administrator' | 'guest'; -} -declare const login: ({ lang, serverURL }: BaseAPIOptions) => Promise< - UserInfo & { - remember: boolean; - } ->; - -interface GetPageviewOptions extends BaseAPIOptions { - /** - * 待获取页面的 path - * - * Path of pages - */ - paths: string[]; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -declare const getPageview: ({ - serverURL, - lang, - paths, - signal, -}: GetPageviewOptions) => Promise; -interface UpdatePageviewOptions extends BaseAPIOptions { - /** - * 待更新页面的 path - * - * Path of pages - */ - path: string; -} -declare const updatePageview: ( - options: UpdatePageviewOptions, -) => Promise; - -interface GetRecentCommentOptions extends BaseAPIOptions { - /** - * 获取评论的数量 - * - * Comment number to be fetched - */ - count: number; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; - /** - * 用户令牌 - * - * User token - */ - token?: string; -} -interface RecentCommentData extends BaseWalineResponseComment { - /** - * Page url where comment locales - * - * 评论所在页面地址 - */ - url: string; -} -declare const getRecentComment: ({ - serverURL, - lang, - count, - signal, - token, -}: GetRecentCommentOptions) => Promise; - -interface GetUserListOptions extends BaseAPIOptions { - /** - * 每页个数 - * - * Number per page - */ - pageSize: number; - /** - * 取消请求的信号 - * - * AbortSignal to cancel request - */ - signal?: AbortSignal; -} -interface WalineUser - extends Pick { - count: number; -} -interface GetUserListResponse extends ErrorStatusResponse { - data: WalineUser[]; -} -declare const getUserList: ({ - serverURL, - signal, - pageSize, - lang, -}: GetUserListOptions) => Promise; - -export { - type AddCommentOptions, - type AddCommentResponse, - type BaseWalineResponseComment, - type DeleteCommentOptions, - type DeleteCommentResponse, - type GetArticleCounterOptions, - type GetArticleCounterResponse, - type GetCommentCountOptions, - type GetCommentOptions, - type GetCommentResponse, - type GetRecentCommentOptions, - type GetUserListOptions, - type GetUserListResponse, - type RecentCommentData, - type UpdateArticleCounterOptions, - type UpdateCommentOptions, - type UpdateCommentResponse, - type UpdatePageviewOptions, - type UserInfo, - type WalineChildComment, - type WalineComment, - type WalineCommentData, - type WalineCommentStatus, - type WalineRootComment, - type WalineUser, - type WalineUserType, - addComment, - deleteComment, - fetchCommentCount, - getArticleCounter, - getComment, - getPageview, - getRecentComment, - getUserList, - login, - updateArticleCounter, - updateComment, - updatePageview, -}; -``` +@[code](@waline/api/types) diff --git a/docs/src/reference/client/props.md b/docs/src/reference/client/props.md index 648f39fb6b5..1c36b3abf8f 100644 --- a/docs/src/reference/client/props.md +++ b/docs/src/reference/client/props.md @@ -63,7 +63,7 @@ Waline 多语言配置。 ## emoji -- 类型: `(WalineEmojiInfo | WalineEmojiPresets)[] | false` +- 类型: `(WalineEmojiInfo | WalineEmojiPresets)[] | 'disabled'` ```ts type WalineEmojiPresets = `http://${string}` | `https://${string}`; @@ -175,7 +175,7 @@ Waline 多语言配置。 ## imageUploader -- 类型: `WalineImageUploader | false` +- 类型: `WalineImageUploader | 'disabled'` - 必填: 否 - 详情: @@ -192,7 +192,7 @@ Waline 多语言配置。 ## highlighter -- 类型: `WalineHighlighter | false` +- 类型: `WalineHighlighter | 'disabled'` ```ts type WalineHighlighter = (code: string, lang: string) => string; @@ -209,7 +209,7 @@ Waline 多语言配置。 ## texRenderer -- 类型: `WalineTeXRenderer | false` +- 类型: `WalineTeXRenderer | 'disabled'` ```ts type WalineTeXRenderer = (blockMode: boolean, tex: string) => string; @@ -229,7 +229,7 @@ Waline 多语言配置。 ## search -- 类型: `WalineSearchOptions | false` +- 类型: `WalineSearchOptions | 'disabled'` ```ts interface WalineSearchImageData extends Record { @@ -286,12 +286,11 @@ Waline 多语言配置。 自定义搜索功能,设置 `false` 可禁用搜索。 -## copyright +## noCopyright - 类型: `boolean` -- 默认值: `true` -是否显示页脚版权信息。 +是否隐藏页脚版权信息。 ::: tip diff --git a/package.json b/package.json index 5b339bbf1b0..a395b785b5c 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "packageManager": "pnpm@10.0.0", "pnpm": { "overrides": { - "stylelint>ignore": "7.0.0" + "@waline/api": "workspace:*" } }, "apidoc": { diff --git a/packages/api/src/comment.ts b/packages/api/src/comment.ts index 40702698da5..8888363903d 100644 --- a/packages/api/src/comment.ts +++ b/packages/api/src/comment.ts @@ -174,7 +174,7 @@ export interface DeleteCommentOptions extends BaseAPIOptions { * * 待删除的评论对象 ID */ - objectId: string | number; + objectId: number; } export interface DeleteCommentResponse extends ErrorStatusResponse { @@ -233,7 +233,7 @@ export interface UpdateCommentOptions extends BaseAPIOptions { * * Comment ID */ - objectId: number | string; + objectId: number; /** * 评论数据 diff --git a/packages/api/src/login.ts b/packages/api/src/login.ts index b9a265aa31b..f722c8e0a86 100644 --- a/packages/api/src/login.ts +++ b/packages/api/src/login.ts @@ -50,7 +50,7 @@ export interface UserInfo { * * User object ID */ - objectId: string | number; + objectId: number; /** * 用户身份 diff --git a/packages/api/src/typings.ts b/packages/api/src/typings.ts index 79b2360ae17..ec4a2054920 100644 --- a/packages/api/src/typings.ts +++ b/packages/api/src/typings.ts @@ -40,14 +40,14 @@ export interface WalineCommentData { * @description Only available when replying comment */ - pid?: string; + pid?: number; /** * Root comment id * * @description Only available when replying comment */ - rid?: string; + rid?: number; /** * User id being at @@ -72,7 +72,7 @@ export interface BaseWalineResponseComment { /** * Comment object ID */ - objectId: string; + objectId: number; /** * Timestamp of the comment @@ -135,7 +135,7 @@ export interface BaseWalineResponseComment { */ // FIXME: Rename it to `userId` // eslint-disable-next-line @typescript-eslint/naming-convention - user_id?: string; + user_id?: number; /** * User location @@ -205,12 +205,12 @@ export interface WalineChildComment extends BaseWalineResponseComment { * Parent comment id */ - pid: string; + pid: number; /** * Root comment id */ - rid: string; + rid: number; /** * User id being at diff --git a/packages/client/src/components/CommentBox.vue b/packages/client/src/components/CommentBox.vue index ed5bb97030e..218cff440f4 100644 --- a/packages/client/src/components/CommentBox.vue +++ b/packages/client/src/components/CommentBox.vue @@ -1,5 +1,10 @@