artalk 2.7.0 → 2.7.2
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/README.md +1 -1
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +209 -188
- package/dist/Artalk.es.js.map +1 -0
- package/dist/Artalk.iife.js +2 -1
- package/dist/Artalk.iife.js.map +1 -0
- package/dist/Artalk.js +2 -1
- package/dist/Artalk.js.map +1 -0
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +209 -188
- package/dist/ArtalkLite.es.js.map +1 -0
- package/dist/ArtalkLite.iife.js +2 -1
- package/dist/ArtalkLite.iife.js.map +1 -0
- package/dist/ArtalkLite.js +2 -1
- package/dist/ArtalkLite.js.map +1 -0
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/src/api/_base.d.ts +7 -0
- package/dist/src/api/_options.d.ts +5 -0
- package/dist/src/artalk.d.ts +0 -2
- package/dist/src/components/checker/index.d.ts +2 -0
- package/dist/src/i18n/en.d.ts +4 -0
- package/dist/src/i18n/external.d.ts +4 -0
- package/dist/src/i18n/index.d.ts +12 -0
- package/dist/src/i18n/jp.d.ts +4 -0
- package/dist/src/i18n/zh-TW.d.ts +4 -0
- package/dist/src/lib/user.d.ts +8 -6
- package/dist/src/main.d.ts +3 -0
- package/dist/src/plugins/editor/_kit.d.ts +7 -1
- package/dist/src/service.d.ts +2 -8
- package/dist/types/event.d.ts +1 -1
- package/package.json +43 -17
- package/dist/src/components/dark-mode.d.ts +0 -2
- package/src/api/_base.ts +0 -18
- package/src/api/_options.ts +0 -25
- package/src/api/_request.ts +0 -104
- package/src/api/admin.ts +0 -18
- package/src/api/captcha.ts +0 -24
- package/src/api/comment.ts +0 -84
- package/src/api/index.ts +0 -29
- package/src/api/page.ts +0 -83
- package/src/api/site.ts +0 -51
- package/src/api/system.ts +0 -49
- package/src/api/upload.ts +0 -28
- package/src/api/user.ts +0 -132
- package/src/artalk.ts +0 -119
- package/src/comment/actions.ts +0 -83
- package/src/comment/comment.html +0 -18
- package/src/comment/comment.ts +0 -192
- package/src/comment/height-limit.ts +0 -100
- package/src/comment/index.ts +0 -3
- package/src/comment/render.ts +0 -150
- package/src/comment/renders/actions.ts +0 -114
- package/src/comment/renders/avatar.ts +0 -22
- package/src/comment/renders/content.ts +0 -39
- package/src/comment/renders/header.ts +0 -84
- package/src/comment/renders/index.ts +0 -19
- package/src/comment/renders/pending.ts +0 -12
- package/src/comment/renders/reply-at.ts +0 -16
- package/src/comment/renders/reply-to.ts +0 -24
- package/src/components/action-btn.ts +0 -170
- package/src/components/checker/admin.ts +0 -37
- package/src/components/checker/captcha-renders.ts +0 -69
- package/src/components/checker/captcha.ts +0 -26
- package/src/components/checker/index.ts +0 -192
- package/src/components/dark-mode.ts +0 -30
- package/src/components/dialog.ts +0 -62
- package/src/components/error-dialog.ts +0 -35
- package/src/components/pagination.ts +0 -153
- package/src/components/read-more-btn.ts +0 -92
- package/src/config.ts +0 -119
- package/src/context.ts +0 -146
- package/src/data.ts +0 -110
- package/src/defaults.ts +0 -61
- package/src/editor/editor.html +0 -18
- package/src/editor/editor.ts +0 -114
- package/src/editor/state.ts +0 -52
- package/src/editor/ui.ts +0 -36
- package/src/i18n/en.ts +0 -81
- package/src/i18n/external.ts +0 -10
- package/src/i18n/index.ts +0 -67
- package/src/i18n/jp.ts +0 -83
- package/src/i18n/zh-CN.ts +0 -85
- package/src/i18n/zh-TW.ts +0 -83
- package/src/layer/index.ts +0 -4
- package/src/layer/layer-manager.ts +0 -32
- package/src/layer/layer.ts +0 -39
- package/src/layer/scrollbar-helper.ts +0 -24
- package/src/layer/sidebar-layer.html +0 -8
- package/src/layer/sidebar-layer.ts +0 -155
- package/src/layer/wrap.ts +0 -77
- package/src/lib/component.ts +0 -12
- package/src/lib/detect.ts +0 -222
- package/src/lib/event-manager.ts +0 -47
- package/src/lib/highlight.ts +0 -5
- package/src/lib/marked-renderer.ts +0 -32
- package/src/lib/marked.ts +0 -72
- package/src/lib/sanitizer.ts +0 -57
- package/src/lib/ui.ts +0 -193
- package/src/lib/user.ts +0 -55
- package/src/lib/utils.ts +0 -236
- package/src/list/comment.ts +0 -20
- package/src/list/layout.ts +0 -120
- package/src/list/list.html +0 -20
- package/src/list/list.ts +0 -79
- package/src/list/nest.ts +0 -66
- package/src/list/page.ts +0 -97
- package/src/list/paginator/index.ts +0 -25
- package/src/list/paginator/read-more.ts +0 -67
- package/src/list/paginator/up-down.ts +0 -51
- package/src/main.ts +0 -5
- package/src/plugins/admin-only-elem.ts +0 -40
- package/src/plugins/conf-remoter.ts +0 -54
- package/src/plugins/dark-mode.ts +0 -12
- package/src/plugins/editor/_kit.ts +0 -57
- package/src/plugins/editor/_plug.ts +0 -60
- package/src/plugins/editor/_sample.ts +0 -8
- package/src/plugins/editor/closable.ts +0 -44
- package/src/plugins/editor/emoticons.scss +0 -72
- package/src/plugins/editor/emoticons.ts +0 -293
- package/src/plugins/editor/header-event.ts +0 -35
- package/src/plugins/editor/header-link.ts +0 -31
- package/src/plugins/editor/header-user.ts +0 -98
- package/src/plugins/editor/index.ts +0 -40
- package/src/plugins/editor/local-storage.ts +0 -36
- package/src/plugins/editor/mover.ts +0 -29
- package/src/plugins/editor/preview.scss +0 -7
- package/src/plugins/editor/preview.ts +0 -41
- package/src/plugins/editor/state-edit.ts +0 -116
- package/src/plugins/editor/state-reply.ts +0 -91
- package/src/plugins/editor/submit-add.ts +0 -33
- package/src/plugins/editor/submit-btn.ts +0 -25
- package/src/plugins/editor/submit.ts +0 -73
- package/src/plugins/editor/textarea.ts +0 -55
- package/src/plugins/editor/upload.ts +0 -145
- package/src/plugins/editor-kit.ts +0 -161
- package/src/plugins/index.ts +0 -16
- package/src/plugins/list/copyright.ts +0 -16
- package/src/plugins/list/count.ts +0 -31
- package/src/plugins/list/dropdown.ts +0 -95
- package/src/plugins/list/error-dialog.ts +0 -22
- package/src/plugins/list/fetch.ts +0 -64
- package/src/plugins/list/goto-first.ts +0 -23
- package/src/plugins/list/goto.ts +0 -72
- package/src/plugins/list/index.ts +0 -25
- package/src/plugins/list/loading.ts +0 -17
- package/src/plugins/list/no-comment.ts +0 -25
- package/src/plugins/list/reach-bottom.ts +0 -46
- package/src/plugins/list/sidebar-btn.ts +0 -39
- package/src/plugins/list/time-ticking.ts +0 -22
- package/src/plugins/list/unread-badge.ts +0 -26
- package/src/plugins/list/unread.ts +0 -38
- package/src/plugins/list/with-editor.ts +0 -59
- package/src/plugins/markdown.ts +0 -10
- package/src/plugins/stat.ts +0 -79
- package/src/plugins/version-check.ts +0 -37
- package/src/service.ts +0 -91
- package/src/style/_color.scss +0 -41
- package/src/style/_extend.scss +0 -20
- package/src/style/_variables.scss +0 -3
- package/src/style/comment.scss +0 -360
- package/src/style/editor.scss +0 -194
- package/src/style/list.scss +0 -212
- package/src/style/main.scss +0 -486
- package/src/style/pagination.scss +0 -58
- package/src/style/sidebar-layer.scss +0 -92
- package/types/config.ts +0 -153
- package/types/context.ts +0 -84
- package/types/data.ts +0 -271
- package/types/editor.ts +0 -95
- package/types/event.ts +0 -40
- package/types/global.d.ts +0 -1
- package/types/index.ts +0 -7
- package/types/plugin.ts +0 -3
- package/types/sidebar.ts +0 -3
package/src/api/page.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { PageData, CommentData } from '~/types'
|
|
2
|
-
import ApiBase from './_base'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 页面 API
|
|
6
|
-
*/
|
|
7
|
-
export default class PageApi extends ApiBase {
|
|
8
|
-
/** 页面 · 获取 */
|
|
9
|
-
public async pageGet(siteName?: string, offset?: number, limit?: number) {
|
|
10
|
-
const params: any = {
|
|
11
|
-
site_name: siteName || '',
|
|
12
|
-
offset: offset || 0,
|
|
13
|
-
limit: limit || 15,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const d = await this.POST<any>('/admin/page-get', params)
|
|
17
|
-
return (d as { pages: PageData[], total: number })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** 页面 · 修改 */
|
|
21
|
-
public async pageEdit(data: PageData) {
|
|
22
|
-
const params: any = {
|
|
23
|
-
id: data.id,
|
|
24
|
-
key: data.key,
|
|
25
|
-
title: data.title,
|
|
26
|
-
admin_only: data.admin_only,
|
|
27
|
-
site_name: data.site_name || this.options.siteName,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const d = await this.POST<any>('/admin/page-edit', params)
|
|
31
|
-
return (d.page as PageData)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** 页面 · 删除 */
|
|
35
|
-
public pageDel(pageKey: string, siteName?: string) {
|
|
36
|
-
const params: any = {
|
|
37
|
-
key: String(pageKey),
|
|
38
|
-
site_name: siteName || '',
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return this.POST('/admin/page-del', params)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** 页面 · 数据更新 */
|
|
45
|
-
public async pageFetch(id?: number, siteName?: string, getStatus?: boolean) {
|
|
46
|
-
const params: any = {}
|
|
47
|
-
if (id) params.id = id
|
|
48
|
-
if (siteName) params.site_name = siteName
|
|
49
|
-
if (getStatus) params.get_status = getStatus
|
|
50
|
-
|
|
51
|
-
const d = await this.POST<any>('/admin/page-fetch', params)
|
|
52
|
-
return (d as any)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** PV */
|
|
56
|
-
public async pv() {
|
|
57
|
-
const params: any = {
|
|
58
|
-
page_key: this.options.pageKey || '',
|
|
59
|
-
page_title: this.options.pageTitle || ''
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const p = await this.POST<any>('/pv', params)
|
|
63
|
-
return p.pv as number
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** 统计 */
|
|
67
|
-
public async stat(
|
|
68
|
-
type: 'latest_comments'|'latest_pages'|'pv_most_pages'|'comment_most_pages'|
|
|
69
|
-
'page_pv'|'site_pv'|'page_comment'|'site_comment',
|
|
70
|
-
pageKeys?: string|string[],
|
|
71
|
-
limit?: number
|
|
72
|
-
) {
|
|
73
|
-
const params: any = {
|
|
74
|
-
type,
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (pageKeys) params.page_keys = Array.isArray(pageKeys) ? pageKeys.join(',') : pageKeys
|
|
78
|
-
if (limit) params.limit = limit
|
|
79
|
-
|
|
80
|
-
const data = await this.POST<PageData[]|CommentData[]|object|number>(`/stat`, params)
|
|
81
|
-
return data
|
|
82
|
-
}
|
|
83
|
-
}
|
package/src/api/site.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { SiteData } from '~/types'
|
|
2
|
-
import ApiBase from './_base'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 站点 API
|
|
6
|
-
*/
|
|
7
|
-
export default class SiteApi extends ApiBase {
|
|
8
|
-
/** 站点 · 获取 */
|
|
9
|
-
public async siteGet() {
|
|
10
|
-
const params: any = {}
|
|
11
|
-
|
|
12
|
-
const d = await this.POST<any>('/admin/site-get', params)
|
|
13
|
-
return (d.sites as SiteData[])
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** 站点 · 创建 */
|
|
17
|
-
public async siteAdd(name: string, urls: string) {
|
|
18
|
-
const params: any = {
|
|
19
|
-
name, urls,
|
|
20
|
-
site_name: '' // 全局保留字段,当前站点名
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const d = await this.POST<any>('/admin/site-add', params)
|
|
24
|
-
return (d.site as SiteData)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** 站点 · 修改 */
|
|
28
|
-
public async siteEdit(data: SiteData) {
|
|
29
|
-
const params: any = {
|
|
30
|
-
id: data.id,
|
|
31
|
-
name: data.name || '',
|
|
32
|
-
urls: data.urls || '',
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const d = await this.POST<any>('/admin/site-edit', params)
|
|
36
|
-
return (d.site as SiteData)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** 站点 · 删除 */
|
|
40
|
-
public siteDel(id: number, delContent = false) {
|
|
41
|
-
const params: any = { id, del_content: delContent }
|
|
42
|
-
|
|
43
|
-
return this.POST('/admin/site-del', params)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** 导出 */
|
|
47
|
-
public async export() {
|
|
48
|
-
const d = await this.Fetch(`/admin/export`, { method: 'POST' }, 0)
|
|
49
|
-
return (d.data?.data || '' as string)
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/api/system.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ArtalkConfig } from '~/types'
|
|
2
|
-
import ApiBase from './_base'
|
|
3
|
-
|
|
4
|
-
interface ApiVersionInfo {
|
|
5
|
-
app: string
|
|
6
|
-
version: string
|
|
7
|
-
commit_hash: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface SystemConfResp {
|
|
11
|
-
frontend_conf: Partial<ArtalkConfig>
|
|
12
|
-
version: ApiVersionInfo
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 系统 API
|
|
17
|
-
*/
|
|
18
|
-
export default class SystemApi extends ApiBase {
|
|
19
|
-
/** 获取配置 */
|
|
20
|
-
public async conf(): Promise<SystemConfResp> {
|
|
21
|
-
const data = await this.POST<any>(`/conf`)
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
frontend_conf: data.frontend_conf,
|
|
25
|
-
version: data.version,
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** 获取配置数据 */
|
|
30
|
-
public async getSettings() {
|
|
31
|
-
const data = await this.POST<{custom: string, template: string}>('/admin/setting-get')
|
|
32
|
-
return data
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** 保存配置数据 */
|
|
36
|
-
public async saveSettings(yamlStr: string) {
|
|
37
|
-
const data = await this.POST<boolean>('/admin/setting-save', {
|
|
38
|
-
data: yamlStr,
|
|
39
|
-
})
|
|
40
|
-
return data
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** 获取 API 版本信息 */
|
|
44
|
-
public async version() {
|
|
45
|
-
const resp = await fetch(`${this.options.baseURL}/version`, { method: 'POST' })
|
|
46
|
-
const data = await resp.json()
|
|
47
|
-
return data as { app: string, version: string, commit_hash: string, fe_min_version: string }
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/api/upload.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ToFormData } from './_request'
|
|
2
|
-
import ApiBase from './_base'
|
|
3
|
-
import User from '../lib/user'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 上传 API
|
|
7
|
-
*/
|
|
8
|
-
export default class UploadApi extends ApiBase {
|
|
9
|
-
/** 图片上传 */
|
|
10
|
-
public async imgUpload(file: File) {
|
|
11
|
-
const params: any = {
|
|
12
|
-
name: User.data.nick,
|
|
13
|
-
email: User.data.email,
|
|
14
|
-
page_key: this.options.pageKey,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const form = ToFormData(params)
|
|
18
|
-
form.set('file', file)
|
|
19
|
-
|
|
20
|
-
const init: RequestInit = {
|
|
21
|
-
method: 'POST',
|
|
22
|
-
body: form
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const json = await this.Fetch('/img-upload', init)
|
|
26
|
-
return ((json.data || {}) as any) as { img_file: string, img_url: string }
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/api/user.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { UserData, NotifyData, UserDataForAdmin } from '~/types'
|
|
2
|
-
import ApiBase from './_base'
|
|
3
|
-
import { ToFormData } from './_request'
|
|
4
|
-
import User from '../lib/user'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 用户 API
|
|
8
|
-
*/
|
|
9
|
-
export default class UserApi extends ApiBase {
|
|
10
|
-
/** 用户 · 登录 */
|
|
11
|
-
public async login(name: string, email: string, password: string) {
|
|
12
|
-
const params: any = {
|
|
13
|
-
name, email, password
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const data = await this.POST<any>('/login', params)
|
|
17
|
-
return data as { token: string, user: UserData }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** 用户 · 获取 */
|
|
21
|
-
public userGet(name: string, email: string) {
|
|
22
|
-
const ctrl = new AbortController()
|
|
23
|
-
const params: any = {
|
|
24
|
-
name, email
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const req = this.Fetch(`/user-get`, {
|
|
28
|
-
method: 'POST',
|
|
29
|
-
body: ToFormData(params),
|
|
30
|
-
signal: ctrl.signal,
|
|
31
|
-
}).then((json) => ({
|
|
32
|
-
user: json.data.user as UserData|null,
|
|
33
|
-
is_login: json.data.is_login as boolean,
|
|
34
|
-
unread: (json.data.unread || []) as NotifyData[],
|
|
35
|
-
unread_count: json.data.unread_count || 0,
|
|
36
|
-
}))
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
req,
|
|
40
|
-
abort: () => { ctrl.abort() },
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** 用户 · 登录状态 */
|
|
45
|
-
public async loginStatus() {
|
|
46
|
-
const data = await this.POST<any>('/login-status', {
|
|
47
|
-
name: User.data.nick,
|
|
48
|
-
email: User.data.email
|
|
49
|
-
})
|
|
50
|
-
return (data || { is_login: false, is_admin: false }) as { is_login: boolean, is_admin: boolean }
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** 用户 · 注销 */
|
|
54
|
-
public async logout() {
|
|
55
|
-
return this.POST('/logout')
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** 已读标记 */
|
|
59
|
-
public markRead(commentID: number, notifyKey: string, readAll = false) {
|
|
60
|
-
const params: any = {
|
|
61
|
-
comment_id: commentID,
|
|
62
|
-
notify_key: notifyKey,
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (readAll) {
|
|
66
|
-
delete params.comment_id
|
|
67
|
-
delete params.notify_key
|
|
68
|
-
params.read_all = true
|
|
69
|
-
params.name = User.data.nick
|
|
70
|
-
params.email = User.data.email
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return this.POST(`/mark-read`, params)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** 用户 · 列表 */
|
|
77
|
-
public async userList(offset?: number, limit?: number, type?: 'all'|'admin'|'in_conf') {
|
|
78
|
-
const params: any = {
|
|
79
|
-
offset: offset || 0,
|
|
80
|
-
limit: limit || 15,
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (type) params.type = type
|
|
84
|
-
|
|
85
|
-
const d = await this.POST<any>('/admin/user-get', params)
|
|
86
|
-
return (d as { users: UserDataForAdmin[], total: number })
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** 用户 · 新增 */
|
|
90
|
-
public async userAdd(user: Partial<UserDataForAdmin>, password?: string) {
|
|
91
|
-
const params: any = {
|
|
92
|
-
name: user.name || '',
|
|
93
|
-
email: user.email || '',
|
|
94
|
-
password: password || '',
|
|
95
|
-
link: user.link || '',
|
|
96
|
-
is_admin: user.is_admin || false,
|
|
97
|
-
site_names: user.site_names_raw || '',
|
|
98
|
-
receive_email: user.receive_email || true,
|
|
99
|
-
badge_name: user.badge_name || '',
|
|
100
|
-
badge_color: user.badge_color || '',
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const d = await this.POST<any>('/admin/user-add', params)
|
|
104
|
-
return (d.user as UserDataForAdmin)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** 用户 · 修改 */
|
|
108
|
-
public async userEdit(user: Partial<UserDataForAdmin>, password?: string) {
|
|
109
|
-
const params: any = {
|
|
110
|
-
id: user.id,
|
|
111
|
-
name: user.name || '',
|
|
112
|
-
email: user.email || '',
|
|
113
|
-
password: password || '',
|
|
114
|
-
link: user.link || '',
|
|
115
|
-
is_admin: user.is_admin || false,
|
|
116
|
-
site_names: user.site_names_raw || '',
|
|
117
|
-
receive_email: user.receive_email || true,
|
|
118
|
-
badge_name: user.badge_name || '',
|
|
119
|
-
badge_color: user.badge_color || '',
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const d = await this.POST<any>('/admin/user-edit', params)
|
|
123
|
-
return (d.user as UserDataForAdmin)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** 用户 · 删除 */
|
|
127
|
-
public userDel(userID: number) {
|
|
128
|
-
return this.POST('/admin/user-del', {
|
|
129
|
-
id: String(userID)
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
}
|
package/src/artalk.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import './style/main.scss'
|
|
2
|
-
|
|
3
|
-
import type { ArtalkConfig, EventPayloadMap, ArtalkPlugin, ContextApi } from '~/types'
|
|
4
|
-
import type { EventHandler } from './lib/event-manager'
|
|
5
|
-
import ConcreteContext from './context'
|
|
6
|
-
import defaults from './defaults'
|
|
7
|
-
import { handelCustomConf, convertApiOptions } from './config'
|
|
8
|
-
import Services from './service'
|
|
9
|
-
import { DefaultPlugins } from './plugins'
|
|
10
|
-
import * as Stat from './plugins/stat'
|
|
11
|
-
import Api from './api'
|
|
12
|
-
|
|
13
|
-
/** Global Plugins for all instances */
|
|
14
|
-
const GlobalPlugins: ArtalkPlugin[] = [ ...DefaultPlugins ]
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Artalk
|
|
18
|
-
*
|
|
19
|
-
* @see https://artalk.js.org
|
|
20
|
-
*/
|
|
21
|
-
export default class Artalk {
|
|
22
|
-
public conf!: ArtalkConfig
|
|
23
|
-
public ctx!: ContextApi
|
|
24
|
-
public $root!: HTMLElement
|
|
25
|
-
|
|
26
|
-
/** Plugins */
|
|
27
|
-
protected plugins: ArtalkPlugin[] = [ ...GlobalPlugins ]
|
|
28
|
-
|
|
29
|
-
constructor(conf: Partial<ArtalkConfig>) {
|
|
30
|
-
// Init Config
|
|
31
|
-
this.conf = handelCustomConf(conf)
|
|
32
|
-
if (this.conf.el instanceof HTMLElement) this.$root = this.conf.el
|
|
33
|
-
|
|
34
|
-
// Init Context
|
|
35
|
-
this.ctx = new ConcreteContext(this.conf, this.$root)
|
|
36
|
-
|
|
37
|
-
// Init Services
|
|
38
|
-
Object.entries(Services).forEach(([name, initService]) => {
|
|
39
|
-
const obj = initService(this.ctx)
|
|
40
|
-
if (obj) this.ctx.inject(name as any, obj) // auto inject deps to ctx
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// Init Plugins
|
|
44
|
-
this.plugins.forEach(plugin => {
|
|
45
|
-
if (typeof plugin === 'function') plugin(this.ctx)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
// Trigger inited event
|
|
49
|
-
this.ctx.trigger('inited')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Update config of Artalk */
|
|
53
|
-
public update(conf: Partial<ArtalkConfig>) {
|
|
54
|
-
this.ctx.updateConf(conf)
|
|
55
|
-
return this
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Reload comment list of Artalk */
|
|
59
|
-
public reload() {
|
|
60
|
-
this.ctx.reload()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** Destroy instance of Artalk */
|
|
64
|
-
public destroy() {
|
|
65
|
-
this.ctx.trigger('destroy')
|
|
66
|
-
this.$root.remove()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Add an event listener */
|
|
70
|
-
public on<K extends keyof EventPayloadMap>(name: K, handler: EventHandler<EventPayloadMap[K]>) {
|
|
71
|
-
this.ctx.on(name, handler)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Remove an event listener */
|
|
75
|
-
public off<K extends keyof EventPayloadMap>(name: K, handler: EventHandler<EventPayloadMap[K]>) {
|
|
76
|
-
this.ctx.off(name, handler)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Trigger an event */
|
|
80
|
-
public trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K]) {
|
|
81
|
-
this.ctx.trigger(name, payload)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Set dark mode */
|
|
85
|
-
public setDarkMode(darkMode: boolean) {
|
|
86
|
-
this.ctx.setDarkMode(darkMode)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ===========================
|
|
90
|
-
// Static Members
|
|
91
|
-
// ===========================
|
|
92
|
-
|
|
93
|
-
/** Default Configs */
|
|
94
|
-
public static readonly defaults: ArtalkConfig = defaults
|
|
95
|
-
|
|
96
|
-
/** Init Artalk */
|
|
97
|
-
public static init(conf: Partial<ArtalkConfig>): Artalk {
|
|
98
|
-
return new Artalk(conf)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Use plugin, the plugin will be used when Artalk.init */
|
|
102
|
-
public static use(plugin: ArtalkPlugin) {
|
|
103
|
-
if (GlobalPlugins.includes(plugin)) return
|
|
104
|
-
GlobalPlugins.push(plugin)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Load count widget */
|
|
108
|
-
public static loadCountWidget(c: Partial<ArtalkConfig>) {
|
|
109
|
-
const conf = handelCustomConf(c)
|
|
110
|
-
|
|
111
|
-
Stat.initCountWidget({
|
|
112
|
-
getApi: () => new Api(convertApiOptions(conf)),
|
|
113
|
-
pageKey: conf.pageKey,
|
|
114
|
-
countEl: conf.countEl,
|
|
115
|
-
pvEl: conf.pvEl,
|
|
116
|
-
pvAdd: false
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/comment/actions.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type Comment from './comment'
|
|
2
|
-
import ActionBtn from '../components/action-btn'
|
|
3
|
-
|
|
4
|
-
export default class CommentActions {
|
|
5
|
-
private comment: Comment
|
|
6
|
-
|
|
7
|
-
private get ctx() { return this.comment.ctx }
|
|
8
|
-
private get data() { return this.comment.getData() }
|
|
9
|
-
private get cConf() { return this.comment.getConf() }
|
|
10
|
-
|
|
11
|
-
public constructor(comment: Comment) {
|
|
12
|
-
this.comment = comment
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** 投票操作 */
|
|
16
|
-
public vote(type: 'up'|'down') {
|
|
17
|
-
const actionBtn = (type === 'up') ? this.comment.getRender().voteBtnUp : this.comment.getRender().voteBtnDown
|
|
18
|
-
|
|
19
|
-
this.ctx.getApi().comment.vote(this.data.id, `comment_${type}`)
|
|
20
|
-
.then((v) => {
|
|
21
|
-
this.data.vote_up = v.up
|
|
22
|
-
this.data.vote_down = v.down
|
|
23
|
-
this.comment.getRender().voteBtnUp?.updateText()
|
|
24
|
-
this.comment.getRender().voteBtnDown?.updateText()
|
|
25
|
-
})
|
|
26
|
-
.catch((err) => {
|
|
27
|
-
actionBtn?.setError(this.ctx.$t('voteFail'))
|
|
28
|
-
console.log(err)
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** 管理员 - 评论状态修改 */
|
|
33
|
-
public adminEdit(type: 'collapsed'|'pending'|'pinned', btnElem: ActionBtn) {
|
|
34
|
-
if (btnElem.isLoading) return // 若正在修改中
|
|
35
|
-
|
|
36
|
-
btnElem.setLoading(true, `${this.ctx.$t('editing')}...`)
|
|
37
|
-
|
|
38
|
-
// 克隆并修改当前数据
|
|
39
|
-
const modify = { ...this.data }
|
|
40
|
-
if (type === 'collapsed') {
|
|
41
|
-
modify.is_collapsed = !modify.is_collapsed
|
|
42
|
-
} else if (type === 'pending') {
|
|
43
|
-
modify.is_pending = !modify.is_pending
|
|
44
|
-
} else if (type === 'pinned') {
|
|
45
|
-
modify.is_pinned = !modify.is_pinned
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.ctx.getApi().comment.commentEdit(modify).then((data) => {
|
|
49
|
-
btnElem.setLoading(false)
|
|
50
|
-
|
|
51
|
-
// 刷新当前 Comment UI
|
|
52
|
-
this.comment.setData(data)
|
|
53
|
-
}).catch((err) => {
|
|
54
|
-
console.error(err)
|
|
55
|
-
btnElem.setError(this.ctx.$t('editFail'))
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 管理员 - 评论删除 */
|
|
60
|
-
public adminDelete(btnElem: ActionBtn) {
|
|
61
|
-
if (btnElem.isLoading) return // 若正在删除中
|
|
62
|
-
|
|
63
|
-
btnElem.setLoading(true, `${this.ctx.$t('deleting')}...`)
|
|
64
|
-
this.ctx.getApi().comment.commentDel(this.data.id, this.data.site_name)
|
|
65
|
-
.then(() => {
|
|
66
|
-
btnElem.setLoading(false)
|
|
67
|
-
if (this.cConf.onDelete) this.cConf.onDelete(this.comment)
|
|
68
|
-
})
|
|
69
|
-
.catch((e) => {
|
|
70
|
-
console.error(e)
|
|
71
|
-
btnElem.setError(this.ctx.$t('deleteFail'))
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** 快速跳转到该评论 */
|
|
76
|
-
public goToReplyComment() {
|
|
77
|
-
const origHash = window.location.hash
|
|
78
|
-
const modifyHash = `#atk-comment-${this.data.rid}`
|
|
79
|
-
|
|
80
|
-
window.location.hash = modifyHash
|
|
81
|
-
if (modifyHash === origHash) window.dispatchEvent(new Event('hashchange')) // 强制触发事件
|
|
82
|
-
}
|
|
83
|
-
}
|
package/src/comment/comment.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<div class="atk-comment-wrap">
|
|
2
|
-
<div class="atk-comment">
|
|
3
|
-
<div class="atk-avatar"></div>
|
|
4
|
-
<div class="atk-main">
|
|
5
|
-
<div class="atk-header">
|
|
6
|
-
<span class="atk-item atk-nick"></span>
|
|
7
|
-
<span class="atk-badge-wrap"></span>
|
|
8
|
-
<span class="atk-item atk-date"></span>
|
|
9
|
-
</div>
|
|
10
|
-
<div class="atk-body">
|
|
11
|
-
<div class="atk-content"></div>
|
|
12
|
-
</div>
|
|
13
|
-
<div class="atk-footer">
|
|
14
|
-
<div class="atk-actions"></div>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|