@mixd-id/web-scaffold 0.1.230406224 → 0.1.230406225
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/package.json +1 -1
- package/src/components/FBLogin.vue +93 -0
- package/src/components/GSignIn.vue +95 -0
- package/src/index.js +3 -1
package/package.json
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button type="button" @click="login">
|
|
3
|
+
<slot>
|
|
4
|
+
Login with Facebook
|
|
5
|
+
</slot>
|
|
6
|
+
</button>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
|
|
11
|
+
export default{
|
|
12
|
+
|
|
13
|
+
emits: [ 'login' ],
|
|
14
|
+
|
|
15
|
+
props: {
|
|
16
|
+
|
|
17
|
+
appId: String,
|
|
18
|
+
|
|
19
|
+
scope: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: 'public_profile,email'
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
version: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'v18.0'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
data(){
|
|
32
|
+
return {
|
|
33
|
+
text: '',
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
mounted() {
|
|
38
|
+
this.loadScript();
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
methods: {
|
|
42
|
+
|
|
43
|
+
onResponse(){
|
|
44
|
+
FB.api('/me', { fields:'name,email' }, function(response){
|
|
45
|
+
console.log('#11', response)
|
|
46
|
+
this.$emit('login', response)
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
login(){
|
|
51
|
+
FB.getLoginStatus((response) => {
|
|
52
|
+
if(response.status === 'connected'){
|
|
53
|
+
this.onResponse(response)
|
|
54
|
+
}
|
|
55
|
+
else{
|
|
56
|
+
FB.login((response) => {
|
|
57
|
+
if(response.status === 'connected'){
|
|
58
|
+
this.onResponse(response)
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{ scope: this.scope }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
loadScript(){
|
|
68
|
+
if('FB' in window) return
|
|
69
|
+
|
|
70
|
+
(function(d, s, id){
|
|
71
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
|
72
|
+
if (d.getElementById(id)) {return;}
|
|
73
|
+
js = d.createElement(s); js.id = id;
|
|
74
|
+
js.src = "https://connect.facebook.net/en_US/sdk.js";
|
|
75
|
+
fjs.parentNode.insertBefore(js, fjs);
|
|
76
|
+
}(document, 'script', 'facebook-jssdk')
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
window.fbAsyncInit = () => {
|
|
80
|
+
FB.init({
|
|
81
|
+
appId: this.appId,
|
|
82
|
+
xfbml: true,
|
|
83
|
+
version: this.version
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
</script>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button type="button" @click="login">
|
|
3
|
+
<slot>
|
|
4
|
+
Sign In with Google
|
|
5
|
+
</slot>
|
|
6
|
+
</button>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
|
|
11
|
+
export default{
|
|
12
|
+
|
|
13
|
+
emits: [ 'login' ],
|
|
14
|
+
|
|
15
|
+
props: {
|
|
16
|
+
|
|
17
|
+
apiKey: String
|
|
18
|
+
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
mounted() {
|
|
22
|
+
this.loadScript();
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
data(){
|
|
26
|
+
return {
|
|
27
|
+
auth2: null
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
methods: {
|
|
32
|
+
|
|
33
|
+
async loadScript(){
|
|
34
|
+
if("gapi" in window) return
|
|
35
|
+
|
|
36
|
+
/*await new Promise(api_ready => document.head.append(Object.assign(
|
|
37
|
+
document.createElement('script'),
|
|
38
|
+
{
|
|
39
|
+
src: 'https://apis.google.com/js/api.js',
|
|
40
|
+
onload: api_ready,
|
|
41
|
+
})));
|
|
42
|
+
|
|
43
|
+
await new Promise(auth2_ready => gapi.load('auth2', auth2_ready));
|
|
44
|
+
|
|
45
|
+
const googleAuth = await new Promise(init_done => gapi.auth2.init({
|
|
46
|
+
client_id: this.apiKey,
|
|
47
|
+
scope: 'profile email',
|
|
48
|
+
}).then(googleAuthWithThen => init_done(Object.assign(googleAuthWithThen, {
|
|
49
|
+
then: undefined,
|
|
50
|
+
}))));
|
|
51
|
+
|
|
52
|
+
console.log('googleAuth =', googleAuth);*/
|
|
53
|
+
|
|
54
|
+
const script = document.createElement('script')
|
|
55
|
+
script.src = 'https://apis.google.com/js/api:client.js'
|
|
56
|
+
document.head.appendChild(script)
|
|
57
|
+
script.addEventListener('load', () => {
|
|
58
|
+
window.gapi.load('auth2', () => {
|
|
59
|
+
var authObj = {
|
|
60
|
+
client_id: this.apiKey,
|
|
61
|
+
scope: 'profile email',
|
|
62
|
+
cookiepolicy: 'single_host_origin'
|
|
63
|
+
};
|
|
64
|
+
console.log(authObj)
|
|
65
|
+
window.gapi.auth2.init(authObj)
|
|
66
|
+
.then(function(gAuth){
|
|
67
|
+
console.log('gAuth', gAuth)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
login(){
|
|
74
|
+
gapi.auth2.getAuthInstance().signIn()
|
|
75
|
+
.then((googleUser) => {
|
|
76
|
+
console.log('googleUser', googleUser)
|
|
77
|
+
var profile = googleUser.getBasicProfile();
|
|
78
|
+
var idToken = googleUser.getAuthResponse().id_token;
|
|
79
|
+
const name = profile.getName()
|
|
80
|
+
const imageUrl = profile.getImageUrl()
|
|
81
|
+
const email = profile.getEmail()
|
|
82
|
+
this.$emit('login', {
|
|
83
|
+
idToken,
|
|
84
|
+
name,
|
|
85
|
+
imageUrl,
|
|
86
|
+
email
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
</script>
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import throttle from "lodash/throttle"
|
|
|
4
4
|
|
|
5
5
|
let _UNIQID = 0
|
|
6
6
|
const uniqid = (additionalKey = '') => {
|
|
7
|
-
return '
|
|
7
|
+
return 'u' + Math.random().toString(36).substr(2) + Date.now().toString(36)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const mediaBreakpoints = {
|
|
@@ -432,6 +432,8 @@ export default{
|
|
|
432
432
|
app.component('YoutubeVideo', defineAsyncComponent(() => import("./components/YoutubeVideo.vue")))
|
|
433
433
|
app.component('Svg', defineAsyncComponent(() => import("./components/Svg.vue")))
|
|
434
434
|
app.component('ConversationBuilder', defineAsyncComponent(() => import("./components/ConversationBuilder.vue")))
|
|
435
|
+
//app.component('FBLogin', defineAsyncComponent(() => import("./components/FBLogin.vue")))
|
|
436
|
+
//app.component('GSignIn', defineAsyncComponent(() => import("./components/GSignIn.vue")))
|
|
435
437
|
|
|
436
438
|
app.component('AhrefSetting', defineAsyncComponent(() => import("./widgets/AhrefSetting.vue")))
|
|
437
439
|
app.component('ArticleSetting', defineAsyncComponent(() => import("./widgets/ArticleSetting.vue")))
|