@waline/client 2.15.0 → 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/comment.cjs +1 -1
- package/dist/comment.js +1 -1
- package/dist/comment.mjs +1 -1
- package/dist/component.mjs +1 -1
- package/dist/component.mjs.map +1 -1
- package/dist/legacy.umd.js +1 -1
- package/dist/legacy.umd.js.map +1 -1
- package/dist/pageview.cjs +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.mjs +1 -1
- package/dist/shim.cjs +1 -1
- package/dist/shim.cjs.map +1 -1
- 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.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 +1 -1
- package/src/components/CommentBox.vue +5 -2
- package/src/composables/index.ts +1 -0
- package/src/composables/turnstile.ts +22 -52
package/package.json
CHANGED
|
@@ -207,6 +207,7 @@
|
|
|
207
207
|
/>
|
|
208
208
|
|
|
209
209
|
<ImageWall
|
|
210
|
+
v-if="searchResults.list.length"
|
|
210
211
|
:items="searchResults.list"
|
|
211
212
|
:column-width="200"
|
|
212
213
|
:gap="6"
|
|
@@ -313,10 +314,10 @@ import { addComment, login, updateComment, UserInfo } from '../api/index.js';
|
|
|
313
314
|
import {
|
|
314
315
|
useEditor,
|
|
315
316
|
useReCaptcha,
|
|
317
|
+
useTurnstile,
|
|
316
318
|
useUserInfo,
|
|
317
319
|
useUserMeta,
|
|
318
320
|
} from '../composables/index.js';
|
|
319
|
-
import { useTurnstile } from '../composables/turnstile';
|
|
320
321
|
import {
|
|
321
322
|
type WalineComment,
|
|
322
323
|
type WalineCommentData,
|
|
@@ -563,7 +564,9 @@ const submitComment = async (): Promise<void> => {
|
|
|
563
564
|
|
|
564
565
|
try {
|
|
565
566
|
if (recaptchaV3Key)
|
|
566
|
-
comment.recaptchaV3 = await useReCaptcha(recaptchaV3Key).execute(
|
|
567
|
+
comment.recaptchaV3 = await useReCaptcha(recaptchaV3Key).execute(
|
|
568
|
+
'social'
|
|
569
|
+
);
|
|
567
570
|
|
|
568
571
|
if (turnstileKey)
|
|
569
572
|
comment.turnstile = await useTurnstile(turnstileKey).execute('social');
|
package/src/composables/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useScriptTag } from '@vueuse/core';
|
|
2
|
+
|
|
1
3
|
interface TurnstileOptions {
|
|
2
4
|
sitekey: string;
|
|
3
5
|
action?: string;
|
|
@@ -19,61 +21,29 @@ interface Turnstile {
|
|
|
19
21
|
execute: (action: string) => Promise<string>;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
interface LoadScriptParameters {
|
|
23
|
-
src: string;
|
|
24
|
-
async?: boolean;
|
|
25
|
-
defer?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const isBrowser =
|
|
29
|
-
typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
30
|
-
|
|
31
|
-
async function loadScript(
|
|
32
|
-
options: LoadScriptParameters
|
|
33
|
-
): Promise<Event | undefined> {
|
|
34
|
-
if (!isBrowser) {
|
|
35
|
-
return Promise.resolve(undefined);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const el = document.createElement('script');
|
|
39
|
-
|
|
40
|
-
el.async = Boolean(options.async);
|
|
41
|
-
el.defer = Boolean(options.defer);
|
|
42
|
-
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
el.onload = resolve;
|
|
45
|
-
el.onerror = reject;
|
|
46
|
-
el.src = options.src;
|
|
47
|
-
|
|
48
|
-
document.head.appendChild(el);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const turnstileScriptPromise = loadScript({
|
|
53
|
-
src: 'https://challenges.cloudflare.com/turnstile/v0/api.js',
|
|
54
|
-
async: false,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
24
|
export const useTurnstile = (key: string): Turnstile => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
}
|
|
74
45
|
);
|
|
75
46
|
});
|
|
76
|
-
}
|
|
77
47
|
|
|
78
48
|
return { execute };
|
|
79
49
|
};
|