artalk 2.2.10 → 2.3.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 +3046 -2342
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/ArtalkLite.css +1 -0
- package/dist/ArtalkLite.es.js +5096 -0
- package/dist/ArtalkLite.iife.js +1 -0
- package/dist/ArtalkLite.js +1 -0
- package/index.html +5 -3
- package/package.json +7 -5
- package/src/api/index.ts +24 -4
- package/src/api/request.ts +50 -81
- package/src/artalk.ts +83 -57
- package/src/comment/actions.ts +87 -0
- package/src/{components/html → comment}/comment.html +1 -1
- package/src/comment/comment.ts +191 -0
- package/src/comment/index.ts +3 -0
- package/src/comment/render.ts +425 -0
- package/src/components/action-btn.ts +6 -3
- package/src/components/dialog.ts +7 -3
- package/src/components/read-more-btn.ts +6 -2
- package/src/context.ts +200 -13
- package/src/defaults.ts +19 -6
- package/src/editor/editor.html +18 -0
- package/src/editor/editor.ts +420 -0
- package/src/editor/index.ts +3 -0
- package/src/editor/plugs/editor-plug.ts +51 -0
- package/src/{components/editor-plugs → editor/plugs}/emoticons-plug.less +1 -0
- package/src/{components/editor-plugs → editor/plugs}/emoticons-plug.ts +65 -63
- package/src/editor/plugs/header-input-plug.ts +79 -0
- package/src/{components/editor-plugs → editor/plugs}/preview-plug.less +0 -0
- package/src/editor/plugs/preview-plug.ts +40 -0
- package/src/editor/plugs/upload-plug.ts +125 -0
- package/src/i18n/en.ts +77 -0
- package/src/i18n/index.ts +21 -0
- package/src/i18n/zh-CN.ts +81 -0
- package/src/layer/index.ts +4 -0
- package/src/{components → layer}/layer.ts +9 -9
- package/src/{components/html → layer}/sidebar-layer.html +0 -0
- package/src/{components → layer}/sidebar-layer.ts +17 -46
- package/src/lib/checker/admin-checker.ts +7 -6
- package/src/lib/checker/captcha-checker.ts +5 -5
- package/src/lib/checker/index.ts +22 -17
- package/src/lib/component.ts +7 -2
- package/src/lib/ui.ts +3 -10
- package/src/lib/user.ts +20 -3
- package/src/lib/utils.ts +23 -9
- package/src/list/index.ts +3 -0
- package/src/{components → list}/list-lite.ts +87 -111
- package/src/{components → list}/list-nest.ts +0 -0
- package/src/{components/html → list}/list.html +3 -6
- package/src/{components → list}/list.ts +37 -35
- package/src/style/comment.less +23 -10
- package/src/style/editor.less +16 -10
- package/src/style/list.less +4 -7
- package/src/style/main.less +3 -1
- package/src/style/pagination.less +1 -1
- package/test/ArtalkLite.html +15 -0
- package/types/artalk-config.d.ts +52 -31
- package/types/context.d.ts +128 -0
- package/types/event.d.ts +6 -66
- package/types/global.d.ts +1 -0
- package/{vite-common.config.ts → vite-base.config.ts} +6 -4
- package/vite-demo.config.ts +2 -4
- package/vite-lite.config.ts +22 -0
- package/vite.config.ts +9 -18
- package/src/components/_component.ts.txt +0 -10
- package/src/components/comment.ts +0 -605
- package/src/components/editor-plugs/_example-plug.ts.txt +0 -29
- package/src/components/editor-plugs/editor-plug.ts +0 -20
- package/src/components/editor-plugs/preview-plug.ts +0 -48
- package/src/components/editor.ts +0 -604
- package/src/components/html/editor.html +0 -18
package/src/style/comment.less
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.atk-comment-wrap {
|
|
2
2
|
overflow: hidden;
|
|
3
3
|
position: relative;
|
|
4
|
-
border-bottom: 1px solid
|
|
4
|
+
border-bottom: 1px solid transparent;
|
|
5
5
|
|
|
6
6
|
&.atk-flash-once {
|
|
7
7
|
animation: atkFlashOnce 1s ease-in-out 0s;
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
float: left;
|
|
50
50
|
|
|
51
51
|
img {
|
|
52
|
-
width:
|
|
53
|
-
height:
|
|
52
|
+
width: 50px;
|
|
53
|
+
height: 50px;
|
|
54
54
|
border-radius: 3px;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
& > .atk-main {
|
|
59
59
|
display: block;
|
|
60
|
-
margin-left:
|
|
60
|
+
margin-left: 63px;
|
|
61
61
|
|
|
62
62
|
& > .atk-header {
|
|
63
63
|
line-height: 1;
|
|
@@ -71,6 +71,8 @@
|
|
|
71
71
|
|
|
72
72
|
.atk-item {
|
|
73
73
|
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
margin-top: 2px;
|
|
74
76
|
margin-bottom: 2px;
|
|
75
77
|
color: var(--at-color-meta);
|
|
76
78
|
|
|
@@ -107,10 +109,11 @@
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
.badge() {
|
|
112
|
+
display: inline-block;
|
|
110
113
|
color: var(--at-color-meta);
|
|
111
114
|
background: var(--at-color-bg-grey);
|
|
112
|
-
padding:
|
|
113
|
-
line-height:
|
|
115
|
+
padding: 0px 6px;
|
|
116
|
+
line-height: 17px;
|
|
114
117
|
border-radius: 3px;
|
|
115
118
|
|
|
116
119
|
&:not(:last-child) {
|
|
@@ -118,6 +121,10 @@
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
.atk-badge-wrap > *:last-child {
|
|
125
|
+
margin-right: 6px;
|
|
126
|
+
}
|
|
127
|
+
|
|
121
128
|
.atk-badge {
|
|
122
129
|
.badge();
|
|
123
130
|
color: #fff;
|
|
@@ -136,6 +143,7 @@
|
|
|
136
143
|
.atk-ua-wrap {
|
|
137
144
|
@media only screen and (max-width: 768px) {
|
|
138
145
|
display: block;
|
|
146
|
+
margin-top: 5px;
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
}
|
|
@@ -253,7 +261,6 @@
|
|
|
253
261
|
&:not(:first-child):not(.atk-hide) {
|
|
254
262
|
margin-left: 8px;
|
|
255
263
|
padding-left: 8px;
|
|
256
|
-
border-left: 1px solid var(--at-color-border);
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
&:hover {
|
|
@@ -291,6 +298,10 @@
|
|
|
291
298
|
font-size: 15px;
|
|
292
299
|
color: var(--at-color-meta);
|
|
293
300
|
user-select: none;
|
|
301
|
+
|
|
302
|
+
&:hover {
|
|
303
|
+
background: var(--at-color-bg-grey);
|
|
304
|
+
}
|
|
294
305
|
}
|
|
295
306
|
|
|
296
307
|
// 避免重复显示按钮
|
|
@@ -303,15 +314,14 @@
|
|
|
303
314
|
.atk-comment-children {
|
|
304
315
|
& > .atk-comment-wrap {
|
|
305
316
|
margin-top: 10px;
|
|
306
|
-
border-left: 1px dashed
|
|
317
|
+
border-left: 1px dashed transparent;
|
|
307
318
|
border-bottom-color: transparent;
|
|
308
319
|
&:not(:last-child) {
|
|
309
320
|
margin-bottom: 5px;
|
|
310
321
|
}
|
|
311
322
|
|
|
312
323
|
& > .atk-comment {
|
|
313
|
-
padding
|
|
314
|
-
padding-bottom: 4px;
|
|
324
|
+
padding: 4px 0;
|
|
315
325
|
|
|
316
326
|
& > .atk-avatar img {
|
|
317
327
|
width: 36px;
|
|
@@ -320,6 +330,9 @@
|
|
|
320
330
|
|
|
321
331
|
& > .atk-main {
|
|
322
332
|
margin-left: 47px;
|
|
333
|
+
|
|
334
|
+
& > .atk-body > .atk-content {
|
|
335
|
+
}
|
|
323
336
|
}
|
|
324
337
|
}
|
|
325
338
|
}
|
package/src/style/editor.less
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
background: var(--at-color-bg);
|
|
7
7
|
border: 1px solid var(--at-color-border);
|
|
8
8
|
border-radius: @block-radius;
|
|
9
|
-
margin-bottom:
|
|
9
|
+
margin-bottom: 10px;
|
|
10
10
|
|
|
11
11
|
@media only screen and (max-width: 768px) {
|
|
12
12
|
margin-bottom: 7px;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
& > .atk-header {
|
|
16
16
|
display: flex;
|
|
17
17
|
flex-direction: row;
|
|
18
|
-
padding:
|
|
18
|
+
padding: 10px 14px 0;
|
|
19
19
|
|
|
20
20
|
input {
|
|
21
21
|
flex: 1;
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
border: 2px solid transparent;
|
|
47
47
|
border-radius: calc(@block-radius / 2);
|
|
48
48
|
width: 100%;
|
|
49
|
-
min-height:
|
|
49
|
+
min-height: 120px;
|
|
50
50
|
margin-top: 2px;
|
|
51
|
-
padding:
|
|
51
|
+
padding: 10px 20px;
|
|
52
52
|
resize: none;
|
|
53
53
|
word-wrap: break-word;
|
|
54
54
|
outline: none;
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
& > .atk-send-reply {
|
|
68
68
|
z-index: 2;
|
|
69
69
|
position: absolute;
|
|
70
|
-
right:
|
|
70
|
+
right: 7px;
|
|
71
71
|
bottom: 8px;
|
|
72
72
|
max-width: calc(100% - 20px);
|
|
73
73
|
height: 30px;
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
text-overflow: ellipsis;
|
|
80
80
|
white-space: nowrap;
|
|
81
81
|
cursor: pointer;
|
|
82
|
+
border-radius: @block-radius;
|
|
82
83
|
|
|
83
84
|
.atk-text {
|
|
84
85
|
}
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
& > .atk-plug-wrap {
|
|
104
|
+
& > .atk-plug-panel-wrap {
|
|
104
105
|
position: relative;
|
|
105
106
|
height: 180px;
|
|
106
107
|
width: 100%;
|
|
@@ -114,8 +115,7 @@
|
|
|
114
115
|
display: flex;
|
|
115
116
|
flex-direction: row;
|
|
116
117
|
justify-content: space-between;
|
|
117
|
-
|
|
118
|
-
padding: 0 0 0 calc(@editor-padding - 5px);
|
|
118
|
+
padding: 5px 5px 5px 10px;
|
|
119
119
|
|
|
120
120
|
& > .atk-item {
|
|
121
121
|
display: flex;
|
|
@@ -129,9 +129,14 @@
|
|
|
129
129
|
color: var(--at-color-grey);
|
|
130
130
|
font-size: @font-size;
|
|
131
131
|
user-select: none;
|
|
132
|
+
border-radius: @block-radius;
|
|
132
133
|
|
|
133
134
|
&:not(:last-child) {
|
|
134
|
-
|
|
135
|
+
margin-right: 2px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&:hover {
|
|
139
|
+
background: var(--at-color-bg-grey);
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
&.active {
|
|
@@ -164,6 +169,7 @@
|
|
|
164
169
|
cursor: pointer;
|
|
165
170
|
transition: opacity 0.3s ease-in-out;
|
|
166
171
|
outline: none;
|
|
172
|
+
border-radius: @block-radius;
|
|
167
173
|
|
|
168
174
|
&:active {
|
|
169
175
|
opacity: 0.9;
|
|
@@ -175,7 +181,7 @@
|
|
|
175
181
|
z-index: 9;
|
|
176
182
|
position: absolute;
|
|
177
183
|
right: -2px;
|
|
178
|
-
bottom:
|
|
184
|
+
bottom: 40px;
|
|
179
185
|
width: 225px;
|
|
180
186
|
opacity: 0.83;
|
|
181
187
|
}
|
package/src/style/list.less
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
& > .atk-list-header {
|
|
5
5
|
display: flex;
|
|
6
6
|
flex-direction: row;
|
|
7
|
-
padding: 10px 10px
|
|
8
|
-
border-bottom: 1px solid var(--at-color-border);
|
|
7
|
+
padding: 10px 17px 10px 17px;
|
|
9
8
|
|
|
10
9
|
.atk-text {
|
|
11
10
|
display: inline-block;
|
|
@@ -103,7 +102,6 @@
|
|
|
103
102
|
&:not(:last-child):not(.atk-hide) {
|
|
104
103
|
margin-right: 10px;
|
|
105
104
|
padding-right: 10px;
|
|
106
|
-
border-right: 1px solid var(--at-color-border);
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
.atk-unread-badge {
|
|
@@ -129,7 +127,6 @@
|
|
|
129
127
|
|
|
130
128
|
.atk-list-comments-wrap {
|
|
131
129
|
.atk-main-editor {
|
|
132
|
-
margin-top: -1px;
|
|
133
130
|
}
|
|
134
131
|
}
|
|
135
132
|
}
|
|
@@ -171,8 +168,8 @@
|
|
|
171
168
|
|
|
172
169
|
.atk-list-read-more {
|
|
173
170
|
border-top: 1px dashed var(--at-color-border);
|
|
174
|
-
margin-top:
|
|
175
|
-
padding-bottom:
|
|
171
|
+
margin-top: 28px;
|
|
172
|
+
padding-bottom: 25px;
|
|
176
173
|
|
|
177
174
|
@media only screen and (max-width: 768px) {
|
|
178
175
|
padding-bottom: 10px;
|
|
@@ -210,8 +207,8 @@
|
|
|
210
207
|
}
|
|
211
208
|
|
|
212
209
|
&:hover {
|
|
210
|
+
background: var(--at-color-bg-grey);
|
|
213
211
|
& > .atk-text {
|
|
214
|
-
color: var(--at-color-main);
|
|
215
212
|
}
|
|
216
213
|
}
|
|
217
214
|
}
|
package/src/style/main.less
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
2
|
+
<link rel="stylesheet" href="../dist/ArtalkLite.css">
|
|
3
|
+
<script src="../dist/ArtalkLite.js"></script>
|
|
4
|
+
|
|
5
|
+
<div id="comments"></div>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
var artalk = new Artalk({
|
|
9
|
+
el: '#comments',
|
|
10
|
+
pageKey: 'https://artalk.js.org/',
|
|
11
|
+
pageTitle: 'Artalk Home',
|
|
12
|
+
server: 'http://localhost:23366',
|
|
13
|
+
site: 'ArtalkDocs',
|
|
14
|
+
});
|
|
15
|
+
</script>
|
package/types/artalk-config.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { I18n } from '~/src/i18n'
|
|
2
|
+
|
|
1
3
|
export default interface ArtalkConfig {
|
|
2
4
|
/** 装载元素 */
|
|
3
5
|
el: string|HTMLElement
|
|
@@ -6,93 +8,112 @@ export default interface ArtalkConfig {
|
|
|
6
8
|
pageKey: string
|
|
7
9
|
|
|
8
10
|
/** 页面标题 */
|
|
9
|
-
pageTitle
|
|
11
|
+
pageTitle: string
|
|
10
12
|
|
|
11
13
|
/** 服务器地址 */
|
|
12
14
|
server: string
|
|
13
15
|
|
|
14
16
|
/** 站点名 */
|
|
15
|
-
site
|
|
17
|
+
site: string
|
|
16
18
|
|
|
17
19
|
/** 评论框占位字符 */
|
|
18
|
-
placeholder
|
|
20
|
+
placeholder: string
|
|
19
21
|
|
|
20
22
|
/** 评论为空时显示字符 */
|
|
21
|
-
noComment
|
|
23
|
+
noComment: string
|
|
22
24
|
|
|
23
25
|
/** 发送按钮文字 */
|
|
24
|
-
sendBtn
|
|
26
|
+
sendBtn: string
|
|
25
27
|
|
|
26
28
|
/** 评论框旅行(显示在待回复评论后面) */
|
|
27
|
-
editorTravel
|
|
29
|
+
editorTravel: boolean
|
|
28
30
|
|
|
29
31
|
/** 表情包 */
|
|
30
|
-
emoticons
|
|
32
|
+
emoticons: object|any[]|string|false
|
|
31
33
|
|
|
32
34
|
/** Gravatar 头像 */
|
|
33
|
-
gravatar
|
|
35
|
+
gravatar: {
|
|
34
36
|
/** 镜像 */
|
|
35
|
-
mirror
|
|
37
|
+
mirror: string
|
|
36
38
|
/** 默认头像(URL or Gravatar Type) */
|
|
37
|
-
default
|
|
39
|
+
default: string
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/** 分页配置 */
|
|
41
|
-
pagination
|
|
43
|
+
pagination: {
|
|
42
44
|
/** 每次请求获取数量 */
|
|
43
|
-
pageSize
|
|
45
|
+
pageSize: number
|
|
44
46
|
/** 阅读更多模式 */
|
|
45
|
-
readMore
|
|
47
|
+
readMore: boolean
|
|
46
48
|
/** 滚动到底部自动加载 */
|
|
47
|
-
autoLoad
|
|
49
|
+
autoLoad: boolean
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/** 内容限高 */
|
|
51
|
-
heightLimit
|
|
53
|
+
heightLimit: {
|
|
52
54
|
/** 评论内容限高 */
|
|
53
|
-
content
|
|
55
|
+
content: number
|
|
54
56
|
|
|
55
57
|
/** 子评论区域限高 */
|
|
56
|
-
children
|
|
58
|
+
children: number
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/** 评论投票按钮 */
|
|
60
|
-
vote
|
|
62
|
+
vote: boolean
|
|
61
63
|
|
|
62
64
|
/** 评论投票反对按钮 */
|
|
63
|
-
voteDown
|
|
65
|
+
voteDown: boolean
|
|
66
|
+
|
|
67
|
+
/** 评论预览功能 */
|
|
68
|
+
preview: boolean
|
|
69
|
+
|
|
70
|
+
/** 评论数绑定元素 Selector */
|
|
71
|
+
countEl: string
|
|
64
72
|
|
|
65
|
-
/** PV
|
|
66
|
-
pvEl
|
|
73
|
+
/** PV 数绑定元素 Selector */
|
|
74
|
+
pvEl: string
|
|
67
75
|
|
|
68
76
|
/** 暗黑模式 */
|
|
69
|
-
darkMode
|
|
77
|
+
darkMode: boolean|'auto'
|
|
70
78
|
|
|
71
79
|
/** 请求超时(单位:秒) */
|
|
72
|
-
reqTimeout
|
|
80
|
+
reqTimeout: number
|
|
73
81
|
|
|
74
82
|
/** 平铺模式 */
|
|
75
|
-
flatMode
|
|
83
|
+
flatMode: boolean|'auto'
|
|
76
84
|
|
|
77
85
|
/** 嵌套模式 · 最大层数 */
|
|
78
|
-
nestMax
|
|
86
|
+
nestMax: number
|
|
87
|
+
|
|
88
|
+
/** 嵌套模式 · 排序方式 */
|
|
89
|
+
nestSort: 'DATE_ASC'|'DATE_DESC'
|
|
79
90
|
|
|
80
91
|
/** 显示 UA 徽标 */
|
|
81
|
-
uaBadge
|
|
92
|
+
uaBadge: boolean
|
|
82
93
|
|
|
83
94
|
/** 评论列表排序功能 (显示 Dropdown) */
|
|
84
|
-
listSort
|
|
95
|
+
listSort: boolean
|
|
85
96
|
|
|
86
97
|
/** 图片上传功能 */
|
|
87
|
-
imgUpload
|
|
98
|
+
imgUpload: boolean
|
|
99
|
+
|
|
100
|
+
/** 图片上传器 */
|
|
101
|
+
imgUploader?: (file: File) => Promise<{ img_url: string }>
|
|
88
102
|
|
|
89
103
|
/** 版本检测 */
|
|
90
|
-
versionCheck
|
|
104
|
+
versionCheck: boolean
|
|
105
|
+
|
|
106
|
+
/** 应用后端配置 */
|
|
107
|
+
useBackendConf: boolean
|
|
91
108
|
|
|
92
|
-
/**
|
|
93
|
-
|
|
109
|
+
/** 语言本地化 */
|
|
110
|
+
locale: I18n|string
|
|
94
111
|
}
|
|
95
112
|
|
|
113
|
+
/**
|
|
114
|
+
* 本地持久化用户数据
|
|
115
|
+
* @note 始终保持一层结构,不支持多层结构
|
|
116
|
+
*/
|
|
96
117
|
export interface LocalUser {
|
|
97
118
|
/** 昵称 */
|
|
98
119
|
nick: string
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { marked as libMarked } from 'marked'
|
|
2
|
+
import ArtalkConfig from './artalk-config'
|
|
3
|
+
import { CommentData, NotifyData } from './artalk-data'
|
|
4
|
+
import { EventPayloadMap, Event, EventScopeType, Handler } from './event'
|
|
5
|
+
import { internal as internalLocales, I18n } from '../src/i18n'
|
|
6
|
+
import Api from '../src/api'
|
|
7
|
+
import User from '../src/lib/user'
|
|
8
|
+
import Editor from '../src/editor'
|
|
9
|
+
import Comment from '../src/comment'
|
|
10
|
+
import ListLite from '../src/list/list-lite'
|
|
11
|
+
import SidebarLayer, { SidebarShowPayload } from '../src/layer/sidebar-layer'
|
|
12
|
+
import CheckerLauncher, { CheckerCaptchaPayload, CheckerPayload } from '../src/lib/checker'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Context 接口
|
|
16
|
+
*
|
|
17
|
+
* (面向接口的编程)
|
|
18
|
+
*/
|
|
19
|
+
export default interface ContextApi {
|
|
20
|
+
/** Context 唯一标识 */
|
|
21
|
+
cid: number
|
|
22
|
+
|
|
23
|
+
/** Artalk 根元素对象 */
|
|
24
|
+
$root: HTMLElement
|
|
25
|
+
|
|
26
|
+
/** 配置对象 */
|
|
27
|
+
conf: ArtalkConfig
|
|
28
|
+
|
|
29
|
+
/** 用户对象 */
|
|
30
|
+
user: User
|
|
31
|
+
|
|
32
|
+
/** marked 依赖对象 */
|
|
33
|
+
markedInstance?: typeof libMarked
|
|
34
|
+
|
|
35
|
+
/** marked 内容替换器 */
|
|
36
|
+
markedReplacers: ((raw: string) => string)[]
|
|
37
|
+
|
|
38
|
+
/* 设置持有的同事类 (中介者模式) */
|
|
39
|
+
setApi(api: Api): void
|
|
40
|
+
setEditor(editor: Editor): void
|
|
41
|
+
setList(list: ListLite): void
|
|
42
|
+
setSidebarLayer(list: SidebarLayer): void
|
|
43
|
+
setCheckerLauncher(checkerLauncher: CheckerLauncher): void
|
|
44
|
+
|
|
45
|
+
/** 获取 API 以供 HTTP 请求 */
|
|
46
|
+
getApi(): Api
|
|
47
|
+
|
|
48
|
+
/** 获取评论实例对象列表 */
|
|
49
|
+
getCommentList(): Comment[]
|
|
50
|
+
|
|
51
|
+
/** 获取评论数据列表 */
|
|
52
|
+
getCommentDataList(): CommentData[]
|
|
53
|
+
|
|
54
|
+
/** 查找评论 */
|
|
55
|
+
findComment(id: number): Comment|undefined
|
|
56
|
+
|
|
57
|
+
/** 删除评论 */
|
|
58
|
+
deleteComment(comment: number|Comment): void
|
|
59
|
+
|
|
60
|
+
/** 清空评论 */
|
|
61
|
+
clearAllComments(): void
|
|
62
|
+
|
|
63
|
+
/** 插入评论 */
|
|
64
|
+
insertComment(commentData: CommentData): void
|
|
65
|
+
|
|
66
|
+
/** 评论回复 */
|
|
67
|
+
replyComment(commentData: CommentData, $comment: HTMLElement, scroll?: boolean): void
|
|
68
|
+
|
|
69
|
+
/** 取消回复评论 */
|
|
70
|
+
cancelReplyComment(): void
|
|
71
|
+
|
|
72
|
+
/** 更新通知数据 */
|
|
73
|
+
updateNotifies(notifies: NotifyData[]): void
|
|
74
|
+
|
|
75
|
+
/** 列表 - 重新加载数据 */
|
|
76
|
+
listReload(): void
|
|
77
|
+
|
|
78
|
+
/** 列表 - UI 更新 */
|
|
79
|
+
listRefreshUI(): void
|
|
80
|
+
|
|
81
|
+
/** 显示侧边栏 */
|
|
82
|
+
showSidebar(payload?: SidebarShowPayload): void
|
|
83
|
+
|
|
84
|
+
/** 隐藏侧边栏 */
|
|
85
|
+
hideSidebar(): void
|
|
86
|
+
|
|
87
|
+
/** 编辑器 - 关闭评论 */
|
|
88
|
+
editorClose(): void
|
|
89
|
+
|
|
90
|
+
/** 编辑器 - 打开评论 */
|
|
91
|
+
editorOpen(): void
|
|
92
|
+
|
|
93
|
+
/** 编辑器 - 显示加载 */
|
|
94
|
+
editorShowLoading(): void
|
|
95
|
+
|
|
96
|
+
/** 编辑器 - 隐藏加载 */
|
|
97
|
+
editorHideLoading(): void
|
|
98
|
+
|
|
99
|
+
/** 编辑器 - 显示提示消息 */
|
|
100
|
+
editorShowNotify(msg: string, type: "i" | "s" | "w" | "e"): void
|
|
101
|
+
|
|
102
|
+
/** 评论框 - 位置移动 */
|
|
103
|
+
editorTravel($el: HTMLElement): void
|
|
104
|
+
|
|
105
|
+
/** 评论框 - 位置回归 */
|
|
106
|
+
editorTravelBack(): void
|
|
107
|
+
|
|
108
|
+
/** 验证码检测 */
|
|
109
|
+
checkCaptcha(payload: CheckerCaptchaPayload): void
|
|
110
|
+
|
|
111
|
+
/** 管理员检测 */
|
|
112
|
+
checkAdmin(payload: CheckerPayload): void
|
|
113
|
+
|
|
114
|
+
/** 管理员显示元素可见性更新 */
|
|
115
|
+
checkAdminShowEl(): void
|
|
116
|
+
|
|
117
|
+
/** 订阅注册 */
|
|
118
|
+
on<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>, scope?: EventScopeType): void
|
|
119
|
+
|
|
120
|
+
/** 订阅取消 */
|
|
121
|
+
off<K extends keyof EventPayloadMap>(name: K, handler?: Handler<EventPayloadMap[K]>, scope?: EventScopeType): void
|
|
122
|
+
|
|
123
|
+
/** 订阅发布 */
|
|
124
|
+
trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K], scope?: EventScopeType): void
|
|
125
|
+
|
|
126
|
+
/** i18n 翻译 */
|
|
127
|
+
$t(key: keyof I18n, args?: {[key: string]: string}): string
|
|
128
|
+
}
|
package/types/event.d.ts
CHANGED
|
@@ -1,77 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommentData } from './artalk-data'
|
|
2
2
|
import { LocalUser } from './artalk-config'
|
|
3
3
|
|
|
4
4
|
/** EventName to EventPayload Type */
|
|
5
5
|
export interface EventPayloadMap {
|
|
6
|
-
'
|
|
7
|
-
'
|
|
6
|
+
'list-load': undefined // 评论加载时
|
|
7
|
+
'list-loaded': undefined // 评论装载后
|
|
8
|
+
'list-inserted': CommentData // 评论插入后
|
|
8
9
|
'editor-submit': undefined // 编辑器提交时
|
|
9
10
|
'editor-submitted': undefined // 编辑器提交后
|
|
10
11
|
'user-changed': LocalUser // 本地用户数据变更时
|
|
11
12
|
'conf-updated': undefined // Artalk 配置变更时
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
'list-reload': undefined // 重新加载 List
|
|
15
|
-
'list-import': CommentData[] // 评论导入
|
|
16
|
-
'list-insert': CommentData // 评论添加
|
|
17
|
-
'list-delete': CommentData // 评论删除
|
|
18
|
-
'list-update': ListUpdatePayload // 更新评论数据
|
|
19
|
-
'list-refresh-ui': undefined // 刷新 List UI
|
|
20
|
-
|
|
21
|
-
// Sidebar
|
|
22
|
-
'sidebar-show': SidebarShowPayload // 侧边栏显示
|
|
23
|
-
'sidebar-hide': undefined // 侧边栏隐藏
|
|
24
|
-
|
|
25
|
-
// Editor
|
|
26
|
-
'editor-open': undefined // 打开评论
|
|
27
|
-
'editor-close': undefined // 关闭评论
|
|
28
|
-
'editor-show-loading': undefined // 加载显示
|
|
29
|
-
'editor-hide-loading': undefined // 加载隐藏
|
|
30
|
-
'editor-notify': NotifyConf // 显示提示
|
|
31
|
-
'editor-reply': EditorReplyPayload // 设置回复
|
|
32
|
-
'editor-reply-cancel': undefined // 取消回复
|
|
33
|
-
'editor-travel': HTMLElement
|
|
34
|
-
'editor-travel-back': undefined
|
|
35
|
-
|
|
36
|
-
// Notify
|
|
37
|
-
'unread-update': UnreadUpdatePayload // 未读数据更新
|
|
38
|
-
|
|
39
|
-
// Checker
|
|
40
|
-
'checker-admin': CheckerPayload // 检查管理员
|
|
41
|
-
'checker-captcha': CheckerCaptchaPayload // 检查验证码
|
|
42
|
-
'check-admin-show-el': undefined // 检查并更新仅管理员显示的元素
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface CheckerPayload {
|
|
46
|
-
onSuccess?: (inputVal: string, dialogEl?: HTMLElement) => void
|
|
47
|
-
onMount?: (dialogEl: HTMLElement) => void
|
|
48
|
-
onCancel?: () => void
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface NotifyConf {
|
|
52
|
-
msg: string
|
|
53
|
-
type: any
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface CheckerCaptchaPayload extends CheckerPayload {
|
|
57
|
-
imgData?: string
|
|
58
|
-
iframe?: string
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface UnreadUpdatePayload {
|
|
62
|
-
notifies: NotifyData[]
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type ListUpdatePayload = (data: ListData | undefined) => void
|
|
66
|
-
|
|
67
|
-
export interface EditorReplyPayload {
|
|
68
|
-
data: CommentData
|
|
69
|
-
$el: HTMLElement
|
|
70
|
-
scroll?: boolean
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface SidebarShowPayload {
|
|
74
|
-
view?: 'comments'|'sites'|'pages'|'transfer'|string
|
|
13
|
+
'sidebar-show': undefined // 侧边栏显示
|
|
14
|
+
'sidebar-hide': undefined // 侧边栏隐藏
|
|
75
15
|
}
|
|
76
16
|
|
|
77
17
|
// ============================================
|
package/types/global.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
2
3
|
import { version } from './package.json'
|
|
3
4
|
|
|
4
|
-
export default {
|
|
5
|
+
export default defineConfig({
|
|
5
6
|
define: {
|
|
6
|
-
ARTALK_VERSION: JSON.stringify(version)
|
|
7
|
+
ARTALK_VERSION: JSON.stringify(version),
|
|
7
8
|
},
|
|
8
9
|
css: {
|
|
9
10
|
preprocessorOptions: {
|
|
@@ -12,4 +13,5 @@ export default {
|
|
|
12
13
|
},
|
|
13
14
|
},
|
|
14
15
|
},
|
|
15
|
-
|
|
16
|
+
plugins: [tsconfigPaths()],
|
|
17
|
+
})
|
package/vite-demo.config.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
2
|
import { resolve } from 'path'
|
|
3
|
-
import
|
|
4
|
-
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
3
|
+
import baseConf from './vite-base.config'
|
|
5
4
|
|
|
6
5
|
export default defineConfig({
|
|
7
6
|
build: {
|
|
@@ -9,6 +8,5 @@ export default defineConfig({
|
|
|
9
8
|
outDir: resolve(__dirname, "deploy"),
|
|
10
9
|
rollupOptions: {}
|
|
11
10
|
},
|
|
12
|
-
|
|
13
|
-
...commonConf
|
|
11
|
+
...baseConf
|
|
14
12
|
})
|