artalk 2.2.9 → 2.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artalk",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "backendMinVersion": "2.1.4",
5
5
  "license": "LGPL-3.0",
6
6
  "description": "A Selfhosted Comment System",
package/src/artalk.ts CHANGED
@@ -47,6 +47,11 @@ export default class Artalk {
47
47
  this.conf.pageTitle = `${document.title}`
48
48
  }
49
49
 
50
+ // 列表显示模式
51
+ if (this.conf.nestMax && this.conf.nestMax <= 1) {
52
+ this.conf.flatMode = true
53
+ }
54
+
50
55
  // 装载元素
51
56
  if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
52
57
  this.$root = this.conf.el
@@ -16,6 +16,7 @@ export default class Comment extends Component {
16
16
  public $main!: HTMLElement
17
17
  public $header!: HTMLElement
18
18
  public $headerNick!: HTMLElement
19
+ public $headerBadge?: HTMLElement
19
20
  public $body!: HTMLElement
20
21
  public $content!: HTMLElement
21
22
  public $children!: HTMLElement|null
@@ -132,13 +133,14 @@ export default class Comment extends Component {
132
133
  this.$headerNick.innerText = this.data.nick
133
134
  }
134
135
 
135
- const $badge = this.$el.querySelector<HTMLElement>('.atk-badge')!
136
+ this.$headerBadge = this.$el.querySelector<HTMLElement>('.atk-badge')!
136
137
  if (this.data.badge_name) {
137
- $badge.innerText = this.data.badge_name
138
+ this.$headerBadge.innerText = this.data.badge_name
138
139
  if (this.data.badge_color)
139
- $badge.style.backgroundColor = this.data.badge_color
140
+ this.$headerBadge.style.backgroundColor = this.data.badge_color
140
141
  } else {
141
- $badge.remove()
142
+ this.$headerBadge.remove()
143
+ this.$headerBadge = undefined
142
144
  }
143
145
 
144
146
  if (this.data.is_pinned) {
@@ -204,7 +206,8 @@ export default class Comment extends Component {
204
206
  this.$replyAt.querySelector<HTMLElement>('.atk-nick')!.innerText = `${this.replyTo.nick}`
205
207
  this.$replyAt.onclick = () => { this.goToReplyComment() }
206
208
 
207
- this.$headerNick.insertAdjacentElement('afterend', this.$replyAt)
209
+ const $after = this.$headerBadge || this.$headerNick
210
+ $after.insertAdjacentElement('afterend', this.$replyAt)
208
211
  }
209
212
 
210
213
  // 回复的对象
package/src/defaults.ts CHANGED
@@ -20,7 +20,7 @@ const defaults: ArtalkConfig = {
20
20
  listSort: true,
21
21
  pvEl: '#ArtalkPV',
22
22
  flatMode: 'auto',
23
- nestMax: 3,
23
+ nestMax: 2,
24
24
 
25
25
  gravatar: {
26
26
  default: 'mp',