File tree Expand file tree Collapse file tree 1 file changed +27
-13
lines changed Expand file tree Collapse file tree 1 file changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -20,33 +20,47 @@ const props = defineProps<{
20
20
const tweet = ref <HTMLElement | null >()
21
21
22
22
const vm = getCurrentInstance ()!
23
+ const loaded = ref (false )
23
24
24
- function create() {
25
+ async function create() {
25
26
// @ts-ignore
26
- window ? .twttr ? .widgets ? .createTweet (
27
+ await window .twttr .widgets .createTweet (
27
28
props .id .toString (),
28
29
tweet .value ,
29
30
{
30
31
theme: isDark .value ? ' dark' : ' light' ,
31
32
conversation: props .conversation || ' none' ,
32
33
},
33
34
)
35
+ loaded .value = true
34
36
}
35
37
36
- useScriptTag (
37
- ' https://platform.twitter.com/widgets.js' ,
38
- () => {
39
- if (vm .isMounted )
40
- create ()
41
- else
42
- onMounted (create , vm )
43
- },
44
- { async: true },
45
- )
38
+ // @ts-ignore
39
+ if (window ?.twttr ?.widgets ) {
40
+ onMounted (create )
41
+ }
42
+ else {
43
+ useScriptTag (
44
+ ' https://platform.twitter.com/widgets.js' ,
45
+ () => {
46
+ if (vm .isMounted )
47
+ create ()
48
+ else
49
+ onMounted (create , vm )
50
+ },
51
+ { async: true },
52
+ )
53
+ }
46
54
</script >
47
55
48
56
<template >
49
57
<Transform :scale =" scale || 1" >
50
- <div ref =" tweet" ></div >
58
+ <div ref =" tweet" >
59
+ <div v-if =" !loaded" class =" w-30 h-30 my-10px bg-gray-400 bg-opacity-10 rounded-lg flex opacity-50" >
60
+ <div class =" m-auto animate-pulse text-4xl" >
61
+ <carbon:logo-twitter />
62
+ </div >
63
+ </div >
64
+ </div >
51
65
</Transform >
52
66
</template >
You can’t perform that action at this time.
0 commit comments