@waline/client 2.14.9 → 2.15.1
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/api.cjs.map +1 -1
- package/dist/api.d.cts +4 -0
- package/dist/api.d.mts +4 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.mjs.map +1 -1
- package/dist/comment.cjs +1 -1
- package/dist/comment.cjs.map +1 -1
- package/dist/comment.js +1 -1
- package/dist/comment.js.map +1 -1
- package/dist/comment.mjs +1 -1
- package/dist/comment.mjs.map +1 -1
- package/dist/component.mjs +1 -1
- package/dist/component.mjs.map +1 -1
- package/dist/legacy.umd.d.ts +92 -88
- package/dist/legacy.umd.js +1 -1
- package/dist/legacy.umd.js.map +1 -1
- package/dist/pageview.cjs +1 -1
- package/dist/pageview.cjs.map +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/pageview.mjs +1 -1
- package/dist/pageview.mjs.map +1 -1
- package/dist/shim.cjs +1 -1
- package/dist/shim.cjs.map +1 -1
- package/dist/shim.d.cts +8 -0
- package/dist/shim.d.mts +8 -0
- package/dist/shim.mjs +1 -1
- package/dist/shim.mjs.map +1 -1
- package/dist/waline.cjs +1 -1
- package/dist/waline.cjs.map +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.cts +8 -0
- package/dist/waline.d.mts +8 -0
- package/dist/waline.d.ts +8 -0
- package/dist/waline.js +1 -1
- package/dist/waline.js.map +1 -1
- package/dist/waline.mjs +1 -1
- package/dist/waline.mjs.map +1 -1
- package/package.json +18 -27
- package/src/api/articleCounter.ts +1 -2
- package/src/api/comment.ts +10 -3
- package/src/api/commentCount.ts +1 -1
- package/src/api/login.ts +1 -1
- package/src/api/pageview.ts +2 -2
- package/src/api/recentComment.ts +2 -2
- package/src/api/user.ts +6 -3
- package/src/comment.ts +3 -3
- package/src/compact/convert.ts +6 -7
- package/src/compact/v1.ts +5 -5
- package/src/compact/valine.ts +6 -6
- package/src/components/ArticleReaction.vue +3 -4
- package/src/components/CommentBox.vue +59 -43
- package/src/components/CommentCard.vue +8 -7
- package/src/components/Icons.ts +4 -3
- package/src/components/ImageWall.vue +1 -2
- package/src/components/WalineComment.vue +8 -7
- package/src/composables/index.ts +1 -0
- package/src/composables/inputs.ts +1 -2
- package/src/composables/like.ts +1 -2
- package/src/composables/reaction.ts +1 -2
- package/src/composables/recaptchaV3.ts +1 -3
- package/src/composables/turnstile.ts +49 -0
- package/src/composables/userInfo.ts +2 -2
- package/src/config/default.ts +8 -7
- package/src/config/i18n/generate.ts +1 -1
- package/src/config/i18n/index.ts +7 -8
- package/src/entries/legacy.ts +10 -10
- package/src/init.ts +4 -5
- package/src/pageview.ts +3 -4
- package/src/shims-vue.d.ts +2 -1
- package/src/styles/card.scss +3 -3
- package/src/styles/emoji.scss +0 -3
- package/src/styles/index.scss +0 -5
- package/src/typings/comment.ts +5 -0
- package/src/typings/options.ts +1 -1
- package/src/typings/waline.ts +17 -12
- package/src/utils/config.ts +10 -10
- package/src/utils/emoji.ts +3 -3
- package/src/utils/index.ts +12 -11
- package/src/utils/markdown.ts +6 -6
- package/src/utils/markedMathExtension.ts +3 -2
- package/src/utils/userAgent.ts +1 -1
- package/src/utils/wordCount.ts +1 -1
- package/src/widgets/recentComments.ts +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.1",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -93,6 +93,16 @@
|
|
|
93
93
|
"dist",
|
|
94
94
|
"src"
|
|
95
95
|
],
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "pnpm rollup && pnpm style",
|
|
98
|
+
"clean": "rimraf ./dist",
|
|
99
|
+
"dev": "vite",
|
|
100
|
+
"prepublishOnly": "pnpm clean && pnpm build",
|
|
101
|
+
"rollup": "rollup -c",
|
|
102
|
+
"style": "pnpm style:main && pnpm style:meta",
|
|
103
|
+
"style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
|
|
104
|
+
"style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
|
|
105
|
+
},
|
|
96
106
|
"browserslist": {
|
|
97
107
|
"production": [
|
|
98
108
|
">0.5%",
|
|
@@ -111,40 +121,21 @@
|
|
|
111
121
|
"dependencies": {
|
|
112
122
|
"@vueuse/core": "^9.13.0",
|
|
113
123
|
"autosize": "^6.0.1",
|
|
114
|
-
"marked": "^4.
|
|
124
|
+
"marked": "^4.3.0",
|
|
115
125
|
"vue": "^3.2.47"
|
|
116
126
|
},
|
|
117
127
|
"devDependencies": {
|
|
118
|
-
"@babel/core": "7.21.
|
|
119
|
-
"@babel/preset-env": "7.
|
|
128
|
+
"@babel/core": "7.21.4",
|
|
129
|
+
"@babel/preset-env": "7.21.4",
|
|
120
130
|
"@giphy/js-types": "4.4.0",
|
|
121
|
-
"@rollup/plugin-babel": "6.0.3",
|
|
122
|
-
"@rollup/plugin-commonjs": "24.0.1",
|
|
123
|
-
"@rollup/plugin-node-resolve": "15.0.1",
|
|
124
|
-
"@rollup/plugin-replace": "5.0.2",
|
|
125
|
-
"@rollup/plugin-terser": "0.4.0",
|
|
126
131
|
"@types/autosize": "4.0.1",
|
|
127
132
|
"@types/marked": "4.0.8",
|
|
128
|
-
"@
|
|
129
|
-
"@vitejs/plugin-vue": "4.0.0",
|
|
133
|
+
"@vitejs/plugin-vue": "4.1.0",
|
|
130
134
|
"recaptcha-v3": "1.10.0",
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"rollup-plugin-ts": "3.2.0",
|
|
134
|
-
"typescript": "4.9.5",
|
|
135
|
-
"user-agent-data-types": "^0.3.1",
|
|
136
|
-
"vite": "4.1.4"
|
|
135
|
+
"user-agent-data-types": "0.3.1",
|
|
136
|
+
"vite": "4.2.1"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": ">=14"
|
|
140
|
-
},
|
|
141
|
-
"scripts": {
|
|
142
|
-
"build": "pnpm rollup && pnpm style",
|
|
143
|
-
"clean": "rimraf ./dist",
|
|
144
|
-
"dev": "vite",
|
|
145
|
-
"rollup": "rollup -c",
|
|
146
|
-
"style": "pnpm style:main && pnpm style:meta",
|
|
147
|
-
"style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
|
|
148
|
-
"style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
|
|
149
140
|
}
|
|
150
|
-
}
|
|
141
|
+
}
|
package/src/api/comment.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BaseAPIOptions,
|
|
3
|
+
type ErrorStatusResponse,
|
|
4
|
+
JSON_HEADERS,
|
|
5
|
+
errorCheck,
|
|
6
|
+
} from './utils.js';
|
|
7
|
+
import {
|
|
8
|
+
type WalineComment,
|
|
9
|
+
type WalineCommentData,
|
|
10
|
+
} from '../typings/index.js';
|
|
4
11
|
|
|
5
12
|
export interface GetCommentOptions extends BaseAPIOptions {
|
|
6
13
|
/**
|
package/src/api/commentCount.ts
CHANGED
package/src/api/login.ts
CHANGED
package/src/api/pageview.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getArticleCounter, updateArticleCounter } from './articleCounter';
|
|
2
|
-
import type
|
|
1
|
+
import { getArticleCounter, updateArticleCounter } from './articleCounter.js';
|
|
2
|
+
import { type BaseAPIOptions } from './utils.js';
|
|
3
3
|
|
|
4
4
|
interface GetPageviewOptions extends BaseAPIOptions {
|
|
5
5
|
/**
|
package/src/api/recentComment.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type BaseAPIOptions } from './utils.js';
|
|
2
|
+
import { type WalineComment } from '../typings/index.js';
|
|
3
3
|
|
|
4
4
|
export interface GetRecentCommentOptions extends BaseAPIOptions {
|
|
5
5
|
/**
|
package/src/api/user.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BaseAPIOptions,
|
|
3
|
+
errorCheck,
|
|
4
|
+
ErrorStatusResponse,
|
|
5
|
+
} from './utils.js';
|
|
6
|
+
import { type WalineComment } from '../typings/index.js';
|
|
4
7
|
|
|
5
8
|
export interface GetUserListOptions extends BaseAPIOptions {
|
|
6
9
|
/**
|
package/src/comment.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fetchCommentCount } from './api';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { fetchCommentCount } from './api/index.js';
|
|
2
|
+
import { type WalineAbort } from './typings/index.js';
|
|
3
|
+
import { decodePath, errorHandler, getServerURL } from './utils/index.js';
|
|
4
4
|
|
|
5
5
|
export interface WalineCommentCountOptions {
|
|
6
6
|
/**
|
package/src/compact/convert.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { warning } from './logger';
|
|
2
|
-
import { resolveOldEmojiMap } from './valine';
|
|
3
1
|
import {
|
|
4
2
|
DROPPED_OPTIONS_WHICH_CAN_NOT_BE_POLYFILLED,
|
|
5
3
|
DROPPED_OPTIONS_WHICH_CAN_STILL_BE_POLYFILLED,
|
|
6
|
-
} from './dropped';
|
|
7
|
-
|
|
8
|
-
import type
|
|
9
|
-
import
|
|
10
|
-
import type
|
|
4
|
+
} from './dropped.js';
|
|
5
|
+
import { warning } from './logger.js';
|
|
6
|
+
import { type DeprecatedWalineOptions } from './v1.js';
|
|
7
|
+
import { resolveOldEmojiMap } from './valine.js';
|
|
8
|
+
import { type DeprecatedValineOptions } from './valine.js';
|
|
9
|
+
import { type WalineInitOptions } from '../typings/index.js';
|
|
11
10
|
|
|
12
11
|
export const covertOptions = (
|
|
13
12
|
options: WalineInitOptions & DeprecatedValineOptions & DeprecatedWalineOptions
|
package/src/compact/v1.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
WalineHighlighter,
|
|
3
|
-
WalineImageUploader,
|
|
4
|
-
WalineTexRenderer,
|
|
5
|
-
} from '../typings';
|
|
1
|
+
import {
|
|
2
|
+
type WalineHighlighter,
|
|
3
|
+
type WalineImageUploader,
|
|
4
|
+
type WalineTexRenderer,
|
|
5
|
+
} from '../typings/index.js';
|
|
6
6
|
|
|
7
7
|
export interface DeprecatedWalineOptions {
|
|
8
8
|
/**
|
package/src/compact/valine.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
WalineEmojiInfo,
|
|
3
|
-
WalineEmojiMaps,
|
|
4
|
-
WalineLocale,
|
|
5
|
-
WalineMeta,
|
|
6
|
-
} from '../typings';
|
|
1
|
+
import {
|
|
2
|
+
type WalineEmojiInfo,
|
|
3
|
+
type WalineEmojiMaps,
|
|
4
|
+
type WalineLocale,
|
|
5
|
+
type WalineMeta,
|
|
6
|
+
} from '../typings/index.js';
|
|
7
7
|
|
|
8
8
|
export type DeprecatedAvatar =
|
|
9
9
|
| ''
|
|
@@ -32,15 +32,14 @@
|
|
|
32
32
|
</template>
|
|
33
33
|
|
|
34
34
|
<script setup lang="ts">
|
|
35
|
+
import { type ComputedRef } from 'vue';
|
|
35
36
|
import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
36
37
|
|
|
37
38
|
import { LoadingIcon } from './Icons.js';
|
|
38
39
|
import { getArticleCounter, updateArticleCounter } from '../api/index.js';
|
|
39
40
|
import { useReactionStorage } from '../composables/index.js';
|
|
40
|
-
|
|
41
|
-
import type
|
|
42
|
-
import type { WalineConfig } from '../utils/index.js';
|
|
43
|
-
import type { WalineReactionLocale } from '../typings';
|
|
41
|
+
import { type WalineReactionLocale } from '../typings/index.js';
|
|
42
|
+
import { type WalineConfig } from '../utils/index.js';
|
|
44
43
|
|
|
45
44
|
defineExpose();
|
|
46
45
|
|
|
@@ -154,6 +154,8 @@
|
|
|
154
154
|
</div>
|
|
155
155
|
|
|
156
156
|
<div class="wl-info">
|
|
157
|
+
<div class="wl-captcha-container"></div>
|
|
158
|
+
|
|
157
159
|
<div class="wl-text-number">
|
|
158
160
|
{{ wordNumber }}
|
|
159
161
|
|
|
@@ -205,6 +207,7 @@
|
|
|
205
207
|
/>
|
|
206
208
|
|
|
207
209
|
<ImageWall
|
|
210
|
+
v-if="searchResults.list.length"
|
|
208
211
|
:items="searchResults.list"
|
|
209
212
|
:column-width="200"
|
|
210
213
|
:gap="6"
|
|
@@ -286,6 +289,8 @@
|
|
|
286
289
|
import { useDebounceFn } from '@vueuse/core';
|
|
287
290
|
import autosize from 'autosize';
|
|
288
291
|
import {
|
|
292
|
+
type ComputedRef,
|
|
293
|
+
type DeepReadonly,
|
|
289
294
|
computed,
|
|
290
295
|
inject,
|
|
291
296
|
onMounted,
|
|
@@ -303,34 +308,34 @@ import {
|
|
|
303
308
|
LoadingIcon,
|
|
304
309
|
MarkdownIcon,
|
|
305
310
|
PreviewIcon,
|
|
306
|
-
} from './Icons';
|
|
311
|
+
} from './Icons.js';
|
|
307
312
|
import ImageWall from './ImageWall.vue';
|
|
308
313
|
import { addComment, login, updateComment, UserInfo } from '../api/index.js';
|
|
309
314
|
import {
|
|
310
315
|
useEditor,
|
|
311
316
|
useReCaptcha,
|
|
317
|
+
useTurnstile,
|
|
312
318
|
useUserInfo,
|
|
313
319
|
useUserMeta,
|
|
314
320
|
} from '../composables/index.js';
|
|
315
321
|
import {
|
|
322
|
+
type WalineComment,
|
|
323
|
+
type WalineCommentData,
|
|
324
|
+
type WalineImageUploader,
|
|
325
|
+
type WalineSearchOptions,
|
|
326
|
+
type WalineSearchResult,
|
|
327
|
+
} from '../typings/index.js';
|
|
328
|
+
import {
|
|
329
|
+
type WalineConfig,
|
|
330
|
+
type WalineEmojiConfig,
|
|
316
331
|
getEmojis,
|
|
317
332
|
getImageFromDataTransfer,
|
|
318
333
|
getWordNumber,
|
|
319
334
|
parseEmoji,
|
|
320
335
|
parseMarkdown,
|
|
336
|
+
userAgent,
|
|
321
337
|
} from '../utils/index.js';
|
|
322
338
|
|
|
323
|
-
import type { ComputedRef, DeepReadonly } from 'vue';
|
|
324
|
-
import type {
|
|
325
|
-
WalineComment,
|
|
326
|
-
WalineCommentData,
|
|
327
|
-
WalineImageUploader,
|
|
328
|
-
WalineSearchOptions,
|
|
329
|
-
WalineSearchResult,
|
|
330
|
-
} from '../typings/index.js';
|
|
331
|
-
import type { WalineConfig, WalineEmojiConfig } from '../utils/index.js';
|
|
332
|
-
import { userAgent } from '../utils/userAgent';
|
|
333
|
-
|
|
334
339
|
const props = withDefaults(
|
|
335
340
|
defineProps<{
|
|
336
341
|
/**
|
|
@@ -482,12 +487,15 @@ const onChange = (): void => {
|
|
|
482
487
|
};
|
|
483
488
|
|
|
484
489
|
const submitComment = async (): Promise<void> => {
|
|
485
|
-
const {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
490
|
+
const {
|
|
491
|
+
serverURL,
|
|
492
|
+
lang,
|
|
493
|
+
login,
|
|
494
|
+
wordLimit,
|
|
495
|
+
requiredMeta,
|
|
496
|
+
recaptchaV3Key,
|
|
497
|
+
turnstileKey,
|
|
498
|
+
} = config.value;
|
|
491
499
|
|
|
492
500
|
const ua = await userAgent();
|
|
493
501
|
const comment: WalineCommentData = {
|
|
@@ -496,7 +504,6 @@ const submitComment = async (): Promise<void> => {
|
|
|
496
504
|
mail: userMeta.value.mail,
|
|
497
505
|
link: userMeta.value.link,
|
|
498
506
|
url: config.value.path,
|
|
499
|
-
recaptchaV3: token,
|
|
500
507
|
ua,
|
|
501
508
|
};
|
|
502
509
|
|
|
@@ -555,37 +562,46 @@ const submitComment = async (): Promise<void> => {
|
|
|
555
562
|
|
|
556
563
|
isSubmitting.value = true;
|
|
557
564
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
};
|
|
565
|
+
try {
|
|
566
|
+
if (recaptchaV3Key)
|
|
567
|
+
comment.recaptchaV3 = await useReCaptcha(recaptchaV3Key).execute(
|
|
568
|
+
'social'
|
|
569
|
+
);
|
|
564
570
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
? updateComment({ objectId: props.edit.objectId, ...options })
|
|
568
|
-
: addComment(options)
|
|
569
|
-
)
|
|
570
|
-
.then((resp) => {
|
|
571
|
-
isSubmitting.value = false;
|
|
571
|
+
if (turnstileKey)
|
|
572
|
+
comment.turnstile = await useTurnstile(turnstileKey).execute('social');
|
|
572
573
|
|
|
573
|
-
|
|
574
|
+
const options = {
|
|
575
|
+
serverURL,
|
|
576
|
+
lang,
|
|
577
|
+
token: userInfo.value?.token,
|
|
578
|
+
comment,
|
|
579
|
+
};
|
|
574
580
|
|
|
575
|
-
|
|
581
|
+
const resp = await (props.edit
|
|
582
|
+
? updateComment({
|
|
583
|
+
objectId: props.edit.objectId,
|
|
584
|
+
...options,
|
|
585
|
+
})
|
|
586
|
+
: addComment(options));
|
|
576
587
|
|
|
577
|
-
|
|
588
|
+
isSubmitting.value = false;
|
|
578
589
|
|
|
579
|
-
|
|
590
|
+
if (resp.errmsg) return alert(resp.errmsg);
|
|
580
591
|
|
|
581
|
-
|
|
582
|
-
if (props.edit?.objectId) emit('cancelEdit');
|
|
583
|
-
})
|
|
584
|
-
.catch((err: TypeError) => {
|
|
585
|
-
isSubmitting.value = false;
|
|
592
|
+
emit('submit', resp.data!);
|
|
586
593
|
|
|
587
|
-
|
|
588
|
-
|
|
594
|
+
editor.value = '';
|
|
595
|
+
|
|
596
|
+
previewText.value = '';
|
|
597
|
+
|
|
598
|
+
if (props.replyId) emit('cancelReply');
|
|
599
|
+
if (props.edit?.objectId) emit('cancelEdit');
|
|
600
|
+
} catch (err: unknown) {
|
|
601
|
+
isSubmitting.value = false;
|
|
602
|
+
|
|
603
|
+
alert((err as TypeError).message);
|
|
604
|
+
}
|
|
589
605
|
};
|
|
590
606
|
|
|
591
607
|
const onLogin = (event: Event): void => {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
class="wl-nick"
|
|
14
14
|
:href="link"
|
|
15
15
|
target="_blank"
|
|
16
|
-
rel="noopener noreferrer"
|
|
16
|
+
rel="nofollow noopener noreferrer"
|
|
17
17
|
>{{ comment.nick }}</a
|
|
18
18
|
>
|
|
19
19
|
|
|
@@ -177,7 +177,8 @@
|
|
|
177
177
|
|
|
178
178
|
<script setup lang="ts">
|
|
179
179
|
import { useNow } from '@vueuse/core';
|
|
180
|
-
import { computed, inject } from 'vue';
|
|
180
|
+
import { type ComputedRef, computed, inject } from 'vue';
|
|
181
|
+
|
|
181
182
|
import CommentBox from './CommentBox.vue';
|
|
182
183
|
import {
|
|
183
184
|
DeleteIcon,
|
|
@@ -186,12 +187,12 @@ import {
|
|
|
186
187
|
ReplyIcon,
|
|
187
188
|
VerifiedIcon,
|
|
188
189
|
} from './Icons.js';
|
|
189
|
-
import { getTimeAgo, isLinkHttp } from '../utils';
|
|
190
190
|
import { useLikeStorage, useUserInfo } from '../composables/index.js';
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
import {
|
|
192
|
+
type WalineComment,
|
|
193
|
+
type WalineCommentStatus,
|
|
194
|
+
} from '../typings/index.js';
|
|
195
|
+
import { type WalineConfig, getTimeAgo, isLinkHttp } from '../utils/index.js';
|
|
195
196
|
|
|
196
197
|
const props = withDefaults(
|
|
197
198
|
defineProps<{
|
package/src/components/Icons.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import type { FunctionalComponent } from 'vue';
|
|
1
|
+
import { type FunctionalComponent, h } from 'vue';
|
|
3
2
|
|
|
4
3
|
export const CloseIcon: FunctionalComponent<{ size: number }> = ({ size }) =>
|
|
5
4
|
h(
|
|
@@ -127,7 +126,9 @@ export const VerifiedIcon: FunctionalComponent = () =>
|
|
|
127
126
|
})
|
|
128
127
|
);
|
|
129
128
|
|
|
130
|
-
export const LoadingIcon: FunctionalComponent<{ size
|
|
129
|
+
export const LoadingIcon: FunctionalComponent<{ size?: number }> = ({
|
|
130
|
+
size = 100,
|
|
131
|
+
}) =>
|
|
131
132
|
h(
|
|
132
133
|
'svg',
|
|
133
134
|
{
|
|
@@ -59,8 +59,7 @@
|
|
|
59
59
|
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
60
60
|
|
|
61
61
|
import { LoadingIcon } from './Icons.js';
|
|
62
|
-
|
|
63
|
-
import type { WalineSearchResult } from '../typings/index.js';
|
|
62
|
+
import { type WalineSearchResult } from '../typings/index.js';
|
|
64
63
|
|
|
65
64
|
type Column = number[];
|
|
66
65
|
|
|
@@ -90,22 +90,22 @@
|
|
|
90
90
|
/* eslint-disable vue/require-prop-types */
|
|
91
91
|
import { useStyleTag } from '@vueuse/core';
|
|
92
92
|
import { computed, onMounted, onUnmounted, provide, ref, watch } from 'vue';
|
|
93
|
+
|
|
93
94
|
import Reaction from './ArticleReaction.vue';
|
|
94
95
|
import CommentBox from './CommentBox.vue';
|
|
95
96
|
import CommentCard from './CommentCard.vue';
|
|
96
97
|
import { LoadingIcon } from './Icons.js';
|
|
97
98
|
import { deleteComment, getComment, updateComment } from '../api/index.js';
|
|
98
99
|
import { useUserInfo, useLikeStorage } from '../composables/index.js';
|
|
100
|
+
import {
|
|
101
|
+
type WalineComment,
|
|
102
|
+
type WalineCommentSorting,
|
|
103
|
+
type WalineCommentStatus,
|
|
104
|
+
type WalineProps,
|
|
105
|
+
} from '../typings/index.js';
|
|
99
106
|
import { getConfig, getDarkStyle } from '../utils/index.js';
|
|
100
107
|
import { version } from '../version.js';
|
|
101
108
|
|
|
102
|
-
import type {
|
|
103
|
-
WalineComment,
|
|
104
|
-
WalineCommentSorting,
|
|
105
|
-
WalineCommentStatus,
|
|
106
|
-
WalineProps,
|
|
107
|
-
} from '../typings/index.js';
|
|
108
|
-
|
|
109
109
|
type SortKey = 'insertedAt_desc' | 'insertedAt_asc' | 'like_desc';
|
|
110
110
|
|
|
111
111
|
const props = defineProps([
|
|
@@ -127,6 +127,7 @@ const props = defineProps([
|
|
|
127
127
|
'search',
|
|
128
128
|
'copyright',
|
|
129
129
|
'recaptchaV3Key',
|
|
130
|
+
'turnstileKey',
|
|
130
131
|
'reaction',
|
|
131
132
|
]);
|
|
132
133
|
|
package/src/composables/index.ts
CHANGED
package/src/composables/like.ts
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useScriptTag } from '@vueuse/core';
|
|
2
|
+
|
|
3
|
+
interface TurnstileOptions {
|
|
4
|
+
sitekey: string;
|
|
5
|
+
action?: string;
|
|
6
|
+
size?: 'normal' | 'compact';
|
|
7
|
+
callback?: (token: string) => void;
|
|
8
|
+
}
|
|
9
|
+
interface TurnstileInstance {
|
|
10
|
+
ready: (fn: () => void) => void;
|
|
11
|
+
render: (className: string, options?: TurnstileOptions) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface Window {
|
|
16
|
+
turnstile?: TurnstileInstance;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Turnstile {
|
|
21
|
+
execute: (action: string) => Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const useTurnstile = (key: string): Turnstile => {
|
|
25
|
+
const execute = (action: string): Promise<string> =>
|
|
26
|
+
new Promise((resolve) => {
|
|
27
|
+
useScriptTag(
|
|
28
|
+
'https://challenges.cloudflare.com/turnstile/v0/api.js',
|
|
29
|
+
() => {
|
|
30
|
+
const turnstile = window?.turnstile;
|
|
31
|
+
|
|
32
|
+
const options: TurnstileOptions = {
|
|
33
|
+
sitekey: key,
|
|
34
|
+
action,
|
|
35
|
+
size: 'compact',
|
|
36
|
+
callback(token: string): void {
|
|
37
|
+
resolve(token);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
turnstile?.ready(() =>
|
|
42
|
+
turnstile?.render('.wl-captcha-container', options)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { execute };
|
|
49
|
+
};
|
package/src/config/default.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { type IGif } from '@giphy/js-types';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type WalineEmojiPresets,
|
|
5
|
+
type WalineMeta,
|
|
6
|
+
type WalineSearchOptions,
|
|
7
|
+
type WalineSearchResult,
|
|
8
|
+
} from '../typings/index.js';
|
|
8
9
|
|
|
9
10
|
const AVAILABLE_META: WalineMeta[] = ['nick', 'mail', 'link'];
|
|
10
11
|
|
package/src/config/i18n/index.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import en from './en';
|
|
3
|
-
import jp from './jp';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import type { WalineLocale } from '../../typings';
|
|
2
|
+
import en from './en.js';
|
|
3
|
+
import jp from './jp.js';
|
|
4
|
+
import ptBR from './pt-BR.js';
|
|
5
|
+
import ru from './ru.js';
|
|
6
|
+
import zhCN from './zh-CN.js';
|
|
7
|
+
import zhTW from './zh-TW.js';
|
|
8
|
+
import { type WalineLocale } from '../../typings/index.js';
|
|
10
9
|
|
|
11
10
|
export type Locales = Record<string, WalineLocale>;
|
|
12
11
|
|