artalk 2.7.1 → 2.7.3

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.
Files changed (305) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/Artalk.cjs +2 -0
  4. package/dist/Artalk.cjs.map +1 -0
  5. package/dist/Artalk.css +1 -1
  6. package/dist/Artalk.iife.js +1 -1
  7. package/dist/Artalk.iife.js.map +1 -1
  8. package/dist/Artalk.js +1 -1
  9. package/dist/Artalk.js.map +1 -1
  10. package/dist/{Artalk.es.js → Artalk.mjs} +250 -222
  11. package/dist/Artalk.mjs.map +1 -0
  12. package/dist/ArtalkLite.cjs +2 -0
  13. package/dist/ArtalkLite.cjs.map +1 -0
  14. package/dist/ArtalkLite.css +1 -1
  15. package/dist/ArtalkLite.iife.js +1 -1
  16. package/dist/ArtalkLite.iife.js.map +1 -1
  17. package/dist/ArtalkLite.js +1 -1
  18. package/dist/ArtalkLite.js.map +1 -1
  19. package/dist/{ArtalkLite.es.js → ArtalkLite.mjs} +250 -227
  20. package/dist/ArtalkLite.mjs.map +1 -0
  21. package/dist/i18n/jp.cjs +1 -0
  22. package/dist/i18n/jp.d.cts +3 -0
  23. package/dist/i18n/jp.d.ts +3 -0
  24. package/dist/i18n/jp.js +1 -1
  25. package/dist/i18n/jp.mjs +93 -0
  26. package/dist/i18n/zh-TW.cjs +1 -0
  27. package/dist/i18n/zh-TW.d.cts +3 -0
  28. package/dist/i18n/zh-TW.d.ts +3 -0
  29. package/dist/i18n/zh-TW.js +1 -1
  30. package/dist/i18n/zh-TW.mjs +93 -0
  31. package/dist/main.d.cts +1476 -0
  32. package/dist/main.d.ts +1476 -0
  33. package/package.json +80 -22
  34. package/dist/Artalk.es.js.map +0 -1
  35. package/dist/ArtalkLite.es.js.map +0 -1
  36. package/dist/src/api/_base.d.ts +0 -10
  37. package/dist/src/api/_options.d.ts +0 -19
  38. package/dist/src/api/_request.d.ts +0 -12
  39. package/dist/src/api/admin.d.ts +0 -10
  40. package/dist/src/api/captcha.d.ts +0 -14
  41. package/dist/src/api/comment.d.ts +0 -29
  42. package/dist/src/api/index.d.ts +0 -29
  43. package/dist/src/api/page.d.ts +0 -22
  44. package/dist/src/api/site.d.ts +0 -17
  45. package/dist/src/api/system.d.ts +0 -33
  46. package/dist/src/api/upload.d.ts +0 -11
  47. package/dist/src/api/user.d.ts +0 -42
  48. package/dist/src/artalk.d.ts +0 -35
  49. package/dist/src/comment/actions.d.ts +0 -17
  50. package/dist/src/comment/comment.d.ts +0 -66
  51. package/dist/src/comment/height-limit.d.ts +0 -30
  52. package/dist/src/comment/index.d.ts +0 -2
  53. package/dist/src/comment/render.d.ts +0 -46
  54. package/dist/src/comment/renders/actions.d.ts +0 -5
  55. package/dist/src/comment/renders/avatar.d.ts +0 -5
  56. package/dist/src/comment/renders/content.d.ts +0 -5
  57. package/dist/src/comment/renders/header.d.ts +0 -5
  58. package/dist/src/comment/renders/index.d.ts +0 -2
  59. package/dist/src/comment/renders/pending.d.ts +0 -5
  60. package/dist/src/comment/renders/reply-at.d.ts +0 -5
  61. package/dist/src/comment/renders/reply-to.d.ts +0 -5
  62. package/dist/src/components/action-btn.d.ts +0 -50
  63. package/dist/src/components/checker/admin.d.ts +0 -3
  64. package/dist/src/components/checker/captcha-renders.d.ts +0 -5
  65. package/dist/src/components/checker/captcha.d.ts +0 -3
  66. package/dist/src/components/checker/index.d.ts +0 -51
  67. package/dist/src/components/dark-mode.d.ts +0 -2
  68. package/dist/src/components/dialog.d.ts +0 -16
  69. package/dist/src/components/error-dialog.d.ts +0 -8
  70. package/dist/src/components/pagination.d.ts +0 -31
  71. package/dist/src/components/read-more-btn.d.ts +0 -33
  72. package/dist/src/config.d.ts +0 -24
  73. package/dist/src/context.d.ts +0 -45
  74. package/dist/src/data.d.ts +0 -27
  75. package/dist/src/defaults.d.ts +0 -3
  76. package/dist/src/editor/editor.d.ts +0 -31
  77. package/dist/src/editor/state.d.ts +0 -20
  78. package/dist/src/editor/ui.d.ts +0 -25
  79. package/dist/src/i18n/en.d.ts +0 -72
  80. package/dist/src/i18n/external.d.ts +0 -73
  81. package/dist/src/i18n/index.d.ts +0 -233
  82. package/dist/src/i18n/jp.d.ts +0 -72
  83. package/dist/src/i18n/zh-CN.d.ts +0 -3
  84. package/dist/src/i18n/zh-TW.d.ts +0 -72
  85. package/dist/src/layer/index.d.ts +0 -4
  86. package/dist/src/layer/layer-manager.d.ts +0 -9
  87. package/dist/src/layer/layer.d.ts +0 -12
  88. package/dist/src/layer/scrollbar-helper.d.ts +0 -5
  89. package/dist/src/layer/sidebar-layer.d.ts +0 -20
  90. package/dist/src/layer/wrap.d.ts +0 -13
  91. package/dist/src/lib/component.d.ts +0 -7
  92. package/dist/src/lib/detect.d.ts +0 -10
  93. package/dist/src/lib/event-manager.d.ts +0 -28
  94. package/dist/src/lib/highlight.d.ts +0 -1
  95. package/dist/src/lib/marked-renderer.d.ts +0 -4
  96. package/dist/src/lib/marked.d.ts +0 -11
  97. package/dist/src/lib/sanitizer.d.ts +0 -1
  98. package/dist/src/lib/ui.d.ts +0 -24
  99. package/dist/src/lib/user.d.ts +0 -19
  100. package/dist/src/lib/utils.d.ts +0 -41
  101. package/dist/src/list/comment.d.ts +0 -3
  102. package/dist/src/list/layout.d.ts +0 -23
  103. package/dist/src/list/list.d.ts +0 -14
  104. package/dist/src/list/nest.d.ts +0 -10
  105. package/dist/src/list/page.d.ts +0 -2
  106. package/dist/src/list/paginator/index.d.ts +0 -25
  107. package/dist/src/list/paginator/read-more.d.ts +0 -18
  108. package/dist/src/list/paginator/up-down.d.ts +0 -14
  109. package/dist/src/main.d.ts +0 -7
  110. package/dist/src/plugins/admin-only-elem.d.ts +0 -2
  111. package/dist/src/plugins/conf-remoter.d.ts +0 -2
  112. package/dist/src/plugins/dark-mode.d.ts +0 -2
  113. package/dist/src/plugins/editor/_kit.d.ts +0 -27
  114. package/dist/src/plugins/editor/_plug.d.ts +0 -29
  115. package/dist/src/plugins/editor/_sample.d.ts +0 -5
  116. package/dist/src/plugins/editor/closable.d.ts +0 -7
  117. package/dist/src/plugins/editor/emoticons.d.ts +0 -30
  118. package/dist/src/plugins/editor/header-event.d.ts +0 -6
  119. package/dist/src/plugins/editor/header-link.d.ts +0 -6
  120. package/dist/src/plugins/editor/header-user.d.ts +0 -16
  121. package/dist/src/plugins/editor/index.d.ts +0 -6
  122. package/dist/src/plugins/editor/local-storage.d.ts +0 -6
  123. package/dist/src/plugins/editor/mover.d.ts +0 -6
  124. package/dist/src/plugins/editor/preview.d.ts +0 -7
  125. package/dist/src/plugins/editor/state-edit.d.ts +0 -11
  126. package/dist/src/plugins/editor/state-reply.d.ts +0 -8
  127. package/dist/src/plugins/editor/submit-add.d.ts +0 -18
  128. package/dist/src/plugins/editor/submit-btn.d.ts +0 -5
  129. package/dist/src/plugins/editor/submit.d.ts +0 -17
  130. package/dist/src/plugins/editor/textarea.d.ts +0 -8
  131. package/dist/src/plugins/editor/upload.d.ts +0 -9
  132. package/dist/src/plugins/editor-kit.d.ts +0 -42
  133. package/dist/src/plugins/index.d.ts +0 -2
  134. package/dist/src/plugins/list/copyright.d.ts +0 -2
  135. package/dist/src/plugins/list/count.d.ts +0 -2
  136. package/dist/src/plugins/list/dropdown.d.ts +0 -2
  137. package/dist/src/plugins/list/error-dialog.d.ts +0 -2
  138. package/dist/src/plugins/list/fetch.d.ts +0 -2
  139. package/dist/src/plugins/list/goto-first.d.ts +0 -3
  140. package/dist/src/plugins/list/goto.d.ts +0 -2
  141. package/dist/src/plugins/list/index.d.ts +0 -3
  142. package/dist/src/plugins/list/loading.d.ts +0 -2
  143. package/dist/src/plugins/list/no-comment.d.ts +0 -2
  144. package/dist/src/plugins/list/reach-bottom.d.ts +0 -2
  145. package/dist/src/plugins/list/sidebar-btn.d.ts +0 -2
  146. package/dist/src/plugins/list/time-ticking.d.ts +0 -3
  147. package/dist/src/plugins/list/unread-badge.d.ts +0 -2
  148. package/dist/src/plugins/list/unread.d.ts +0 -2
  149. package/dist/src/plugins/list/with-editor.d.ts +0 -2
  150. package/dist/src/plugins/markdown.d.ts +0 -2
  151. package/dist/src/plugins/stat.d.ts +0 -13
  152. package/dist/src/plugins/version-check.d.ts +0 -2
  153. package/dist/src/service.d.ts +0 -42
  154. package/dist/tests/e2e/comment-add.spec.d.ts +0 -1
  155. package/dist/types/config.d.ts +0 -110
  156. package/dist/types/context.d.ts +0 -62
  157. package/dist/types/data.d.ts +0 -194
  158. package/dist/types/editor.d.ts +0 -76
  159. package/dist/types/event.d.ts +0 -39
  160. package/dist/types/global.d.ts +0 -1
  161. package/dist/types/index.d.ts +0 -7
  162. package/dist/types/plugin.d.ts +0 -2
  163. package/dist/types/sidebar.d.ts +0 -3
  164. package/src/api/_base.ts +0 -18
  165. package/src/api/_options.ts +0 -25
  166. package/src/api/_request.ts +0 -104
  167. package/src/api/admin.ts +0 -18
  168. package/src/api/captcha.ts +0 -24
  169. package/src/api/comment.ts +0 -84
  170. package/src/api/index.ts +0 -29
  171. package/src/api/page.ts +0 -83
  172. package/src/api/site.ts +0 -51
  173. package/src/api/system.ts +0 -49
  174. package/src/api/upload.ts +0 -28
  175. package/src/api/user.ts +0 -132
  176. package/src/artalk.ts +0 -115
  177. package/src/comment/actions.ts +0 -83
  178. package/src/comment/comment.html +0 -18
  179. package/src/comment/comment.ts +0 -192
  180. package/src/comment/height-limit.ts +0 -100
  181. package/src/comment/index.ts +0 -3
  182. package/src/comment/render.ts +0 -150
  183. package/src/comment/renders/actions.ts +0 -114
  184. package/src/comment/renders/avatar.ts +0 -22
  185. package/src/comment/renders/content.ts +0 -39
  186. package/src/comment/renders/header.ts +0 -84
  187. package/src/comment/renders/index.ts +0 -19
  188. package/src/comment/renders/pending.ts +0 -12
  189. package/src/comment/renders/reply-at.ts +0 -16
  190. package/src/comment/renders/reply-to.ts +0 -24
  191. package/src/components/action-btn.ts +0 -170
  192. package/src/components/checker/admin.ts +0 -37
  193. package/src/components/checker/captcha-renders.ts +0 -69
  194. package/src/components/checker/captcha.ts +0 -26
  195. package/src/components/checker/index.ts +0 -192
  196. package/src/components/dark-mode.ts +0 -30
  197. package/src/components/dialog.ts +0 -62
  198. package/src/components/error-dialog.ts +0 -35
  199. package/src/components/pagination.ts +0 -153
  200. package/src/components/read-more-btn.ts +0 -92
  201. package/src/config.ts +0 -119
  202. package/src/context.ts +0 -146
  203. package/src/data.ts +0 -110
  204. package/src/defaults.ts +0 -61
  205. package/src/editor/editor.html +0 -18
  206. package/src/editor/editor.ts +0 -114
  207. package/src/editor/state.ts +0 -52
  208. package/src/editor/ui.ts +0 -36
  209. package/src/i18n/en.ts +0 -84
  210. package/src/i18n/external.ts +0 -10
  211. package/src/i18n/index.ts +0 -67
  212. package/src/i18n/jp.ts +0 -86
  213. package/src/i18n/zh-CN.ts +0 -88
  214. package/src/i18n/zh-TW.ts +0 -86
  215. package/src/layer/index.ts +0 -4
  216. package/src/layer/layer-manager.ts +0 -32
  217. package/src/layer/layer.ts +0 -39
  218. package/src/layer/scrollbar-helper.ts +0 -24
  219. package/src/layer/sidebar-layer.html +0 -8
  220. package/src/layer/sidebar-layer.ts +0 -155
  221. package/src/layer/wrap.ts +0 -77
  222. package/src/lib/component.ts +0 -12
  223. package/src/lib/detect.ts +0 -222
  224. package/src/lib/event-manager.ts +0 -47
  225. package/src/lib/highlight.ts +0 -5
  226. package/src/lib/marked-renderer.ts +0 -32
  227. package/src/lib/marked.ts +0 -72
  228. package/src/lib/sanitizer.ts +0 -57
  229. package/src/lib/ui.ts +0 -193
  230. package/src/lib/user.ts +0 -55
  231. package/src/lib/utils.ts +0 -236
  232. package/src/list/comment.ts +0 -20
  233. package/src/list/layout.ts +0 -120
  234. package/src/list/list.html +0 -20
  235. package/src/list/list.ts +0 -79
  236. package/src/list/nest.ts +0 -66
  237. package/src/list/page.ts +0 -97
  238. package/src/list/paginator/index.ts +0 -25
  239. package/src/list/paginator/read-more.ts +0 -67
  240. package/src/list/paginator/up-down.ts +0 -51
  241. package/src/main.ts +0 -14
  242. package/src/plugins/admin-only-elem.ts +0 -40
  243. package/src/plugins/conf-remoter.ts +0 -54
  244. package/src/plugins/dark-mode.ts +0 -12
  245. package/src/plugins/editor/_kit.ts +0 -57
  246. package/src/plugins/editor/_plug.ts +0 -60
  247. package/src/plugins/editor/_sample.ts +0 -8
  248. package/src/plugins/editor/closable.ts +0 -44
  249. package/src/plugins/editor/emoticons.scss +0 -72
  250. package/src/plugins/editor/emoticons.ts +0 -293
  251. package/src/plugins/editor/header-event.ts +0 -35
  252. package/src/plugins/editor/header-link.ts +0 -31
  253. package/src/plugins/editor/header-user.ts +0 -98
  254. package/src/plugins/editor/index.ts +0 -40
  255. package/src/plugins/editor/local-storage.ts +0 -36
  256. package/src/plugins/editor/mover.ts +0 -29
  257. package/src/plugins/editor/preview.scss +0 -7
  258. package/src/plugins/editor/preview.ts +0 -41
  259. package/src/plugins/editor/state-edit.ts +0 -116
  260. package/src/plugins/editor/state-reply.ts +0 -91
  261. package/src/plugins/editor/submit-add.ts +0 -33
  262. package/src/plugins/editor/submit-btn.ts +0 -25
  263. package/src/plugins/editor/submit.ts +0 -73
  264. package/src/plugins/editor/textarea.ts +0 -55
  265. package/src/plugins/editor/upload.ts +0 -145
  266. package/src/plugins/editor-kit.ts +0 -161
  267. package/src/plugins/index.ts +0 -16
  268. package/src/plugins/list/copyright.ts +0 -16
  269. package/src/plugins/list/count.ts +0 -31
  270. package/src/plugins/list/dropdown.ts +0 -95
  271. package/src/plugins/list/error-dialog.ts +0 -22
  272. package/src/plugins/list/fetch.ts +0 -64
  273. package/src/plugins/list/goto-first.ts +0 -23
  274. package/src/plugins/list/goto.ts +0 -72
  275. package/src/plugins/list/index.ts +0 -25
  276. package/src/plugins/list/loading.ts +0 -17
  277. package/src/plugins/list/no-comment.ts +0 -25
  278. package/src/plugins/list/reach-bottom.ts +0 -46
  279. package/src/plugins/list/sidebar-btn.ts +0 -39
  280. package/src/plugins/list/time-ticking.ts +0 -22
  281. package/src/plugins/list/unread-badge.ts +0 -26
  282. package/src/plugins/list/unread.ts +0 -38
  283. package/src/plugins/list/with-editor.ts +0 -59
  284. package/src/plugins/markdown.ts +0 -10
  285. package/src/plugins/stat.ts +0 -82
  286. package/src/plugins/version-check.ts +0 -36
  287. package/src/service.ts +0 -91
  288. package/src/style/_color.scss +0 -41
  289. package/src/style/_extend.scss +0 -20
  290. package/src/style/_variables.scss +0 -3
  291. package/src/style/comment.scss +0 -360
  292. package/src/style/editor.scss +0 -194
  293. package/src/style/list.scss +0 -212
  294. package/src/style/main.scss +0 -486
  295. package/src/style/pagination.scss +0 -58
  296. package/src/style/sidebar-layer.scss +0 -92
  297. package/types/config.ts +0 -153
  298. package/types/context.ts +0 -84
  299. package/types/data.ts +0 -271
  300. package/types/editor.ts +0 -95
  301. package/types/event.ts +0 -40
  302. package/types/global.d.ts +0 -1
  303. package/types/index.ts +0 -7
  304. package/types/plugin.ts +0 -3
  305. package/types/sidebar.ts +0 -3
package/src/i18n/zh-TW.ts DELETED
@@ -1,86 +0,0 @@
1
- import { defineLocaleExternal } from './external'
2
-
3
- export default defineLocaleExternal('zh-TW', {
4
- /* Editor */
5
- placeholder: '鍵入內容...',
6
- noComment: '「此時無聲勝有聲」',
7
- send: '發送評論',
8
- save: '保存評論',
9
- nick: '昵稱',
10
- email: '郵箱',
11
- link: '網址',
12
- emoticon: '表情',
13
- preview: '預覽',
14
- image: '圖片',
15
- uploadFail: '上傳失敗',
16
- commentFail: '評論失敗',
17
- restoredMsg: '內容已自動恢復',
18
- onlyAdminCanReply: '僅管理員可評論',
19
- uploadLoginMsg: '填入你的名字郵箱才能上傳哦',
20
-
21
- /* List */
22
- counter: '{count} 條評論',
23
- sortLatest: '最新',
24
- sortOldest: '最早',
25
- sortBest: '最熱',
26
- sortAuthor: '作者',
27
- openComment: '打開評論',
28
- closeComment: '關閉評論',
29
- listLoadFailMsg: '無法獲取評論列表數據',
30
- listRetry: '點擊重新獲取',
31
- loadMore: '加載更多',
32
-
33
- /* Comment */
34
- admin: '管理員',
35
- reply: '回覆',
36
- voteUp: '贊同',
37
- voteDown: '反對',
38
- voteFail: '投票失敗',
39
- readMore: '閱讀更多',
40
- actionConfirm: '確認操作',
41
- collapse: '摺疊',
42
- collapsed: '已摺疊',
43
- collapsedMsg: '該評論已被系統或管理員摺疊',
44
- expand: '展開',
45
- approved: '已審',
46
- pending: '待審',
47
- pendingMsg: '審核中,僅本人可見。',
48
- edit: '編輯',
49
- editCancel: '取消編輯',
50
- delete: '刪除',
51
- deleteConfirm: '確認刪除',
52
- pin: '置頂',
53
- unpin: '取消置頂',
54
-
55
- /* Time */
56
- seconds: '秒前',
57
- minutes: '分鐘前',
58
- hours: '小時前',
59
- days: '天前',
60
- now: '剛剛',
61
-
62
- /* Checker */
63
- adminCheck: '鍵入密碼來驗證管理員身份:',
64
- captchaCheck: '鍵入驗證碼繼續:',
65
- confirm: '確認',
66
- cancel: '取消',
67
-
68
- /* Sidebar */
69
- msgCenter: '通知中心',
70
- ctrlCenter: '控制中心',
71
-
72
- /* General */
73
- frontend: '前端',
74
- backend: '後端',
75
- loading: '加載中',
76
- loadFail: '加載失敗',
77
- editing: '修改中',
78
- editFail: '修改失敗',
79
- deleting: '刪除中',
80
- deleteFail: '刪除失敗',
81
- reqGot: '請求響應',
82
- reqAborted: '請求超時或意外終止',
83
- updateMsg: '請更新 Artalk {name} 以獲得完整體驗',
84
- currentVersion: '當前版本',
85
- ignore: '忽略',
86
- })
@@ -1,4 +0,0 @@
1
- export * from './layer'
2
- export * from './wrap'
3
- export * from './scrollbar-helper'
4
- export * from './layer-manager'
@@ -1,32 +0,0 @@
1
- import type { ContextApi } from '~/types'
2
- import { getScrollbarHelper } from './scrollbar-helper'
3
- import { LayerWrap } from './wrap'
4
- import { Layer } from './layer'
5
-
6
- export class LayerManager {
7
- private wrap: LayerWrap
8
- private ctx: ContextApi
9
-
10
- constructor(ctx: ContextApi) {
11
- this.ctx = ctx
12
-
13
- this.wrap = new LayerWrap()
14
- document.body.appendChild(this.wrap.getWrap())
15
-
16
- ctx.on('destroy', () => {
17
- this.wrap.getWrap().remove()
18
- })
19
-
20
- // 记录页面原始 CSS 属性
21
- getScrollbarHelper().init()
22
- }
23
-
24
- getEl() {
25
- return this.wrap.getWrap()
26
- }
27
-
28
- create(name: string, el?: HTMLElement | undefined) {
29
- const layer = new Layer(this.wrap, name, el)
30
- return layer
31
- }
32
- }
@@ -1,39 +0,0 @@
1
- import type { LayerWrap } from './wrap'
2
-
3
- export class Layer {
4
- private $el: HTMLElement
5
- private wrap: LayerWrap
6
- private onAfterHide?: () => void
7
-
8
- constructor(wrap: LayerWrap, name: string, el?: HTMLElement) {
9
- this.wrap = wrap
10
- this.$el = this.wrap.createItem(name, el)
11
- }
12
-
13
- setOnAfterHide(func: () => void) {
14
- this.onAfterHide = func
15
- }
16
-
17
- getEl() {
18
- return this.$el
19
- }
20
-
21
- show() {
22
- this.$el.style.display = ''
23
- this.wrap.show()
24
- }
25
-
26
- hide() {
27
- this.wrap.hide(() => {
28
- this.$el.style.display = 'none'
29
- this.onAfterHide && this.onAfterHide()
30
- })
31
- }
32
-
33
- destroy() {
34
- this.wrap.hide(() => {
35
- this.$el.remove()
36
- this.onAfterHide && this.onAfterHide()
37
- })
38
- }
39
- }
@@ -1,24 +0,0 @@
1
- import * as Ui from '@/lib/ui'
2
-
3
- let bodyOrgOverflow: string
4
- let bodyOrgPaddingRight: string
5
-
6
- export function getScrollbarHelper() {
7
- return {
8
- init() {
9
- bodyOrgOverflow = document.body.style.overflow
10
- bodyOrgPaddingRight = document.body.style.paddingRight
11
- },
12
-
13
- unlock() {
14
- document.body.style.overflow = bodyOrgOverflow
15
- document.body.style.paddingRight = bodyOrgPaddingRight
16
- },
17
-
18
- lock() {
19
- document.body.style.overflow = 'hidden'
20
- const barPaddingRight = parseInt(window.getComputedStyle(document.body, null).getPropertyValue('padding-right'), 10)
21
- document.body.style.paddingRight = `${Ui.getScrollBarWidth() + barPaddingRight || 0}px`
22
- }
23
- }
24
- }
@@ -1,8 +0,0 @@
1
- <div class="atk-sidebar-layer">
2
- <div class="atk-sidebar-inner">
3
- <div class="atk-sidebar-header">
4
- <div class="atk-sidebar-close"><i class="atk-icon atk-icon-close"></i></div>
5
- </div>
6
- <div class="atk-sidebar-iframe-wrap"></div>
7
- </div>
8
- </div>
@@ -1,155 +0,0 @@
1
- import type { ContextApi, SidebarShowPayload } from '~/types'
2
- import Component from '@/lib/component'
3
- import * as Utils from '@/lib/utils'
4
- import * as Ui from '@/lib/ui'
5
- import SidebarHTML from './sidebar-layer.html?raw'
6
- import User from '../lib/user'
7
- import type { Layer } from './layer'
8
-
9
- export default class SidebarLayer extends Component {
10
- public layer?: Layer
11
- public $header: HTMLElement
12
- public $closeBtn: HTMLElement
13
- public $iframeWrap: HTMLElement
14
- public $iframe?: HTMLIFrameElement
15
-
16
- constructor(ctx: ContextApi) {
17
- super(ctx)
18
-
19
- this.$el = Utils.createElement(SidebarHTML)
20
- this.$header = this.$el.querySelector('.atk-sidebar-header')!
21
- this.$closeBtn = this.$header.querySelector('.atk-sidebar-close')!
22
- this.$iframeWrap = this.$el.querySelector('.atk-sidebar-iframe-wrap')!
23
-
24
- this.$closeBtn.onclick = () => {
25
- this.hide()
26
- }
27
-
28
- // event
29
- this.ctx.on('user-changed', () => { this.firstShow = true })
30
- }
31
-
32
- private firstShow = true
33
-
34
- /** 显示 */
35
- public async show(conf: SidebarShowPayload = {}) {
36
- this.$el.style.transform = '' // 动画清除,防止二次打开失效
37
-
38
- // 获取 Layer
39
- this.initLayer()
40
- this.layer!.show()
41
-
42
- // 管理员身份验证 (若身份失效,弹出验证窗口)
43
- this.authCheck({
44
- onSuccess: () => this.show(conf) // retry show after auth check
45
- })
46
-
47
- // 第一次加载
48
- if (this.firstShow) {
49
- this.$iframeWrap.innerHTML = ''
50
- this.$iframe = this.createIframe(conf.view)
51
- this.$iframeWrap.append(this.$iframe)
52
- this.firstShow = false
53
- } else {
54
- const $iframe = this.$iframe!
55
-
56
- // 夜间模式
57
- const isIframeSrcDarkMode = $iframe.src.includes('darkMode=1')
58
-
59
- if (this.conf.darkMode && !isIframeSrcDarkMode)
60
- this.iframeLoad($iframe, `${this.$iframe!.src}&darkMode=1`)
61
-
62
- if (!this.conf.darkMode && isIframeSrcDarkMode)
63
- this.iframeLoad($iframe, this.$iframe!.src.replace('&darkMode=1', ''))
64
- }
65
-
66
- // 执行滑动显示动画
67
- setTimeout(() => {
68
- this.$el.style.transform = 'translate(0, 0)'
69
- }, 100)
70
-
71
- // 清空 unread
72
- setTimeout(() => {
73
- this.ctx.getData().updateUnreads([])
74
- }, 0)
75
-
76
- this.ctx.trigger('sidebar-show')
77
- }
78
-
79
- /** 隐藏 */
80
- public hide() {
81
- // 执行动画
82
- this.$el.style.transform = ''
83
-
84
- this.layer?.hide()
85
-
86
- this.ctx.trigger('sidebar-hide')
87
- }
88
-
89
- // --------------------------------------------------
90
-
91
- private async authCheck(opts: { onSuccess: () => void }) {
92
- const resp = await this.ctx.getApi().user.loginStatus()
93
- if (resp.is_admin && !resp.is_login) {
94
- this.firstShow = true
95
-
96
- this.ctx.checkAdmin({
97
- onSuccess: () => {
98
- setTimeout(() => {
99
- opts.onSuccess()
100
- }, 500)
101
- },
102
- onCancel: () => {
103
- this.hide()
104
- }
105
- })
106
- }
107
- }
108
-
109
- private initLayer() {
110
- if (this.layer) return
111
-
112
- this.layer = this.ctx.get('layerManager').create('sidebar', this.$el)
113
- this.layer.setOnAfterHide(() => {
114
- // 防止评论框被吞
115
- this.ctx.editorResetState()
116
- })
117
- }
118
-
119
- private createIframe(view?: string) {
120
- const $iframe = Utils.createElement<HTMLIFrameElement>('<iframe></iframe>')
121
-
122
- // 准备 Iframe 参数
123
- const baseURL = (import.meta.env.DEV) ? 'http://localhost:23367/'
124
- : Utils.getURLBasedOnApi({
125
- base: this.ctx.conf.server,
126
- path: '/sidebar/',
127
- })
128
-
129
- const query: any = {
130
- pageKey: this.conf.pageKey,
131
- site: this.conf.site || '',
132
- user: JSON.stringify(User.data),
133
- time: +new Date()
134
- }
135
-
136
- if (view) query.view = view
137
- if (this.conf.darkMode) query.darkMode = '1'
138
- if (typeof this.conf.locale === 'string') query.locale = this.conf.locale
139
-
140
- const urlParams = new URLSearchParams(query);
141
- this.iframeLoad($iframe, `${baseURL}?${urlParams.toString()}`)
142
-
143
- return $iframe
144
- }
145
-
146
- private iframeLoad($iframe: HTMLIFrameElement, src: string) {
147
- $iframe.src = src
148
-
149
- // 加载动画
150
- Ui.showLoading(this.$iframeWrap)
151
- $iframe.onload = () => {
152
- Ui.hideLoading(this.$iframeWrap)
153
- }
154
- }
155
- }
package/src/layer/wrap.ts DELETED
@@ -1,77 +0,0 @@
1
- import * as Utils from '@/lib/utils'
2
- import { getScrollbarHelper } from './scrollbar-helper'
3
-
4
- export class LayerWrap {
5
- private $wrap: HTMLElement
6
- private $mask: HTMLElement
7
- private allowMaskClose: boolean = true
8
- private items: HTMLElement[] = []
9
-
10
- constructor() {
11
- this.$wrap = Utils.createElement(
12
- `<div class="atk-layer-wrap" style="display: none;"><div class="atk-layer-mask"></div></div>`
13
- )
14
- this.$mask = this.$wrap.querySelector<HTMLElement>('.atk-layer-mask')!
15
- }
16
-
17
- createItem(name: string, el?: HTMLElement) {
18
- if (!el) {
19
- el = document.createElement('div')
20
- el.classList.add('atk-layer-item')
21
- el.setAttribute('data-layer-name', name)
22
- el.style.display = 'none'
23
- }
24
- this.$wrap.appendChild(el)
25
- this.items.push(el)
26
- return el
27
- }
28
-
29
- getWrap() {
30
- return this.$wrap
31
- }
32
-
33
- getMask() {
34
- return this.$mask
35
- }
36
-
37
- setMaskClose(enabled: boolean) {
38
- this.allowMaskClose = enabled
39
- }
40
-
41
- show() {
42
- this.$wrap.style.display = 'block'
43
- this.$mask.style.display = 'block'
44
- this.$mask.classList.add('atk-fade-in')
45
- this.$mask.onclick = () => {
46
- if (this.allowMaskClose) this.hide()
47
- }
48
- getScrollbarHelper().lock()
49
- }
50
-
51
- hide(callback?: () => void) {
52
- // if wrap contains more than one item, do not hide entire wrap
53
- if (this.items.filter(e => e.isConnected && e.style.display !== 'none').length > 1) {
54
- callback && callback()
55
- return
56
- }
57
-
58
- const onAfterHide = () => {
59
- this.$wrap.style.display = 'none'
60
- this.$wrap.classList.remove('atk-fade-out')
61
-
62
- callback && callback()
63
-
64
- getScrollbarHelper().unlock()
65
-
66
- this.$wrap.onanimationend = null
67
- }
68
-
69
- // perform animation
70
- this.$wrap.classList.add('atk-fade-out')
71
- if (window.getComputedStyle(this.$wrap)['animation-name'] !== 'none') {
72
- this.$wrap.onanimationend = () => onAfterHide()
73
- } else {
74
- onAfterHide()
75
- }
76
- }
77
- }
@@ -1,12 +0,0 @@
1
- import type { ArtalkConfig, ContextApi } from '~/types'
2
-
3
- export default abstract class Component {
4
- public $el!: HTMLElement
5
- public readonly conf: ArtalkConfig
6
-
7
- public constructor(
8
- public ctx: ContextApi
9
- ) {
10
- this.conf = ctx.conf
11
- }
12
- }
package/src/lib/detect.ts DELETED
@@ -1,222 +0,0 @@
1
- const win = (window as any) || {}
2
- const nav = navigator || {}
3
-
4
- function Detect(userAgent?: string) {
5
- const u = String(userAgent || nav.userAgent)
6
- const dest = {
7
- os: '',
8
- osVersion: '',
9
- engine: '',
10
- browser: '',
11
- device: '',
12
- language: '',
13
- version: ''
14
- }
15
-
16
- // 内核
17
- const engineMatch = {
18
- Trident: u.includes('Trident') || u.includes('NET CLR'),
19
- Presto: u.includes('Presto'),
20
- WebKit: u.includes('AppleWebKit'),
21
- Gecko: u.includes('Gecko/')
22
- }
23
-
24
- // 浏览器
25
- const browserMatch = {
26
- Safari: u.includes('Safari'),
27
- Chrome: u.includes('Chrome') || u.includes('CriOS'),
28
- IE: u.includes('MSIE') || u.includes('Trident'),
29
- Edge: u.includes('Edge') || u.includes('Edg'),
30
- Firefox: u.includes('Firefox') || u.includes('FxiOS'),
31
- 'Firefox Focus': u.includes('Focus'),
32
- Chromium: u.includes('Chromium'),
33
- Opera: u.includes('Opera') || u.includes('OPR'),
34
- Vivaldi: u.includes('Vivaldi'),
35
- Yandex: u.includes('YaBrowser'),
36
- Kindle: u.includes('Kindle') || u.includes('Silk/'),
37
- 360: u.includes('360EE') || u.includes('360SE'),
38
- UC: u.includes('UC') || u.includes(' UBrowser'),
39
- QQBrowser: u.includes('QQBrowser'),
40
- QQ: u.includes('QQ/'),
41
- Baidu: u.includes('Baidu') || u.includes('BIDUBrowser'),
42
- Maxthon: u.includes('Maxthon'),
43
- Sogou: u.includes('MetaSr') || u.includes('Sogou'),
44
- LBBROWSER: u.includes('LBBROWSER'),
45
- '2345Explorer': u.includes('2345Explorer'),
46
- TheWorld: u.includes('TheWorld'),
47
- MIUI: u.includes('MiuiBrowser'),
48
- Quark: u.includes('Quark'),
49
- Qiyu: u.includes('Qiyu'),
50
- Wechat: u.includes('MicroMessenger'),
51
- Taobao: u.includes('AliApp(TB'),
52
- Alipay: u.includes('AliApp(AP'),
53
- Weibo: u.includes('Weibo'),
54
- Douban: u.includes('com.douban.frodo'),
55
- Suning: u.includes('SNEBUY-APP'),
56
- iQiYi: u.includes('IqiyiApp'),
57
- }
58
-
59
- // 系统或平台
60
- const osMatch = {
61
- Windows: u.includes('Windows'),
62
- Linux: u.includes('Linux') || u.includes('X11'),
63
- 'macOS': u.includes('Macintosh'),
64
- Android: u.includes('Android') || u.includes('Adr'),
65
- Ubuntu: u.includes('Ubuntu'),
66
- FreeBSD: u.includes('FreeBSD'),
67
- Debian: u.includes('Debian'),
68
- 'Windows Phone': u.includes('IEMobile') || u.includes('Windows Phone'),
69
- BlackBerry: u.includes('BlackBerry') || u.includes('RIM'),
70
- MeeGo: u.includes('MeeGo'),
71
- Symbian: u.includes('Symbian'),
72
- iOS: u.includes('like Mac OS X'),
73
- 'Chrome OS': u.includes('CrOS'),
74
- WebOS: u.includes('hpwOS'),
75
- }
76
-
77
- // 设备
78
- const deviceMatch = {
79
- Mobile: u.includes('Mobi') || u.includes('iPh') || u.includes('480'),
80
- Tablet: u.includes('Tablet') || u.includes('Pad') || u.includes('Nexus 7')
81
- }
82
-
83
- // 修正
84
- if (deviceMatch.Mobile) {
85
- deviceMatch.Mobile = !(u.includes('iPad'))
86
- } else if (browserMatch.Chrome && u.includes('Edg')) {
87
- // Chrome 内核的 Edge
88
- browserMatch.Chrome = false
89
- browserMatch.Edge = true
90
- } else if (win.showModalDialog && win.chrome) {
91
- browserMatch.Chrome = false
92
- browserMatch['360'] = true
93
- }
94
-
95
- // 默认设备
96
- dest.device = 'PC'
97
-
98
- // 语言
99
- dest.language = (() => {
100
- const g = ((nav as any).browserLanguage || nav.language)
101
- const arr = g.split('-')
102
- if (arr[1]) arr[1] = arr[1].toUpperCase()
103
- return arr.join('_')
104
- })()
105
-
106
- // 应用判断数据
107
- const hash = {
108
- engine: engineMatch,
109
- browser: browserMatch,
110
- os: osMatch,
111
- device: deviceMatch,
112
- }
113
- Object.entries(hash).forEach(([type, match]) => {
114
- Object.entries(match).forEach(([name, result]) => {
115
- if (result === true) dest[type] = name
116
- })
117
- })
118
-
119
- // 系统版本信息
120
- const osVersion = {
121
- Windows: () => {
122
- const v = u.replace(/^.*Windows NT ([\d.]+);.*$/, '$1')
123
- const wvHash = {
124
- '6.4': '10',
125
- '6.3': '8.1',
126
- '6.2': '8',
127
- '6.1': '7',
128
- '6.0': 'Vista',
129
- '5.2': 'XP',
130
- '5.1': 'XP',
131
- '5.0': '2000',
132
- '10.0': '10',
133
- '11.0': '11' // 自定的,不是微软官方的判断方法
134
- }
135
- return wvHash[v] || v
136
- },
137
- Android: () => u.replace(/^.*Android ([\d.]+);.*$/, '$1'),
138
- iOS: () => u.replace(/^.*OS ([\d_]+) like.*$/, '$1').replace(/_/g, '.'),
139
- Debian: () => u.replace(/^.*Debian\/([\d.]+).*$/, '$1'),
140
- 'Windows Phone': () => u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, '$2'),
141
- 'macOS': () => u.replace(/^.*Mac OS X ([\d_]+).*$/, '$1').replace(/_/g, '.'),
142
- WebOS: () => u.replace(/^.*hpwOS\/([\d.]+);.*$/, '$1')
143
- }
144
-
145
- dest.osVersion = ''
146
- if (osVersion[dest.os]) {
147
- dest.osVersion = osVersion[dest.os]()
148
- if (dest.osVersion === u) {
149
- dest.osVersion = ''
150
- }
151
- }
152
-
153
- // 浏览器版本信息
154
- const version = {
155
- Safari: () => u.replace(/^.*Version\/([\d.]+).*$/, '$1'),
156
- Chrome: () => u.replace(/^.*Chrome\/([\d.]+).*$/, '$1').replace(/^.*CriOS\/([\d.]+).*$/, '$1'),
157
- IE: () => u.replace(/^.*MSIE ([\d.]+).*$/, '$1').replace(/^.*rv:([\d.]+).*$/, '$1'),
158
- Edge: () => u.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/, '$2'),
159
- Firefox: () => u.replace(/^.*Firefox\/([\d.]+).*$/, '$1').replace(/^.*FxiOS\/([\d.]+).*$/, '$1'),
160
- 'Firefox Focus': () => u.replace(/^.*Focus\/([\d.]+).*$/, '$1'),
161
- Chromium: () => u.replace(/^.*Chromium\/([\d.]+).*$/, '$1'),
162
- Opera: () => u.replace(/^.*Opera\/([\d.]+).*$/, '$1').replace(/^.*OPR\/([\d.]+).*$/, '$1'),
163
- Vivaldi: () => u.replace(/^.*Vivaldi\/([\d.]+).*$/, '$1'),
164
- Yandex: () => u.replace(/^.*YaBrowser\/([\d.]+).*$/, '$1'),
165
- Kindle: () => u.replace(/^.*Version\/([\d.]+).*$/, '$1'),
166
- Maxthon: () => u.replace(/^.*Maxthon\/([\d.]+).*$/, '$1'),
167
- QQBrowser: () => u.replace(/^.*QQBrowser\/([\d.]+).*$/, '$1'),
168
- QQ: () => u.replace(/^.*QQ\/([\d.]+).*$/, '$1'),
169
- Baidu: () => u.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/, '$1'),
170
- UC: () => u.replace(/^.*UC?Browser\/([\d.]+).*$/, '$1'),
171
- Sogou: () => u.replace(/^.*SE ([\d.X]+).*$/, '$1').replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, '$1'),
172
- '2345Explorer': () => u.replace(/^.*2345Explorer\/([\d.]+).*$/, '$1'),
173
- TheWorld: () => u.replace(/^.*TheWorld ([\d.]+).*$/, '$1'),
174
- MIUI: () => u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, '$1'),
175
- Quark: () => u.replace(/^.*Quark\/([\d.]+).*$/, '$1'),
176
- Qiyu: () => u.replace(/^.*Qiyu\/([\d.]+).*$/, '$1'),
177
- Wechat: () => u.replace(/^.*MicroMessenger\/([\d.]+).*$/, '$1'),
178
- Taobao: () => u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, '$1'),
179
- Alipay: () => u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, '$1'),
180
- Weibo: () => u.replace(/^.*weibo__([\d.]+).*$/, '$1'),
181
- Douban: () => u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, '$1'),
182
- Suning: () => u.replace(/^.*SNEBUY-APP([\d.]+).*$/, '$1'),
183
- iQiYi: () => u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, '$1'),
184
- }
185
-
186
- dest.version = ''
187
- if (version[dest.browser]) {
188
- dest.version = version[dest.browser]()
189
- if (dest.version === u) {
190
- dest.version = ''
191
- }
192
- }
193
-
194
- // 简化版本号
195
- /* if (_this.osVersion.indexOf('.')) {
196
- _this.osVersion = _this.osVersion.substring(0, _this.osVersion.indexOf('.'))
197
- } */
198
- if (dest.version.indexOf('.')) {
199
- dest.version = dest.version.substring(0, dest.version.indexOf('.'))
200
- }
201
-
202
- // 修正
203
- if (dest.os === 'iOS' && u.includes('iPad')) {
204
- dest.os = 'iPadOS'
205
- } else if (dest.browser === 'Edge' && !u.includes('Edg')) {
206
- dest.engine = 'EdgeHTML'
207
- } else if (dest.browser === 'MIUI') {
208
- dest.os = 'Android'
209
- } else if (dest.browser === 'Chrome' && Number(dest.version) > 27) {
210
- dest.engine = 'Blink'
211
- } else if (dest.browser === 'Opera' && Number(dest.version) > 12) {
212
- dest.engine = 'Blink'
213
- } else if (dest.browser === 'Yandex') {
214
- dest.engine = 'Blink'
215
- } else if (dest.browser === undefined) {
216
- dest.browser = 'Unknow App'
217
- }
218
-
219
- return dest
220
- }
221
-
222
- export default Detect