artalk 2.2.12 → 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.
Files changed (73) hide show
  1. package/dist/Artalk.css +1 -1
  2. package/dist/Artalk.es.js +3216 -2883
  3. package/dist/Artalk.iife.js +1 -1
  4. package/dist/Artalk.js +1 -1
  5. package/dist/ArtalkLite.css +1 -0
  6. package/dist/ArtalkLite.es.js +5096 -0
  7. package/dist/ArtalkLite.iife.js +1 -0
  8. package/dist/ArtalkLite.js +1 -0
  9. package/index.html +2 -2
  10. package/package.json +6 -5
  11. package/src/api/index.ts +20 -1
  12. package/src/api/request.ts +7 -7
  13. package/src/artalk.ts +68 -50
  14. package/src/comment/actions.ts +87 -0
  15. package/src/{components/html → comment}/comment.html +1 -1
  16. package/src/comment/comment.ts +191 -0
  17. package/src/comment/index.ts +3 -0
  18. package/src/comment/render.ts +425 -0
  19. package/src/components/action-btn.ts +6 -3
  20. package/src/components/dialog.ts +7 -3
  21. package/src/components/read-more-btn.ts +6 -2
  22. package/src/context.ts +200 -13
  23. package/src/defaults.ts +16 -5
  24. package/src/editor/editor.html +18 -0
  25. package/src/editor/editor.ts +420 -0
  26. package/src/editor/index.ts +3 -0
  27. package/src/editor/plugs/editor-plug.ts +51 -0
  28. package/src/{components/editor-plugs → editor/plugs}/emoticons-plug.less +1 -0
  29. package/src/{components/editor-plugs → editor/plugs}/emoticons-plug.ts +65 -63
  30. package/src/editor/plugs/header-input-plug.ts +79 -0
  31. package/src/{components/editor-plugs → editor/plugs}/preview-plug.less +0 -0
  32. package/src/editor/plugs/preview-plug.ts +40 -0
  33. package/src/editor/plugs/upload-plug.ts +125 -0
  34. package/src/i18n/en.ts +77 -0
  35. package/src/i18n/index.ts +21 -0
  36. package/src/i18n/zh-CN.ts +81 -0
  37. package/src/layer/index.ts +4 -0
  38. package/src/{components → layer}/layer.ts +9 -9
  39. package/src/{components/html → layer}/sidebar-layer.html +0 -0
  40. package/src/{components → layer}/sidebar-layer.ts +17 -46
  41. package/src/lib/checker/admin-checker.ts +7 -6
  42. package/src/lib/checker/captcha-checker.ts +5 -5
  43. package/src/lib/checker/index.ts +22 -17
  44. package/src/lib/component.ts +7 -2
  45. package/src/lib/ui.ts +3 -10
  46. package/src/lib/user.ts +20 -3
  47. package/src/lib/utils.ts +23 -9
  48. package/src/list/index.ts +3 -0
  49. package/src/{components → list}/list-lite.ts +80 -99
  50. package/src/{components → list}/list-nest.ts +0 -0
  51. package/src/{components/html → list}/list.html +3 -6
  52. package/src/{components → list}/list.ts +37 -35
  53. package/src/style/comment.less +23 -10
  54. package/src/style/editor.less +16 -10
  55. package/src/style/list.less +4 -7
  56. package/src/style/main.less +3 -1
  57. package/src/style/pagination.less +1 -1
  58. package/test/ArtalkLite.html +15 -0
  59. package/types/artalk-config.d.ts +50 -32
  60. package/types/context.d.ts +128 -0
  61. package/types/event.d.ts +6 -66
  62. package/types/global.d.ts +1 -0
  63. package/{vite-common.config.ts → vite-base.config.ts} +6 -4
  64. package/vite-demo.config.ts +2 -4
  65. package/vite-lite.config.ts +22 -0
  66. package/vite.config.ts +9 -12
  67. package/src/components/_component.ts.txt +0 -10
  68. package/src/components/comment.ts +0 -605
  69. package/src/components/editor-plugs/_example-plug.ts.txt +0 -29
  70. package/src/components/editor-plugs/editor-plug.ts +0 -20
  71. package/src/components/editor-plugs/preview-plug.ts +0 -48
  72. package/src/components/editor.ts +0 -607
  73. package/src/components/html/editor.html +0 -18
@@ -1,7 +1,7 @@
1
1
  .atk-comment-wrap {
2
2
  overflow: hidden;
3
3
  position: relative;
4
- border-bottom: 1px solid var(--at-color-border);
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: 48px;
53
- height: 48px;
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: 62px;
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: 0 6px;
113
- line-height: 18px;
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 var(--at-color-border);
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-top: 4px;
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
  }
@@ -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: 15px;
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: calc(@editor-padding / 2) @editor-padding 0;
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: 130px;
49
+ min-height: 120px;
50
50
  margin-top: 2px;
51
- padding: @editor-padding calc(10px + 5px);
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: 10px;
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
- border-top: 1px solid var(--at-color-border);
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
- border-right: 1px solid var(--at-color-border);
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: 36px;
184
+ bottom: 40px;
179
185
  width: 225px;
180
186
  opacity: 0.83;
181
187
  }
@@ -4,8 +4,7 @@
4
4
  & > .atk-list-header {
5
5
  display: flex;
6
6
  flex-direction: row;
7
- padding: 10px 10px 5px 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: 20px;
175
- padding-bottom: 20px;
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
  }
@@ -28,7 +28,9 @@
28
28
  code {
29
29
  font-family: @codeFont;
30
30
  margin: 0 .3em;
31
- padding: .1em .2em;
31
+ padding: 0 .5em;
32
+ display: inline-block;
33
+ font-size: .9em;
32
34
  background-color: var(--at-color-bg-grey);
33
35
  color: var(--at-color-font);
34
36
  border-radius: @block-radius;
@@ -8,7 +8,7 @@
8
8
  & > .atk-btn,
9
9
  & > .atk-input {
10
10
  font-size: 15px;
11
- height: 32px;
11
+ height: 30px;
12
12
  border: 1px solid var(--at-color-border);
13
13
  border-radius: 3px;
14
14
  padding: 0 5px;
@@ -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>
@@ -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,96 +8,112 @@ export default interface ArtalkConfig {
6
8
  pageKey: string
7
9
 
8
10
  /** 页面标题 */
9
- pageTitle?: string
11
+ pageTitle: string
10
12
 
11
13
  /** 服务器地址 */
12
14
  server: string
13
15
 
14
16
  /** 站点名 */
15
- site?: string
17
+ site: string
16
18
 
17
19
  /** 评论框占位字符 */
18
- placeholder?: string
20
+ placeholder: string
19
21
 
20
22
  /** 评论为空时显示字符 */
21
- noComment?: string
23
+ noComment: string
22
24
 
23
25
  /** 发送按钮文字 */
24
- sendBtn?: string
26
+ sendBtn: string
25
27
 
26
28
  /** 评论框旅行(显示在待回复评论后面) */
27
- editorTravel?: boolean
29
+ editorTravel: boolean
28
30
 
29
31
  /** 表情包 */
30
- emoticons?: object|any[]|string|false
32
+ emoticons: object|any[]|string|false
31
33
 
32
34
  /** Gravatar 头像 */
33
- gravatar?: {
35
+ gravatar: {
34
36
  /** 镜像 */
35
- mirror?: string
37
+ mirror: string
36
38
  /** 默认头像(URL or Gravatar Type) */
37
- default?: string
39
+ default: string
38
40
  }
39
41
 
40
42
  /** 分页配置 */
41
- pagination?: {
43
+ pagination: {
42
44
  /** 每次请求获取数量 */
43
- pageSize?: number
45
+ pageSize: number
44
46
  /** 阅读更多模式 */
45
- readMore?: boolean
47
+ readMore: boolean
46
48
  /** 滚动到底部自动加载 */
47
- autoLoad?: boolean
49
+ autoLoad: boolean
48
50
  }
49
51
 
50
52
  /** 内容限高 */
51
- heightLimit?: {
53
+ heightLimit: {
52
54
  /** 评论内容限高 */
53
- content?: number
55
+ content: number
54
56
 
55
57
  /** 子评论区域限高 */
56
- children?: number
58
+ children: number
57
59
  }
58
60
 
59
61
  /** 评论投票按钮 */
60
- vote?: boolean
62
+ vote: boolean
61
63
 
62
64
  /** 评论投票反对按钮 */
63
- voteDown?: boolean
65
+ voteDown: boolean
66
+
67
+ /** 评论预览功能 */
68
+ preview: boolean
69
+
70
+ /** 评论数绑定元素 Selector */
71
+ countEl: string
64
72
 
65
- /** PV 元素 Selector */
66
- pvEl?: string
73
+ /** PV 数绑定元素 Selector */
74
+ pvEl: string
67
75
 
68
76
  /** 暗黑模式 */
69
- darkMode?: boolean|'auto'
77
+ darkMode: boolean|'auto'
70
78
 
71
79
  /** 请求超时(单位:秒) */
72
- reqTimeout?: number
80
+ reqTimeout: number
73
81
 
74
82
  /** 平铺模式 */
75
- flatMode?: boolean|'auto'
83
+ flatMode: boolean|'auto'
76
84
 
77
85
  /** 嵌套模式 · 最大层数 */
78
- nestMax?: number
86
+ nestMax: number
79
87
 
80
88
  /** 嵌套模式 · 排序方式 */
81
- nestSort?: 'DATE_ASC'|'DATE_DESC'
89
+ nestSort: 'DATE_ASC'|'DATE_DESC'
82
90
 
83
91
  /** 显示 UA 徽标 */
84
- uaBadge?: boolean
92
+ uaBadge: boolean
85
93
 
86
94
  /** 评论列表排序功能 (显示 Dropdown) */
87
- listSort?: boolean
95
+ listSort: boolean
88
96
 
89
97
  /** 图片上传功能 */
90
- imgUpload?: boolean
98
+ imgUpload: boolean
99
+
100
+ /** 图片上传器 */
101
+ imgUploader?: (file: File) => Promise<{ img_url: string }>
91
102
 
92
103
  /** 版本检测 */
93
- versionCheck?: boolean
104
+ versionCheck: boolean
105
+
106
+ /** 应用后端配置 */
107
+ useBackendConf: boolean
94
108
 
95
- /** 复用后端配置 */
96
- useBackendConf?: boolean
109
+ /** 语言本地化 */
110
+ locale: I18n|string
97
111
  }
98
112
 
113
+ /**
114
+ * 本地持久化用户数据
115
+ * @note 始终保持一层结构,不支持多层结构
116
+ */
99
117
  export interface LocalUser {
100
118
  /** 昵称 */
101
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 { ListData, CommentData, NotifyData } from './artalk-data'
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
- 'comments-load': undefined // 评论加载时
7
- 'comments-loaded': undefined // 评论装载后
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
- // List 操作(外部:不建议 listen,仅 trigger)
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 +1,2 @@
1
1
  declare const ARTALK_VERSION: string
2
+ declare const ARTALK_LITE: boolean
@@ -1,9 +1,10 @@
1
- import { UserConfigExport } from 'vite'
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
- } as UserConfigExport
16
+ plugins: [tsconfigPaths()],
17
+ })
@@ -1,7 +1,6 @@
1
1
  import { defineConfig } from 'vite'
2
2
  import { resolve } from 'path'
3
- import commonConf from './vite-common.config'
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
- plugins: [tsconfigPaths()],
13
- ...commonConf
11
+ ...baseConf
14
12
  })