@@ -15,6 +15,7 @@ import {
15
15
import { ref , onMounted , watch } from " vue" ;
16
16
import { basicCode } from " @/constant" ;
17
17
import { memberList } from " @/constant" ;
18
+ import { isElementInViewport } from " @/hooks/detectElm" ;
18
19
// import createMonaco, { PlMonaco } from "@pivot-lang/create-monaco";
19
20
import CodeBlock from " @/components/codeBlock.vue" ;
20
21
import { cp } from " fs" ;
@@ -26,6 +27,7 @@ const tabList = basicCode.map((item) => item.title);
26
27
let code = ref (" " );
27
28
let runResult = ref (" " );
28
29
let initialized = ref (false );
30
+ let startLoad = ref (false );
29
31
let watchCallback = (val : string ) => {
30
32
console .log (' not initialized yet...' );
31
33
};
@@ -51,22 +53,27 @@ function handleOutput(re: string) {
51
53
52
54
onMounted (async () => {
53
55
code .value = basicCode [0 ].code ;
54
- import (" @pivot-lang/create-monaco" ).then (async pl => {
55
- let monaco = await pl .default (
56
- document .getElementById (" container" )! ,
57
- basicCode [0 ].code
58
- );
59
- monaco .editor .onDidChangeModelContent (() => {
60
- code .value = monaco .editor .getModel ()! .getValue ();
61
- });
62
- terminal .open (document .querySelector (" .code-block" ) as HTMLElement );
63
- terminal .resize (44 , 17 );
64
- watchCallback = (val ) => {
65
- const code1 = basicCode .find ((item ) => item .title === val )?.code || " " ;
66
- code .value = code1 ;
67
- monaco .setContent (code1 );
68
- };
69
- initialized .value = true ;
56
+ window .addEventListener (" scroll" , () => {
57
+ if (! startLoad .value && isElementInViewport (document .getElementById (" spinner" )! )) {
58
+ startLoad .value = true ;
59
+ import (" @pivot-lang/create-monaco" ).then (async pl => {
60
+ let monaco = await pl .default (
61
+ document .getElementById (" container" )! ,
62
+ basicCode [0 ].code
63
+ );
64
+ monaco .editor .onDidChangeModelContent (() => {
65
+ code .value = monaco .editor .getModel ()! .getValue ();
66
+ });
67
+ terminal .open (document .querySelector (" .code-block" ) as HTMLElement );
68
+ terminal .resize (44 , 17 );
69
+ watchCallback = (val ) => {
70
+ const code1 = basicCode .find ((item ) => item .title === val )?.code || " " ;
71
+ code .value = code1 ;
72
+ monaco .setContent (code1 );
73
+ };
74
+ initialized .value = true ;
75
+ });
76
+ }
70
77
});
71
78
});
72
79
watch (
@@ -105,7 +112,7 @@ watch(
105
112
<div class =" code-block" ></div >
106
113
</div >
107
114
</div >
108
- <div v-show =" !initialized" class =" code-now-container" >
115
+ <div v-show =" !initialized" id = " spinner " class =" code-now-container" >
109
116
<div class =" spinner" ></div >
110
117
</div >
111
118
</div >
@@ -118,7 +125,7 @@ watch(
118
125
to be highly concurrent and to exploit the locality of reference
119
126
patterns in modern programs.
120
127
</div >
121
- <GcEcharts ></GcEcharts >
128
+ <GcEcharts v-if = " startLoad " ></GcEcharts >
122
129
</div >
123
130
<div id =" advantage" >
124
131
<div class =" gradient-font title" >Reliability</div >
@@ -127,14 +134,14 @@ watch(
127
134
We have a large number of unit tests and integration tests to ensure
128
135
that the coverage of the code is as high as possible.
129
136
</div >
130
- <CodeCovEcharts ></CodeCovEcharts >
137
+ <CodeCovEcharts v-if = " startLoad " ></CodeCovEcharts >
131
138
</div >
132
139
<CrossPlatforms ></CrossPlatforms >
133
140
<VscSupportShow ></VscSupportShow >
134
141
<div id =" team" >
135
142
<div class =" gradient-font title" >Meet The Team</div >
136
143
<div class =" team-card" >
137
- <div class =" card-container" >
144
+ <div v-if = " startLoad " class =" card-container" >
138
145
<MemberCard
139
146
v-for =" member in memberList"
140
147
:key =" member.name"
0 commit comments