artalk 2.3.4 → 2.4.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 +3171 -3008
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +3124 -2980
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/src/api/admin.d.ts +10 -0
- package/dist/src/api/api-base.d.ts +14 -0
- package/dist/src/api/captcha.d.ts +14 -0
- package/dist/src/api/comment.d.ts +29 -0
- package/dist/src/api/index.d.ts +31 -0
- package/dist/src/api/page.d.ts +22 -0
- package/dist/src/api/request.d.ts +12 -0
- package/dist/src/api/site.d.ts +17 -0
- package/dist/src/api/system.d.ts +13 -0
- package/dist/src/api/upload.d.ts +11 -0
- package/dist/src/api/user.d.ts +28 -0
- package/dist/src/artalk.d.ts +56 -0
- package/dist/src/comment/actions.d.ts +17 -0
- package/dist/src/comment/comment.d.ts +67 -0
- package/dist/src/comment/index.d.ts +2 -0
- package/dist/src/comment/render.d.ts +76 -0
- package/dist/src/components/action-btn.d.ts +52 -0
- package/dist/src/components/dialog.d.ts +18 -0
- package/dist/src/components/pagination.d.ts +30 -0
- package/dist/src/components/read-more-btn.d.ts +33 -0
- package/dist/src/context.d.ts +72 -0
- package/dist/src/defaults.d.ts +3 -0
- package/dist/src/editor/editor.d.ts +84 -0
- package/dist/src/editor/index.d.ts +2 -0
- package/dist/src/editor/plugs/editor-plug.d.ts +26 -0
- package/dist/src/editor/plugs/emoticons-plug.d.ts +36 -0
- package/dist/src/editor/plugs/header-input-plug.d.ts +13 -0
- package/dist/src/editor/plugs/preview-plug.d.ts +10 -0
- package/dist/src/editor/plugs/upload-plug.d.ts +10 -0
- package/dist/src/i18n/en.d.ts +69 -0
- package/dist/src/i18n/index.d.ts +294 -0
- package/dist/src/i18n/zh-CN.d.ts +3 -0
- package/dist/src/layer/index.d.ts +3 -0
- package/dist/src/layer/layer.d.ts +32 -0
- package/dist/src/layer/sidebar-layer.d.ts +20 -0
- package/dist/src/lib/checker/admin-checker.d.ts +3 -0
- package/dist/src/lib/checker/captcha-checker.d.ts +3 -0
- package/dist/src/lib/checker/index.d.ts +42 -0
- package/dist/src/lib/component.d.ts +12 -0
- package/dist/src/lib/detect.d.ts +10 -0
- package/dist/src/lib/stat.d.ts +15 -0
- package/dist/src/lib/ui.d.ts +23 -0
- package/dist/src/lib/user.d.ts +13 -0
- package/dist/src/lib/utils.d.ts +39 -0
- package/dist/src/list/index.d.ts +2 -0
- package/dist/src/list/list-lite.d.ts +63 -0
- package/dist/src/list/list-nest.d.ts +10 -0
- package/dist/src/list/list.d.ts +26 -0
- package/dist/src/main.d.ts +4 -0
- package/dist/types/artalk-config.d.ts +132 -0
- package/dist/types/artalk-data.d.ts +204 -0
- package/dist/types/context.d.ts +146 -0
- package/dist/types/event.d.ts +28 -0
- package/dist/types/global.d.ts +0 -0
- package/dist/types/plug.d.ts +4 -0
- package/index.html +3 -3
- package/package.json +5 -5
- package/src/api/admin.ts +18 -0
- package/src/api/api-base.ts +27 -0
- package/src/api/captcha.ts +24 -0
- package/src/api/comment.ts +84 -0
- package/src/api/index.ts +25 -366
- package/src/api/page.ts +85 -0
- package/src/api/site.ts +51 -0
- package/src/api/system.ts +39 -0
- package/src/api/upload.ts +29 -0
- package/src/api/user.ts +75 -0
- package/src/artalk.ts +50 -46
- package/src/comment/actions.ts +3 -3
- package/src/comment/comment.ts +6 -9
- package/src/comment/render.ts +76 -40
- package/src/components/pagination.ts +0 -1
- package/src/context.ts +31 -31
- package/src/editor/editor.ts +2 -4
- package/src/editor/plugs/header-input-plug.ts +1 -1
- package/src/editor/plugs/upload-plug.ts +1 -1
- package/src/i18n/index.ts +117 -2
- package/src/layer/sidebar-layer.ts +1 -3
- package/src/lib/checker/admin-checker.ts +1 -1
- package/src/lib/checker/captcha-checker.ts +3 -3
- package/src/lib/stat.ts +2 -2
- package/src/lib/ui.ts +6 -0
- package/src/list/list-lite.ts +25 -25
- package/src/list/list.ts +3 -4
- package/src/main.ts +3 -0
- package/src/style/main.less +6 -0
- package/types/context.d.ts +4 -1
- package/types/global.d.ts +0 -2
- package/vite-base.config.ts +9 -5
- package/vite.config.ts +5 -1
- package/types/index.d.ts +0 -3
package/src/list/list-lite.ts
CHANGED
|
@@ -7,7 +7,7 @@ import Comment from '../comment'
|
|
|
7
7
|
import Pagination from '../components/pagination'
|
|
8
8
|
import ReadMoreBtn from '../components/read-more-btn'
|
|
9
9
|
import * as ListNest from './list-nest'
|
|
10
|
-
import { backendMinVersion } from '../../package.json'
|
|
10
|
+
import { backendMinVersion, version as ARTALK_VERSION } from '../../package.json'
|
|
11
11
|
|
|
12
12
|
export default class ListLite extends Component {
|
|
13
13
|
protected $commentsWrap: HTMLElement
|
|
@@ -78,40 +78,42 @@ export default class ListLite extends Component {
|
|
|
78
78
|
return this.$commentsWrap
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/** 加载动画 */
|
|
82
|
+
public setLoading(val: boolean, isFirstLoad: boolean = false) {
|
|
83
|
+
this.isLoading = val
|
|
84
|
+
if (isFirstLoad) Ui.setLoading(val, this.$el)
|
|
85
|
+
else if (this.pageMode === 'read-more') this.readMoreBtn!.setLoading(val)
|
|
86
|
+
else if (this.pageMode === 'pagination') this.pagination!.setLoading(val)
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
/** 评论获取 */
|
|
82
90
|
public async fetchComments(offset: number) {
|
|
83
91
|
if (this.isLoading) return
|
|
84
92
|
|
|
93
|
+
const isFirstLoad = (offset === 0)
|
|
94
|
+
const setLoading = (val: boolean) => this.setLoading(val, isFirstLoad)
|
|
95
|
+
|
|
85
96
|
// 加载动画
|
|
86
|
-
|
|
87
|
-
this.isLoading = true
|
|
88
|
-
if (offset === 0) Ui.showLoading(this.$el)
|
|
89
|
-
else if (this.pageMode === 'read-more') this.readMoreBtn!.setLoading(true)
|
|
90
|
-
else if (this.pageMode === 'pagination') this.pagination!.setLoading(true)
|
|
91
|
-
}
|
|
92
|
-
const hideLoading = () => {
|
|
93
|
-
this.isLoading = false
|
|
94
|
-
if (offset === 0) Ui.hideLoading(this.$el)
|
|
95
|
-
else if (this.pageMode === 'read-more') this.readMoreBtn!.setLoading(false)
|
|
96
|
-
else if (this.pageMode === 'pagination') this.pagination!.setLoading(false)
|
|
97
|
-
}
|
|
98
|
-
showLoading()
|
|
97
|
+
setLoading(true)
|
|
99
98
|
|
|
100
99
|
// 事件通知(开始加载评论)
|
|
101
100
|
this.ctx.trigger('list-load')
|
|
102
101
|
|
|
103
102
|
// 清空评论(加载按钮)
|
|
104
|
-
if (this.pageMode === 'read-more'
|
|
103
|
+
if (isFirstLoad && this.pageMode === 'read-more') {
|
|
104
|
+
this.ctx.clearAllComments()
|
|
105
|
+
}
|
|
105
106
|
|
|
106
107
|
// 请求评论数据
|
|
107
108
|
let listData: ListData
|
|
108
109
|
try {
|
|
109
|
-
listData = await this.ctx.getApi().
|
|
110
|
+
listData = await this.ctx.getApi().comment
|
|
111
|
+
.get(offset, this.pageSize, this.flatMode, this.paramsEditor)
|
|
110
112
|
} catch (e: any) {
|
|
111
113
|
this.onError(e.msg || String(e), offset, e.data)
|
|
112
114
|
throw e
|
|
113
115
|
} finally {
|
|
114
|
-
|
|
116
|
+
setLoading(false)
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
// 清除原有错误
|
|
@@ -124,7 +126,7 @@ export default class ListLite extends Component {
|
|
|
124
126
|
this.onError(String(e), offset)
|
|
125
127
|
throw e
|
|
126
128
|
} finally {
|
|
127
|
-
|
|
129
|
+
setLoading(false)
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
|
|
@@ -194,15 +196,13 @@ export default class ListLite extends Component {
|
|
|
194
196
|
const at = this.scrollListenerAt || document
|
|
195
197
|
if (this.autoLoadScrollEvent) at.removeEventListener('scroll', this.autoLoadScrollEvent) // 解除原有
|
|
196
198
|
this.autoLoadScrollEvent = () => {
|
|
197
|
-
if (this.pageMode !== 'read-more'
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (this.isLoading) return
|
|
199
|
+
if (this.pageMode !== 'read-more'
|
|
200
|
+
|| !this.readMoreBtn?.hasMore
|
|
201
|
+
|| this.isLoading
|
|
202
|
+
) return
|
|
202
203
|
|
|
203
204
|
const $target = this.$el.querySelector<HTMLElement>('.atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)') // 获取倒数第3个评论元素
|
|
204
|
-
if (
|
|
205
|
-
if (Ui.isVisible($target, this.scrollListenerAt)) {
|
|
205
|
+
if ($target && Ui.isVisible($target, this.scrollListenerAt)) {
|
|
206
206
|
this.readMoreBtn.click() // 自动点击加载更多按钮
|
|
207
207
|
}
|
|
208
208
|
}
|
package/src/list/list.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import '../style/list.less'
|
|
2
|
-
|
|
3
1
|
import { ListData, NotifyData } from '~/types/artalk-data'
|
|
4
2
|
import Context from '~/types/context'
|
|
3
|
+
import { version as ARTALK_VERSION } from '../../package.json'
|
|
5
4
|
import * as Utils from '../lib/utils'
|
|
6
5
|
import * as Ui from '../lib/ui'
|
|
7
6
|
import ListHTML from './list.html?raw'
|
|
@@ -143,7 +142,7 @@ export default class List extends ListLite {
|
|
|
143
142
|
// 已阅 API
|
|
144
143
|
const notifyKey = Utils.getQueryParam('atk_notify_key')
|
|
145
144
|
if (notifyKey) {
|
|
146
|
-
this.ctx.getApi().markRead(notifyKey)
|
|
145
|
+
this.ctx.getApi().user.markRead(notifyKey)
|
|
147
146
|
.then(() => {
|
|
148
147
|
this.unread = this.unread.filter(o => o.comment_id !== commentId)
|
|
149
148
|
this.updateUnread(this.unread)
|
|
@@ -175,7 +174,7 @@ export default class List extends ListLite {
|
|
|
175
174
|
if (!this.data || !this.data.page) return
|
|
176
175
|
|
|
177
176
|
this.ctx.editorShowLoading()
|
|
178
|
-
this.ctx.getApi().pageEdit(this.data.page)
|
|
177
|
+
this.ctx.getApi().page.pageEdit(this.data.page)
|
|
179
178
|
.then((page) => {
|
|
180
179
|
if (this.data)
|
|
181
180
|
this.data.page = { ...page }
|
package/src/main.ts
CHANGED
package/src/style/main.less
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
@import "./_color.less";
|
|
2
|
+
@import './comment.less';
|
|
3
|
+
@import './list.less';
|
|
4
|
+
@import './pagination.less';
|
|
5
|
+
@import './editor.less';
|
|
6
|
+
@import './sidebar-layer.less';
|
|
2
7
|
|
|
3
8
|
.artalk {
|
|
4
9
|
position: relative;
|
|
@@ -460,4 +465,5 @@ i.atk-icon {
|
|
|
460
465
|
|
|
461
466
|
img[atk-emoticon] {
|
|
462
467
|
max-height: 60px;
|
|
468
|
+
display: initial;
|
|
463
469
|
}
|
package/types/context.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export default interface ContextApi {
|
|
|
38
38
|
/* 设置持有的同事类 (中介者模式) */
|
|
39
39
|
setApi(api: Api): void
|
|
40
40
|
setEditor(editor: Editor): void
|
|
41
|
-
setList(list
|
|
41
|
+
setList(list?: ListLite): void
|
|
42
42
|
setSidebarLayer(list: SidebarLayer): void
|
|
43
43
|
setCheckerLauncher(checkerLauncher: CheckerLauncher): void
|
|
44
44
|
|
|
@@ -90,6 +90,9 @@ export default interface ContextApi {
|
|
|
90
90
|
/** 列表 - UI 更新 */
|
|
91
91
|
listRefreshUI(): void
|
|
92
92
|
|
|
93
|
+
/** 列表 - HashGoto 功能检测 */
|
|
94
|
+
listHashGotoCheck(): void
|
|
95
|
+
|
|
93
96
|
/** 显示侧边栏 */
|
|
94
97
|
showSidebar(payload?: SidebarShowPayload): void
|
|
95
98
|
|
package/types/global.d.ts
CHANGED
package/vite-base.config.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
2
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
3
|
-
import {
|
|
3
|
+
import { resolve } from 'path'
|
|
4
|
+
import dts from 'vite-plugin-dts'
|
|
4
5
|
|
|
5
6
|
export default defineConfig({
|
|
6
|
-
define: {
|
|
7
|
-
ARTALK_VERSION: JSON.stringify(version),
|
|
8
|
-
},
|
|
9
7
|
css: {
|
|
10
8
|
preprocessorOptions: {
|
|
11
9
|
less: {
|
|
@@ -13,5 +11,11 @@ export default defineConfig({
|
|
|
13
11
|
},
|
|
14
12
|
},
|
|
15
13
|
},
|
|
16
|
-
|
|
14
|
+
resolve: {
|
|
15
|
+
alias: {
|
|
16
|
+
'@': resolve(__dirname, 'src'),
|
|
17
|
+
'~': resolve(__dirname),
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
plugins: [tsconfigPaths(), dts()],
|
|
17
21
|
})
|
package/vite.config.ts
CHANGED
|
@@ -17,7 +17,11 @@ export default Utils.mergeDeep(baseConf, defineConfig({
|
|
|
17
17
|
},
|
|
18
18
|
rollupOptions: {
|
|
19
19
|
output: {
|
|
20
|
-
assetFileNames: (assetInfo) => (/\.css$/.test(assetInfo.name) ? "Artalk.css" : "[name].[ext]")
|
|
20
|
+
assetFileNames: (assetInfo) => (/\.css$/.test(assetInfo.name || '') ? "Artalk.css" : "[name].[ext]"),
|
|
21
|
+
|
|
22
|
+
// Entry module "src/main.ts" is using named and default exports together.
|
|
23
|
+
// Consumers of your bundle will have to use `Artalk["default"]` to access the default export
|
|
24
|
+
exports: 'named'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
package/types/index.d.ts
DELETED