Skip to content

Commit

Permalink
评论系统 Waline 新增兰空图床 V2 适配 (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
i-abc authored Jan 12, 2023
1 parent 4068032 commit f249900
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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] 选项
Expand Down
4 changes: 2 additions & 2 deletions layout/_plugins/comments/waline/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f249900

Please sign in to comment.