artalk 2.2.5 → 2.2.6
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.es.js +26 -16
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/src/api/index.ts +1 -1
- package/src/artalk.ts +18 -9
- package/src/components/sidebar-layer.ts +1 -1
- package/src/lib/checker/captcha-checker.ts +1 -1
- package/src/lib/utils.ts +1 -1
- package/types/artalk-config.d.ts +1 -1
package/index.html
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
el: '#comments',
|
|
65
65
|
pageKey: 'https://artalk.js.org/',
|
|
66
66
|
pageTitle: 'Artalk Home',
|
|
67
|
-
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366
|
|
67
|
+
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366' : 'https://artalk.qwqaq.com',
|
|
68
68
|
site: 'ArtalkDemo',
|
|
69
69
|
});
|
|
70
70
|
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
package/src/artalk.ts
CHANGED
|
@@ -33,22 +33,31 @@ export default class Artalk {
|
|
|
33
33
|
constructor (customConf: ArtalkConfig) {
|
|
34
34
|
// 配置
|
|
35
35
|
this.conf = { ...Artalk.defaults, ...customConf }
|
|
36
|
-
this.conf.server = this.conf.server.replace(/\/$/, '')
|
|
36
|
+
this.conf.server = this.conf.server.replace(/\/$/, '').replace(/\/api\/?$/, '')
|
|
37
37
|
|
|
38
38
|
// 默认 pageKey
|
|
39
39
|
if (!this.conf.pageKey) {
|
|
40
40
|
// @link http://bl.ocks.org/abernier/3070589
|
|
41
|
-
this.conf.pageKey = `${window.location.
|
|
41
|
+
this.conf.pageKey = `${window.location.pathname}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 默认 pageTitle
|
|
45
|
+
if (!this.conf.pageTitle) {
|
|
46
|
+
this.conf.pageTitle = `${document.title}`
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
// 装载元素
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
|
|
51
|
+
this.$root = this.conf.el
|
|
52
|
+
} else {
|
|
53
|
+
try {
|
|
54
|
+
const $root = document.querySelector<HTMLElement>(this.conf.el)
|
|
55
|
+
if (!$root) throw Error(`Sorry, target element "${this.conf.el}" was not found.`)
|
|
56
|
+
this.$root = $root
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e)
|
|
59
|
+
throw new Error('Please check your Artalk `el` config.')
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
// Context 初始化
|
|
@@ -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,
|
|
@@ -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/utils.ts
CHANGED
|
@@ -286,7 +286,7 @@ 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 */
|