artalk 2.2.5 → 2.2.8
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 +96 -21
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/index.html +11 -9
- package/package.json +2 -2
- package/src/api/index.ts +34 -2
- package/src/artalk.ts +57 -21
- package/src/components/comment.ts +1 -1
- package/src/components/editor-plugs/emoticons-plug.ts +2 -2
- package/src/components/editor-plugs/preview-plug.ts +1 -1
- package/src/components/editor.ts +1 -1
- package/src/components/list-lite.ts +4 -1
- package/src/components/list.ts +1 -1
- package/src/components/pagination.ts +1 -1
- package/src/components/sidebar-layer.ts +3 -3
- package/src/context.ts +1 -1
- package/src/defaults.ts +1 -0
- package/src/lib/checker/captcha-checker.ts +1 -1
- package/src/lib/checker/index.ts +1 -1
- package/src/lib/utils.ts +31 -1
- package/src/style/_color.less +2 -2
- package/types/artalk-config.d.ts +4 -1
package/index.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<title>Artalk DEMO</title>
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
.title > a:hover { margin-left:0 }
|
|
17
17
|
.title > a > span { opacity:0 }
|
|
18
18
|
.title > a:hover>span { opacity:1 }
|
|
19
|
-
.desc { font-size:12px;color:#
|
|
19
|
+
.desc { font-size:12px;color:#697182 }
|
|
20
|
+
body.dark-mode .desc { color:#848da3 }
|
|
20
21
|
.social { margin-top:20px }
|
|
21
22
|
.social > a:not(:last-child) { margin-right:2px }
|
|
22
23
|
@media only screen and (max-width: 768px) {
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
}
|
|
27
28
|
.float-btn { user-select: none;bottom: 25px;display: block;cursor: pointer;text-align: center;width: 60px;height: 37px;line-height: 37px;font-size: 13px;color: #757e91;background: #fff;opacity: 0.8;border-radius: 4px;border: 1px solid #eceff2;position: fixed; }
|
|
28
29
|
.to-night { z-index: 99999;left: 25px;background: #1e2223;color: #fff; }
|
|
29
|
-
body.dark-mode .to-night { background: #
|
|
30
|
+
body.dark-mode .to-night { background: #006fd9;border: 1px solid #2d3235;color: #fff; }
|
|
30
31
|
.to-top { right: 25px; }
|
|
31
32
|
</style>
|
|
32
33
|
<!--<link rel="stylesheet"
|
|
@@ -45,11 +46,11 @@
|
|
|
45
46
|
<div class="title"><a href="https://github.com/ArtalkJS/Artalk" target="_blank"><span>『 </span>Artalk<span> 』</span></a></div>
|
|
46
47
|
<div class="desc">一款简洁的自托管评论系统 <span id="ArtalkPV"></span></div>
|
|
47
48
|
<div class="social">
|
|
48
|
-
<a href="https://www.npmjs.com/package/artalk" target="_blank"><img src="https://img.shields.io/npm/v/artalk.svg?style=flat-square"></a>
|
|
49
|
-
<a href="https://www.npmjs.com/package/artalk" target="_blank"><img src="https://img.shields.io/npm/dt/artalk.svg?style=flat-square"></a>
|
|
50
|
-
<a href="https://github.com/ArtalkJS/Artalk/commits/master" target="_blank"><img src="https://img.shields.io/github/last-commit/ArtalkJS/Artalk?style=flat-square"></a>
|
|
51
|
-
<a href="https://github.com/ArtalkJS/Artalk/blob/master/LICENSE" target="_blank"><img src="https://img.shields.io/github/license/ArtalkJS/Artalk.svg?style=flat-square"></a>
|
|
52
|
-
<a href="https://github.com/ArtalkJS/Artalk" target="_blank"><img src="https://img.shields.io/github/stars/ArtalkJS/Artalk?style=flat-square"></a>
|
|
49
|
+
<a href="https://www.npmjs.com/package/artalk" aria-label="npm package version" target="_blank"><img src="https://img.shields.io/npm/v/artalk.svg?style=flat-square"></a>
|
|
50
|
+
<a href="https://www.npmjs.com/package/artalk" aria-label="npm package download number" target="_blank"><img src="https://img.shields.io/npm/dt/artalk.svg?style=flat-square"></a>
|
|
51
|
+
<a href="https://github.com/ArtalkJS/Artalk/commits/master" aria-label="last commit" target="_blank"><img src="https://img.shields.io/github/last-commit/ArtalkJS/Artalk?style=flat-square"></a>
|
|
52
|
+
<a href="https://github.com/ArtalkJS/Artalk/blob/master/LICENSE" aria-label="open source license" target="_blank"><img src="https://img.shields.io/github/license/ArtalkJS/Artalk.svg?style=flat-square"></a>
|
|
53
|
+
<a href="https://github.com/ArtalkJS/Artalk" aria-label="GitHub star number" target="_blank"><img src="https://img.shields.io/github/stars/ArtalkJS/Artalk?style=flat-square"></a>
|
|
53
54
|
</div>
|
|
54
55
|
</div>
|
|
55
56
|
<div class="card atk-fade-in">
|
|
@@ -64,8 +65,9 @@
|
|
|
64
65
|
el: '#comments',
|
|
65
66
|
pageKey: 'https://artalk.js.org/',
|
|
66
67
|
pageTitle: 'Artalk Home',
|
|
67
|
-
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366
|
|
68
|
+
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366' : 'https://artalk.qwqaq.com',
|
|
68
69
|
site: 'ArtalkDemo',
|
|
70
|
+
//useBackendConf: true,
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
window.artalk = artalk;
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import Context from '../context'
|
|
2
1
|
import { CommentData, ListData, UserData, PageData, SiteData, NotifyData } from '~/types/artalk-data'
|
|
2
|
+
import ArtalkConfig from '~/types/artalk-config'
|
|
3
|
+
import Context from '../context'
|
|
3
4
|
import { Fetch, ToFormData, POST, GET } from './request'
|
|
4
5
|
import * as Utils from '../lib/utils'
|
|
5
6
|
|
|
@@ -9,7 +10,7 @@ export default class Api {
|
|
|
9
10
|
|
|
10
11
|
constructor (ctx: Context) {
|
|
11
12
|
this.ctx = ctx
|
|
12
|
-
this.baseURL = ctx.conf.server
|
|
13
|
+
this.baseURL = `${ctx.conf.server}/api`
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
// ============================
|
|
@@ -294,7 +295,22 @@ export default class Api {
|
|
|
294
295
|
|
|
295
296
|
const json = await Fetch(this.ctx, `${this.baseURL}/img-upload`, init)
|
|
296
297
|
return ((json.data || {}) as any) as { img_file: string, img_url: string }
|
|
298
|
+
}
|
|
297
299
|
|
|
300
|
+
/** 获取配置 */
|
|
301
|
+
public async conf() {
|
|
302
|
+
const data = await POST<any>(this.ctx, `${this.baseURL}/conf`)
|
|
303
|
+
const conf = (data.frontend_conf || {}) as ArtalkConfig
|
|
304
|
+
|
|
305
|
+
// Patch: `emoticons` config string to json
|
|
306
|
+
if (conf.emoticons && typeof conf.emoticons === "string") {
|
|
307
|
+
conf.emoticons = conf.emoticons.trim()
|
|
308
|
+
if (conf.emoticons.startsWith("[") || conf.emoticons.startsWith("{")) {
|
|
309
|
+
conf.emoticons = JSON.parse(conf.emoticons) // pase json
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return conf
|
|
298
314
|
}
|
|
299
315
|
|
|
300
316
|
// ============================
|
|
@@ -318,4 +334,20 @@ export default class Api {
|
|
|
318
334
|
const data = await POST<any>(this.ctx, `${this.baseURL}/captcha/status`)
|
|
319
335
|
return (data || { is_pass: false }) as { is_pass: boolean }
|
|
320
336
|
}
|
|
337
|
+
|
|
338
|
+
// ============================
|
|
339
|
+
// 管理员缓存操作
|
|
340
|
+
// ============================
|
|
341
|
+
|
|
342
|
+
/** 缓存清除 */
|
|
343
|
+
public cacheFlushAll() {
|
|
344
|
+
const params: any = { flush_all: true }
|
|
345
|
+
return POST(this.ctx, `${this.baseURL}/admin/cache-flush`, params)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** 缓存预热 */
|
|
349
|
+
public cacheWarmUp() {
|
|
350
|
+
const params: any = {}
|
|
351
|
+
return POST(this.ctx, `${this.baseURL}/admin/cache-warm`, params)
|
|
352
|
+
}
|
|
321
353
|
}
|
package/src/artalk.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import './style/main.less'
|
|
2
2
|
|
|
3
|
-
import Context from './context'
|
|
4
3
|
import ArtalkConfig from '~/types/artalk-config'
|
|
4
|
+
import { EventPayloadMap, Handler } from '~/types/event'
|
|
5
|
+
import Context from './context'
|
|
5
6
|
import defaults from './defaults'
|
|
6
7
|
|
|
7
8
|
import CheckerLauncher from './lib/checker'
|
|
@@ -10,9 +11,9 @@ import List from './components/list'
|
|
|
10
11
|
import SidebarLayer from './components/sidebar-layer'
|
|
11
12
|
|
|
12
13
|
import Layer, { GetLayerWrap } from './components/layer'
|
|
13
|
-
import { EventPayloadMap, Handler } from '~/types/event'
|
|
14
14
|
import Api from './api'
|
|
15
15
|
import * as Utils from './lib/utils'
|
|
16
|
+
import * as Ui from './lib/ui'
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Artalk
|
|
@@ -21,34 +22,43 @@ import * as Utils from './lib/utils'
|
|
|
21
22
|
export default class Artalk {
|
|
22
23
|
public static readonly defaults: ArtalkConfig = defaults
|
|
23
24
|
|
|
24
|
-
public ctx
|
|
25
|
-
public conf
|
|
26
|
-
public $root
|
|
25
|
+
public ctx!: Context
|
|
26
|
+
public conf!: ArtalkConfig
|
|
27
|
+
public $root!: HTMLElement
|
|
27
28
|
|
|
28
|
-
public checkerLauncher
|
|
29
|
-
public editor
|
|
30
|
-
public list
|
|
31
|
-
public sidebarLayer
|
|
29
|
+
public checkerLauncher!: CheckerLauncher
|
|
30
|
+
public editor!: Editor
|
|
31
|
+
public list!: List
|
|
32
|
+
public sidebarLayer!: SidebarLayer
|
|
32
33
|
|
|
33
34
|
constructor (customConf: ArtalkConfig) {
|
|
34
35
|
// 配置
|
|
35
|
-
this.conf =
|
|
36
|
-
this.conf.server = this.conf.server.replace(/\/$/, '')
|
|
36
|
+
this.conf = Utils.mergeDeep(Artalk.defaults, customConf)
|
|
37
|
+
this.conf.server = this.conf.server.replace(/\/$/, '').replace(/\/api\/?$/, '')
|
|
37
38
|
|
|
38
39
|
// 默认 pageKey
|
|
39
40
|
if (!this.conf.pageKey) {
|
|
40
41
|
// @link http://bl.ocks.org/abernier/3070589
|
|
41
|
-
this.conf.pageKey = `${window.location.
|
|
42
|
+
this.conf.pageKey = `${window.location.pathname}`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 默认 pageTitle
|
|
46
|
+
if (!this.conf.pageTitle) {
|
|
47
|
+
this.conf.pageTitle = `${document.title}`
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
// 装载元素
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
|
|
52
|
+
this.$root = this.conf.el
|
|
53
|
+
} else {
|
|
54
|
+
try {
|
|
55
|
+
const $root = document.querySelector<HTMLElement>(this.conf.el)
|
|
56
|
+
if (!$root) throw Error(`Sorry, target element "${this.conf.el}" was not found.`)
|
|
57
|
+
this.$root = $root
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.error(e)
|
|
60
|
+
throw new Error('Please check your Artalk `el` config.')
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
// Context 初始化
|
|
@@ -57,10 +67,25 @@ export default class Artalk {
|
|
|
57
67
|
// 界面初始化
|
|
58
68
|
this.$root.classList.add('artalk')
|
|
59
69
|
this.$root.innerHTML = ''
|
|
60
|
-
this.initLayer()
|
|
61
|
-
this.initDarkMode()
|
|
62
70
|
|
|
71
|
+
// 初始化组件
|
|
72
|
+
if (this.conf.useBackendConf) {
|
|
73
|
+
// 复用后端的配置
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
return (async () => {
|
|
76
|
+
await this.loadConfRemote()
|
|
77
|
+
this.initCore()
|
|
78
|
+
return this // Promise<Artalk>
|
|
79
|
+
})()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.initCore()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private initCore() {
|
|
63
86
|
// 组件初始化
|
|
87
|
+
this.initLayer()
|
|
88
|
+
this.initDarkMode()
|
|
64
89
|
this.checkerLauncher = new CheckerLauncher(this.ctx)
|
|
65
90
|
Utils.initMarked(this.ctx) // 初始化 marked
|
|
66
91
|
|
|
@@ -93,6 +118,17 @@ export default class Artalk {
|
|
|
93
118
|
})
|
|
94
119
|
}
|
|
95
120
|
|
|
121
|
+
/** 获取远程配置 */
|
|
122
|
+
private async loadConfRemote() {
|
|
123
|
+
Ui.showLoading(this.$root)
|
|
124
|
+
let backendConf = {}
|
|
125
|
+
try {
|
|
126
|
+
backendConf = await (new Api(this.ctx)).conf()
|
|
127
|
+
} catch (err) { console.error("配置远程获取失败", err) }
|
|
128
|
+
this.ctx.conf = Utils.mergeDeep(this.ctx.conf, backendConf)
|
|
129
|
+
Ui.hideLoading(this.$root)
|
|
130
|
+
}
|
|
131
|
+
|
|
96
132
|
/** 事件绑定 · 初始化 */
|
|
97
133
|
private initEventBind() {
|
|
98
134
|
// 锚点快速跳转评论
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import '../style/comment.less'
|
|
2
2
|
|
|
3
|
+
import { CommentData } from '~/types/artalk-data'
|
|
3
4
|
import Context from '../context'
|
|
4
5
|
import Component from '../lib/component'
|
|
5
6
|
import * as Utils from '../lib/utils'
|
|
6
7
|
import * as Ui from '../lib/ui'
|
|
7
8
|
import UADetect from '../lib/detect'
|
|
8
|
-
import { CommentData } from '~/types/artalk-data'
|
|
9
9
|
import CommentHTML from './html/comment.html?raw'
|
|
10
10
|
import Api from '../api'
|
|
11
11
|
import ActionBtn from './action-btn'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import './emoticons-plug.less'
|
|
2
2
|
|
|
3
|
-
import Editor from '../editor'
|
|
4
|
-
import EditorPlug from './editor-plug'
|
|
5
3
|
import * as Utils from '~/src/lib/utils'
|
|
6
4
|
import * as Ui from '~/src/lib/ui'
|
|
7
5
|
import { EmoticonListData, EmoticonGrpData } from '~/types/artalk-data'
|
|
6
|
+
import EditorPlug from './editor-plug'
|
|
7
|
+
import Editor from '../editor'
|
|
8
8
|
|
|
9
9
|
type OwOFormatType = {
|
|
10
10
|
[key: string] : {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import './preview-plug.less'
|
|
2
2
|
|
|
3
|
+
import * as Utils from '~/src/lib/utils'
|
|
3
4
|
import Editor from '../editor'
|
|
4
5
|
import EditorPlug from './editor-plug'
|
|
5
|
-
import * as Utils from '~/src/lib/utils'
|
|
6
6
|
|
|
7
7
|
export default class PreviewPlug extends EditorPlug {
|
|
8
8
|
$el!: HTMLElement
|
package/src/components/editor.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '../style/editor.less'
|
|
2
2
|
|
|
3
|
+
import { CommentData } from '~/types/artalk-data'
|
|
3
4
|
import Context from '../context'
|
|
4
5
|
import Component from '../lib/component'
|
|
5
6
|
import * as Utils from '../lib/utils'
|
|
@@ -8,7 +9,6 @@ import EditorHTML from './html/editor.html?raw'
|
|
|
8
9
|
|
|
9
10
|
import EmoticonsPlug from './editor-plugs/emoticons-plug'
|
|
10
11
|
import PreviewPlug from './editor-plugs/preview-plug'
|
|
11
|
-
import { CommentData } from '~/types/artalk-data'
|
|
12
12
|
import Api from '../api'
|
|
13
13
|
|
|
14
14
|
export default class Editor extends Component {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { ListData, CommentData, NotifyData, ApiVersionData } from '~/types/artalk-data'
|
|
1
2
|
import Context from '../context'
|
|
2
3
|
import Component from '../lib/component'
|
|
3
4
|
import * as Utils from '../lib/utils'
|
|
4
5
|
import * as Ui from '../lib/ui'
|
|
5
6
|
import Api from '../api'
|
|
6
7
|
import Comment from './comment'
|
|
7
|
-
import { ListData, CommentData, NotifyData, ApiVersionData } from '~/types/artalk-data'
|
|
8
8
|
import Pagination from './pagination'
|
|
9
9
|
import ReadMoreBtn from './read-more-btn'
|
|
10
10
|
import { backendMinVersion } from '../../package.json'
|
|
@@ -49,6 +49,9 @@ export default class ListLite extends Component {
|
|
|
49
49
|
</div>`)
|
|
50
50
|
this.$commentsWrap = this.$el.querySelector('.atk-list-comments-wrap')!
|
|
51
51
|
|
|
52
|
+
// 评论为空时显示字符
|
|
53
|
+
if (ctx.conf.noComment) this.noCommentText = ctx.conf.noComment
|
|
54
|
+
|
|
52
55
|
// 评论时间自动更新
|
|
53
56
|
window.setInterval(() => {
|
|
54
57
|
this.$el.querySelectorAll<HTMLElement>('[data-atk-comment-date]').forEach(el => {
|
package/src/components/list.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import '../style/list.less'
|
|
2
2
|
|
|
3
|
+
import { ListData } from '~/types/artalk-data'
|
|
3
4
|
import Context from '../context'
|
|
4
5
|
import * as Utils from '../lib/utils'
|
|
5
6
|
import * as Ui from '../lib/ui'
|
|
6
7
|
import Api from '../api'
|
|
7
8
|
import ListHTML from './html/list.html?raw'
|
|
8
9
|
import ListLite from './list-lite'
|
|
9
|
-
import { ListData } from '~/types/artalk-data'
|
|
10
10
|
|
|
11
11
|
export default class List extends ListLite {
|
|
12
12
|
private $closeCommentBtn!: HTMLElement
|
|
@@ -38,7 +38,7 @@ export default class Pagination {
|
|
|
38
38
|
`<div class="atk-pagination-wrap">
|
|
39
39
|
<div class="atk-pagination">
|
|
40
40
|
<div class="atk-btn atk-btn-prev">Prev</div>
|
|
41
|
-
<input type="text" class="atk-input" />
|
|
41
|
+
<input type="text" class="atk-input" aria-label="Enter the number of page" />
|
|
42
42
|
<div class="atk-btn atk-btn-next">Next</div>
|
|
43
43
|
</div>
|
|
44
44
|
</div>`)
|
|
@@ -3,11 +3,11 @@ import '../style/sidebar-layer.less'
|
|
|
3
3
|
import Context from '@/context'
|
|
4
4
|
import Component from '@/lib/component'
|
|
5
5
|
import * as Utils from '@/lib/utils'
|
|
6
|
-
import SidebarHTML from './html/sidebar-layer.html?raw'
|
|
7
6
|
import * as Ui from '@/lib/ui'
|
|
7
|
+
import { SidebarShowPayload } from '~/types/event'
|
|
8
|
+
import SidebarHTML from './html/sidebar-layer.html?raw'
|
|
8
9
|
import Layer from './layer'
|
|
9
10
|
import Api from '../api'
|
|
10
|
-
import { SidebarShowPayload } from '~/types/event'
|
|
11
11
|
|
|
12
12
|
export default class SidebarLayer extends Component {
|
|
13
13
|
public layer?: Layer
|
|
@@ -88,7 +88,7 @@ export default class SidebarLayer extends Component {
|
|
|
88
88
|
|
|
89
89
|
// 准备 Iframe 参数
|
|
90
90
|
const baseURL = (import.meta.env.MODE === 'development') ? 'http://localhost:23367/'
|
|
91
|
-
: Utils.getURLBasedOnApi(this.ctx, 'sidebar/')
|
|
91
|
+
: Utils.getURLBasedOnApi(this.ctx, '/sidebar/')
|
|
92
92
|
|
|
93
93
|
const query: any = {
|
|
94
94
|
pageKey: this.conf.pageKey,
|
package/src/context.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { marked as libMarked } from 'marked'
|
|
2
|
-
import User from './lib/user'
|
|
3
2
|
import ArtalkConfig from '~/types/artalk-config'
|
|
4
3
|
import { EventPayloadMap, Event, EventScopeType, Handler } from '~/types/event'
|
|
4
|
+
import User from './lib/user'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Artalk Context
|
package/src/defaults.ts
CHANGED
|
@@ -15,7 +15,7 @@ const CaptchaChecker: Checker = {
|
|
|
15
15
|
const $iframe = Utils.createElement<HTMLIFrameElement>(`<iframe class="atk-fade-in"></iframe>`)
|
|
16
16
|
$iframe.style.display = 'none'
|
|
17
17
|
Ui.showLoading($iframeWrap, { transparentBg: true })
|
|
18
|
-
$iframe.src = `${that.ctx.conf.server}/captcha/get?t=${+new Date()}`
|
|
18
|
+
$iframe.src = `${that.ctx.conf.server}/api/captcha/get?t=${+new Date()}`
|
|
19
19
|
$iframe.onload = () => {
|
|
20
20
|
$iframe.style.display = ''
|
|
21
21
|
Ui.hideLoading($iframeWrap)
|
package/src/lib/checker/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Context from '@/context'
|
|
2
2
|
import Layer from '@/components/layer'
|
|
3
3
|
import Dialog from '@/components/dialog'
|
|
4
|
+
import { CheckerPayload } from '~/types/event'
|
|
4
5
|
import * as Utils from '../utils'
|
|
5
6
|
import * as Ui from '../ui'
|
|
6
|
-
import { CheckerPayload } from '~/types/event'
|
|
7
7
|
import CaptchaChecker from './captcha-checker'
|
|
8
8
|
import AdminChecker from './admin-checker'
|
|
9
9
|
|
package/src/lib/utils.ts
CHANGED
|
@@ -286,10 +286,40 @@ export function isValidURL(urlRaw: string) {
|
|
|
286
286
|
|
|
287
287
|
/** 获取基于 conf.server 的 URL */
|
|
288
288
|
export function getURLBasedOnApi(ctx: Context, path: string) {
|
|
289
|
-
return
|
|
289
|
+
return getURLBasedOn(ctx.conf.server, path)
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
/** 获取基于某个 baseURL 的 URL */
|
|
293
293
|
export function getURLBasedOn(baseURL: string, path: string) {
|
|
294
294
|
return `${baseURL.replace(/\/$/, '')}/${path.replace(/^\//, '')}`
|
|
295
295
|
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Performs a deep merge of `source` into `target`.
|
|
299
|
+
* Mutates `target` only but not its objects and arrays.
|
|
300
|
+
*
|
|
301
|
+
* @author inspired by [jhildenbiddle](https://stackoverflow.com/a/48218209).
|
|
302
|
+
* @link https://gist.github.com/ahtcx/0cd94e62691f539160b32ecda18af3d6
|
|
303
|
+
*/
|
|
304
|
+
export function mergeDeep(target: any, source: any) {
|
|
305
|
+
const isObject = (obj: any) => obj && typeof obj === 'object'
|
|
306
|
+
|
|
307
|
+
if (!isObject(target) || !isObject(source)) {
|
|
308
|
+
return source
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
Object.keys(source).forEach(key => {
|
|
312
|
+
const targetValue = target[key]
|
|
313
|
+
const sourceValue = source[key]
|
|
314
|
+
|
|
315
|
+
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
316
|
+
target[key] = targetValue.concat(sourceValue)
|
|
317
|
+
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
318
|
+
target[key] = mergeDeep({ ...targetValue}, sourceValue)
|
|
319
|
+
} else {
|
|
320
|
+
target[key] = sourceValue
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
return target
|
|
325
|
+
}
|
package/src/style/_color.less
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
--at-color-font: #2a2e2e;
|
|
3
3
|
--at-color-deep: #2a2e2e;
|
|
4
4
|
--at-color-sub: #757575;
|
|
5
|
-
--at-color-grey: #
|
|
6
|
-
--at-color-meta: #
|
|
5
|
+
--at-color-grey: #747474;
|
|
6
|
+
--at-color-meta: #697182;
|
|
7
7
|
--at-color-border: #eceff2;
|
|
8
8
|
--at-color-light: #4285f4;
|
|
9
9
|
--at-color-bg: #FFF;
|
package/types/artalk-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default interface ArtalkConfig {
|
|
2
2
|
/** 装载元素 */
|
|
3
|
-
el: string
|
|
3
|
+
el: string|HTMLElement
|
|
4
4
|
|
|
5
5
|
/** 页面唯一标识(完整 URL) */
|
|
6
6
|
pageKey: string
|
|
@@ -88,6 +88,9 @@ export default interface ArtalkConfig {
|
|
|
88
88
|
|
|
89
89
|
/** 版本检测 */
|
|
90
90
|
versionCheck?: boolean
|
|
91
|
+
|
|
92
|
+
/** 复用后端配置 */
|
|
93
|
+
useBackendConf?: boolean
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
export interface LocalUser {
|