artalk 2.7.1 → 2.7.3
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/Artalk.cjs +2 -0
- package/dist/Artalk.cjs.map +1 -0
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/Artalk.js.map +1 -1
- package/dist/{Artalk.es.js → Artalk.mjs} +250 -222
- package/dist/Artalk.mjs.map +1 -0
- package/dist/ArtalkLite.cjs +2 -0
- package/dist/ArtalkLite.cjs.map +1 -0
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.iife.js.map +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/ArtalkLite.js.map +1 -1
- package/dist/{ArtalkLite.es.js → ArtalkLite.mjs} +250 -227
- package/dist/ArtalkLite.mjs.map +1 -0
- package/dist/i18n/jp.cjs +1 -0
- package/dist/i18n/jp.d.cts +3 -0
- package/dist/i18n/jp.d.ts +3 -0
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/jp.mjs +93 -0
- package/dist/i18n/zh-TW.cjs +1 -0
- package/dist/i18n/zh-TW.d.cts +3 -0
- package/dist/i18n/zh-TW.d.ts +3 -0
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +93 -0
- package/dist/main.d.cts +1476 -0
- package/dist/main.d.ts +1476 -0
- package/package.json +80 -22
- package/dist/Artalk.es.js.map +0 -1
- package/dist/ArtalkLite.es.js.map +0 -1
- package/dist/src/api/_base.d.ts +0 -10
- package/dist/src/api/_options.d.ts +0 -19
- package/dist/src/api/_request.d.ts +0 -12
- package/dist/src/api/admin.d.ts +0 -10
- package/dist/src/api/captcha.d.ts +0 -14
- package/dist/src/api/comment.d.ts +0 -29
- package/dist/src/api/index.d.ts +0 -29
- package/dist/src/api/page.d.ts +0 -22
- package/dist/src/api/site.d.ts +0 -17
- package/dist/src/api/system.d.ts +0 -33
- package/dist/src/api/upload.d.ts +0 -11
- package/dist/src/api/user.d.ts +0 -42
- package/dist/src/artalk.d.ts +0 -35
- package/dist/src/comment/actions.d.ts +0 -17
- package/dist/src/comment/comment.d.ts +0 -66
- package/dist/src/comment/height-limit.d.ts +0 -30
- package/dist/src/comment/index.d.ts +0 -2
- package/dist/src/comment/render.d.ts +0 -46
- package/dist/src/comment/renders/actions.d.ts +0 -5
- package/dist/src/comment/renders/avatar.d.ts +0 -5
- package/dist/src/comment/renders/content.d.ts +0 -5
- package/dist/src/comment/renders/header.d.ts +0 -5
- package/dist/src/comment/renders/index.d.ts +0 -2
- package/dist/src/comment/renders/pending.d.ts +0 -5
- package/dist/src/comment/renders/reply-at.d.ts +0 -5
- package/dist/src/comment/renders/reply-to.d.ts +0 -5
- package/dist/src/components/action-btn.d.ts +0 -50
- package/dist/src/components/checker/admin.d.ts +0 -3
- package/dist/src/components/checker/captcha-renders.d.ts +0 -5
- package/dist/src/components/checker/captcha.d.ts +0 -3
- package/dist/src/components/checker/index.d.ts +0 -51
- package/dist/src/components/dark-mode.d.ts +0 -2
- package/dist/src/components/dialog.d.ts +0 -16
- package/dist/src/components/error-dialog.d.ts +0 -8
- package/dist/src/components/pagination.d.ts +0 -31
- package/dist/src/components/read-more-btn.d.ts +0 -33
- package/dist/src/config.d.ts +0 -24
- package/dist/src/context.d.ts +0 -45
- package/dist/src/data.d.ts +0 -27
- package/dist/src/defaults.d.ts +0 -3
- package/dist/src/editor/editor.d.ts +0 -31
- package/dist/src/editor/state.d.ts +0 -20
- package/dist/src/editor/ui.d.ts +0 -25
- package/dist/src/i18n/en.d.ts +0 -72
- package/dist/src/i18n/external.d.ts +0 -73
- package/dist/src/i18n/index.d.ts +0 -233
- package/dist/src/i18n/jp.d.ts +0 -72
- package/dist/src/i18n/zh-CN.d.ts +0 -3
- package/dist/src/i18n/zh-TW.d.ts +0 -72
- package/dist/src/layer/index.d.ts +0 -4
- package/dist/src/layer/layer-manager.d.ts +0 -9
- package/dist/src/layer/layer.d.ts +0 -12
- package/dist/src/layer/scrollbar-helper.d.ts +0 -5
- package/dist/src/layer/sidebar-layer.d.ts +0 -20
- package/dist/src/layer/wrap.d.ts +0 -13
- package/dist/src/lib/component.d.ts +0 -7
- package/dist/src/lib/detect.d.ts +0 -10
- package/dist/src/lib/event-manager.d.ts +0 -28
- package/dist/src/lib/highlight.d.ts +0 -1
- package/dist/src/lib/marked-renderer.d.ts +0 -4
- package/dist/src/lib/marked.d.ts +0 -11
- package/dist/src/lib/sanitizer.d.ts +0 -1
- package/dist/src/lib/ui.d.ts +0 -24
- package/dist/src/lib/user.d.ts +0 -19
- package/dist/src/lib/utils.d.ts +0 -41
- package/dist/src/list/comment.d.ts +0 -3
- package/dist/src/list/layout.d.ts +0 -23
- package/dist/src/list/list.d.ts +0 -14
- package/dist/src/list/nest.d.ts +0 -10
- package/dist/src/list/page.d.ts +0 -2
- package/dist/src/list/paginator/index.d.ts +0 -25
- package/dist/src/list/paginator/read-more.d.ts +0 -18
- package/dist/src/list/paginator/up-down.d.ts +0 -14
- package/dist/src/main.d.ts +0 -7
- package/dist/src/plugins/admin-only-elem.d.ts +0 -2
- package/dist/src/plugins/conf-remoter.d.ts +0 -2
- package/dist/src/plugins/dark-mode.d.ts +0 -2
- package/dist/src/plugins/editor/_kit.d.ts +0 -27
- package/dist/src/plugins/editor/_plug.d.ts +0 -29
- package/dist/src/plugins/editor/_sample.d.ts +0 -5
- package/dist/src/plugins/editor/closable.d.ts +0 -7
- package/dist/src/plugins/editor/emoticons.d.ts +0 -30
- package/dist/src/plugins/editor/header-event.d.ts +0 -6
- package/dist/src/plugins/editor/header-link.d.ts +0 -6
- package/dist/src/plugins/editor/header-user.d.ts +0 -16
- package/dist/src/plugins/editor/index.d.ts +0 -6
- package/dist/src/plugins/editor/local-storage.d.ts +0 -6
- package/dist/src/plugins/editor/mover.d.ts +0 -6
- package/dist/src/plugins/editor/preview.d.ts +0 -7
- package/dist/src/plugins/editor/state-edit.d.ts +0 -11
- package/dist/src/plugins/editor/state-reply.d.ts +0 -8
- package/dist/src/plugins/editor/submit-add.d.ts +0 -18
- package/dist/src/plugins/editor/submit-btn.d.ts +0 -5
- package/dist/src/plugins/editor/submit.d.ts +0 -17
- package/dist/src/plugins/editor/textarea.d.ts +0 -8
- package/dist/src/plugins/editor/upload.d.ts +0 -9
- package/dist/src/plugins/editor-kit.d.ts +0 -42
- package/dist/src/plugins/index.d.ts +0 -2
- package/dist/src/plugins/list/copyright.d.ts +0 -2
- package/dist/src/plugins/list/count.d.ts +0 -2
- package/dist/src/plugins/list/dropdown.d.ts +0 -2
- package/dist/src/plugins/list/error-dialog.d.ts +0 -2
- package/dist/src/plugins/list/fetch.d.ts +0 -2
- package/dist/src/plugins/list/goto-first.d.ts +0 -3
- package/dist/src/plugins/list/goto.d.ts +0 -2
- package/dist/src/plugins/list/index.d.ts +0 -3
- package/dist/src/plugins/list/loading.d.ts +0 -2
- package/dist/src/plugins/list/no-comment.d.ts +0 -2
- package/dist/src/plugins/list/reach-bottom.d.ts +0 -2
- package/dist/src/plugins/list/sidebar-btn.d.ts +0 -2
- package/dist/src/plugins/list/time-ticking.d.ts +0 -3
- package/dist/src/plugins/list/unread-badge.d.ts +0 -2
- package/dist/src/plugins/list/unread.d.ts +0 -2
- package/dist/src/plugins/list/with-editor.d.ts +0 -2
- package/dist/src/plugins/markdown.d.ts +0 -2
- package/dist/src/plugins/stat.d.ts +0 -13
- package/dist/src/plugins/version-check.d.ts +0 -2
- package/dist/src/service.d.ts +0 -42
- package/dist/tests/e2e/comment-add.spec.d.ts +0 -1
- package/dist/types/config.d.ts +0 -110
- package/dist/types/context.d.ts +0 -62
- package/dist/types/data.d.ts +0 -194
- package/dist/types/editor.d.ts +0 -76
- package/dist/types/event.d.ts +0 -39
- package/dist/types/global.d.ts +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/plugin.d.ts +0 -2
- package/dist/types/sidebar.d.ts +0 -3
- package/src/api/_base.ts +0 -18
- package/src/api/_options.ts +0 -25
- package/src/api/_request.ts +0 -104
- package/src/api/admin.ts +0 -18
- package/src/api/captcha.ts +0 -24
- package/src/api/comment.ts +0 -84
- package/src/api/index.ts +0 -29
- package/src/api/page.ts +0 -83
- package/src/api/site.ts +0 -51
- package/src/api/system.ts +0 -49
- package/src/api/upload.ts +0 -28
- package/src/api/user.ts +0 -132
- package/src/artalk.ts +0 -115
- package/src/comment/actions.ts +0 -83
- package/src/comment/comment.html +0 -18
- package/src/comment/comment.ts +0 -192
- package/src/comment/height-limit.ts +0 -100
- package/src/comment/index.ts +0 -3
- package/src/comment/render.ts +0 -150
- package/src/comment/renders/actions.ts +0 -114
- package/src/comment/renders/avatar.ts +0 -22
- package/src/comment/renders/content.ts +0 -39
- package/src/comment/renders/header.ts +0 -84
- package/src/comment/renders/index.ts +0 -19
- package/src/comment/renders/pending.ts +0 -12
- package/src/comment/renders/reply-at.ts +0 -16
- package/src/comment/renders/reply-to.ts +0 -24
- package/src/components/action-btn.ts +0 -170
- package/src/components/checker/admin.ts +0 -37
- package/src/components/checker/captcha-renders.ts +0 -69
- package/src/components/checker/captcha.ts +0 -26
- package/src/components/checker/index.ts +0 -192
- package/src/components/dark-mode.ts +0 -30
- package/src/components/dialog.ts +0 -62
- package/src/components/error-dialog.ts +0 -35
- package/src/components/pagination.ts +0 -153
- package/src/components/read-more-btn.ts +0 -92
- package/src/config.ts +0 -119
- package/src/context.ts +0 -146
- package/src/data.ts +0 -110
- package/src/defaults.ts +0 -61
- package/src/editor/editor.html +0 -18
- package/src/editor/editor.ts +0 -114
- package/src/editor/state.ts +0 -52
- package/src/editor/ui.ts +0 -36
- package/src/i18n/en.ts +0 -84
- package/src/i18n/external.ts +0 -10
- package/src/i18n/index.ts +0 -67
- package/src/i18n/jp.ts +0 -86
- package/src/i18n/zh-CN.ts +0 -88
- package/src/i18n/zh-TW.ts +0 -86
- package/src/layer/index.ts +0 -4
- package/src/layer/layer-manager.ts +0 -32
- package/src/layer/layer.ts +0 -39
- package/src/layer/scrollbar-helper.ts +0 -24
- package/src/layer/sidebar-layer.html +0 -8
- package/src/layer/sidebar-layer.ts +0 -155
- package/src/layer/wrap.ts +0 -77
- package/src/lib/component.ts +0 -12
- package/src/lib/detect.ts +0 -222
- package/src/lib/event-manager.ts +0 -47
- package/src/lib/highlight.ts +0 -5
- package/src/lib/marked-renderer.ts +0 -32
- package/src/lib/marked.ts +0 -72
- package/src/lib/sanitizer.ts +0 -57
- package/src/lib/ui.ts +0 -193
- package/src/lib/user.ts +0 -55
- package/src/lib/utils.ts +0 -236
- package/src/list/comment.ts +0 -20
- package/src/list/layout.ts +0 -120
- package/src/list/list.html +0 -20
- package/src/list/list.ts +0 -79
- package/src/list/nest.ts +0 -66
- package/src/list/page.ts +0 -97
- package/src/list/paginator/index.ts +0 -25
- package/src/list/paginator/read-more.ts +0 -67
- package/src/list/paginator/up-down.ts +0 -51
- package/src/main.ts +0 -14
- package/src/plugins/admin-only-elem.ts +0 -40
- package/src/plugins/conf-remoter.ts +0 -54
- package/src/plugins/dark-mode.ts +0 -12
- package/src/plugins/editor/_kit.ts +0 -57
- package/src/plugins/editor/_plug.ts +0 -60
- package/src/plugins/editor/_sample.ts +0 -8
- package/src/plugins/editor/closable.ts +0 -44
- package/src/plugins/editor/emoticons.scss +0 -72
- package/src/plugins/editor/emoticons.ts +0 -293
- package/src/plugins/editor/header-event.ts +0 -35
- package/src/plugins/editor/header-link.ts +0 -31
- package/src/plugins/editor/header-user.ts +0 -98
- package/src/plugins/editor/index.ts +0 -40
- package/src/plugins/editor/local-storage.ts +0 -36
- package/src/plugins/editor/mover.ts +0 -29
- package/src/plugins/editor/preview.scss +0 -7
- package/src/plugins/editor/preview.ts +0 -41
- package/src/plugins/editor/state-edit.ts +0 -116
- package/src/plugins/editor/state-reply.ts +0 -91
- package/src/plugins/editor/submit-add.ts +0 -33
- package/src/plugins/editor/submit-btn.ts +0 -25
- package/src/plugins/editor/submit.ts +0 -73
- package/src/plugins/editor/textarea.ts +0 -55
- package/src/plugins/editor/upload.ts +0 -145
- package/src/plugins/editor-kit.ts +0 -161
- package/src/plugins/index.ts +0 -16
- package/src/plugins/list/copyright.ts +0 -16
- package/src/plugins/list/count.ts +0 -31
- package/src/plugins/list/dropdown.ts +0 -95
- package/src/plugins/list/error-dialog.ts +0 -22
- package/src/plugins/list/fetch.ts +0 -64
- package/src/plugins/list/goto-first.ts +0 -23
- package/src/plugins/list/goto.ts +0 -72
- package/src/plugins/list/index.ts +0 -25
- package/src/plugins/list/loading.ts +0 -17
- package/src/plugins/list/no-comment.ts +0 -25
- package/src/plugins/list/reach-bottom.ts +0 -46
- package/src/plugins/list/sidebar-btn.ts +0 -39
- package/src/plugins/list/time-ticking.ts +0 -22
- package/src/plugins/list/unread-badge.ts +0 -26
- package/src/plugins/list/unread.ts +0 -38
- package/src/plugins/list/with-editor.ts +0 -59
- package/src/plugins/markdown.ts +0 -10
- package/src/plugins/stat.ts +0 -82
- package/src/plugins/version-check.ts +0 -36
- package/src/service.ts +0 -91
- package/src/style/_color.scss +0 -41
- package/src/style/_extend.scss +0 -20
- package/src/style/_variables.scss +0 -3
- package/src/style/comment.scss +0 -360
- package/src/style/editor.scss +0 -194
- package/src/style/list.scss +0 -212
- package/src/style/main.scss +0 -486
- package/src/style/pagination.scss +0 -58
- package/src/style/sidebar-layer.scss +0 -92
- package/types/config.ts +0 -153
- package/types/context.ts +0 -84
- package/types/data.ts +0 -271
- package/types/editor.ts +0 -95
- package/types/event.ts +0 -40
- package/types/global.d.ts +0 -1
- package/types/index.ts +0 -7
- package/types/plugin.ts +0 -3
- package/types/sidebar.ts +0 -3
package/dist/types/data.d.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
export interface CommentData {
|
|
2
|
-
/** 评论 ID */
|
|
3
|
-
id: number;
|
|
4
|
-
/** 评论正文 */
|
|
5
|
-
content: string;
|
|
6
|
-
/** 用户昵称 */
|
|
7
|
-
nick: string;
|
|
8
|
-
/** 用户邮箱 (该字段仅管理员可见) */
|
|
9
|
-
email?: string;
|
|
10
|
-
/** 用户邮箱(已加密) */
|
|
11
|
-
email_encrypted: string;
|
|
12
|
-
/** 用户链接 */
|
|
13
|
-
link: string;
|
|
14
|
-
/** 回复目标评论 ID */
|
|
15
|
-
rid: number;
|
|
16
|
-
/** User Agent */
|
|
17
|
-
ua: string;
|
|
18
|
-
/** 评论日期 */
|
|
19
|
-
date: string;
|
|
20
|
-
/** 是否折叠 */
|
|
21
|
-
is_collapsed?: boolean;
|
|
22
|
-
/** 是否待审 */
|
|
23
|
-
is_pending?: boolean;
|
|
24
|
-
/** 是否置顶 */
|
|
25
|
-
is_pinned?: boolean;
|
|
26
|
-
/** 是否为管理员 */
|
|
27
|
-
is_admin?: boolean;
|
|
28
|
-
/** 徽章文字 */
|
|
29
|
-
badge_name?: string;
|
|
30
|
-
/** 徽章颜色 */
|
|
31
|
-
badge_color?: string;
|
|
32
|
-
/** IP 归属地 */
|
|
33
|
-
ip_region?: string;
|
|
34
|
-
/** 是否允许回复 */
|
|
35
|
-
is_allow_reply?: boolean;
|
|
36
|
-
/** 评论页面 key */
|
|
37
|
-
page_key: string;
|
|
38
|
-
/** 评论页面 url */
|
|
39
|
-
page_url?: string;
|
|
40
|
-
/** 是否可见 */
|
|
41
|
-
visible: boolean;
|
|
42
|
-
/** 站点名(用于隔离) */
|
|
43
|
-
site_name: string;
|
|
44
|
-
/** 赞同数 */
|
|
45
|
-
vote_up: number;
|
|
46
|
-
/** 反对数 */
|
|
47
|
-
vote_down: number;
|
|
48
|
-
}
|
|
49
|
-
export interface ListData {
|
|
50
|
-
/** 评论数据 */
|
|
51
|
-
comments: CommentData[];
|
|
52
|
-
/** 根评论总数 */
|
|
53
|
-
total_roots: number;
|
|
54
|
-
/** 评论总数(包括所有子评论) */
|
|
55
|
-
total: number;
|
|
56
|
-
/** 页面信息 */
|
|
57
|
-
page: PageData;
|
|
58
|
-
/** 站点信息 */
|
|
59
|
-
site: SiteData;
|
|
60
|
-
/** 未读的 Notifies */
|
|
61
|
-
unread: NotifyData[];
|
|
62
|
-
/** 未读计数 */
|
|
63
|
-
unread_count: number;
|
|
64
|
-
/** API 版本 */
|
|
65
|
-
api_version: ApiVersionData;
|
|
66
|
-
/** 后端配置 */
|
|
67
|
-
conf: any;
|
|
68
|
-
}
|
|
69
|
-
export interface PageData {
|
|
70
|
-
/** 页面 ID */
|
|
71
|
-
id: number;
|
|
72
|
-
/** 页面唯一标识符 */
|
|
73
|
-
key: string;
|
|
74
|
-
/** 页面标题 */
|
|
75
|
-
title: string;
|
|
76
|
-
/** 页面 url */
|
|
77
|
-
url: string;
|
|
78
|
-
/** 仅管理员可评 */
|
|
79
|
-
admin_only: boolean;
|
|
80
|
-
/** 站点名(用于隔离) */
|
|
81
|
-
site_name: string;
|
|
82
|
-
/** 赞同数 */
|
|
83
|
-
vote_up: number;
|
|
84
|
-
/** 反对数 */
|
|
85
|
-
vote_down: number;
|
|
86
|
-
}
|
|
87
|
-
export interface SiteData {
|
|
88
|
-
/** 站点 ID */
|
|
89
|
-
id: number;
|
|
90
|
-
/** 站点名 */
|
|
91
|
-
name: string;
|
|
92
|
-
/** 站点 URLs */
|
|
93
|
-
urls: string[];
|
|
94
|
-
/** 站点 URLs(原始字符串) */
|
|
95
|
-
urls_raw: string;
|
|
96
|
-
/** 站点主 URL */
|
|
97
|
-
first_url: string;
|
|
98
|
-
}
|
|
99
|
-
export interface UserData {
|
|
100
|
-
/** 用户 ID */
|
|
101
|
-
id: number;
|
|
102
|
-
/** 用户名 */
|
|
103
|
-
name: string;
|
|
104
|
-
/** 邮箱 */
|
|
105
|
-
email: string;
|
|
106
|
-
/** 链接 */
|
|
107
|
-
link: string;
|
|
108
|
-
/** 徽章名称 */
|
|
109
|
-
badge_name: string;
|
|
110
|
-
/** 徽章颜色 */
|
|
111
|
-
badge_color: string;
|
|
112
|
-
/** 是否属于管理员 */
|
|
113
|
-
is_admin: boolean;
|
|
114
|
-
/** 所属站点名 */
|
|
115
|
-
site_names: string[];
|
|
116
|
-
/** 所属站点名 (字符串) */
|
|
117
|
-
site_names_raw: string;
|
|
118
|
-
/** 是否允许接收邮件通知 */
|
|
119
|
-
receive_email: boolean;
|
|
120
|
-
}
|
|
121
|
-
export interface UserDataForAdmin extends UserData {
|
|
122
|
-
/** 最后一次操作 IP */
|
|
123
|
-
last_ip: string;
|
|
124
|
-
/** 最后一次操作 UA */
|
|
125
|
-
last_ua: string;
|
|
126
|
-
/** 是否存在于配置文件中 */
|
|
127
|
-
is_in_conf: boolean;
|
|
128
|
-
/** 评论数 */
|
|
129
|
-
comment_count: number;
|
|
130
|
-
/** 密码 */
|
|
131
|
-
password: string;
|
|
132
|
-
}
|
|
133
|
-
export interface NotifyData {
|
|
134
|
-
/** 通知 ID */
|
|
135
|
-
id: number;
|
|
136
|
-
/** 用户 ID */
|
|
137
|
-
user_id: number;
|
|
138
|
-
/** 评论 ID */
|
|
139
|
-
comment_id: number;
|
|
140
|
-
/** 是否已读 */
|
|
141
|
-
is_read: boolean;
|
|
142
|
-
/** 是否已发送邮件通知 */
|
|
143
|
-
is_emailed: boolean;
|
|
144
|
-
/** 标为已读地址 */
|
|
145
|
-
read_link: string;
|
|
146
|
-
}
|
|
147
|
-
export type EmoticonGrpData = {
|
|
148
|
-
name: string;
|
|
149
|
-
type: 'emoticon' | 'image' | 'emoji';
|
|
150
|
-
items: {
|
|
151
|
-
key: string;
|
|
152
|
-
val: string;
|
|
153
|
-
}[];
|
|
154
|
-
};
|
|
155
|
-
export type EmoticonListData = EmoticonGrpData[];
|
|
156
|
-
export interface ApiVersionData {
|
|
157
|
-
/** API 程序名 */
|
|
158
|
-
app: string;
|
|
159
|
-
/** API 程序版本号 */
|
|
160
|
-
version: string;
|
|
161
|
-
/** API 程序 CommitHash */
|
|
162
|
-
commit_hash: string;
|
|
163
|
-
}
|
|
164
|
-
export interface ListFetchParams {
|
|
165
|
-
offset: number;
|
|
166
|
-
limit: number;
|
|
167
|
-
flatMode: boolean;
|
|
168
|
-
paramsModifier?: (p: any) => void;
|
|
169
|
-
onSuccess?: (data: ListData) => void;
|
|
170
|
-
onError?: (err: any) => void;
|
|
171
|
-
}
|
|
172
|
-
export interface ListLastFetchData {
|
|
173
|
-
params: ListFetchParams;
|
|
174
|
-
data?: ListData;
|
|
175
|
-
}
|
|
176
|
-
export interface DataManagerApi {
|
|
177
|
-
getLoading(): boolean;
|
|
178
|
-
setLoading(val: boolean): void;
|
|
179
|
-
getListLastFetch(): ListLastFetchData | undefined;
|
|
180
|
-
setListLastFetch(val: ListLastFetchData): void;
|
|
181
|
-
getComments(): CommentData[];
|
|
182
|
-
findComment(id: number): CommentData | undefined;
|
|
183
|
-
fetchComments(params: Partial<ListFetchParams>): void;
|
|
184
|
-
loadComments(comments: CommentData[]): void;
|
|
185
|
-
clearComments(): void;
|
|
186
|
-
insertComment(comment: CommentData): void;
|
|
187
|
-
updateComment(comment: CommentData): void;
|
|
188
|
-
deleteComment(id: number): void;
|
|
189
|
-
getUnreads(): NotifyData[];
|
|
190
|
-
updateUnreads(unreads: NotifyData[]): void;
|
|
191
|
-
getPage(): PageData | undefined;
|
|
192
|
-
updatePage(pageData: PageData): void;
|
|
193
|
-
}
|
|
194
|
-
export type NotifyLevel = "i" | "s" | "w" | "e";
|
package/dist/types/editor.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { CommentData, NotifyLevel } from '.';
|
|
2
|
-
import type Component from '../src/lib/component';
|
|
3
|
-
import type { EditorUI } from '../src/editor/ui';
|
|
4
|
-
export type EditorState = 'reply' | 'edit' | 'normal';
|
|
5
|
-
export interface EditorApi extends Component {
|
|
6
|
-
getUI(): EditorUI;
|
|
7
|
-
/**
|
|
8
|
-
* Get the header input elements
|
|
9
|
-
*/
|
|
10
|
-
getHeaderInputEls(): Record<string, HTMLInputElement>;
|
|
11
|
-
/**
|
|
12
|
-
* Set content
|
|
13
|
-
*/
|
|
14
|
-
setContent(val: string): void;
|
|
15
|
-
/**
|
|
16
|
-
* Insert content
|
|
17
|
-
*/
|
|
18
|
-
insertContent(val: string): void;
|
|
19
|
-
/**
|
|
20
|
-
* Get the final content
|
|
21
|
-
*
|
|
22
|
-
* This function returns the raw content or the content transformed through a plugin hook.
|
|
23
|
-
*/
|
|
24
|
-
getContentFinal(): string;
|
|
25
|
-
/**
|
|
26
|
-
* Get the raw content which is inputed by user
|
|
27
|
-
*/
|
|
28
|
-
getContentRaw(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Get the HTML format content which is rendered by marked (a markdown parser)
|
|
31
|
-
*/
|
|
32
|
-
getContentMarked(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Get editor current state
|
|
35
|
-
*/
|
|
36
|
-
getState(): EditorState;
|
|
37
|
-
/**
|
|
38
|
-
* Focus editor
|
|
39
|
-
*/
|
|
40
|
-
focus(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Reset editor
|
|
43
|
-
*/
|
|
44
|
-
reset(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Reset editor UI
|
|
47
|
-
*
|
|
48
|
-
* call it will move editor to the initial position
|
|
49
|
-
*/
|
|
50
|
-
resetState(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Submit comment
|
|
53
|
-
*/
|
|
54
|
-
submit(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Show notification message
|
|
57
|
-
*/
|
|
58
|
-
showNotify(msg: string, type: NotifyLevel): void;
|
|
59
|
-
/**
|
|
60
|
-
* Show loading on editor
|
|
61
|
-
*/
|
|
62
|
-
showLoading(): void;
|
|
63
|
-
/**
|
|
64
|
-
* Hide loading on editor
|
|
65
|
-
*/
|
|
66
|
-
hideLoading(): void;
|
|
67
|
-
/**
|
|
68
|
-
* Start replaying a comment
|
|
69
|
-
*/
|
|
70
|
-
setReply(commentData: CommentData, $comment: HTMLElement, scroll?: boolean): void;
|
|
71
|
-
/**
|
|
72
|
-
* Start editing a comment
|
|
73
|
-
*/
|
|
74
|
-
setEditComment(commentData: CommentData, $comment: HTMLElement): void;
|
|
75
|
-
}
|
|
76
|
-
export default EditorApi;
|
package/dist/types/event.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type Comment from '../src/comment';
|
|
2
|
-
import { CommentData, ListData, ListFetchParams, NotifyData, PageData } from './data';
|
|
3
|
-
import { ArtalkConfig, LocalUser } from './config';
|
|
4
|
-
interface ErrorData {
|
|
5
|
-
msg: string;
|
|
6
|
-
data?: any;
|
|
7
|
-
}
|
|
8
|
-
interface ListFetchedArgs {
|
|
9
|
-
params: Partial<ListFetchParams>;
|
|
10
|
-
data?: ListData;
|
|
11
|
-
error?: ErrorData;
|
|
12
|
-
}
|
|
13
|
-
/** EventName to EventPayload Type */
|
|
14
|
-
export interface EventPayloadMap {
|
|
15
|
-
'inited': undefined;
|
|
16
|
-
'destroy': undefined;
|
|
17
|
-
'list-fetch': Partial<ListFetchParams>;
|
|
18
|
-
'list-fetched': ListFetchedArgs;
|
|
19
|
-
'list-load': CommentData[];
|
|
20
|
-
'list-loaded': CommentData[];
|
|
21
|
-
'list-error': ErrorData;
|
|
22
|
-
'list-goto-first': undefined;
|
|
23
|
-
'list-reach-bottom': undefined;
|
|
24
|
-
'comment-inserted': CommentData;
|
|
25
|
-
'comment-updated': CommentData;
|
|
26
|
-
'comment-deleted': CommentData;
|
|
27
|
-
'comment-rendered': Comment;
|
|
28
|
-
'unreads-updated': NotifyData[];
|
|
29
|
-
'list-goto': number;
|
|
30
|
-
'page-loaded': PageData;
|
|
31
|
-
'editor-submit': undefined;
|
|
32
|
-
'editor-submitted': undefined;
|
|
33
|
-
'user-changed': LocalUser;
|
|
34
|
-
'conf-loaded': ArtalkConfig;
|
|
35
|
-
'dark-mode-changed': boolean;
|
|
36
|
-
'sidebar-show': undefined;
|
|
37
|
-
'sidebar-hide': undefined;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
package/dist/types/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const ARTALK_LITE: boolean
|
package/dist/types/index.d.ts
DELETED
package/dist/types/plugin.d.ts
DELETED
package/dist/types/sidebar.d.ts
DELETED
package/src/api/_base.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ApiOptions } from './_options'
|
|
2
|
-
import { POST, Fetch } from './_request'
|
|
3
|
-
|
|
4
|
-
abstract class ApiBase {
|
|
5
|
-
constructor(
|
|
6
|
-
protected options: ApiOptions
|
|
7
|
-
) {}
|
|
8
|
-
|
|
9
|
-
protected async POST<T>(path: string, data?: {[key: string]: any}) {
|
|
10
|
-
return POST<T>(this.options, this.options.baseURL+path, data)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
protected async Fetch(path: string, init: RequestInit, timeout?: number): Promise<any> {
|
|
14
|
-
return Fetch(this.options, this.options.baseURL+path, init, timeout)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default ApiBase
|
package/src/api/_options.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface ApiOptions {
|
|
2
|
-
baseURL: string
|
|
3
|
-
siteName: string
|
|
4
|
-
pageKey: string
|
|
5
|
-
pageTitle: string
|
|
6
|
-
timeout?: number
|
|
7
|
-
|
|
8
|
-
// -------------------------------------------------------------------
|
|
9
|
-
// Hooks
|
|
10
|
-
// -------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
onNeedCheckCaptcha?: (payload: {
|
|
13
|
-
recall: () => void
|
|
14
|
-
reject: () => void
|
|
15
|
-
data: {
|
|
16
|
-
imgData: string
|
|
17
|
-
iframe: string
|
|
18
|
-
}
|
|
19
|
-
}) => void
|
|
20
|
-
|
|
21
|
-
onNeedCheckAdmin?: (payload: {
|
|
22
|
-
recall: () => void
|
|
23
|
-
reject: () => void
|
|
24
|
-
}) => void
|
|
25
|
-
}
|
package/src/api/_request.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
|
|
2
|
-
|
|
3
|
-
import { ApiOptions } from './_options'
|
|
4
|
-
import User from '../lib/user'
|
|
5
|
-
import $t from '../i18n'
|
|
6
|
-
|
|
7
|
-
/** 公共请求函数 */
|
|
8
|
-
export async function Fetch(opts: ApiOptions, input: RequestInfo, init: RequestInit, timeout?: number): Promise<any> {
|
|
9
|
-
// JWT
|
|
10
|
-
if (User.data.token) {
|
|
11
|
-
const headers = new Headers(init.headers) // 保留原有 headers
|
|
12
|
-
headers.set('Authorization', `Bearer ${User.data.token}`)
|
|
13
|
-
init.headers = headers
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// 跨域请求携带 cookie (无需)
|
|
17
|
-
// init.credentials = 'include'
|
|
18
|
-
|
|
19
|
-
// 请求操作
|
|
20
|
-
const resp = await timeoutFetch(input, timeout || opts.timeout || 15000, init)
|
|
21
|
-
|
|
22
|
-
const respHttpCode = resp.status
|
|
23
|
-
const noAccessCodes = [401, 400]
|
|
24
|
-
const isNoAccess = noAccessCodes.includes(respHttpCode)
|
|
25
|
-
|
|
26
|
-
if (!resp.ok && !isNoAccess)
|
|
27
|
-
throw new Error(`${$t('reqGot')} ${respHttpCode}`)
|
|
28
|
-
|
|
29
|
-
// 解析获取响应的 json
|
|
30
|
-
let json: any = await resp.json()
|
|
31
|
-
|
|
32
|
-
// 重新发起请求
|
|
33
|
-
const recall = (resolve, reject) => {
|
|
34
|
-
Fetch(opts, input, init)
|
|
35
|
-
.then(d => { resolve(d) })
|
|
36
|
-
.catch(e => { reject(e) })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// 请求弹出层验证
|
|
40
|
-
if (json.data?.need_captcha) {
|
|
41
|
-
// 请求需要验证码
|
|
42
|
-
json = await (new Promise<any>((resolve, reject) => {
|
|
43
|
-
opts.onNeedCheckCaptcha && opts.onNeedCheckCaptcha({
|
|
44
|
-
data: { imgData: json.data.img_data, iframe: json.data.iframe },
|
|
45
|
-
recall: () => { recall(resolve, reject) },
|
|
46
|
-
reject: () => { reject(json) }
|
|
47
|
-
})
|
|
48
|
-
}))
|
|
49
|
-
} else if (json.data?.need_login || isNoAccess) {
|
|
50
|
-
// 请求需要管理员权限
|
|
51
|
-
json = await (new Promise<any>((resolve, reject) => {
|
|
52
|
-
opts.onNeedCheckAdmin && opts.onNeedCheckAdmin({
|
|
53
|
-
recall: () => { recall(resolve, reject) },
|
|
54
|
-
reject: () => { reject(json) }
|
|
55
|
-
})
|
|
56
|
-
}))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!json.success) throw json // throw 相当于 reject(json)
|
|
60
|
-
|
|
61
|
-
return json
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** 公共 POST 请求 */
|
|
65
|
-
export async function POST<T>(opts: ApiOptions, url: string, data?: {[key: string]: any}) {
|
|
66
|
-
const init: RequestInit = {
|
|
67
|
-
method: 'POST',
|
|
68
|
-
}
|
|
69
|
-
data = { site_name: opts.siteName || '', ...(data || {}) } // 总是携带 site_name
|
|
70
|
-
init.body = ToFormData(data)
|
|
71
|
-
|
|
72
|
-
const json = await Fetch(opts, url, init)
|
|
73
|
-
return ((json.data || {}) as T)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** 公共 GET 请求 (无 GET 方式 API) */
|
|
77
|
-
// export async function GET<T>(opts: ApiOptions, url: string, data?: {[key: string]: any}) {
|
|
78
|
-
// const json = await Fetch(opts, url + (data ? (`?${new URLSearchParams(data)}`) : ''), {
|
|
79
|
-
// method: 'GET',
|
|
80
|
-
// })
|
|
81
|
-
// return ((json.data || {}) as T)
|
|
82
|
-
// }
|
|
83
|
-
|
|
84
|
-
/** 对象转 FormData */
|
|
85
|
-
export function ToFormData(object: {[key: string]: any}): FormData {
|
|
86
|
-
const formData = new FormData()
|
|
87
|
-
Object.keys(object).forEach(key => formData.append(key, String(object[key])))
|
|
88
|
-
return formData
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** 我靠,fetch 一个 timeout,都要丑陋的实现 */
|
|
92
|
-
function timeoutFetch(url: RequestInfo, ms: number, opts: RequestInit) {
|
|
93
|
-
const controller = new AbortController()
|
|
94
|
-
opts.signal?.addEventListener('abort', () => controller.abort()) // 保留原有 signal 功能
|
|
95
|
-
let promise = fetch(url, { ...opts, signal: controller.signal })
|
|
96
|
-
if (ms > 0) {
|
|
97
|
-
const timer = setTimeout(() => controller.abort(), ms)
|
|
98
|
-
promise.finally(() => { clearTimeout(timer) })
|
|
99
|
-
}
|
|
100
|
-
promise = promise.catch((err) => {
|
|
101
|
-
throw ((err || {}).name === 'AbortError') ? new Error($t('reqAborted')) : err
|
|
102
|
-
})
|
|
103
|
-
return promise
|
|
104
|
-
}
|
package/src/api/admin.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import ApiBase from './_base'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 管理员 API
|
|
5
|
-
*/
|
|
6
|
-
export default class AdminApi extends ApiBase {
|
|
7
|
-
/** 缓存清除 */
|
|
8
|
-
public cacheFlushAll() {
|
|
9
|
-
const params: any = { flush_all: true }
|
|
10
|
-
return this.POST('/admin/cache-flush', params)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** 缓存预热 */
|
|
14
|
-
public cacheWarmUp() {
|
|
15
|
-
const params: any = {}
|
|
16
|
-
return this.POST('/admin/cache-warm', params)
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/api/captcha.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import ApiBase from './_base'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 验证码 API
|
|
5
|
-
*/
|
|
6
|
-
export default class CaptchaApi extends ApiBase {
|
|
7
|
-
/** 验证码 · 获取 */
|
|
8
|
-
public async captchaGet() {
|
|
9
|
-
const data = await this.POST<any>('/captcha/refresh')
|
|
10
|
-
return (data.img_data || '') as string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** 验证码 · 检验 */
|
|
14
|
-
public async captchaCheck(value: string) {
|
|
15
|
-
const data = await this.POST<any>('/captcha/check', { value })
|
|
16
|
-
return (data.img_data || '') as string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** 验证码 · 状态 */
|
|
20
|
-
public async captchaStatus() {
|
|
21
|
-
const data = await this.POST<any>('/captcha/status')
|
|
22
|
-
return (data || { is_pass: false }) as { is_pass: boolean }
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/api/comment.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { CommentData, ListData } from '~/types'
|
|
2
|
-
import * as Utils from '../lib/utils'
|
|
3
|
-
import ApiBase from './_base'
|
|
4
|
-
import User from '../lib/user'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 评论 API
|
|
8
|
-
*/
|
|
9
|
-
export default class CommentApi extends ApiBase {
|
|
10
|
-
/** 评论 · 获取 */
|
|
11
|
-
public get(offset: number, pageSize: number, flatMode?: boolean, paramsEditor?: (params: any) => void) {
|
|
12
|
-
const params: any = {
|
|
13
|
-
page_key: this.options.pageKey,
|
|
14
|
-
site_name: this.options.siteName,
|
|
15
|
-
limit: pageSize,
|
|
16
|
-
offset,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (flatMode) params.flat_mode = flatMode // 平铺模式
|
|
20
|
-
if (User.checkHasBasicUserInfo()) {
|
|
21
|
-
params.name = User.data.nick
|
|
22
|
-
params.email = User.data.email
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (paramsEditor) paramsEditor(params)
|
|
26
|
-
|
|
27
|
-
return this.POST<ListData>('/get', params)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** 评论 · 创建 */
|
|
31
|
-
public async add(comment: { nick: string, email: string, link: string, content: string, rid: number, page_key: string, page_title?: string, site_name?: string }) {
|
|
32
|
-
const params: any = {
|
|
33
|
-
name: comment.nick,
|
|
34
|
-
email: comment.email,
|
|
35
|
-
link: comment.link,
|
|
36
|
-
content: comment.content,
|
|
37
|
-
rid: comment.rid,
|
|
38
|
-
page_key: comment.page_key,
|
|
39
|
-
ua: await Utils.getCorrectUserAgent(), // 需要后端支持,获取修正后的 UA
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (comment.page_title) params.page_title = comment.page_title
|
|
43
|
-
if (comment.site_name) params.site_name = comment.site_name
|
|
44
|
-
|
|
45
|
-
const data = await this.POST<any>('/add', params)
|
|
46
|
-
return (data.comment as CommentData)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** 评论 · 修改 */
|
|
50
|
-
public async commentEdit(data: Partial<CommentData>) {
|
|
51
|
-
const params: any = {
|
|
52
|
-
...data,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const d = await this.POST<any>('/admin/comment-edit', params)
|
|
56
|
-
return (d.comment as CommentData)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 评论 · 删除 */
|
|
60
|
-
public commentDel(commentID: number, siteName?: string) {
|
|
61
|
-
const params: any = {
|
|
62
|
-
id: String(commentID),
|
|
63
|
-
site_name: siteName || '',
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return this.POST('/admin/comment-del', params)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** 投票 */
|
|
70
|
-
public async vote(targetID: number, type: string) {
|
|
71
|
-
const params: any = {
|
|
72
|
-
target_id: targetID,
|
|
73
|
-
type,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (User.checkHasBasicUserInfo()) {
|
|
77
|
-
params.name = User.data.nick
|
|
78
|
-
params.email = User.data.email
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const data = await this.POST<any>('/vote', params)
|
|
82
|
-
return (data as {up: number, down: number})
|
|
83
|
-
}
|
|
84
|
-
}
|
package/src/api/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ApiOptions } from './_options'
|
|
2
|
-
import comment from './comment'
|
|
3
|
-
import page from './page'
|
|
4
|
-
import site from './site'
|
|
5
|
-
import user from './user'
|
|
6
|
-
import system from './system'
|
|
7
|
-
import captcha from './captcha'
|
|
8
|
-
import admin from './admin'
|
|
9
|
-
import upload from './upload'
|
|
10
|
-
|
|
11
|
-
const ApiComponents = {
|
|
12
|
-
comment, page, site,
|
|
13
|
-
user, system, captcha,
|
|
14
|
-
admin, upload
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class Api {
|
|
18
|
-
constructor (opts: ApiOptions) {
|
|
19
|
-
Object.entries(ApiComponents).forEach(([key, ApiComponent]) => {
|
|
20
|
-
this[key] = new ApiComponent(opts)
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type TC = typeof ApiComponents
|
|
26
|
-
type AC = { [K in keyof TC]: InstanceType<TC[K]> }
|
|
27
|
-
interface Api extends AC {}
|
|
28
|
-
|
|
29
|
-
export default Api
|