Skip to content

Commit

Permalink
Merge pull request #169 from jason5ng32/dev
Browse files Browse the repository at this point in the history
SpeedTest Improvements
  • Loading branch information
jason5ng32 authored Apr 12, 2024
2 parents 0360cdc + 60dea30 commit f170792
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/components/speedtest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<span v-if="speedTestStatus === 'running'">
<i class="bi bi-pause-fill"></i>
</span>
<span v-else-if="speedTestStatus === 'finished' || speedTestStatus === 'error'">
<i class="bi bi-arrow-clockwise"></i>
</span>
<span v-else><i class="bi bi-caret-right-fill"></i></span>
</button>
</div>
Expand Down Expand Up @@ -84,7 +87,7 @@
</div>
</div>
<div class="row alert alert-success m-1 p-2 " :data-bs-theme="isDarkMode ? 'dark' : ''"
v-if="speedTestStatus === 'finished'">
v-if="speedTestStatus === 'finished' && hasScores">
<p id="score" class="speedtest-p"><i class="bi bi-calendar2-check"></i> {{ $t('speedtest.score') }}
{{ $t('speedtest.videoStreaming') }}
<span :class="speedTest.streamingScore >= 50 ? 'text-success' : 'text-warning'">
Expand Down Expand Up @@ -158,6 +161,7 @@ export default {
}
},
testEngine: null,
hasScores: false,
};
},
Expand Down Expand Up @@ -193,6 +197,7 @@ export default {
// 重置 Speed Test
resetSpeedTest() {
this.hasScores = false;
const engine = new SpeedTestEngine({
autoStart: false,
measurements: [
Expand Down Expand Up @@ -322,12 +327,15 @@ export default {
this.testEngine.onFinish = results => {
this.speedTestStatus = "finished";
this.updateSpeedTestResults(results);
const scores = results.getScores();
// 更新 Vue 实例的数据属性
this.speedTest.streamingScore = scores.streaming.points;
this.speedTest.gamingScore = scores.gaming.points;
this.speedTest.rtcScore = scores.rtc.points;
const scores = results.getScores().streaming ? results.getScores() : '';
if (scores) {
this.hasScores = true;
// 更新 Vue 实例的数据属性
this.speedTest.streamingScore = scores.streaming.points;
this.speedTest.gamingScore = scores.gaming.points;
this.speedTest.rtcScore = scores.rtc.points;
}
};
this.testEngine.onError = (e) => {
Expand All @@ -345,5 +353,4 @@ export default {
}
</script>

<style scoped>
</style>
<style scoped></style>

0 comments on commit f170792

Please sign in to comment.