artalk 2.1.3 → 2.1.4
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 +285 -323
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/package.json +6 -9
- package/src/api/index.ts +2 -3
- package/src/artalk.ts +2 -2
- package/src/components/action-btn.ts +1 -1
- package/src/components/comment.ts +88 -3
- package/src/components/editor-plugs/emoticons-plug.less +21 -11
- package/src/components/editor-plugs/emoticons-plug.ts +18 -18
- package/src/components/editor-plugs/preview-plug.less +1 -1
- package/src/components/editor.ts +15 -20
- package/src/components/html/comment.html +6 -13
- package/src/components/html/editor.html +8 -9
- package/src/components/html/list.html +1 -1
- package/src/components/list-lite.ts +203 -299
- package/src/components/list.ts +11 -9
- package/src/components/pagination.ts +2 -2
- package/src/components/read-more-btn.ts +27 -4
- package/src/components/sidebar-views/comments-view.ts +4 -5
- package/src/defaults.ts +1 -1
- package/src/lib/utils.ts +2 -1
- package/src/style/_color.less +19 -23
- package/src/style/_extend.less +3 -3
- package/src/style/_variables.less +0 -24
- package/src/style/comment.less +191 -197
- package/src/style/editor.less +69 -94
- package/src/style/item-text-editor.less +2 -2
- package/src/style/list.less +13 -13
- package/src/style/main.less +31 -31
- package/src/style/page-list.less +4 -4
- package/src/style/pagination.less +6 -6
- package/src/style/sidebar.less +35 -35
- package/src/style/site-list.less +13 -13
- package/types/artalk-data.d.ts +2 -2
package/src/components/list.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default class List extends ListLite {
|
|
|
16
16
|
constructor (ctx: Context) {
|
|
17
17
|
const el = Utils.createElement(ListHTML)
|
|
18
18
|
|
|
19
|
-
super(ctx
|
|
19
|
+
super(ctx)
|
|
20
20
|
|
|
21
21
|
// 把 listLite $el 变为子元素
|
|
22
22
|
el.querySelector('.atk-list-body')!.append(this.$el)
|
|
@@ -34,6 +34,8 @@ export default class List extends ListLite {
|
|
|
34
34
|
|
|
35
35
|
// 分页模式
|
|
36
36
|
this.pageMode = this.conf.pagination?.readMore ? 'read-more' : 'pagination'
|
|
37
|
+
this.pageSize = this.conf.pagination?.pageSize || 20
|
|
38
|
+
this.repositionAt = this.$el
|
|
37
39
|
|
|
38
40
|
// 操作按钮
|
|
39
41
|
this.initListActionBtn()
|
|
@@ -42,7 +44,7 @@ export default class List extends ListLite {
|
|
|
42
44
|
this.$el.querySelector<HTMLElement>('.atk-copyright')!.innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${ARTALK_VERSION}">Artalk</a>`
|
|
43
45
|
|
|
44
46
|
// event listen
|
|
45
|
-
this.ctx.on('list-reload', () => (this.
|
|
47
|
+
this.ctx.on('list-reload', () => (this.fetchComments(0))) // 刷新评论
|
|
46
48
|
this.ctx.on('list-refresh-ui', () => (this.refreshUI()))
|
|
47
49
|
this.ctx.on('list-import', (data) => (this.importComments(data)))
|
|
48
50
|
this.ctx.on('list-insert', (data) => (this.insertComment(data)))
|
|
@@ -51,7 +53,7 @@ export default class List extends ListLite {
|
|
|
51
53
|
this.ctx.on('unread-update', (data) => (this.showUnreadBadge(data.notifies?.length || 0)))
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
private initListActionBtn
|
|
56
|
+
private initListActionBtn() {
|
|
55
57
|
// 侧边栏呼出按钮
|
|
56
58
|
this.$openSidebarBtn = this.$el.querySelector('[data-action="open-sidebar"]')!
|
|
57
59
|
this.$closeCommentBtn = this.$el.querySelector('[data-action="admin-close-comment"]')!
|
|
@@ -71,10 +73,10 @@ export default class List extends ListLite {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/** 刷新界面 */
|
|
74
|
-
public refreshUI
|
|
76
|
+
public refreshUI() {
|
|
75
77
|
super.refreshUI()
|
|
76
78
|
|
|
77
|
-
this.$el.querySelector<HTMLElement>('.atk-comment-count-num')!.innerText = String(this.
|
|
79
|
+
this.$el.querySelector<HTMLElement>('.atk-comment-count-num')!.innerText = String(Number(this.data?.total) || 0)
|
|
78
80
|
|
|
79
81
|
// 已输入个人信息
|
|
80
82
|
if (!!this.ctx.user.data.nick && !!this.ctx.user.data.email) {
|
|
@@ -85,7 +87,7 @@ export default class List extends ListLite {
|
|
|
85
87
|
|
|
86
88
|
// 仅管理员显示控制
|
|
87
89
|
this.ctx.trigger('check-admin-show-el')
|
|
88
|
-
this.$openSidebarBtn.innerText = (!this.ctx.user.data.isAdmin) ? '通知中心' : '控制中心'
|
|
90
|
+
this.$openSidebarBtn.querySelector<HTMLElement>('.atk-text')!.innerText = (!this.ctx.user.data.isAdmin) ? '通知中心' : '控制中心'
|
|
89
91
|
|
|
90
92
|
// 关闭评论
|
|
91
93
|
if (!!this.data && !!this.data.page && this.data.page.admin_only === true) {
|
|
@@ -97,7 +99,7 @@ export default class List extends ListLite {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
protected onLoad(data: ListData, offset: number) {
|
|
101
103
|
super.onLoad(data, offset)
|
|
102
104
|
|
|
103
105
|
// 检测锚点跳转
|
|
@@ -130,7 +132,7 @@ export default class List extends ListLite {
|
|
|
130
132
|
// TODO 若找不到评论的情况
|
|
131
133
|
// if (!comment) { // 若找不到评论
|
|
132
134
|
// if (this.hasMoreComments) { // 阅读更多,并重试
|
|
133
|
-
// await this.
|
|
135
|
+
// await this.fetchComments()
|
|
134
136
|
// }
|
|
135
137
|
// }
|
|
136
138
|
|
|
@@ -161,7 +163,7 @@ export default class List extends ListLite {
|
|
|
161
163
|
})
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
public showUnreadBadge
|
|
166
|
+
public showUnreadBadge(count: number) {
|
|
165
167
|
if (count > 0) {
|
|
166
168
|
this.$unreadBadge.innerText = `${Number(count || 0)}`
|
|
167
169
|
this.$unreadBadge.style.display = 'block'
|
|
@@ -4,7 +4,7 @@ import * as Ui from '../lib/ui'
|
|
|
4
4
|
|
|
5
5
|
export interface PaginationConf {
|
|
6
6
|
/** 每页条数 */
|
|
7
|
-
pageSize
|
|
7
|
+
pageSize: number
|
|
8
8
|
|
|
9
9
|
/** 回调函数 */
|
|
10
10
|
onChange: (offset: number) => void
|
|
@@ -21,7 +21,7 @@ export default class Pagination {
|
|
|
21
21
|
|
|
22
22
|
public page: number = 1
|
|
23
23
|
get pageSize(): number {
|
|
24
|
-
return this.conf.pageSize
|
|
24
|
+
return this.conf.pageSize
|
|
25
25
|
}
|
|
26
26
|
get offset(): number {
|
|
27
27
|
return this.pageSize * (this.page - 1)
|
|
@@ -2,7 +2,9 @@ import * as Utils from '../lib/utils'
|
|
|
2
2
|
|
|
3
3
|
export interface ReadMoreBtnConf {
|
|
4
4
|
/** 回调函数 */
|
|
5
|
-
onClick: () => void
|
|
5
|
+
onClick: (offset: number) => void
|
|
6
|
+
|
|
7
|
+
pageSize: number
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -13,6 +15,13 @@ export default class ReadMoreBtn {
|
|
|
13
15
|
public $el: HTMLElement
|
|
14
16
|
private $loading: HTMLElement
|
|
15
17
|
private $text: HTMLElement
|
|
18
|
+
private offset: number = 0
|
|
19
|
+
private total: number = 0
|
|
20
|
+
|
|
21
|
+
/** 是否有更多内容 */
|
|
22
|
+
get hasMore() {
|
|
23
|
+
return this.total > (this.offset + this.conf.pageSize)
|
|
24
|
+
}
|
|
16
25
|
|
|
17
26
|
public constructor(conf: ReadMoreBtnConf) {
|
|
18
27
|
this.conf = conf
|
|
@@ -21,18 +30,19 @@ export default class ReadMoreBtn {
|
|
|
21
30
|
`<div class="atk-list-read-more" style="display: none;">
|
|
22
31
|
<div class="atk-list-read-more-inner">
|
|
23
32
|
<div class="atk-loading-icon" style="display: none;"></div>
|
|
24
|
-
<span class="atk-text"
|
|
33
|
+
<span class="atk-text">加载更多</span>
|
|
25
34
|
</div>
|
|
26
35
|
</div>`)
|
|
27
36
|
|
|
28
37
|
this.$loading = this.$el.querySelector<HTMLElement>('.atk-loading-icon')!
|
|
29
38
|
this.$text = this.$el.querySelector<HTMLElement>('.atk-text')!
|
|
30
39
|
|
|
31
|
-
this.$el.onclick = () => this.click()
|
|
40
|
+
this.$el.onclick = () => { this.click() }
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
click() {
|
|
35
|
-
this.conf.onClick()
|
|
44
|
+
if (this.hasMore) this.conf.onClick(this.offset + this.conf.pageSize)
|
|
45
|
+
this.checkDisabled()
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
/** 显示 */
|
|
@@ -62,4 +72,17 @@ export default class ReadMoreBtn {
|
|
|
62
72
|
this.$el.classList.remove('atk-err')
|
|
63
73
|
}, 2000) // 2s后错误提示复原
|
|
64
74
|
}
|
|
75
|
+
|
|
76
|
+
/** 更新数据 */
|
|
77
|
+
public update(offset: number, total: number) {
|
|
78
|
+
this.offset = offset
|
|
79
|
+
this.total = total
|
|
80
|
+
|
|
81
|
+
this.checkDisabled()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public checkDisabled() {
|
|
85
|
+
if (this.hasMore) this.show()
|
|
86
|
+
else this.hide()
|
|
87
|
+
}
|
|
65
88
|
}
|
|
@@ -31,10 +31,10 @@ export default class MessageView extends SidebarView {
|
|
|
31
31
|
this.viewActiveTab = 'mentions'
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
this.list = new ListLite(this.ctx
|
|
34
|
+
this.list = new ListLite(this.ctx)
|
|
35
35
|
this.list.flatMode = true
|
|
36
36
|
this.list.unreadHighlight = true
|
|
37
|
-
this.list.
|
|
37
|
+
this.list.scrollListenerAt = this.$parent
|
|
38
38
|
this.list.pageMode = 'pagination'
|
|
39
39
|
this.list.noCommentText = '<div class="atk-sidebar-no-content">无内容</div>'
|
|
40
40
|
this.list.renderComment = (comment) => {
|
|
@@ -61,12 +61,11 @@ export default class MessageView extends SidebarView {
|
|
|
61
61
|
switchTab(tab: string, siteName: string): boolean|void {
|
|
62
62
|
//console.log(tab, siteName)
|
|
63
63
|
this.viewActiveTab = tab
|
|
64
|
-
this.list.type = tab as any;
|
|
65
|
-
this.list.isFirstLoad = true
|
|
66
64
|
this.list.paramsEditor = (params) => {
|
|
65
|
+
params.type = tab as any
|
|
67
66
|
params.site_name = siteName
|
|
68
67
|
}
|
|
69
|
-
this.list.
|
|
68
|
+
this.list.fetchComments(0)
|
|
70
69
|
|
|
71
70
|
return true
|
|
72
71
|
}
|
package/src/defaults.ts
CHANGED
package/src/lib/utils.ts
CHANGED
|
@@ -98,6 +98,7 @@ export function timeAgo(date: Date) {
|
|
|
98
98
|
|
|
99
99
|
/** 所有图片加载完毕后执行 */
|
|
100
100
|
export function onImagesLoaded($container: HTMLElement, event: Function) {
|
|
101
|
+
if (!$container) return
|
|
101
102
|
const images = $container.getElementsByTagName('img')
|
|
102
103
|
if (!images.length) return
|
|
103
104
|
let loaded = images.length
|
|
@@ -121,7 +122,7 @@ export function getGravatarURL(ctx: Context, emailMD5: string) {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
export function sleep(ms: number) {
|
|
124
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
125
|
+
return new Promise(resolve => { setTimeout(resolve, ms) });
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
/** 版本号比较(a < b :-1 | 0 | b < a :1) */
|
package/src/style/_color.less
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
.artalk, .atk-layer-wrap {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
--at-color-quote: #687a86;
|
|
21
|
-
--at-color-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255));
|
|
22
|
-
}
|
|
2
|
+
--at-color-font: #2a2e2e;
|
|
3
|
+
--at-color-deep: #2a2e2e;
|
|
4
|
+
--at-color-sub: #757575;
|
|
5
|
+
--at-color-grey: #999;
|
|
6
|
+
--at-color-meta: #757e91;
|
|
7
|
+
--at-color-border: #eceff2;
|
|
8
|
+
--at-color-light: #4285f4;
|
|
9
|
+
--at-color-bg: #FFF;
|
|
10
|
+
--at-color-bg-transl: rgba(255, 255, 255, 0.94);
|
|
11
|
+
--at-color-bg-grey: #F4F4F4;
|
|
12
|
+
--at-color-bg-grey-transl: rgba(244, 244, 244, 0.75);
|
|
13
|
+
--at-color-bg-light: rgba(29, 161, 242, 0.1);
|
|
14
|
+
--at-color-main: #0083ff;
|
|
15
|
+
--at-color-red: #ff5652;
|
|
16
|
+
--at-color-pink: #fa5a57;
|
|
17
|
+
--at-color-yellow: #ff7c37;
|
|
18
|
+
--at-color-green: #4caf50;
|
|
19
|
+
--at-color-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255));
|
|
23
20
|
|
|
24
|
-
&.atk-dark-mode
|
|
21
|
+
&.atk-dark-mode {
|
|
25
22
|
--at-color-font: #fff;
|
|
26
23
|
--at-color-deep: #e7e7e7;
|
|
27
24
|
--at-color-sub: #e7e7e7;
|
|
@@ -39,7 +36,6 @@
|
|
|
39
36
|
--at-color-pink: #fa5a57;
|
|
40
37
|
--at-color-yellow: #ff7c37;
|
|
41
38
|
--at-color-green: #4caf50;
|
|
42
|
-
--at-color-quote: #687a86;
|
|
43
39
|
--at-color-gradient: linear-gradient(180deg, rgba(30, 34, 36, 0), rgba(30, 34, 36, 1));
|
|
44
40
|
}
|
|
45
41
|
}
|
package/src/style/_extend.less
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
|
|
70
70
|
.atk-item {
|
|
71
71
|
&:hover {
|
|
72
|
-
background:
|
|
72
|
+
background: var(--at-color-bg-grey);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
&:not(:last-child) {
|
|
@@ -91,10 +91,10 @@
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
.atk-icon {
|
|
94
|
-
background-color:
|
|
94
|
+
background-color: var(--at-color-meta);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
.atk-icon-yes {
|
|
98
|
-
background-color:
|
|
98
|
+
background-color: var(--at-color-main);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
@color-font: var(--at-color-font);
|
|
2
|
-
@color-deep: var(--at-color-deep);
|
|
3
|
-
@color-sub: var(--at-color-sub);
|
|
4
|
-
@color-grey: var(--at-color-grey);
|
|
5
|
-
@color-meta: var(--at-color-meta);
|
|
6
|
-
@color-light: var(--at-color-light);
|
|
7
|
-
@color-border: var(--at-color-border);
|
|
8
|
-
@color-bg: var(--at-color-bg);
|
|
9
|
-
@color-bg-transl: var(--at-color-bg-transl);
|
|
10
|
-
@color-bg-grey: var(--at-color-bg-grey);
|
|
11
|
-
@color-bg-grey-transl: var(--at-color-bg-grey-transl);
|
|
12
|
-
@color-bg-light: var(--at-color-bg-light);
|
|
13
|
-
@color-main: var(--at-color-main);
|
|
14
|
-
@color-red: var(--at-color-red);
|
|
15
|
-
@color-pink: var(--at-color-pink);
|
|
16
|
-
@color-yellow: var(--at-color-yellow);
|
|
17
|
-
@color-green: var(--at-color-green);
|
|
18
|
-
@color-quote: var(--at-color-quote);
|
|
19
|
-
@color-gradient: var(--at-color-gradient);
|
|
20
|
-
|
|
21
1
|
@font-family: "Helvetica Neue", "PingFangSC-Light", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
|
|
22
2
|
@font-size: 14px;
|
|
23
3
|
@line-height: 1.6em;
|
|
24
|
-
|
|
25
|
-
@block-margin: 15px;
|
|
26
|
-
@block-margin-mobile: 7px;
|
|
27
|
-
@block-padding: 10px;
|
|
28
4
|
@block-radius: 4px;
|