diff --git a/_config.yml b/_config.yml index 7bc25d13c..7ebd93b2c 100755 --- a/_config.yml +++ b/_config.yml @@ -516,13 +516,24 @@ comments: placeholder: # 评论占位提示 serverURL: # Waline 的服务端地址(必填) 测试用地址: https://waline.vercel.app imageUploader: - # 以兰空图床为例,下列填写内容为: + # 适配了兰空图床V1、V2版本 + # 以兰空图床V1为例,下列填写内容为: + # fileName: file + # tokenName: Authorization # url: https://xxxxxx/api/v1/upload # token: Bearer xxxxxxxxxxxxxx # resp: data.links.url - api: # 图床地址 + # 以兰空图床V2为例,下列填写内容为: + # fileName: image + # tokenName: token + # url: https://xxxxxx/api/upload + # token: xxxxxxxxxxxxxx + # resp: data.url + fileName: # 根据版本二选一 + tokenName: # 根据版本二选一 + api: # 图床 api 地址 token: # 图床验证 - resp: # 图片地址返回值的字段 + resp: # 图片地址返回值的字段 pageview: true # 是否显示文章阅读数 comment: true # 是否显示文章评论数 # 其他配置项按照yml格式继续填写即可 除了 [el path imageUploader] 选项 diff --git a/layout/_plugins/comments/waline/script.ejs b/layout/_plugins/comments/waline/script.ejs index f278c403b..906757676 100644 --- a/layout/_plugins/comments/waline/script.ejs +++ b/layout/_plugins/comments/waline/script.ejs @@ -24,10 +24,10 @@ let headers = new Headers(); headers.set('Accept', 'application/json'); <% if(!!theme.comments.waline.imageUploader?.token) { %> - headers.set('Authorization', '<%= theme.comments.waline.imageUploader?.token %>') + headers.set('<%= theme.comments.waline.imageUploader?.tokenName %>', '<%= theme.comments.waline.imageUploader?.token %>') <% } %> let formData = new FormData(); - formData.append('file', file); + formData.append('<%= theme.comments.waline.imageUploader?.fileName %>', file); return fetch('<%= theme.comments.waline.imageUploader?.api %>',{ method: 'POST', body: formData,