artalk 2.6.4 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +7794 -7483
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +5587 -5276
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/src/api/{api-base.d.ts → _base.d.ts} +3 -7
- package/dist/src/api/_options.d.ts +19 -0
- package/dist/src/api/{request.d.ts → _request.d.ts} +3 -3
- package/dist/src/api/admin.d.ts +1 -1
- package/dist/src/api/captcha.d.ts +1 -1
- package/dist/src/api/comment.d.ts +2 -2
- package/dist/src/api/index.d.ts +2 -4
- package/dist/src/api/page.d.ts +3 -3
- package/dist/src/api/site.d.ts +2 -2
- package/dist/src/api/system.d.ts +13 -3
- package/dist/src/api/upload.d.ts +1 -1
- package/dist/src/api/user.d.ts +2 -2
- package/dist/src/artalk.d.ts +14 -37
- package/dist/src/comment/actions.d.ts +1 -1
- package/dist/src/comment/comment.d.ts +3 -4
- package/dist/src/comment/render.d.ts +21 -3
- package/dist/src/comment/renders/actions.d.ts +2 -2
- package/dist/src/comment/renders/avatar.d.ts +2 -2
- package/dist/src/comment/renders/content.d.ts +2 -2
- package/dist/src/comment/renders/header.d.ts +2 -2
- package/dist/src/comment/renders/index.d.ts +2 -2
- package/dist/src/comment/renders/pending.d.ts +2 -2
- package/dist/src/comment/renders/reply-at.d.ts +2 -2
- package/dist/src/comment/renders/reply-to.d.ts +2 -2
- package/dist/src/components/action-btn.d.ts +3 -5
- package/dist/src/{lib → components}/checker/admin.d.ts +1 -1
- package/dist/src/{lib → components}/checker/captcha-renders.d.ts +1 -1
- package/dist/src/{lib → components}/checker/captcha.d.ts +1 -1
- package/dist/src/{lib → components}/checker/index.d.ts +10 -7
- package/dist/src/components/dark-mode.d.ts +2 -0
- package/dist/src/components/dialog.d.ts +1 -3
- package/dist/src/components/error-dialog.d.ts +8 -0
- package/dist/src/components/pagination.d.ts +4 -3
- package/dist/src/components/read-more-btn.d.ts +3 -3
- package/dist/src/config.d.ts +24 -8
- package/dist/src/context.d.ts +16 -35
- package/dist/src/data.d.ts +27 -0
- package/dist/src/defaults.d.ts +1 -1
- package/dist/src/editor/editor.d.ts +14 -61
- package/dist/src/editor/state.d.ts +20 -0
- package/dist/src/i18n/zh-CN.d.ts +1 -1
- package/dist/src/layer/index.d.ts +4 -3
- package/dist/src/layer/layer-manager.d.ts +9 -0
- package/dist/src/layer/layer.d.ts +8 -28
- package/dist/src/layer/scrollbar-helper.d.ts +5 -0
- package/dist/src/layer/sidebar-layer.d.ts +6 -6
- package/dist/src/layer/wrap.d.ts +13 -0
- package/dist/src/lib/component.d.ts +3 -8
- package/dist/src/lib/event-manager.d.ts +28 -0
- package/dist/src/lib/highlight.d.ts +1 -0
- package/dist/src/lib/marked-renderer.d.ts +4 -0
- package/dist/src/lib/marked.d.ts +4 -2
- package/dist/src/lib/sanitizer.d.ts +1 -0
- package/dist/src/lib/ui.d.ts +3 -2
- package/dist/src/lib/user.d.ts +8 -5
- package/dist/src/lib/utils.d.ts +11 -5
- package/dist/src/list/comment.d.ts +3 -0
- package/dist/src/list/layout.d.ts +23 -0
- package/dist/src/list/list.d.ts +13 -25
- package/dist/src/list/{list-nest.d.ts → nest.d.ts} +1 -1
- package/dist/src/list/page.d.ts +2 -0
- package/dist/src/list/paginator/index.d.ts +22 -7
- package/dist/src/list/paginator/read-more.d.ts +18 -0
- package/dist/src/list/paginator/up-down.d.ts +14 -0
- package/dist/src/main.d.ts +2 -0
- package/dist/src/plugins/admin-only-elem.d.ts +2 -0
- package/dist/src/plugins/conf-remoter.d.ts +2 -0
- package/dist/src/plugins/dark-mode.d.ts +2 -0
- package/dist/src/plugins/editor/_kit.d.ts +27 -0
- package/dist/src/plugins/editor/_plug.d.ts +29 -0
- package/dist/src/plugins/editor/_sample.d.ts +5 -0
- package/dist/src/plugins/editor/closable.d.ts +7 -0
- package/dist/src/{editor/plugs/emoticons-plug.d.ts → plugins/editor/emoticons.d.ts} +10 -16
- package/dist/src/plugins/editor/header-event.d.ts +6 -0
- package/dist/src/plugins/editor/header-link.d.ts +6 -0
- package/dist/src/plugins/editor/header-user.d.ts +16 -0
- package/dist/src/plugins/editor/index.d.ts +6 -0
- package/dist/src/plugins/editor/local-storage.d.ts +6 -0
- package/dist/src/plugins/editor/mover.d.ts +6 -0
- package/dist/src/plugins/editor/preview.d.ts +7 -0
- package/dist/src/plugins/editor/state-edit.d.ts +11 -0
- package/dist/src/plugins/editor/state-reply.d.ts +8 -0
- package/dist/src/plugins/editor/submit-add.d.ts +18 -0
- package/dist/src/plugins/editor/submit-btn.d.ts +5 -0
- package/dist/src/plugins/editor/submit.d.ts +17 -0
- package/dist/src/plugins/editor/textarea.d.ts +8 -0
- package/dist/src/plugins/editor/upload.d.ts +9 -0
- package/dist/src/plugins/editor-kit.d.ts +42 -0
- package/dist/src/plugins/index.d.ts +2 -0
- package/dist/src/plugins/list/copyright.d.ts +2 -0
- package/dist/src/plugins/list/count.d.ts +2 -0
- package/dist/src/plugins/list/dropdown.d.ts +2 -0
- package/dist/src/plugins/list/error-dialog.d.ts +2 -0
- package/dist/src/plugins/list/fetch.d.ts +2 -0
- package/dist/src/plugins/list/goto-first.d.ts +3 -0
- package/dist/src/plugins/list/goto.d.ts +2 -0
- package/dist/src/plugins/list/index.d.ts +3 -0
- package/dist/src/plugins/list/loading.d.ts +2 -0
- package/dist/src/plugins/list/no-comment.d.ts +2 -0
- package/dist/src/plugins/list/reach-bottom.d.ts +2 -0
- package/dist/src/plugins/list/sidebar-btn.d.ts +2 -0
- package/dist/src/plugins/list/time-ticking.d.ts +3 -0
- package/dist/src/plugins/list/unread-badge.d.ts +2 -0
- package/dist/src/plugins/list/unread.d.ts +2 -0
- package/dist/src/plugins/list/with-editor.d.ts +2 -0
- package/dist/src/plugins/markdown.d.ts +2 -0
- package/dist/src/plugins/stat.d.ts +13 -0
- package/dist/src/plugins/version-check.d.ts +2 -0
- package/dist/src/service.d.ts +19 -23
- package/dist/tests/e2e/comment-add.spec.d.ts +1 -0
- package/dist/types/config.d.ts +110 -0
- package/dist/types/context.d.ts +56 -136
- package/dist/types/data.d.ts +194 -0
- package/dist/types/editor.d.ts +76 -0
- package/dist/types/event.d.ts +36 -25
- package/dist/types/index.d.ts +7 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/sidebar.d.ts +3 -0
- package/package.json +5 -2
- package/src/api/_base.ts +18 -0
- package/src/api/_options.ts +25 -0
- package/src/api/{request.ts → _request.ts} +19 -18
- package/src/api/admin.ts +1 -1
- package/src/api/captcha.ts +1 -1
- package/src/api/comment.ts +4 -4
- package/src/api/index.ts +3 -12
- package/src/api/page.ts +5 -5
- package/src/api/site.ts +2 -2
- package/src/api/system.ts +19 -7
- package/src/api/upload.ts +3 -3
- package/src/api/user.ts +3 -3
- package/src/artalk.ts +49 -97
- package/src/comment/actions.ts +1 -4
- package/src/comment/comment.ts +9 -6
- package/src/comment/render.ts +27 -5
- package/src/comment/renders/actions.ts +45 -45
- package/src/comment/renders/avatar.ts +7 -7
- package/src/comment/renders/content.ts +18 -18
- package/src/comment/renders/header.ts +13 -13
- package/src/comment/renders/index.ts +3 -3
- package/src/comment/renders/pending.ts +5 -5
- package/src/comment/renders/reply-at.ts +8 -8
- package/src/comment/renders/reply-to.ts +13 -13
- package/src/components/action-btn.ts +11 -13
- package/src/{lib → components}/checker/admin.ts +6 -6
- package/src/{lib → components}/checker/captcha-renders.ts +7 -6
- package/src/{lib → components}/checker/captcha.ts +1 -1
- package/src/{lib → components}/checker/index.ts +21 -26
- package/src/components/dark-mode.ts +30 -0
- package/src/components/dialog.ts +4 -9
- package/src/components/error-dialog.ts +35 -0
- package/src/components/pagination.ts +10 -6
- package/src/components/read-more-btn.ts +7 -7
- package/src/config.ts +60 -6
- package/src/context.ts +39 -144
- package/src/data.ts +110 -0
- package/src/defaults.ts +1 -1
- package/src/editor/editor.ts +39 -152
- package/src/editor/state.ts +52 -0
- package/src/i18n/zh-CN.ts +1 -1
- package/src/layer/index.ts +4 -4
- package/src/layer/layer-manager.ts +32 -0
- package/src/layer/layer.ts +20 -144
- package/src/layer/scrollbar-helper.ts +24 -0
- package/src/layer/sidebar-layer.ts +74 -64
- package/src/layer/wrap.ts +77 -0
- package/src/lib/component.ts +4 -11
- package/src/lib/detect.ts +1 -1
- package/src/lib/event-manager.ts +47 -0
- package/src/lib/highlight.ts +5 -0
- package/src/lib/marked-renderer.ts +32 -0
- package/src/lib/marked.ts +43 -104
- package/src/lib/sanitizer.ts +57 -0
- package/src/lib/ui.ts +22 -15
- package/src/lib/user.ts +21 -16
- package/src/lib/utils.ts +29 -18
- package/src/list/comment.ts +20 -0
- package/src/list/layout.ts +120 -0
- package/src/list/list.html +3 -1
- package/src/list/list.ts +56 -200
- package/src/list/{list-nest.ts → nest.ts} +1 -1
- package/src/list/page.ts +97 -0
- package/src/list/paginator/index.ts +20 -8
- package/src/list/paginator/read-more.ts +67 -0
- package/src/list/paginator/up-down.ts +51 -0
- package/src/main.ts +2 -0
- package/src/plugins/admin-only-elem.ts +40 -0
- package/src/plugins/conf-remoter.ts +54 -0
- package/src/plugins/dark-mode.ts +12 -0
- package/src/plugins/editor/_kit.ts +57 -0
- package/src/plugins/editor/_plug.ts +60 -0
- package/src/plugins/editor/_sample.ts +8 -0
- package/src/plugins/editor/closable.ts +44 -0
- package/src/{editor/plugs/emoticons-plug.ts → plugins/editor/emoticons.ts} +51 -52
- package/src/plugins/editor/header-event.ts +35 -0
- package/src/plugins/editor/header-link.ts +31 -0
- package/src/plugins/editor/header-user.ts +98 -0
- package/src/plugins/editor/index.ts +40 -0
- package/src/plugins/editor/local-storage.ts +36 -0
- package/src/plugins/editor/mover.ts +29 -0
- package/src/plugins/editor/preview.ts +41 -0
- package/src/plugins/editor/state-edit.ts +116 -0
- package/src/plugins/editor/state-reply.ts +91 -0
- package/src/plugins/editor/submit-add.ts +33 -0
- package/src/plugins/editor/submit-btn.ts +25 -0
- package/src/plugins/editor/submit.ts +73 -0
- package/src/plugins/editor/textarea.ts +55 -0
- package/src/plugins/editor/upload.ts +145 -0
- package/src/plugins/editor-kit.ts +161 -0
- package/src/plugins/index.ts +16 -0
- package/src/plugins/list/copyright.ts +16 -0
- package/src/plugins/list/count.ts +31 -0
- package/src/plugins/list/dropdown.ts +95 -0
- package/src/plugins/list/error-dialog.ts +22 -0
- package/src/plugins/list/fetch.ts +64 -0
- package/src/plugins/list/goto-first.ts +23 -0
- package/src/plugins/list/goto.ts +72 -0
- package/src/plugins/list/index.ts +25 -0
- package/src/plugins/list/loading.ts +17 -0
- package/src/plugins/list/no-comment.ts +25 -0
- package/src/plugins/list/reach-bottom.ts +46 -0
- package/src/plugins/list/sidebar-btn.ts +39 -0
- package/src/plugins/list/time-ticking.ts +22 -0
- package/src/plugins/list/unread-badge.ts +26 -0
- package/src/plugins/list/unread.ts +38 -0
- package/src/plugins/list/with-editor.ts +59 -0
- package/src/plugins/markdown.ts +10 -0
- package/src/plugins/stat.ts +79 -0
- package/src/plugins/version-check.ts +37 -0
- package/src/service.ts +34 -61
- package/src/style/comment.scss +5 -7
- package/src/style/editor.scss +5 -0
- package/src/style/list.scss +1 -1
- package/types/{artalk-config.d.ts → config.ts} +16 -2
- package/types/context.ts +84 -0
- package/types/{artalk-data.d.ts → data.ts} +41 -0
- package/types/editor.ts +95 -0
- package/types/event.ts +40 -0
- package/types/index.ts +7 -0
- package/types/plugin.ts +3 -0
- package/types/sidebar.ts +3 -0
- package/dist/src/comment/render-ctx.d.ts +0 -23
- package/dist/src/editor/edit-mode.d.ts +0 -9
- package/dist/src/editor/funcs.d.ts +0 -2
- package/dist/src/editor/index.d.ts +0 -2
- package/dist/src/editor/mover.d.ts +0 -8
- package/dist/src/editor/plug-manager.d.ts +0 -17
- package/dist/src/editor/plugs/editor-plug.d.ts +0 -38
- package/dist/src/editor/plugs/header-input-plug.d.ts +0 -13
- package/dist/src/editor/plugs/preview-plug.d.ts +0 -10
- package/dist/src/editor/plugs/upload-plug.d.ts +0 -10
- package/dist/src/editor/reply.d.ts +0 -9
- package/dist/src/editor/submit.d.ts +0 -16
- package/dist/src/lib/dark-mode.d.ts +0 -4
- package/dist/src/lib/stat.d.ts +0 -15
- package/dist/src/list/index.d.ts +0 -2
- package/dist/src/list/list-lite.d.ts +0 -77
- package/dist/src/list/list-ui.d.ts +0 -16
- package/dist/src/list/paginator/adaptors/index.d.ts +0 -12
- package/dist/src/list/paginator/adaptors/pagination.d.ts +0 -9
- package/dist/src/list/paginator/adaptors/read-more.d.ts +0 -10
- package/dist/src/list/paginator/holder.d.ts +0 -16
- package/dist/types/artalk-config.d.ts +0 -139
- package/dist/types/artalk-data.d.ts +0 -230
- package/dist/types/plug.d.ts +0 -4
- package/src/api/api-base.ts +0 -27
- package/src/comment/render-ctx.ts +0 -30
- package/src/editor/edit-mode.ts +0 -105
- package/src/editor/funcs.ts +0 -150
- package/src/editor/index.ts +0 -3
- package/src/editor/mover.ts +0 -43
- package/src/editor/plug-manager.ts +0 -172
- package/src/editor/plugs/editor-plug.ts +0 -69
- package/src/editor/plugs/header-input-plug.ts +0 -79
- package/src/editor/plugs/preview-plug.ts +0 -44
- package/src/editor/plugs/upload-plug.ts +0 -122
- package/src/editor/reply.ts +0 -62
- package/src/editor/submit.ts +0 -99
- package/src/lib/dark-mode.ts +0 -48
- package/src/lib/stat.ts +0 -71
- package/src/list/index.ts +0 -3
- package/src/list/list-lite.ts +0 -424
- package/src/list/list-ui.ts +0 -137
- package/src/list/paginator/adaptors/index.ts +0 -21
- package/src/list/paginator/adaptors/pagination.ts +0 -42
- package/src/list/paginator/adaptors/read-more.ts +0 -56
- package/src/list/paginator/holder.ts +0 -56
- package/types/context.d.ts +0 -142
- package/types/event.d.ts +0 -28
- package/types/plug.d.ts +0 -4
- /package/src/{editor/plugs/emoticons-plug.scss → plugins/editor/emoticons.scss} +0 -0
- /package/src/{editor/plugs/preview-plug.scss → plugins/editor/preview.scss} +0 -0
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
2
|
import ActionBtn from '../../components/action-btn'
|
|
3
|
-
import
|
|
3
|
+
import type Render from '../render'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 评论操作按钮界面
|
|
7
7
|
*/
|
|
8
|
-
export default function renderActions(
|
|
8
|
+
export default function renderActions(r: Render) {
|
|
9
9
|
Object.entries({
|
|
10
10
|
renderVote, renderReply,
|
|
11
11
|
// 管理员操作
|
|
12
12
|
renderCollapse, renderModerator, renderPin, renderEdit, renderDel
|
|
13
13
|
}).forEach(([name, render]) => {
|
|
14
|
-
render(
|
|
14
|
+
render(r)
|
|
15
15
|
})
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
// 操作按钮 - 投票
|
|
20
|
-
function renderVote(
|
|
21
|
-
if (!
|
|
20
|
+
function renderVote(r: Render) {
|
|
21
|
+
if (!r.ctx.conf.vote) return // 关闭投票功能
|
|
22
22
|
|
|
23
23
|
// 赞同按钮
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
r.voteBtnUp = new ActionBtn(() => `${r.ctx.$t('voteUp')} (${r.data.vote_up || 0})`).appendTo(r.$actions)
|
|
25
|
+
r.voteBtnUp.setClick(() => {
|
|
26
|
+
r.comment.getActions().vote('up')
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
// 反对按钮
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (r.ctx.conf.voteDown) {
|
|
31
|
+
r.voteBtnDown = new ActionBtn(() => `${r.ctx.$t('voteDown')} (${r.data.vote_down || 0})`).appendTo(r.$actions)
|
|
32
|
+
r.voteBtnDown.setClick(() => {
|
|
33
|
+
r.comment.getActions().vote('down')
|
|
34
34
|
})
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// 操作按钮 - 回复
|
|
39
|
-
function renderReply(
|
|
40
|
-
if (!
|
|
39
|
+
function renderReply(r: Render) {
|
|
40
|
+
if (!r.data.is_allow_reply) return // 不允许回复
|
|
41
41
|
|
|
42
|
-
const replyBtn = Utils.createElement(`<span>${
|
|
43
|
-
|
|
42
|
+
const replyBtn = Utils.createElement(`<span>${r.ctx.$t('reply')}</span>`)
|
|
43
|
+
r.$actions.append(replyBtn)
|
|
44
44
|
replyBtn.addEventListener('click', (e) => {
|
|
45
45
|
e.stopPropagation() // 防止穿透
|
|
46
|
-
if (!
|
|
47
|
-
|
|
46
|
+
if (!r.cConf.onReplyBtnClick) {
|
|
47
|
+
r.ctx.replyComment(r.data, r.$el)
|
|
48
48
|
} else {
|
|
49
|
-
|
|
49
|
+
r.cConf.onReplyBtnClick()
|
|
50
50
|
}
|
|
51
51
|
})
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// 操作按钮 - 折叠
|
|
55
|
-
function renderCollapse(
|
|
56
|
-
const collapseBtn = new ActionBtn(
|
|
57
|
-
text: () => (
|
|
55
|
+
function renderCollapse(r: Render) {
|
|
56
|
+
const collapseBtn = new ActionBtn({
|
|
57
|
+
text: () => (r.data.is_collapsed ? r.ctx.$t('expand') : r.ctx.$t('collapse')),
|
|
58
58
|
adminOnly: true
|
|
59
59
|
})
|
|
60
|
-
collapseBtn.appendTo(
|
|
60
|
+
collapseBtn.appendTo(r.$actions)
|
|
61
61
|
collapseBtn.setClick(() => {
|
|
62
|
-
|
|
62
|
+
r.comment.getActions().adminEdit('collapsed', collapseBtn)
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// 操作按钮 - 审核
|
|
67
|
-
function renderModerator(
|
|
68
|
-
const pendingBtn = new ActionBtn(
|
|
69
|
-
text: () => (
|
|
67
|
+
function renderModerator(r: Render) {
|
|
68
|
+
const pendingBtn = new ActionBtn({
|
|
69
|
+
text: () => (r.data.is_pending ? r.ctx.$t('pending') : r.ctx.$t('approved')),
|
|
70
70
|
adminOnly: true
|
|
71
71
|
})
|
|
72
|
-
pendingBtn.appendTo(
|
|
72
|
+
pendingBtn.appendTo(r.$actions)
|
|
73
73
|
pendingBtn.setClick(() => {
|
|
74
|
-
|
|
74
|
+
r.comment.getActions().adminEdit('pending', pendingBtn)
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// 操作按钮 - 置顶
|
|
79
|
-
function renderPin(
|
|
80
|
-
const pinnedBtn = new ActionBtn(
|
|
81
|
-
text: () => (
|
|
79
|
+
function renderPin(r: Render) {
|
|
80
|
+
const pinnedBtn = new ActionBtn({
|
|
81
|
+
text: () => (r.data.is_pinned ? r.ctx.$t('unpin') : r.ctx.$t('pin')),
|
|
82
82
|
adminOnly: true
|
|
83
83
|
})
|
|
84
|
-
pinnedBtn.appendTo(
|
|
84
|
+
pinnedBtn.appendTo(r.$actions)
|
|
85
85
|
pinnedBtn.setClick(() => {
|
|
86
|
-
|
|
86
|
+
r.comment.getActions().adminEdit('pinned', pinnedBtn)
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// 操作按钮 - 编辑
|
|
91
|
-
function renderEdit(
|
|
92
|
-
const editBtn = new ActionBtn(
|
|
93
|
-
text:
|
|
91
|
+
function renderEdit(r: Render) {
|
|
92
|
+
const editBtn = new ActionBtn({
|
|
93
|
+
text: r.ctx.$t('edit'),
|
|
94
94
|
adminOnly: true
|
|
95
95
|
})
|
|
96
|
-
editBtn.appendTo(
|
|
96
|
+
editBtn.appendTo(r.$actions)
|
|
97
97
|
editBtn.setClick(() => {
|
|
98
|
-
|
|
98
|
+
r.ctx.editComment(r.data, r.$el)
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// 操作按钮 - 删除
|
|
103
|
-
function renderDel(
|
|
104
|
-
const delBtn = new ActionBtn(
|
|
105
|
-
text:
|
|
103
|
+
function renderDel(r: Render) {
|
|
104
|
+
const delBtn = new ActionBtn({
|
|
105
|
+
text: r.ctx.$t('delete'),
|
|
106
106
|
confirm: true,
|
|
107
|
-
confirmText:
|
|
107
|
+
confirmText: r.ctx.$t('deleteConfirm'),
|
|
108
108
|
adminOnly: true,
|
|
109
109
|
})
|
|
110
|
-
delBtn.appendTo(
|
|
110
|
+
delBtn.appendTo(r.$actions)
|
|
111
111
|
delBtn.setClick(() => {
|
|
112
|
-
|
|
112
|
+
r.comment.getActions().adminDelete(delBtn)
|
|
113
113
|
})
|
|
114
114
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
|
-
import
|
|
2
|
+
import type Render from '../render'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 评论头像界面
|
|
6
6
|
*/
|
|
7
|
-
export default function renderAvatar(
|
|
8
|
-
const $avatar =
|
|
7
|
+
export default function renderAvatar(r: Render) {
|
|
8
|
+
const $avatar = r.$el.querySelector<HTMLElement>('.atk-avatar')!
|
|
9
9
|
const $avatarImg = Utils.createElement<HTMLImageElement>('<img />')
|
|
10
10
|
|
|
11
|
-
const avatarURLBuilder =
|
|
12
|
-
$avatarImg.src = avatarURLBuilder ? avatarURLBuilder(
|
|
11
|
+
const avatarURLBuilder = r.conf.avatarURLBuilder
|
|
12
|
+
$avatarImg.src = avatarURLBuilder ? avatarURLBuilder(r.data) : r.comment.getGravatarURL()
|
|
13
13
|
|
|
14
|
-
if (
|
|
14
|
+
if (r.data.link) {
|
|
15
15
|
const $avatarA = Utils.createElement<HTMLLinkElement>('<a target="_blank" rel="noreferrer noopener nofollow"></a>')
|
|
16
|
-
$avatarA.href = Utils.isValidURL(
|
|
16
|
+
$avatarA.href = Utils.isValidURL(r.data.link) ? r.data.link : `https://${r.data.link}`
|
|
17
17
|
$avatarA.append($avatarImg)
|
|
18
18
|
$avatar.append($avatarA)
|
|
19
19
|
} else {
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
2
|
import * as Ui from '../../lib/ui'
|
|
3
|
-
import
|
|
3
|
+
import type Render from '../render'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 评论内容界面
|
|
7
7
|
*/
|
|
8
|
-
export default function renderContent(
|
|
9
|
-
if (!
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export default function renderContent(r: Render) {
|
|
9
|
+
if (!r.data.is_collapsed) {
|
|
10
|
+
r.$content.innerHTML = r.comment.getContentMarked()
|
|
11
|
+
r.$content.classList.remove('atk-hide', 'atk-collapsed')
|
|
12
12
|
return
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// 内容 & 折叠
|
|
16
|
-
|
|
16
|
+
r.$content.classList.add('atk-hide', 'atk-type-collapsed')
|
|
17
17
|
const collapsedInfoEl = Utils.createElement(`
|
|
18
18
|
<div class="atk-collapsed">
|
|
19
|
-
<span class="atk-text">${
|
|
20
|
-
<span class="atk-show-btn">${
|
|
19
|
+
<span class="atk-text">${r.ctx.$t('collapsedMsg')}</span>
|
|
20
|
+
<span class="atk-show-btn">${r.ctx.$t('expand')}</span>
|
|
21
21
|
</div>`)
|
|
22
|
-
|
|
22
|
+
r.$body.insertAdjacentElement('beforeend', collapsedInfoEl)
|
|
23
23
|
|
|
24
|
-
const contentShowBtn = collapsedInfoEl.querySelector('.atk-show-btn')!
|
|
24
|
+
const contentShowBtn = collapsedInfoEl.querySelector<HTMLElement>('.atk-show-btn')!
|
|
25
25
|
contentShowBtn.addEventListener('click', (e) => {
|
|
26
26
|
e.stopPropagation() // 防止穿透
|
|
27
27
|
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Ui.playFadeInAnim(
|
|
32
|
-
contentShowBtn.
|
|
28
|
+
if (r.$content.classList.contains('atk-hide')) {
|
|
29
|
+
r.$content.innerHTML = r.comment.getContentMarked()
|
|
30
|
+
r.$content.classList.remove('atk-hide')
|
|
31
|
+
Ui.playFadeInAnim(r.$content)
|
|
32
|
+
contentShowBtn.innerText = r.ctx.$t('collapse')
|
|
33
33
|
} else {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
contentShowBtn.
|
|
34
|
+
r.$content.innerHTML = ''
|
|
35
|
+
r.$content.classList.add('atk-hide')
|
|
36
|
+
contentShowBtn.innerText = r.ctx.$t('expand')
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
|
-
import
|
|
2
|
+
import type Render from '../render'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 评论头部界面
|
|
6
6
|
*/
|
|
7
|
-
export default function renderHeader(
|
|
7
|
+
export default function renderHeader(r: Render) {
|
|
8
8
|
Object.entries({
|
|
9
9
|
renderNick, renderVerifyBadge, renderDate, renderUABadge
|
|
10
10
|
}).forEach(([name, render]) => {
|
|
11
|
-
render(
|
|
11
|
+
render(r)
|
|
12
12
|
})
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function renderNick(
|
|
16
|
-
|
|
15
|
+
function renderNick(r: Render) {
|
|
16
|
+
r.$headerNick = r.$el.querySelector<HTMLElement>('.atk-nick')!
|
|
17
17
|
|
|
18
|
-
if (
|
|
18
|
+
if (r.data.link) {
|
|
19
19
|
const $nickA = Utils.createElement<HTMLLinkElement>('<a target="_blank" rel="noreferrer noopener nofollow"></a>')
|
|
20
|
-
$nickA.innerText =
|
|
21
|
-
$nickA.href = Utils.isValidURL(
|
|
22
|
-
|
|
20
|
+
$nickA.innerText = r.data.nick
|
|
21
|
+
$nickA.href = Utils.isValidURL(r.data.link) ? r.data.link : `https://${r.data.link}`
|
|
22
|
+
r.$headerNick.append($nickA)
|
|
23
23
|
} else {
|
|
24
|
-
|
|
24
|
+
r.$headerNick.innerText = r.data.nick
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function renderVerifyBadge(ctx:
|
|
28
|
+
function renderVerifyBadge(ctx: Render) {
|
|
29
29
|
ctx.$headerBadgeWrap = ctx.$el.querySelector<HTMLElement>('.atk-badge-wrap')!
|
|
30
30
|
ctx.$headerBadgeWrap.innerHTML = ''
|
|
31
31
|
|
|
@@ -44,13 +44,13 @@ function renderVerifyBadge(ctx: RenderCtx) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function renderDate(ctx:
|
|
47
|
+
function renderDate(ctx: Render) {
|
|
48
48
|
const $date = ctx.$el.querySelector<HTMLElement>('.atk-date')!
|
|
49
49
|
$date.innerText = ctx.comment.getDateFormatted()
|
|
50
50
|
$date.setAttribute('data-atk-comment-date', String(+new Date(ctx.data.date)))
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function renderUABadge(ctx:
|
|
53
|
+
function renderUABadge(ctx: Render) {
|
|
54
54
|
if (!ctx.ctx.conf.uaBadge && !ctx.data.ip_region) return
|
|
55
55
|
|
|
56
56
|
let $uaWrap = ctx.$header.querySelector('atk-ua-wrap')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type Render from '../render'
|
|
2
2
|
import Avatar from './avatar'
|
|
3
3
|
import Header from './header'
|
|
4
4
|
import Content from './content'
|
|
@@ -12,8 +12,8 @@ const Renders = {
|
|
|
12
12
|
ReplyTo, Pending, Actions
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export default function loadRenders(
|
|
15
|
+
export default function loadRenders(r: Render) {
|
|
16
16
|
Object.entries(Renders).forEach(([ name, render ]) => {
|
|
17
|
-
render(
|
|
17
|
+
render(r)
|
|
18
18
|
})
|
|
19
19
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
|
-
import
|
|
2
|
+
import type Render from '../render'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 待审核状态界面
|
|
6
6
|
*/
|
|
7
|
-
export default function renderPending(
|
|
8
|
-
if (!
|
|
7
|
+
export default function renderPending(r: Render) {
|
|
8
|
+
if (!r.data.is_pending) return
|
|
9
9
|
|
|
10
|
-
const pendingEl = Utils.createElement(`<div class="atk-pending">${
|
|
11
|
-
|
|
10
|
+
const pendingEl = Utils.createElement(`<div class="atk-pending">${r.ctx.$t('pendingMsg')}</div>`)
|
|
11
|
+
r.$body.prepend(pendingEl)
|
|
12
12
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
|
-
import
|
|
2
|
+
import type Render from '../render'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 层级嵌套模式显示 AT 界面
|
|
6
6
|
*/
|
|
7
|
-
export default function renderReplyAt(
|
|
8
|
-
if (
|
|
9
|
-
if (!
|
|
7
|
+
export default function renderReplyAt(r: Render) {
|
|
8
|
+
if (r.cConf.isFlatMode || r.data.rid === 0) return // not 平铺模式 或 根评论
|
|
9
|
+
if (!r.cConf.replyTo) return
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
r.$replyAt = Utils.createElement(`<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`)
|
|
12
|
+
r.$replyAt.querySelector<HTMLElement>('.atk-nick')!.innerText = `${r.cConf.replyTo.nick}`
|
|
13
|
+
r.$replyAt.onclick = () => { r.comment.getActions().goToReplyComment() }
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
r.$headerBadgeWrap.insertAdjacentElement('afterend', r.$replyAt)
|
|
16
16
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import * as Utils from '../../lib/utils'
|
|
2
2
|
import marked from '../../lib/marked'
|
|
3
|
-
import
|
|
3
|
+
import type Render from '../render'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 回复的对象界面
|
|
7
7
|
*/
|
|
8
|
-
export default function renderReplyTo(
|
|
9
|
-
if (!
|
|
10
|
-
if (!
|
|
8
|
+
export default function renderReplyTo(r: Render) {
|
|
9
|
+
if (!r.cConf.isFlatMode) return // 仅平铺模式显示
|
|
10
|
+
if (!r.cConf.replyTo) return
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
r.$replyTo = Utils.createElement(`
|
|
13
13
|
<div class="atk-reply-to">
|
|
14
|
-
<div class="atk-meta">${
|
|
14
|
+
<div class="atk-meta">${r.ctx.$t('reply')} <span class="atk-nick"></span>:</div>
|
|
15
15
|
<div class="atk-content"></div>
|
|
16
16
|
</div>`)
|
|
17
|
-
const $nick =
|
|
18
|
-
$nick.innerText = `@${
|
|
19
|
-
$nick.onclick = () => {
|
|
20
|
-
let replyContent = marked(
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const $nick = r.$replyTo.querySelector<HTMLElement>('.atk-nick')!
|
|
18
|
+
$nick.innerText = `@${r.cConf.replyTo.nick}`
|
|
19
|
+
$nick.onclick = () => { r.comment.getActions().goToReplyComment() }
|
|
20
|
+
let replyContent = marked(r.cConf.replyTo.content)
|
|
21
|
+
if (r.cConf.replyTo.is_collapsed) replyContent = `[${Utils.htmlEncode(r.ctx.$t('collapsed'))}]`
|
|
22
|
+
r.$replyTo.querySelector<HTMLElement>('.atk-content')!.innerHTML = replyContent
|
|
23
|
+
r.$body.prepend(r.$replyTo)
|
|
24
24
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import $t from '@/i18n'
|
|
2
2
|
import * as Utils from '../lib/utils'
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface ActionBtnOptions {
|
|
5
5
|
/** 按钮文字 (动态/静态) */
|
|
6
6
|
text: (() => string) | string
|
|
7
7
|
|
|
@@ -19,8 +19,7 @@ interface ActionBtnConf {
|
|
|
19
19
|
* 通用操作按钮
|
|
20
20
|
*/
|
|
21
21
|
export default class ActionBtn {
|
|
22
|
-
private
|
|
23
|
-
private conf: ActionBtnConf
|
|
22
|
+
private opts: ActionBtnOptions
|
|
24
23
|
public $el: HTMLElement
|
|
25
24
|
|
|
26
25
|
public isLoading = false // 正在加载
|
|
@@ -33,15 +32,14 @@ export default class ActionBtn {
|
|
|
33
32
|
public confirmRecTimer?: number // 确认消息复原定时器
|
|
34
33
|
|
|
35
34
|
/** 构造函数 */
|
|
36
|
-
constructor(
|
|
37
|
-
this.ctx = ctx
|
|
35
|
+
constructor(opts: ActionBtnOptions|string|(() => string)) {
|
|
38
36
|
this.$el = Utils.createElement(`<span class="atk-common-action-btn"></span>`)
|
|
39
37
|
|
|
40
|
-
this.
|
|
38
|
+
this.opts = (typeof opts !== 'object') ? ({ text: opts }) : opts
|
|
41
39
|
this.$el.innerText = this.getText()
|
|
42
40
|
|
|
43
41
|
// 仅管理员可操作
|
|
44
|
-
if (this.
|
|
42
|
+
if (this.opts.adminOnly) this.$el.setAttribute('atk-only-admin-show', '')
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
/** 将按钮装载到指定元素 */
|
|
@@ -52,7 +50,7 @@ export default class ActionBtn {
|
|
|
52
50
|
|
|
53
51
|
/** 获取按钮文字(动态/静态) */
|
|
54
52
|
private getText() {
|
|
55
|
-
return (typeof this.
|
|
53
|
+
return (typeof this.opts.text === 'string') ? this.opts.text : this.opts.text()
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
/** 设置点击事件 */
|
|
@@ -66,7 +64,7 @@ export default class ActionBtn {
|
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
// 操作确认
|
|
69
|
-
if (this.
|
|
67
|
+
if (this.opts.confirm && !this.isMessaging) {
|
|
70
68
|
const confirmRestore = () => {
|
|
71
69
|
this.isConfirming = false
|
|
72
70
|
this.$el.classList.remove('atk-btn-confirm')
|
|
@@ -76,7 +74,7 @@ export default class ActionBtn {
|
|
|
76
74
|
if (!this.isConfirming) {
|
|
77
75
|
this.isConfirming = true
|
|
78
76
|
this.$el.classList.add('atk-btn-confirm')
|
|
79
|
-
this.$el.innerText = this.
|
|
77
|
+
this.$el.innerText = this.opts.confirmText || $t('actionConfirm')
|
|
80
78
|
this.confirmRecTimer = window.setTimeout(() => confirmRestore(), 5000)
|
|
81
79
|
return
|
|
82
80
|
}
|
|
@@ -99,7 +97,7 @@ export default class ActionBtn {
|
|
|
99
97
|
|
|
100
98
|
/** 文字刷新(动态/静态) */
|
|
101
99
|
public updateText(text?: (() => string) | string) {
|
|
102
|
-
if (text) this.
|
|
100
|
+
if (text) this.opts.text = text
|
|
103
101
|
this.setLoading(false)
|
|
104
102
|
this.$el.innerText = this.getText()
|
|
105
103
|
}
|
|
@@ -110,7 +108,7 @@ export default class ActionBtn {
|
|
|
110
108
|
this.isLoading = value
|
|
111
109
|
if (value) {
|
|
112
110
|
this.$el.classList.add('atk-btn-loading')
|
|
113
|
-
this.$el.innerText = loadingText || `${
|
|
111
|
+
this.$el.innerText = loadingText || `${$t('loading')}...`
|
|
114
112
|
} else {
|
|
115
113
|
this.$el.classList.remove('atk-btn-loading')
|
|
116
114
|
this.$el.innerText = this.getText()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import $t from '@/i18n'
|
|
2
|
+
import * as Utils from '@/lib/utils'
|
|
3
|
+
import User from '@/lib/user'
|
|
4
|
+
import type { Checker } from '.'
|
|
4
5
|
|
|
5
6
|
const AdminChecker: Checker = {
|
|
6
7
|
inputType: 'password',
|
|
@@ -19,7 +20,7 @@ const AdminChecker: Checker = {
|
|
|
19
20
|
},
|
|
20
21
|
|
|
21
22
|
body(checker) {
|
|
22
|
-
return Utils.createElement(`<span>${
|
|
23
|
+
return Utils.createElement(`<span>${$t('adminCheck')}</span>`)
|
|
23
24
|
},
|
|
24
25
|
|
|
25
26
|
onSuccess(checker, userToken, inputVal, formEl) {
|
|
@@ -27,8 +28,7 @@ const AdminChecker: Checker = {
|
|
|
27
28
|
isAdmin: true,
|
|
28
29
|
token: userToken
|
|
29
30
|
})
|
|
30
|
-
checker.
|
|
31
|
-
checker.getCtx().listReload()
|
|
31
|
+
checker.getOpts().onReload()
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
onError(checker, err, inputVal, formEl) {}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
1
|
+
import $t from '@/i18n'
|
|
2
|
+
import * as Utils from '@/lib/utils'
|
|
3
|
+
import * as Ui from '@/lib/ui'
|
|
4
|
+
import type { CheckerCtx } from '.'
|
|
4
5
|
|
|
5
6
|
/** 图片验证码 */
|
|
6
7
|
export function imgBody(checker: CheckerCtx) {
|
|
7
8
|
// 图片验证方式
|
|
8
9
|
const elem = Utils.createElement(
|
|
9
|
-
`<span><img class="atk-captcha-img" src="${checker.get('img_data') || ''}">${
|
|
10
|
+
`<span><img class="atk-captcha-img" src="${checker.get('img_data') || ''}">${$t('captchaCheck')}</span>`
|
|
10
11
|
);
|
|
11
12
|
|
|
12
13
|
// 刷新验证码
|
|
@@ -29,7 +30,7 @@ export function iframeBody(checker: CheckerCtx) {
|
|
|
29
30
|
const $iframe = Utils.createElement<HTMLIFrameElement>(`<iframe class="atk-fade-in"></iframe>`)
|
|
30
31
|
$iframe.style.display = 'none'
|
|
31
32
|
Ui.showLoading($iframeWrap, { transparentBg: true })
|
|
32
|
-
$iframe.src = `${checker.
|
|
33
|
+
$iframe.src = `${checker.getOpts().getIframeURLBase() || ''}/api/captcha/get?t=${+new Date()}`
|
|
33
34
|
$iframe.onload = () => {
|
|
34
35
|
$iframe.style.display = ''
|
|
35
36
|
Ui.hideLoading($iframeWrap)
|
|
@@ -49,7 +50,7 @@ export function iframeBody(checker: CheckerCtx) {
|
|
|
49
50
|
if (stop) return
|
|
50
51
|
let isPass = false
|
|
51
52
|
try {
|
|
52
|
-
const resp = await checker.
|
|
53
|
+
const resp = await checker.getApi().captcha.captchaStatus()
|
|
53
54
|
isPass = resp.is_pass
|
|
54
55
|
} catch { isPass = false }
|
|
55
56
|
if (isPass) {
|