diff --git a/_config.yml b/_config.yml index 298999ff..0a2c18fa 100644 --- a/_config.yml +++ b/_config.yml @@ -149,6 +149,9 @@ waline: meta: ['nick', 'mail'] requiredMeta: ['nick', 'mail'] commentSorting: 'latest' + wordLimit: 0 + imageUploader: false + pageSize: 10 serverURL: '' # 填写服务端地址 # Enable Busuanzi statistic plugin diff --git a/src/components/Comment.vue b/src/components/Comment.vue index 636b8813..14e1f8d8 100644 --- a/src/components/Comment.vue +++ b/src/components/Comment.vue @@ -140,7 +140,10 @@ export default defineComponent({ reaction, meta, requiredMeta, - commentSorting + commentSorting, + wordLimit, + imageUploader, + pageSize } = appStore.themeConfig.plugins.waline waline = walineInit({ @@ -150,7 +153,10 @@ export default defineComponent({ reaction, meta, requiredMeta, - commentSorting + commentSorting, + wordLimit, + imageUploader, + pageSize }) } } diff --git a/src/models/ThemeConfig.class.ts b/src/models/ThemeConfig.class.ts index 1bfd6a1c..a4fc240e 100644 --- a/src/models/ThemeConfig.class.ts +++ b/src/models/ThemeConfig.class.ts @@ -469,6 +469,9 @@ export interface PluginsData { login: string meta: string[] | never[] requiredMeta: string[] | never[] + imageUploader?: boolean + wordLimit: number | number[] + pageSize: number commentSorting: string } @@ -546,6 +549,9 @@ export class Plugins implements PluginsData { login: 'disable', meta: [], requiredMeta: [], + imageUploader: false, + wordLimit: 0, + pageSize: 10, commentSorting: 'latest' } recent_comments = false diff --git a/src/utils/comments/waline-api.ts b/src/utils/comments/waline-api.ts index a855e16c..6231ad90 100644 --- a/src/utils/comments/waline-api.ts +++ b/src/utils/comments/waline-api.ts @@ -36,6 +36,12 @@ interface WalineComment { user_id: number | null } +interface WalineInitOptions extends WalineConfig { + el: string + dark: string + locale: string +} + export const walineInit = ({ serverURL, lang = 'en', @@ -43,20 +49,28 @@ export const walineInit = ({ login = 'disable', meta, requiredMeta, - commentSorting + commentSorting, + wordLimit, + imageUploader, + pageSize }: Partial) => { - return init({ + let options: Partial = { el: '#waline', dark: 'body[class="theme-dark"]', reaction, serverURL, lang, login, - local: 'zh-CN', + locale: 'zh-CN', meta, requiredMeta, - commentSorting - }) + commentSorting, + wordLimit, + pageSize + } + + if (imageUploader === false) options = { imageUploader, ...options } + return init(options) } export class WalineComments {