Skip to content

Commit ac07a3f

Browse files
committed
abinnovision#117 - Allow late configuration: siteKey
Credit goes to https://github.com/fatfingers23 and his push request abinnovision#161
1 parent 501253b commit ac07a3f

File tree

8 files changed

+14001
-3278
lines changed

8 files changed

+14001
-3278
lines changed

demo/src/delaydemo.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { createApp } from 'vue'
2+
import { VueReCaptcha } from '../../src/ReCaptchaVuePlugin'
3+
4+
const component = {
5+
methods: {
6+
async recaptcha () {
7+
console.log('recaptcha clicked')
8+
9+
this.$recaptchaLoaded().then(() => {
10+
console.log('recaptcha loaded')
11+
this.$recaptcha('login').then((token: string) => {
12+
console.log(token) // Will print the token
13+
})
14+
})
15+
await this.delay(1000)
16+
this.$loadRecaptchaAfterSetup('6LfC6HgUAAAAAEtG92bYRzwYkczElxq7WkCoG4Ob')
17+
},
18+
async delay (ms: number) {
19+
return await new Promise(resolve => setTimeout(resolve, ms))
20+
}
21+
},
22+
template: '<button @click="recaptcha">Execute with delay recaptcha</button>'
23+
}
24+
25+
createApp(component)
26+
.use(VueReCaptcha)
27+
.mount('#delaydemo')

demo/src/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
</head>
88
<body>
99
<div id="inject"></div>
10+
<br>
11+
<br>
12+
<div id="delaydemo"></div>
1013
</body>
1114
</html>

demo/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const component = {
1313
})
1414
}
1515
},
16-
template: '<button @click="recaptcha">Execute recaptcha</button>'
16+
template: '<button @click="recaptcha">Execute without delay recaptcha</button>'
1717
}
1818

1919
createApp(component)

demo/webpack.config.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const path = require('path')
2-
const webpack = require('webpack')
32
const WebpackHtmlPlugin = require('html-webpack-plugin')
43

54
module.exports = {
6-
entry: path.resolve(__dirname, './src/index.ts'),
5+
entry: {
6+
index: path.resolve(__dirname, './src/index.ts'),
7+
delaydemo: path.resolve(__dirname, './src/delaydemo.ts')
8+
},
79

810
output: {
911
path: path.resolve(__dirname, './dist'),
@@ -24,22 +26,22 @@ module.exports = {
2426
resolve: {
2527
extensions: [
2628
'.js',
27-
'.ts',
29+
'.ts'
2830
],
2931
alias: {
30-
'vue$': 'vue/dist/vue.esm-bundler.js'
32+
vue$: 'vue/dist/vue.esm-bundler.js'
3133
}
3234
},
33-
mode: "development",
35+
mode: 'development',
3436
devServer: {
3537
compress: true,
36-
disableHostCheck: true,
38+
// disableHostCheck: true,
3739
historyApiFallback: true
3840
},
3941
plugins: [
4042
new WebpackHtmlPlugin({
4143
template: path.resolve(__dirname, './src/index.html'),
42-
inject: true,
44+
inject: true
4345
})
44-
],
45-
};
46+
]
47+
}

0 commit comments

Comments
 (0)