Skip to content

Commit 0a2ba51

Browse files
authored
fix: avatar issue (#287)
* fix: avatar issue * fix: version number
1 parent a954b3c commit 0a2ba51

File tree

8 files changed

+16
-18
lines changed

8 files changed

+16
-18
lines changed

docs/.vuepress/theme/layouts/Layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<!-- Twikoo -->
1515
<div id="twikoo"></div>
16-
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.4.12/dist/twikoo.all.min.js" ref="twikooJs"></script>
16+
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.4.13/dist/twikoo.all.min.js" ref="twikooJs"></script>
1717
</div>
1818
</template>
1919
</ParentLayout>

docs/quick-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ exports.main = require('twikoo-func').main
4444
8. 创建完成后,点击“twikoo"进入云函数详情页,进入“函数代码”标签,点击“文件 - 新建文件”,输入 `package.json`,回车
4545
9. 复制以下代码、粘贴到代码框中,点击“保存并安装依赖”
4646
``` json
47-
{ "dependencies": { "twikoo-func": "1.4.12" } }
47+
{ "dependencies": { "twikoo-func": "1.4.13" } }
4848
```
4949

5050
### 命令行部署
@@ -174,7 +174,7 @@ twikoo:
174174

175175
``` html
176176
<div id="tcomment"></div>
177-
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.4.12/dist/twikoo.all.min.js"></script>
177+
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.4.13/dist/twikoo.all.min.js"></script>
178178
<script>
179179
twikoo.init({
180180
envId: '您的环境id',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twikoo",
3-
"version": "1.4.12",
3+
"version": "1.4.13",
44
"description": "A simple comment system based on Tencent CloudBase (tcb).",
55
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
66
"license": "MIT",

src/function/twikoo/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Twikoo cloudbase function v1.4.12
2+
* Twikoo cloudbase function v1.4.13
33
* (c) 2020-present iMaeGoo
44
* Released under the MIT License.
55
*/
@@ -31,7 +31,7 @@ const window = new JSDOM('').window
3131
const DOMPurify = createDOMPurify(window)
3232

3333
// 常量 / constants
34-
const VERSION = '1.4.12'
34+
const VERSION = '1.4.13'
3535
const RES_CODE = {
3636
SUCCESS: 0,
3737
FAIL: 1000,
@@ -1182,7 +1182,6 @@ async function parse (comment) {
11821182
ip: auth.getClientIP(),
11831183
master: isBloggerMail,
11841184
url: comment.url,
1185-
avatar: getAvatar(comment),
11861185
href: comment.href,
11871186
comment: DOMPurify.sanitize(comment.comment, { FORBID_TAGS: ['style'], FORBID_ATTR: ['style'] }),
11881187
pid: comment.pid ? comment.pid : comment.rid,

src/function/twikoo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twikoo-func",
3-
"version": "1.4.12",
3+
"version": "1.4.13",
44
"description": "A simple comment system based on Tencent CloudBase (tcb).",
55
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
66
"license": "MIT",

src/vercel-min/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "dependencies": { "twikoo-vercel": "1.4.12" } }
1+
{ "dependencies": { "twikoo-vercel": "1.4.13" } }

src/vercel/api/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Twikoo vercel function v1.4.12
2+
* Twikoo vercel function v1.4.13
33
* (c) 2020-present iMaeGoo
44
* Released under the MIT License.
55
*/
@@ -27,7 +27,7 @@ const window = new JSDOM('').window
2727
const DOMPurify = createDOMPurify(window)
2828

2929
// 常量 / constants
30-
const VERSION = '1.4.12'
30+
const VERSION = '1.4.13'
3131
const RES_CODE = {
3232
SUCCESS: 0,
3333
NO_PARAM: 100,
@@ -852,7 +852,7 @@ async function commentSubmit (event) {
852852
axios.post(`https://${process.env.VERCEL_URL}`, {
853853
event: 'POST_SUBMIT',
854854
comment
855-
}, { headers: { 'x-twikoo-recursion': 'true' } }),
855+
}, { headers: { 'x-twikoo-recursion': config.ADMIN_PASS || 'true' } }),
856856
// 如果超过 5 秒还没收到异步返回,直接继续,减少用户等待的时间
857857
new Promise((resolve) => setTimeout(resolve, 5000))
858858
])
@@ -950,7 +950,7 @@ async function noticeMaster (comment) {
950950
if (hasIMPushConfig && config.SC_MAIL_NOTIFY !== 'true') return
951951
const SITE_NAME = config.SITE_NAME
952952
const NICK = comment.nick
953-
const IMG = comment.avatar
953+
const IMG = getAvatar(comment)
954954
const IP = comment.ip
955955
const MAIL = comment.mail
956956
const COMMENT = comment.comment
@@ -1113,8 +1113,8 @@ async function noticeReply (currentComment) {
11131113
// 回复自己的评论,不邮件通知
11141114
if (currentComment.mail === parentComment.mail) return
11151115
const PARENT_NICK = parentComment.nick
1116-
const IMG = currentComment.avatar
1117-
const PARENT_IMG = parentComment.avatar
1116+
const IMG = getAvatar(currentComment)
1117+
const PARENT_IMG = getAvatar(parentComment)
11181118
const SITE_NAME = config.SITE_NAME
11191119
const NICK = currentComment.nick
11201120
const COMMENT = currentComment.comment
@@ -1192,7 +1192,6 @@ async function parse (comment) {
11921192
ip: request.headers['x-real-ip'],
11931193
master: isBloggerMail,
11941194
url: comment.url,
1195-
avatar: getAvatar(comment),
11961195
href: comment.href,
11971196
comment: DOMPurify.sanitize(comment.comment, { FORBID_TAGS: ['style'], FORBID_ATTR: ['style'] }),
11981197
pid: comment.pid ? comment.pid : comment.rid,
@@ -1626,7 +1625,7 @@ async function isAdmin () {
16261625

16271626
// 判断是否为递归调用(即云函数调用自身)
16281627
function isRecursion () {
1629-
return request.headers['x-twikoo-recursion'] === 'true'
1628+
return request.headers['x-twikoo-recursion'] === (config.ADMIN_PASS || 'true')
16301629
}
16311630

16321631
// 建立数据库 collections

src/vercel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twikoo-vercel",
3-
"version": "1.4.12",
3+
"version": "1.4.13",
44
"description": "A simple comment system based on Tencent CloudBase (tcb).",
55
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
66
"license": "MIT",

0 commit comments

Comments
 (0)