@waline/client 2.14.1 → 2.14.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.
Files changed (62) hide show
  1. package/dist/comment.cjs +1 -1
  2. package/dist/comment.cjs.map +1 -1
  3. package/dist/comment.js +1 -68
  4. package/dist/comment.js.map +1 -1
  5. package/dist/comment.mjs +1 -1
  6. package/dist/comment.mjs.map +1 -1
  7. package/dist/component.mjs +1 -1
  8. package/dist/component.mjs.map +1 -1
  9. package/dist/legacy.umd.d.ts +14 -5
  10. package/dist/legacy.umd.js +1 -1
  11. package/dist/legacy.umd.js.map +1 -1
  12. package/dist/pageview.cjs +1 -1
  13. package/dist/pageview.cjs.map +1 -1
  14. package/dist/pageview.js +1 -121
  15. package/dist/pageview.js.map +1 -1
  16. package/dist/pageview.mjs +1 -1
  17. package/dist/pageview.mjs.map +1 -1
  18. package/dist/shim.cjs +1 -1
  19. package/dist/shim.cjs.map +1 -1
  20. package/dist/shim.d.cts +15 -6
  21. package/dist/shim.d.mts +15 -6
  22. package/dist/shim.mjs +1 -1
  23. package/dist/shim.mjs.map +1 -1
  24. package/dist/waline.cjs +1 -1
  25. package/dist/waline.cjs.map +1 -1
  26. package/dist/waline.css +1 -1
  27. package/dist/waline.css.map +1 -1
  28. package/dist/waline.d.cts +15 -6
  29. package/dist/waline.d.mts +15 -6
  30. package/dist/waline.d.ts +15 -6
  31. package/dist/waline.js +1 -6787
  32. package/dist/waline.js.map +1 -1
  33. package/dist/waline.mjs +1 -1
  34. package/dist/waline.mjs.map +1 -1
  35. package/package.json +18 -18
  36. package/src/comment.ts +1 -2
  37. package/src/components/ArticleReaction.vue +120 -117
  38. package/src/components/CommentBox.vue +451 -488
  39. package/src/components/CommentCard.vue +109 -98
  40. package/src/components/ImageWall.vue +132 -131
  41. package/src/components/WalineComment.vue +683 -0
  42. package/src/composables/index.ts +1 -2
  43. package/src/composables/reaction.ts +16 -0
  44. package/src/composables/recaptchaV3.ts +4 -6
  45. package/src/config/default.ts +5 -0
  46. package/src/{entrys → entries}/api.ts +0 -0
  47. package/src/{entrys → entries}/comment.ts +0 -0
  48. package/src/entries/components.ts +2 -0
  49. package/src/{entrys → entries}/full.ts +0 -0
  50. package/src/{entrys → entries}/init.ts +0 -0
  51. package/src/{entrys → entries}/legacy.ts +0 -0
  52. package/src/{entrys → entries}/pageview.ts +0 -0
  53. package/src/init.ts +1 -1
  54. package/src/styles/reaction.scss +27 -16
  55. package/src/typings/base.ts +5 -0
  56. package/src/typings/waline.ts +14 -5
  57. package/src/utils/config.ts +27 -5
  58. package/src/utils/image.ts +1 -1
  59. package/src/components/Waline.vue +0 -509
  60. package/src/composables/timeAgo.ts +0 -15
  61. package/src/composables/vote.ts +0 -20
  62. package/src/entrys/components.ts +0 -2
@@ -0,0 +1,683 @@
1
+ <template>
2
+ <div data-waline>
3
+ <Reaction />
4
+
5
+ <CommentBox v-if="!reply" @log="refresh" @submit="onSubmit" />
6
+
7
+ <div class="wl-meta-head">
8
+ <div class="wl-count">
9
+ <span v-if="count" class="wl-num" v-text="count" />
10
+ {{ i18n.comment }}
11
+ </div>
12
+
13
+ <ul class="wl-sort">
14
+ <li
15
+ v-for="item in sortingMethods"
16
+ :key="item"
17
+ :class="[item === commentSorting ? 'active' : '']"
18
+ @click="onSortByChange(item)"
19
+ >
20
+ {{ i18n[item] }}
21
+ </li>
22
+ </ul>
23
+ </div>
24
+
25
+ <div class="wl-cards">
26
+ <CommentCard
27
+ v-for="comment in data"
28
+ :key="comment.objectId"
29
+ :root-id="comment.objectId"
30
+ :comment="comment"
31
+ :reply="reply"
32
+ :edit="edit"
33
+ @log="refresh"
34
+ @reply="onReply"
35
+ @edit="onEdit"
36
+ @submit="onSubmit"
37
+ @status="onStatusChange"
38
+ @delete="onDelete"
39
+ @sticky="onSticky"
40
+ @like="onLike"
41
+ />
42
+ </div>
43
+
44
+ <div v-if="status === 'error'" class="wl-operation">
45
+ <button
46
+ type="button"
47
+ class="wl-btn"
48
+ @click="refresh"
49
+ v-text="i18n.refresh"
50
+ />
51
+ </div>
52
+
53
+ <template v-else>
54
+ <div v-if="status === 'loading'" class="wl-loading">
55
+ <LoadingIcon :size="30" />
56
+ </div>
57
+
58
+ <div v-else-if="!data.length" class="wl-empty" v-text="i18n.sofa" />
59
+
60
+ <!-- Load more button -->
61
+ <div v-else-if="page < totalPages" class="wl-operation">
62
+ <button
63
+ type="button"
64
+ class="wl-btn"
65
+ @click="loadMore"
66
+ v-text="i18n.more"
67
+ />
68
+ </div>
69
+ </template>
70
+
71
+ <!-- Copyright Information -->
72
+ <div v-if="config.copyright" class="wl-power">
73
+ Powered by
74
+ <a
75
+ href="https://github.com/walinejs/waline"
76
+ target="_blank"
77
+ rel="noopener noreferrer"
78
+ >
79
+ Waline
80
+ </a>
81
+ v{{ version }}
82
+ </div>
83
+ </div>
84
+ </template>
85
+
86
+ <script setup lang="ts">
87
+ /* eslint-disable vue/no-unused-properties */
88
+ import { useStyleTag } from '@vueuse/core';
89
+ import { computed, onMounted, onUnmounted, provide, ref, watch } from 'vue';
90
+ import Reaction from './ArticleReaction.vue';
91
+ import CommentBox from './CommentBox.vue';
92
+ import CommentCard from './CommentCard.vue';
93
+ import { LoadingIcon } from './Icons.js';
94
+ import { deleteComment, getComment, updateComment } from '../api/index.js';
95
+ import { useUserInfo, useLikeStorage } from '../composables/index.js';
96
+ import { getConfig, getDarkStyle } from '../utils/index.js';
97
+ import { version } from '../version.js';
98
+
99
+ import type {
100
+ WalineComment,
101
+ WalineCommentStatus,
102
+ WalineLocale,
103
+ } from '../typings/index.js';
104
+
105
+ type SortKey = 'insertedAt_desc' | 'insertedAt_asc' | 'like_desc';
106
+
107
+ // TODO: Currently complex types and type imports from other files are not supported. It is possible to support type imports in the future.
108
+ // @see https://vuejs.org/api/sfc-script-setup.html#typescript-only-features
109
+ // this issue may be addressed in Vue3.3
110
+ // the following line is the same as WalineProps
111
+
112
+ type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
113
+
114
+ type WalineEmojiPresets =
115
+ | `//${string}`
116
+ | `http://${string}`
117
+ | `https://${string}`;
118
+
119
+ interface WalineEmojiInfo {
120
+ /**
121
+ * 选项卡上的 Emoji 名称
122
+ *
123
+ * Emoji name show on tab
124
+ */
125
+ name: string;
126
+ /**
127
+ * 所在文件夹链接
128
+ *
129
+ * Current folder link
130
+ */
131
+ folder?: string;
132
+ /**
133
+ * Emoji 通用路径前缀
134
+ *
135
+ * Common prefix of Emoji icons
136
+ */
137
+ prefix?: string;
138
+ /**
139
+ * Emoji 图片的类型,会作为文件扩展名使用
140
+ *
141
+ * Type of Emoji icons, will be regarded as file extension
142
+ */
143
+ type?: string;
144
+ /**
145
+ * 选项卡显示的 Emoji 图标
146
+ *
147
+ * Emoji icon show on tab
148
+ */
149
+ icon: string;
150
+ /**
151
+ * Emoji 图片列表
152
+ *
153
+ * Emoji image list
154
+ */
155
+ items: string[];
156
+ }
157
+
158
+ type WalineLoginStatus = 'enable' | 'disable' | 'force';
159
+
160
+ interface WalineSearchImageData extends Record<string, unknown> {
161
+ /**
162
+ * 图片链接
163
+ *
164
+ * Image link
165
+ */
166
+ src: string;
167
+
168
+ /**
169
+ * 图片标题
170
+ *
171
+ * @description 用于图片的 alt 属性
172
+ *
173
+ * Image title
174
+ *
175
+ * @description Used for alt attribute of image
176
+ */
177
+ title?: string;
178
+
179
+ /**
180
+ * 图片缩略图
181
+ *
182
+ * @description 为了更好的加载性能,我们会优先在列表中使用此缩略图
183
+ *
184
+ * Image preview link
185
+ *
186
+ * @description For better loading performance, we will use this thumbnail first in the list
187
+ *
188
+ * @default src
189
+ */
190
+ preview?: string;
191
+ }
192
+
193
+ type WalineSearchResult = WalineSearchImageData[];
194
+
195
+ interface WalineSearchOptions {
196
+ /**
197
+ * 搜索操作
198
+ *
199
+ * Search action
200
+ */
201
+ search: (word: string) => Promise<WalineSearchResult>;
202
+
203
+ /**
204
+ * 打开列表时展示的默认结果
205
+ *
206
+ * Default result when opening list
207
+ *
208
+ * @default () => search('')
209
+ */
210
+ default?: () => Promise<WalineSearchResult>;
211
+
212
+ /**
213
+ * 获取更多的操作
214
+ *
215
+ * @description 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
216
+ *
217
+ * Fetch more action
218
+ *
219
+ * @description It will be triggered when the list scrolls to the bottom. If your search service supports paging, you should set this to achieve infinite scrolling
220
+ *
221
+ * @default (word) => search(word)
222
+ */
223
+ more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
224
+ }
225
+
226
+ type WalineMeta = 'nick' | 'mail' | 'link';
227
+
228
+ type WalineImageUploader = (image: File) => Promise<string>;
229
+
230
+ type WalineHighlighter = (code: string, lang: string) => string;
231
+
232
+ type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
233
+
234
+ const props = defineProps<{
235
+ /**
236
+ * Waline 的服务端地址
237
+ *
238
+ * Waline server address url
239
+ */
240
+ serverURL: string;
241
+
242
+ /**
243
+ * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
244
+ *
245
+ * 你可以将其设置为 `window.location.pathname`
246
+ *
247
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
248
+ *
249
+ * You can set it to `window.location.pathname`
250
+ */
251
+ path: string;
252
+
253
+ /**
254
+ * 评论者相关属性
255
+ *
256
+ * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
257
+ *
258
+ * Reviewer attributes.
259
+ *
260
+ * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
261
+ *
262
+ * @default ['nick', 'mail', 'link']
263
+ */
264
+ meta?: WalineMeta[];
265
+
266
+ /**
267
+ * 设置**必填项**,默认昵称为匿名
268
+ *
269
+ * Set required fields, default anonymous with nickname
270
+ *
271
+ * @default []
272
+ */
273
+ requiredMeta?: WalineMeta[];
274
+
275
+ /**
276
+ * 评论字数限制。填入单个数字时为最大字数限制
277
+ *
278
+ * @more 设置为 `0` 时无限制
279
+ *
280
+ * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
281
+ *
282
+ * @more No limit when set to `0`.
283
+ *
284
+ * @default 0
285
+ */
286
+ wordLimit?: number | [number, number];
287
+
288
+ /**
289
+ * 评论列表分页,每页条数
290
+ *
291
+ * number of pages per page
292
+ *
293
+ * @default 10
294
+ */
295
+ pageSize?: number;
296
+
297
+ /**
298
+ * Waline 显示语言
299
+ *
300
+ * 可选值:
301
+ *
302
+ * - `'zh'`
303
+ * - `'zh-cn'`
304
+ * - `'zh-CN'`
305
+ * - `'zh-tw'`
306
+ * - `'zh-TW'`
307
+ * - `'en'`
308
+ * - `'en-US'`
309
+ * - `'en-us'`
310
+ * - `'jp'`
311
+ * - `'jp-jp'`
312
+ * - `'jp-JP'`
313
+ * - `'pt-br'`
314
+ * - `'pt-BR'`
315
+ * - `'ru'`
316
+ * - `'ru-ru'`
317
+ * - `'ru-RU'`
318
+ *
319
+ * Display language for waline
320
+ *
321
+ * Optional value:
322
+ *
323
+ * - `'zh'`
324
+ * - `'zh-cn'`
325
+ * - `'zh-CN'`
326
+ * - `'zh-tw'`
327
+ * - `'zh-TW'`
328
+ * - `'en'`
329
+ * - `'en-US'`
330
+ * - `'en-us'`
331
+ * - `'jp'`
332
+ * - `'jp-jp'`
333
+ * - `'jp-JP'`
334
+ * - `'pt-br'`
335
+ * - `'pt-BR'`
336
+ * - `'ru'`
337
+ * - `'ru-ru'`
338
+ * - `'ru-RU'`
339
+ *
340
+ * @default 'zh-CN'
341
+ */
342
+ lang?: string;
343
+
344
+ /**
345
+ * 自定义 waline 语言显示
346
+ *
347
+ * @see [自定义语言](https://waline.js.org/client/i18n.html)
348
+ *
349
+ * Custom display language in waline
350
+ *
351
+ * @see [I18n](https://waline.js.org/en/client/i18n.html)
352
+ */
353
+ locale?: Partial<WalineLocale>;
354
+
355
+ /**
356
+ * 评论列表排序方式
357
+ *
358
+ * Sorting method for comment list
359
+ *
360
+ * @default 'latest'
361
+ */
362
+ commentSorting?: WalineCommentSorting;
363
+
364
+ /**
365
+ * 是否启用暗黑模式适配
366
+ *
367
+ * @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
368
+ *
369
+ * Whether to enable darkmode support
370
+ *
371
+ * @more Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will enable darkmode only when the selector match waline ancestor nodes.
372
+ */
373
+ dark?: string | boolean;
374
+
375
+ /**
376
+ * 设置表情包
377
+ *
378
+ * Set Emojis
379
+ *
380
+ * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
381
+ */
382
+ emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
383
+
384
+ /**
385
+ * 设置搜索功能
386
+ *
387
+ * Customize Search feature
388
+ *
389
+ * @default true
390
+ */
391
+ search?: WalineSearchOptions | boolean;
392
+
393
+ /**
394
+ * 代码高亮
395
+ *
396
+ * Code highlighting
397
+ *
398
+ * @default true
399
+ */
400
+
401
+ highlighter?: WalineHighlighter | boolean;
402
+
403
+ /**
404
+ * 自定义图片上传方法,方便更好的存储图片
405
+ *
406
+ * 方法执行时会将图片对象传入。
407
+ *
408
+ * Custom image upload callback to manage picture by yourself.
409
+ *
410
+ * We will pass a picture file object when execute it.
411
+ *
412
+ * @default true
413
+ */
414
+
415
+ imageUploader?: WalineImageUploader | boolean;
416
+
417
+ /**
418
+ * 自定义数学公式处理方法,用于预览。
419
+ *
420
+ * Custom math formula parse callback for preview.
421
+ *
422
+ * @default true
423
+ */
424
+ texRenderer?: WalineTexRenderer | boolean;
425
+
426
+ /**
427
+ *
428
+ * 登录模式状态,可选值:
429
+ *
430
+ * - `'enable'`: 启用登录 (默认)
431
+ * - `'disable'`: 禁用登录,用户只能填写信息评论
432
+ * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
433
+ *
434
+ * Login mode status, optional values:
435
+ *
436
+ * - `'enable'`: enable login (default)
437
+ * - `'disable'`: Login is disabled, users should fill in information to comment
438
+ * - `'force'`: Forced login, users must login to comment
439
+ *
440
+ * @default 'enable'
441
+ */
442
+ login?: WalineLoginStatus;
443
+
444
+ /**
445
+ * 是否在页脚展示版权信息
446
+ *
447
+ * 为了支持 Waline,我们强烈建议你开启它
448
+ *
449
+ * Whether show copyright in footer
450
+ *
451
+ * We strongly recommended you to keep it on to support waline
452
+ *
453
+ * @default true
454
+ */
455
+ copyright?: boolean;
456
+
457
+ /**
458
+ * recaptcha v3 client key
459
+ */
460
+ recaptchaV3Key?: string;
461
+
462
+ /**
463
+ * reaction
464
+ */
465
+ reaction?: string[] | boolean;
466
+ }>();
467
+
468
+ const sortKeyMap: Record<WalineCommentSorting, SortKey> = {
469
+ latest: 'insertedAt_desc',
470
+ oldest: 'insertedAt_asc',
471
+ hottest: 'like_desc',
472
+ };
473
+ const sortingMethods = Object.keys(sortKeyMap) as WalineCommentSorting[];
474
+
475
+ const userInfo = useUserInfo();
476
+ const likeStorage = useLikeStorage();
477
+
478
+ const status = ref<'loading' | 'success' | 'error'>('loading');
479
+
480
+ const count = ref(0);
481
+ const page = ref(1);
482
+ const totalPages = ref(0);
483
+
484
+ const config = computed(() => getConfig(props));
485
+
486
+ // eslint-disable-next-line vue/no-ref-object-destructure
487
+ const commentSorting = ref(config.value.commentSorting);
488
+
489
+ const data = ref<WalineComment[]>([]);
490
+ const reply = ref<WalineComment | null>(null);
491
+ const edit = ref<WalineComment | null>(null);
492
+
493
+ const darkmodeStyle = computed(() => getDarkStyle(config.value.dark));
494
+
495
+ const i18n = computed(() => config.value.locale);
496
+
497
+ useStyleTag(darkmodeStyle);
498
+
499
+ let abort: () => void;
500
+
501
+ const getCommentData = (pageNumber: number): void => {
502
+ const { serverURL, path, pageSize } = config.value;
503
+ const controller = new AbortController();
504
+
505
+ status.value = 'loading';
506
+
507
+ abort?.();
508
+
509
+ getComment({
510
+ serverURL,
511
+ lang: config.value.lang,
512
+ path,
513
+ pageSize,
514
+ sortBy: sortKeyMap[commentSorting.value],
515
+ page: pageNumber,
516
+ signal: controller.signal,
517
+ token: userInfo.value?.token,
518
+ })
519
+ .then((resp) => {
520
+ status.value = 'success';
521
+ count.value = resp.count;
522
+ data.value.push(...resp.data);
523
+ page.value = pageNumber;
524
+ totalPages.value = resp.totalPages;
525
+ })
526
+ .catch((err: Error) => {
527
+ if (err.name !== 'AbortError') {
528
+ console.error(err.message);
529
+ status.value = 'error';
530
+ }
531
+ });
532
+
533
+ abort = controller.abort.bind(controller);
534
+ };
535
+
536
+ const loadMore = (): void => getCommentData(page.value + 1);
537
+
538
+ const refresh = (): void => {
539
+ count.value = 0;
540
+ data.value = [];
541
+ getCommentData(1);
542
+ };
543
+
544
+ const onSortByChange = (item: WalineCommentSorting): void => {
545
+ if (commentSorting.value !== item) {
546
+ commentSorting.value = item;
547
+ refresh();
548
+ }
549
+ };
550
+
551
+ const onReply = (comment: WalineComment | null): void => {
552
+ reply.value = comment;
553
+ };
554
+
555
+ const onEdit = (comment: WalineComment | null): void => {
556
+ edit.value = comment;
557
+ };
558
+
559
+ const onSubmit = (comment: WalineComment): void => {
560
+ if (edit.value) {
561
+ edit.value.comment = comment.comment;
562
+ edit.value.orig = comment.orig;
563
+ } else if (comment.rid) {
564
+ const repliedComment = data.value.find(
565
+ ({ objectId }) => objectId === comment.rid
566
+ );
567
+
568
+ if (!repliedComment) return;
569
+
570
+ if (!Array.isArray(repliedComment.children)) repliedComment.children = [];
571
+
572
+ repliedComment.children.push(comment);
573
+ } else data.value.unshift(comment);
574
+ };
575
+
576
+ const onStatusChange = async ({
577
+ comment,
578
+ status,
579
+ }: {
580
+ comment: WalineComment;
581
+ status: WalineCommentStatus;
582
+ }): Promise<void> => {
583
+ if (comment.status === status) return;
584
+
585
+ const { serverURL, lang } = config.value;
586
+
587
+ await updateComment({
588
+ serverURL,
589
+ lang,
590
+ token: userInfo.value?.token,
591
+ objectId: comment.objectId,
592
+ status,
593
+ });
594
+
595
+ comment.status = status;
596
+ };
597
+
598
+ const onSticky = async (comment: WalineComment): Promise<void> => {
599
+ if (comment.rid) return;
600
+
601
+ const { serverURL, lang } = config.value;
602
+
603
+ await updateComment({
604
+ serverURL,
605
+ lang,
606
+ token: userInfo.value?.token,
607
+ objectId: comment.objectId,
608
+ sticky: comment.sticky ? 0 : 1,
609
+ });
610
+
611
+ comment.sticky = !comment.sticky;
612
+ };
613
+
614
+ const onDelete = async ({ objectId }: WalineComment): Promise<void> => {
615
+ if (!confirm('Are you sure you want to delete this comment?')) return;
616
+
617
+ const { serverURL, lang } = config.value;
618
+
619
+ await deleteComment({
620
+ serverURL,
621
+ lang,
622
+ token: userInfo.value?.token,
623
+ objectId: objectId,
624
+ });
625
+
626
+ // delete comment from data
627
+ data.value.some((item, index) => {
628
+ if (item.objectId === objectId) {
629
+ data.value = data.value.filter((_item, i) => i !== index);
630
+
631
+ return true;
632
+ }
633
+
634
+ return item.children.some((child, childIndex) => {
635
+ if (child.objectId === objectId) {
636
+ data.value[index].children = item.children.filter(
637
+ (_item, i) => i !== childIndex
638
+ );
639
+
640
+ return true;
641
+ }
642
+
643
+ return false;
644
+ });
645
+ });
646
+ };
647
+
648
+ const onLike = async (comment: WalineComment): Promise<void> => {
649
+ const { serverURL, lang } = config.value;
650
+ const { objectId } = comment;
651
+ const hasLiked = likeStorage.value.includes(objectId);
652
+
653
+ await updateComment({
654
+ serverURL,
655
+ lang,
656
+ objectId,
657
+ token: userInfo.value?.token,
658
+ like: !hasLiked,
659
+ });
660
+
661
+ if (hasLiked)
662
+ likeStorage.value = likeStorage.value.filter((id) => id !== objectId);
663
+ else {
664
+ likeStorage.value = [...likeStorage.value, objectId];
665
+
666
+ if (likeStorage.value.length > 50)
667
+ likeStorage.value = likeStorage.value.slice(-50);
668
+ }
669
+
670
+ comment.like = (comment.like || 0) + (hasLiked ? -1 : 1);
671
+ };
672
+
673
+ provide('config', config);
674
+
675
+ onMounted(() => {
676
+ watch(
677
+ () => [props.serverURL, props.path],
678
+ () => refresh(),
679
+ { immediate: true }
680
+ );
681
+ });
682
+ onUnmounted(() => abort?.());
683
+ </script>
@@ -1,6 +1,5 @@
1
1
  export * from './inputs';
2
2
  export * from './like';
3
+ export * from './reaction';
3
4
  export * from './recaptchaV3';
4
- export * from './timeAgo';
5
- export * from './vote';
6
5
  export * from './userInfo';
@@ -0,0 +1,16 @@
1
+ import { useStorage } from '@vueuse/core';
2
+
3
+ import type { Ref } from 'vue';
4
+
5
+ const REACTION_KEY = 'WALINE_REACTION';
6
+
7
+ export interface WalineReactionStore {
8
+ [VOTE_IDENTIFIER: string]: number | undefined;
9
+ }
10
+
11
+ export type VoteRef = Ref<WalineReactionStore>;
12
+
13
+ let reactionStorage: VoteRef | null = null;
14
+
15
+ export const useReactionStorage = (): VoteRef =>
16
+ (reactionStorage ??= useStorage<WalineReactionStore>(REACTION_KEY, {}));
@@ -9,12 +9,10 @@ interface ReCaptcha {
9
9
  }
10
10
 
11
11
  export const useReCaptcha = (key: string): ReCaptcha => {
12
- const init =
13
- recaptchaStore[key] ??
14
- (recaptchaStore[key] = load(key, {
15
- useRecaptchaNet: true,
16
- autoHideBadge: true,
17
- }));
12
+ const init = (recaptchaStore[key] ??= load(key, {
13
+ useRecaptchaNet: true,
14
+ autoHideBadge: true,
15
+ }));
18
16
 
19
17
  return {
20
18
  execute: (action: string) =>