Skip to content

Commit 7761808

Browse files
author
Guillaume Chau
committed
perf(task): better perceived perf with display priority
1 parent 24edd93 commit 7761808

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export default function (count = 1) {
2+
// @vue/component
3+
return {
4+
data () {
5+
return {
6+
displayPriority: 0
7+
}
8+
},
9+
10+
mounted () {
11+
this.runDislayPriority()
12+
},
13+
14+
methods: {
15+
runDislayPriority () {
16+
const step = () => {
17+
requestAnimationFrame(() => {
18+
this.displayPriority++
19+
if (this.displayPriority < count) {
20+
step()
21+
}
22+
})
23+
}
24+
step()
25+
}
26+
}
27+
}
28+
}

packages/@vue/cli-ui/src/views/ProjectTaskDetails.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</VueGroup>
7575
</div>
7676

77-
<div class="content">
77+
<div v-if="displayPriority >= 2" class="content">
7878
<TerminalView
7979
ref="terminal"
8080
:class="{
@@ -130,6 +130,7 @@
130130

131131
<script>
132132
import Prompts from '../mixins/Prompts'
133+
import DisplayPriority from '../mixins/DisplayPriority'
133134
134135
import TASK from '../graphql/task.gql'
135136
import TASK_LOGS from '../graphql/taskLogs.gql'
@@ -154,7 +155,8 @@ export default {
154155
Prompts({
155156
field: 'task',
156157
query: TASK
157-
})
158+
}),
159+
DisplayPriority(2)
158160
],
159161
160162
metaInfo () {
@@ -192,6 +194,9 @@ export default {
192194
await this.$nextTick()
193195
this.currentView = data.task.defaultView
194196
}
197+
},
198+
skip () {
199+
return this.displayPriority < 1
195200
}
196201
},
197202
@@ -212,6 +217,9 @@ export default {
212217
data.taskLogs.logs.forEach(terminal.addLog)
213218
}
214219
}
220+
},
221+
skip () {
222+
return this.displayPriority < 2
215223
}
216224
},
217225
@@ -229,6 +237,9 @@ export default {
229237
const terminal = this.$refs.terminal
230238
terminal.addLog(data.taskLogAdded)
231239
}
240+
},
241+
skip () {
242+
return this.displayPriority < 2
232243
}
233244
}
234245
}
@@ -254,6 +265,7 @@ export default {
254265
this.currentView = '_output'
255266
this.$_init = false
256267
this.open()
268+
this.runDisplayPriority()
257269
}
258270
},
259271

0 commit comments

Comments
 (0)