artalk 2.7.1 → 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 +155 -147
- package/dist/Artalk.es.js.map +1 -1
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/Artalk.js.map +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +155 -147
- package/dist/ArtalkLite.es.js.map +1 -1
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.iife.js.map +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/ArtalkLite.js.map +1 -1
- 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/components/checker/index.d.ts +2 -0
- package/dist/src/i18n/en.d.ts +1 -0
- package/dist/src/i18n/external.d.ts +1 -0
- package/dist/src/i18n/index.d.ts +3 -0
- package/dist/src/i18n/jp.d.ts +1 -0
- package/dist/src/i18n/zh-TW.d.ts +1 -0
- package/dist/src/lib/user.d.ts +8 -6
- 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 -115
- 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 -84
- package/src/i18n/external.ts +0 -10
- package/src/i18n/index.ts +0 -67
- package/src/i18n/jp.ts +0 -86
- package/src/i18n/zh-CN.ts +0 -88
- package/src/i18n/zh-TW.ts +0 -86
- 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 -14
- 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 -82
- package/src/plugins/version-check.ts +0 -36
- 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/dist/i18n/jp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).jp=n()}(this,(function(){"use strict";const e="ArtalkI18n";var n,o,t;return n="jp",o={placeholder:"コメントを残す",noComment:"コメントなし",send:"送信",save:"保存",nick:"ニックネーム",email:"メール",link:"ウェブサイト",emoticon:"絵文字",preview:"プレビュー",image:"画像",uploadFail:"アップロードに失敗しました",commentFail:"コメントに失敗しました",restoredMsg:"コンテンツが復元されました",onlyAdminCanReply:"管理者のみが返信できます",uploadLoginMsg:"アップロードするには、名前とメールアドレスを入力してください",counter:"{count} コメント",sortLatest:"最新のもの",sortOldest:"最も古い",sortBest:"ベスト",sortAuthor:"著者",openComment:"コメントを開く",closeComment:"コメントを閉じる",listLoadFailMsg:"コメントの読み込みに失敗しました",listRetry:"クリックで再試行",loadMore:"もっと読み込む",admin:"管理者",reply:"返信",voteUp:"アップ",voteDown:"ダウン",voteFail:"投票に失敗しました",readMore:"続きを読む",actionConfirm:"確認",collapse:"折りたたむ",collapsed:"折りたたまれた",collapsedMsg:"このコメントは折りたたまれました",expand:"展開",approved:"承認されました",pending:"保留中",pendingMsg:"保留中、コメント投稿者にのみ表示されます",edit:"編集",editCancel:"編集をキャンセル",delete:"削除",deleteConfirm:"確認",pin:"ピン",unpin:"ピン外し",seconds:"秒前",minutes:"分前",hours:"時間前",days:"数日前",now:"たった今",adminCheck:"管理者パスワードを入力してください:",captchaCheck:"続けるにはCAPTCHAを入力してください:",confirm:"確認",cancel:"取消",msgCenter:"メッセージ",ctrlCenter:"コンソール",frontend:"フロントエンド",backend:"バックエンド",loading:"読み込み中",loadFail:"読み込みに失敗しました",editing:"編集中",editFail:"編集に失敗しました",deleting:"削除中",deleteFail:"削除に失敗しました",reqGot:"リクエストを取得しました",reqAborted:"リクエストがタイムアウトしたか、予期せず終了した",updateMsg:"フルな体験をするためには、Artalk {name} をアップデートしてください",currentVersion:"現在のバージョン",ignore:"無視する"},t=["jp-JP"],window[e]||(window[e]={}),window[e][n]=o,t&&t.forEach((n=>{window[e][n]=o})),o}));
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).jp=n()}(this,(function(){"use strict";const e="ArtalkI18n";var n,o,t;return n="jp",o={placeholder:"コメントを残す",noComment:"コメントなし",send:"送信",save:"保存",nick:"ニックネーム",email:"メール",link:"ウェブサイト",emoticon:"絵文字",preview:"プレビュー",image:"画像",uploadFail:"アップロードに失敗しました",commentFail:"コメントに失敗しました",restoredMsg:"コンテンツが復元されました",onlyAdminCanReply:"管理者のみが返信できます",uploadLoginMsg:"アップロードするには、名前とメールアドレスを入力してください",counter:"{count} コメント",sortLatest:"最新のもの",sortOldest:"最も古い",sortBest:"ベスト",sortAuthor:"著者",openComment:"コメントを開く",closeComment:"コメントを閉じる",listLoadFailMsg:"コメントの読み込みに失敗しました",listRetry:"クリックで再試行",loadMore:"もっと読み込む",admin:"管理者",reply:"返信",voteUp:"アップ",voteDown:"ダウン",voteFail:"投票に失敗しました",readMore:"続きを読む",actionConfirm:"確認",collapse:"折りたたむ",collapsed:"折りたたまれた",collapsedMsg:"このコメントは折りたたまれました",expand:"展開",approved:"承認されました",pending:"保留中",pendingMsg:"保留中、コメント投稿者にのみ表示されます",edit:"編集",editCancel:"編集をキャンセル",delete:"削除",deleteConfirm:"確認",pin:"ピン",unpin:"ピン外し",seconds:"秒前",minutes:"分前",hours:"時間前",days:"数日前",now:"たった今",adminCheck:"管理者パスワードを入力してください:",captchaCheck:"続けるにはCAPTCHAを入力してください:",confirm:"確認",cancel:"取消",msgCenter:"メッセージ",ctrlCenter:"コンソール",frontend:"フロントエンド",backend:"バックエンド",loading:"読み込み中",loadFail:"読み込みに失敗しました",editing:"編集中",editFail:"編集に失敗しました",deleting:"削除中",deleteFail:"削除に失敗しました",reqGot:"リクエストを取得しました",reqAborted:"リクエストがタイムアウトしたか、予期せず終了した",updateMsg:"フルな体験をするためには、Artalk {name} をアップデートしてください",currentVersion:"現在のバージョン",ignore:"無視する",open:"オープン"},t=["jp-JP"],window[e]||(window[e]={}),window[e][n]=o,t&&t.forEach((n=>{window[e][n]=o})),o}));
|
package/dist/i18n/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self)["zh-TW"]=n()}(this,(function(){"use strict";const e="ArtalkI18n";var n,o,t;return n="zh-TW",o={placeholder:"鍵入內容...",noComment:"「此時無聲勝有聲」",send:"發送評論",save:"保存評論",nick:"昵稱",email:"郵箱",link:"網址",emoticon:"表情",preview:"預覽",image:"圖片",uploadFail:"上傳失敗",commentFail:"評論失敗",restoredMsg:"內容已自動恢復",onlyAdminCanReply:"僅管理員可評論",uploadLoginMsg:"填入你的名字郵箱才能上傳哦",counter:"{count} 條評論",sortLatest:"最新",sortOldest:"最早",sortBest:"最熱",sortAuthor:"作者",openComment:"打開評論",closeComment:"關閉評論",listLoadFailMsg:"無法獲取評論列表數據",listRetry:"點擊重新獲取",loadMore:"加載更多",admin:"管理員",reply:"回覆",voteUp:"贊同",voteDown:"反對",voteFail:"投票失敗",readMore:"閱讀更多",actionConfirm:"確認操作",collapse:"摺疊",collapsed:"已摺疊",collapsedMsg:"該評論已被系統或管理員摺疊",expand:"展開",approved:"已審",pending:"待審",pendingMsg:"審核中,僅本人可見。",edit:"編輯",editCancel:"取消編輯",delete:"刪除",deleteConfirm:"確認刪除",pin:"置頂",unpin:"取消置頂",seconds:"秒前",minutes:"分鐘前",hours:"小時前",days:"天前",now:"剛剛",adminCheck:"鍵入密碼來驗證管理員身份:",captchaCheck:"鍵入驗證碼繼續:",confirm:"確認",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"後端",loading:"加載中",loadFail:"加載失敗",editing:"修改中",editFail:"修改失敗",deleting:"刪除中",deleteFail:"刪除失敗",reqGot:"請求響應",reqAborted:"請求超時或意外終止",updateMsg:"請更新 Artalk {name} 以獲得完整體驗",currentVersion:"當前版本",ignore:"忽略"},window[e]||(window[e]={}),window[e][n]=o,t&&t.forEach((n=>{window[e][n]=o})),o}));
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self)["zh-TW"]=n()}(this,(function(){"use strict";const e="ArtalkI18n";var n,o,t;return n="zh-TW",o={placeholder:"鍵入內容...",noComment:"「此時無聲勝有聲」",send:"發送評論",save:"保存評論",nick:"昵稱",email:"郵箱",link:"網址",emoticon:"表情",preview:"預覽",image:"圖片",uploadFail:"上傳失敗",commentFail:"評論失敗",restoredMsg:"內容已自動恢復",onlyAdminCanReply:"僅管理員可評論",uploadLoginMsg:"填入你的名字郵箱才能上傳哦",counter:"{count} 條評論",sortLatest:"最新",sortOldest:"最早",sortBest:"最熱",sortAuthor:"作者",openComment:"打開評論",closeComment:"關閉評論",listLoadFailMsg:"無法獲取評論列表數據",listRetry:"點擊重新獲取",loadMore:"加載更多",admin:"管理員",reply:"回覆",voteUp:"贊同",voteDown:"反對",voteFail:"投票失敗",readMore:"閱讀更多",actionConfirm:"確認操作",collapse:"摺疊",collapsed:"已摺疊",collapsedMsg:"該評論已被系統或管理員摺疊",expand:"展開",approved:"已審",pending:"待審",pendingMsg:"審核中,僅本人可見。",edit:"編輯",editCancel:"取消編輯",delete:"刪除",deleteConfirm:"確認刪除",pin:"置頂",unpin:"取消置頂",seconds:"秒前",minutes:"分鐘前",hours:"小時前",days:"天前",now:"剛剛",adminCheck:"鍵入密碼來驗證管理員身份:",captchaCheck:"鍵入驗證碼繼續:",confirm:"確認",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"後端",loading:"加載中",loadFail:"加載失敗",editing:"修改中",editFail:"修改失敗",deleting:"刪除中",deleteFail:"刪除失敗",reqGot:"請求響應",reqAborted:"請求超時或意外終止",updateMsg:"請更新 Artalk {name} 以獲得完整體驗",currentVersion:"當前版本",ignore:"忽略",open:"打开"},window[e]||(window[e]={}),window[e][n]=o,t&&t.forEach((n=>{window[e][n]=o})),o}));
|
package/dist/src/api/_base.d.ts
CHANGED
|
@@ -6,5 +6,12 @@ declare abstract class ApiBase {
|
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
}): Promise<T>;
|
|
8
8
|
protected Fetch(path: string, init: RequestInit, timeout?: number): Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Carry user info to request params
|
|
11
|
+
*
|
|
12
|
+
* @param params Request params
|
|
13
|
+
* @returns Request params with user info
|
|
14
|
+
*/
|
|
15
|
+
protected withUserInfo(params: any): any;
|
|
9
16
|
}
|
|
10
17
|
export default ApiBase;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type Api from '../../api';
|
|
2
2
|
import type { ContextApi } from '../../../types';
|
|
3
|
+
import type User from '../../lib/user';
|
|
3
4
|
export interface CheckerCaptchaPayload extends CheckerPayload {
|
|
4
5
|
imgData?: string;
|
|
5
6
|
iframe?: string;
|
|
@@ -44,6 +45,7 @@ export interface CheckerCtx {
|
|
|
44
45
|
set<K extends keyof CheckerStore>(key: K, val: CheckerStore[K]): void;
|
|
45
46
|
getOpts(): CheckerLauncherOptions;
|
|
46
47
|
getApi(): Api;
|
|
48
|
+
getUser(): User;
|
|
47
49
|
hideInteractInput(): void;
|
|
48
50
|
triggerSuccess(): void;
|
|
49
51
|
cancel(): void;
|
package/dist/src/i18n/en.d.ts
CHANGED
package/dist/src/i18n/index.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export declare const internal: {
|
|
|
72
72
|
updateMsg: string;
|
|
73
73
|
currentVersion: string;
|
|
74
74
|
ignore: string;
|
|
75
|
+
open: string;
|
|
75
76
|
};
|
|
76
77
|
'en-US': {
|
|
77
78
|
placeholder: string;
|
|
@@ -143,6 +144,7 @@ export declare const internal: {
|
|
|
143
144
|
updateMsg: string;
|
|
144
145
|
currentVersion: string;
|
|
145
146
|
ignore: string;
|
|
147
|
+
open: string;
|
|
146
148
|
};
|
|
147
149
|
'zh-CN': {
|
|
148
150
|
placeholder: string;
|
|
@@ -214,6 +216,7 @@ export declare const internal: {
|
|
|
214
216
|
updateMsg: string;
|
|
215
217
|
currentVersion: string;
|
|
216
218
|
ignore: string;
|
|
219
|
+
open: string;
|
|
217
220
|
};
|
|
218
221
|
};
|
|
219
222
|
/**
|
package/dist/src/i18n/jp.d.ts
CHANGED
package/dist/src/i18n/zh-TW.d.ts
CHANGED
package/dist/src/lib/user.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { LocalUser } from '../../types';
|
|
2
|
+
interface UserOpts {
|
|
3
|
+
onUserChanged?: (user: LocalUser) => void;
|
|
4
|
+
}
|
|
2
5
|
declare class User {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor();
|
|
6
|
+
private opts;
|
|
7
|
+
private data;
|
|
8
|
+
constructor(opts: UserOpts);
|
|
9
|
+
getData(): LocalUser;
|
|
6
10
|
/** 保存用户到 localStorage 中 */
|
|
7
11
|
update(obj?: Partial<LocalUser>): void;
|
|
8
|
-
setOnUserChanged(fn: ((user: LocalUser) => void) | null): void;
|
|
9
12
|
/**
|
|
10
13
|
* Logout
|
|
11
14
|
*
|
|
@@ -15,5 +18,4 @@ declare class User {
|
|
|
15
18
|
/** 是否已填写基本用户信息 */
|
|
16
19
|
checkHasBasicUserInfo(): boolean;
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
export default UserInstance;
|
|
21
|
+
export default User;
|
|
@@ -8,12 +8,18 @@ export default class PlugKit {
|
|
|
8
8
|
constructor(plugs: PlugManager);
|
|
9
9
|
/** Use the editor */
|
|
10
10
|
useEditor(): import("../../../types").EditorApi;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Use the context of global
|
|
13
|
+
*
|
|
14
|
+
* @deprecated The calls to this function should be reduced as much as possible
|
|
15
|
+
*/
|
|
12
16
|
useGlobalCtx(): import("../../../types").ContextApi;
|
|
13
17
|
/** Use the config of Artalk */
|
|
14
18
|
useConf(): import("../../../types").ArtalkConfig;
|
|
15
19
|
/** Use the http api client */
|
|
16
20
|
useApi(): import("../../api").default;
|
|
21
|
+
/** Use the user manager */
|
|
22
|
+
useUser(): import("../../lib/user").default;
|
|
17
23
|
/** Use the ui of editor */
|
|
18
24
|
useUI(): import("../../editor/ui").EditorUI;
|
|
19
25
|
/** Use the events in editor scope */
|
package/dist/src/service.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import SidebarLayer from './layer/sidebar-layer';
|
|
|
5
5
|
import List from './list/list';
|
|
6
6
|
import { PlugManager } from './plugins/editor-kit';
|
|
7
7
|
import { LayerManager } from './layer/layer-manager';
|
|
8
|
+
import User from './lib/user';
|
|
8
9
|
/**
|
|
9
10
|
* Services
|
|
10
11
|
*
|
|
@@ -12,14 +13,7 @@ import { LayerManager } from './layer/layer-manager';
|
|
|
12
13
|
*/
|
|
13
14
|
declare const services: {
|
|
14
15
|
i18n(ctx: ContextApi): void;
|
|
15
|
-
user(ctx: ContextApi):
|
|
16
|
-
data: import('../types').LocalUser;
|
|
17
|
-
onUserChanged: ((user: import('../types').LocalUser) => void) | null;
|
|
18
|
-
update(obj?: Partial<import('../types').LocalUser>): void;
|
|
19
|
-
setOnUserChanged(fn: ((user: import('../types').LocalUser) => void) | null): void;
|
|
20
|
-
logout(): void;
|
|
21
|
-
checkHasBasicUserInfo(): boolean;
|
|
22
|
-
};
|
|
16
|
+
user(ctx: ContextApi): User;
|
|
23
17
|
layerManager(ctx: ContextApi): LayerManager;
|
|
24
18
|
checkerLauncher(ctx: ContextApi): CheckerLauncher;
|
|
25
19
|
editor(ctx: ContextApi): Editor;
|
package/dist/types/event.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface EventPayloadMap {
|
|
|
32
32
|
'editor-submitted': undefined;
|
|
33
33
|
'user-changed': LocalUser;
|
|
34
34
|
'conf-loaded': ArtalkConfig;
|
|
35
|
-
'dark-mode-changed': boolean;
|
|
35
|
+
'dark-mode-changed': boolean | 'auto';
|
|
36
36
|
'sidebar-show': undefined;
|
|
37
37
|
'sidebar-hide': undefined;
|
|
38
38
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "artalk",
|
|
3
|
-
"version": "2.7.
|
|
4
|
-
"
|
|
5
|
-
"description": "A Selfhosted Comment System",
|
|
3
|
+
"version": "2.7.2",
|
|
4
|
+
"description": "A self-hosted comment system",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"comment-system",
|
|
8
7
|
"comments-widget",
|
|
@@ -10,39 +9,66 @@
|
|
|
10
9
|
"comments",
|
|
11
10
|
"blog"
|
|
12
11
|
],
|
|
12
|
+
"homepage": "https://artalk.js.org",
|
|
13
|
+
"bugs": "https://github.com/ArtalkJS/Artalk/issue",
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
15
16
|
"url": "https://github.com/ArtalkJS/Artalk.git",
|
|
16
17
|
"directory": "ui/packages/artalk"
|
|
17
18
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/src/main.d.ts",
|
|
24
|
+
"require": "./dist/Artalk.js",
|
|
25
|
+
"default": "./dist/Artalk.es.js"
|
|
26
|
+
},
|
|
27
|
+
"./dist/*": "./dist/*",
|
|
28
|
+
"./dist/Artalk": "./dist/Artalk.js",
|
|
29
|
+
"./dist/Artalk.es": "./dist/Artalk.es.js",
|
|
30
|
+
"./dist/Artalk.iife": "./dist/Artalk.iife.js",
|
|
31
|
+
"./dist/ArtalkLite": "./dist/ArtalkLite.js",
|
|
32
|
+
"./dist/ArtalkLite.es": "./dist/ArtalkLite.es.js",
|
|
33
|
+
"./dist/ArtalkLite.iife": "./dist/ArtalkLite.iife.js",
|
|
34
|
+
"./dist/i18n/jp": "./dist/i18n/jp.js",
|
|
35
|
+
"./dist/i18n/zh-TW": "./dist/i18n/zh-TW.js",
|
|
36
|
+
"./i18n/*": "./dist/i18n/*",
|
|
37
|
+
"./lite/*": {
|
|
38
|
+
"types": "./dist/src/main.d.ts",
|
|
39
|
+
"require": "./dist/ArtalkLite.js",
|
|
40
|
+
"default": "./dist/ArtalkLite.es.js"
|
|
41
|
+
},
|
|
42
|
+
"./style": "./dist/Artalk.css"
|
|
43
|
+
},
|
|
20
44
|
"main": "./dist/Artalk.js",
|
|
21
|
-
"unpkg": "./dist/Artalk.iife.js",
|
|
22
45
|
"jsdelivr": "./dist/Artalk.iife.js",
|
|
46
|
+
"unpkg": "./dist/Artalk.iife.js",
|
|
23
47
|
"module": "./dist/Artalk.es.js",
|
|
24
48
|
"types": "./dist/src/main.d.ts",
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
29
52
|
"dependencies": {
|
|
30
53
|
"abortcontroller-polyfill": "^1.7.5",
|
|
31
54
|
"hanabi": "^0.4.0",
|
|
32
55
|
"insane": "^2.6.2",
|
|
33
56
|
"marked": "^7.0.4"
|
|
34
57
|
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/marked": "5.0.2"
|
|
60
|
+
},
|
|
35
61
|
"scripts": {
|
|
36
|
-
"dev": "vite",
|
|
37
62
|
"build": "vite build && pnpm build:lite && pnpm build:i18n",
|
|
38
|
-
"build:lite": "vite build --config vite-lite.config.ts",
|
|
39
|
-
"build:i18n": "node scripts/build-i18n.mjs",
|
|
40
63
|
"build:demo": "vite build --config vite-demo.config.ts",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"predeploy": "pnpm build && pnpm build:demo && pnpm copy:deploy",
|
|
64
|
+
"build:i18n": "node scripts/build-i18n.mjs",
|
|
65
|
+
"build:lite": "vite build --config vite-lite.config.ts",
|
|
44
66
|
"copy:deploy": "cp -r dist deploy && cp CNAME deploy",
|
|
45
|
-
"
|
|
67
|
+
"predeploy": "pnpm build && pnpm build:demo && pnpm copy:deploy",
|
|
68
|
+
"deploy": "gh-pages -d deploy",
|
|
69
|
+
"dev": "vite",
|
|
70
|
+
"lint": "eslint --ext .js,.ts src --fix",
|
|
71
|
+
"serve": "vite preview",
|
|
46
72
|
"test:e2e": "playwright test",
|
|
47
73
|
"test:report": "playwright show-report"
|
|
48
74
|
}
|
package/src/api/_base.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ApiOptions } from './_options'
|
|
2
|
-
import { POST, Fetch } from './_request'
|
|
3
|
-
|
|
4
|
-
abstract class ApiBase {
|
|
5
|
-
constructor(
|
|
6
|
-
protected options: ApiOptions
|
|
7
|
-
) {}
|
|
8
|
-
|
|
9
|
-
protected async POST<T>(path: string, data?: {[key: string]: any}) {
|
|
10
|
-
return POST<T>(this.options, this.options.baseURL+path, data)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
protected async Fetch(path: string, init: RequestInit, timeout?: number): Promise<any> {
|
|
14
|
-
return Fetch(this.options, this.options.baseURL+path, init, timeout)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default ApiBase
|
package/src/api/_options.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface ApiOptions {
|
|
2
|
-
baseURL: string
|
|
3
|
-
siteName: string
|
|
4
|
-
pageKey: string
|
|
5
|
-
pageTitle: string
|
|
6
|
-
timeout?: number
|
|
7
|
-
|
|
8
|
-
// -------------------------------------------------------------------
|
|
9
|
-
// Hooks
|
|
10
|
-
// -------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
onNeedCheckCaptcha?: (payload: {
|
|
13
|
-
recall: () => void
|
|
14
|
-
reject: () => void
|
|
15
|
-
data: {
|
|
16
|
-
imgData: string
|
|
17
|
-
iframe: string
|
|
18
|
-
}
|
|
19
|
-
}) => void
|
|
20
|
-
|
|
21
|
-
onNeedCheckAdmin?: (payload: {
|
|
22
|
-
recall: () => void
|
|
23
|
-
reject: () => void
|
|
24
|
-
}) => void
|
|
25
|
-
}
|
package/src/api/_request.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
|
|
2
|
-
|
|
3
|
-
import { ApiOptions } from './_options'
|
|
4
|
-
import User from '../lib/user'
|
|
5
|
-
import $t from '../i18n'
|
|
6
|
-
|
|
7
|
-
/** 公共请求函数 */
|
|
8
|
-
export async function Fetch(opts: ApiOptions, input: RequestInfo, init: RequestInit, timeout?: number): Promise<any> {
|
|
9
|
-
// JWT
|
|
10
|
-
if (User.data.token) {
|
|
11
|
-
const headers = new Headers(init.headers) // 保留原有 headers
|
|
12
|
-
headers.set('Authorization', `Bearer ${User.data.token}`)
|
|
13
|
-
init.headers = headers
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// 跨域请求携带 cookie (无需)
|
|
17
|
-
// init.credentials = 'include'
|
|
18
|
-
|
|
19
|
-
// 请求操作
|
|
20
|
-
const resp = await timeoutFetch(input, timeout || opts.timeout || 15000, init)
|
|
21
|
-
|
|
22
|
-
const respHttpCode = resp.status
|
|
23
|
-
const noAccessCodes = [401, 400]
|
|
24
|
-
const isNoAccess = noAccessCodes.includes(respHttpCode)
|
|
25
|
-
|
|
26
|
-
if (!resp.ok && !isNoAccess)
|
|
27
|
-
throw new Error(`${$t('reqGot')} ${respHttpCode}`)
|
|
28
|
-
|
|
29
|
-
// 解析获取响应的 json
|
|
30
|
-
let json: any = await resp.json()
|
|
31
|
-
|
|
32
|
-
// 重新发起请求
|
|
33
|
-
const recall = (resolve, reject) => {
|
|
34
|
-
Fetch(opts, input, init)
|
|
35
|
-
.then(d => { resolve(d) })
|
|
36
|
-
.catch(e => { reject(e) })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// 请求弹出层验证
|
|
40
|
-
if (json.data?.need_captcha) {
|
|
41
|
-
// 请求需要验证码
|
|
42
|
-
json = await (new Promise<any>((resolve, reject) => {
|
|
43
|
-
opts.onNeedCheckCaptcha && opts.onNeedCheckCaptcha({
|
|
44
|
-
data: { imgData: json.data.img_data, iframe: json.data.iframe },
|
|
45
|
-
recall: () => { recall(resolve, reject) },
|
|
46
|
-
reject: () => { reject(json) }
|
|
47
|
-
})
|
|
48
|
-
}))
|
|
49
|
-
} else if (json.data?.need_login || isNoAccess) {
|
|
50
|
-
// 请求需要管理员权限
|
|
51
|
-
json = await (new Promise<any>((resolve, reject) => {
|
|
52
|
-
opts.onNeedCheckAdmin && opts.onNeedCheckAdmin({
|
|
53
|
-
recall: () => { recall(resolve, reject) },
|
|
54
|
-
reject: () => { reject(json) }
|
|
55
|
-
})
|
|
56
|
-
}))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!json.success) throw json // throw 相当于 reject(json)
|
|
60
|
-
|
|
61
|
-
return json
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** 公共 POST 请求 */
|
|
65
|
-
export async function POST<T>(opts: ApiOptions, url: string, data?: {[key: string]: any}) {
|
|
66
|
-
const init: RequestInit = {
|
|
67
|
-
method: 'POST',
|
|
68
|
-
}
|
|
69
|
-
data = { site_name: opts.siteName || '', ...(data || {}) } // 总是携带 site_name
|
|
70
|
-
init.body = ToFormData(data)
|
|
71
|
-
|
|
72
|
-
const json = await Fetch(opts, url, init)
|
|
73
|
-
return ((json.data || {}) as T)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** 公共 GET 请求 (无 GET 方式 API) */
|
|
77
|
-
// export async function GET<T>(opts: ApiOptions, url: string, data?: {[key: string]: any}) {
|
|
78
|
-
// const json = await Fetch(opts, url + (data ? (`?${new URLSearchParams(data)}`) : ''), {
|
|
79
|
-
// method: 'GET',
|
|
80
|
-
// })
|
|
81
|
-
// return ((json.data || {}) as T)
|
|
82
|
-
// }
|
|
83
|
-
|
|
84
|
-
/** 对象转 FormData */
|
|
85
|
-
export function ToFormData(object: {[key: string]: any}): FormData {
|
|
86
|
-
const formData = new FormData()
|
|
87
|
-
Object.keys(object).forEach(key => formData.append(key, String(object[key])))
|
|
88
|
-
return formData
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** 我靠,fetch 一个 timeout,都要丑陋的实现 */
|
|
92
|
-
function timeoutFetch(url: RequestInfo, ms: number, opts: RequestInit) {
|
|
93
|
-
const controller = new AbortController()
|
|
94
|
-
opts.signal?.addEventListener('abort', () => controller.abort()) // 保留原有 signal 功能
|
|
95
|
-
let promise = fetch(url, { ...opts, signal: controller.signal })
|
|
96
|
-
if (ms > 0) {
|
|
97
|
-
const timer = setTimeout(() => controller.abort(), ms)
|
|
98
|
-
promise.finally(() => { clearTimeout(timer) })
|
|
99
|
-
}
|
|
100
|
-
promise = promise.catch((err) => {
|
|
101
|
-
throw ((err || {}).name === 'AbortError') ? new Error($t('reqAborted')) : err
|
|
102
|
-
})
|
|
103
|
-
return promise
|
|
104
|
-
}
|
package/src/api/admin.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import ApiBase from './_base'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 管理员 API
|
|
5
|
-
*/
|
|
6
|
-
export default class AdminApi extends ApiBase {
|
|
7
|
-
/** 缓存清除 */
|
|
8
|
-
public cacheFlushAll() {
|
|
9
|
-
const params: any = { flush_all: true }
|
|
10
|
-
return this.POST('/admin/cache-flush', params)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** 缓存预热 */
|
|
14
|
-
public cacheWarmUp() {
|
|
15
|
-
const params: any = {}
|
|
16
|
-
return this.POST('/admin/cache-warm', params)
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/api/captcha.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import ApiBase from './_base'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 验证码 API
|
|
5
|
-
*/
|
|
6
|
-
export default class CaptchaApi extends ApiBase {
|
|
7
|
-
/** 验证码 · 获取 */
|
|
8
|
-
public async captchaGet() {
|
|
9
|
-
const data = await this.POST<any>('/captcha/refresh')
|
|
10
|
-
return (data.img_data || '') as string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** 验证码 · 检验 */
|
|
14
|
-
public async captchaCheck(value: string) {
|
|
15
|
-
const data = await this.POST<any>('/captcha/check', { value })
|
|
16
|
-
return (data.img_data || '') as string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** 验证码 · 状态 */
|
|
20
|
-
public async captchaStatus() {
|
|
21
|
-
const data = await this.POST<any>('/captcha/status')
|
|
22
|
-
return (data || { is_pass: false }) as { is_pass: boolean }
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/api/comment.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { CommentData, ListData } from '~/types'
|
|
2
|
-
import * as Utils from '../lib/utils'
|
|
3
|
-
import ApiBase from './_base'
|
|
4
|
-
import User from '../lib/user'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 评论 API
|
|
8
|
-
*/
|
|
9
|
-
export default class CommentApi extends ApiBase {
|
|
10
|
-
/** 评论 · 获取 */
|
|
11
|
-
public get(offset: number, pageSize: number, flatMode?: boolean, paramsEditor?: (params: any) => void) {
|
|
12
|
-
const params: any = {
|
|
13
|
-
page_key: this.options.pageKey,
|
|
14
|
-
site_name: this.options.siteName,
|
|
15
|
-
limit: pageSize,
|
|
16
|
-
offset,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (flatMode) params.flat_mode = flatMode // 平铺模式
|
|
20
|
-
if (User.checkHasBasicUserInfo()) {
|
|
21
|
-
params.name = User.data.nick
|
|
22
|
-
params.email = User.data.email
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (paramsEditor) paramsEditor(params)
|
|
26
|
-
|
|
27
|
-
return this.POST<ListData>('/get', params)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** 评论 · 创建 */
|
|
31
|
-
public async add(comment: { nick: string, email: string, link: string, content: string, rid: number, page_key: string, page_title?: string, site_name?: string }) {
|
|
32
|
-
const params: any = {
|
|
33
|
-
name: comment.nick,
|
|
34
|
-
email: comment.email,
|
|
35
|
-
link: comment.link,
|
|
36
|
-
content: comment.content,
|
|
37
|
-
rid: comment.rid,
|
|
38
|
-
page_key: comment.page_key,
|
|
39
|
-
ua: await Utils.getCorrectUserAgent(), // 需要后端支持,获取修正后的 UA
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (comment.page_title) params.page_title = comment.page_title
|
|
43
|
-
if (comment.site_name) params.site_name = comment.site_name
|
|
44
|
-
|
|
45
|
-
const data = await this.POST<any>('/add', params)
|
|
46
|
-
return (data.comment as CommentData)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** 评论 · 修改 */
|
|
50
|
-
public async commentEdit(data: Partial<CommentData>) {
|
|
51
|
-
const params: any = {
|
|
52
|
-
...data,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const d = await this.POST<any>('/admin/comment-edit', params)
|
|
56
|
-
return (d.comment as CommentData)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 评论 · 删除 */
|
|
60
|
-
public commentDel(commentID: number, siteName?: string) {
|
|
61
|
-
const params: any = {
|
|
62
|
-
id: String(commentID),
|
|
63
|
-
site_name: siteName || '',
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return this.POST('/admin/comment-del', params)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** 投票 */
|
|
70
|
-
public async vote(targetID: number, type: string) {
|
|
71
|
-
const params: any = {
|
|
72
|
-
target_id: targetID,
|
|
73
|
-
type,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (User.checkHasBasicUserInfo()) {
|
|
77
|
-
params.name = User.data.nick
|
|
78
|
-
params.email = User.data.email
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const data = await this.POST<any>('/vote', params)
|
|
82
|
-
return (data as {up: number, down: number})
|
|
83
|
-
}
|
|
84
|
-
}
|
package/src/api/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ApiOptions } from './_options'
|
|
2
|
-
import comment from './comment'
|
|
3
|
-
import page from './page'
|
|
4
|
-
import site from './site'
|
|
5
|
-
import user from './user'
|
|
6
|
-
import system from './system'
|
|
7
|
-
import captcha from './captcha'
|
|
8
|
-
import admin from './admin'
|
|
9
|
-
import upload from './upload'
|
|
10
|
-
|
|
11
|
-
const ApiComponents = {
|
|
12
|
-
comment, page, site,
|
|
13
|
-
user, system, captcha,
|
|
14
|
-
admin, upload
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class Api {
|
|
18
|
-
constructor (opts: ApiOptions) {
|
|
19
|
-
Object.entries(ApiComponents).forEach(([key, ApiComponent]) => {
|
|
20
|
-
this[key] = new ApiComponent(opts)
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type TC = typeof ApiComponents
|
|
26
|
-
type AC = { [K in keyof TC]: InstanceType<TC[K]> }
|
|
27
|
-
interface Api extends AC {}
|
|
28
|
-
|
|
29
|
-
export default Api
|