From e469482103e49437a74bb7397f62fa6b347ef7dd Mon Sep 17 00:00:00 2001 From: gvcayetano Date: Sat, 21 Sep 2019 11:04:01 +0800 Subject: [PATCH] Added loading progress bar. --- Gvc.ClientApp/nuxt.config.js | 2 +- Gvc.ClientApp/pages/about.vue | 12 ++++++++---- Gvc.ClientApp/pages/index.vue | 6 ++++++ Gvc.Web/VueHelper.cs | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Gvc.ClientApp/nuxt.config.js b/Gvc.ClientApp/nuxt.config.js index dd18b9b..d629326 100644 --- a/Gvc.ClientApp/nuxt.config.js +++ b/Gvc.ClientApp/nuxt.config.js @@ -24,7 +24,7 @@ export default { /* ** Customize the progress-bar color */ - loading: { color: '#fff' }, + loading: { color: '#ff8c00' }, /* ** Global CSS */ diff --git a/Gvc.ClientApp/pages/about.vue b/Gvc.ClientApp/pages/about.vue index 7613432..824a264 100644 --- a/Gvc.ClientApp/pages/about.vue +++ b/Gvc.ClientApp/pages/about.vue @@ -37,12 +37,16 @@ }, methods: { async getSocialMediaLinks() { - this.socialMediaLinks = await this.$axios.$get('/api/about') + this.socialMediaLinks = await this.$axios.$get('/api/about', { progress: true }) } }, - mounted() { - this.getSocialMediaLinks(); - } + mounted () { + this.$nextTick(() => { + this.$nuxt.$loading.start(); + this.getSocialMediaLinks(); + setTimeout(() => this.$nuxt.$loading.finish(), 500); + }) + } } diff --git a/Gvc.ClientApp/pages/index.vue b/Gvc.ClientApp/pages/index.vue index 7c0f2c5..a41a558 100644 --- a/Gvc.ClientApp/pages/index.vue +++ b/Gvc.ClientApp/pages/index.vue @@ -18,6 +18,12 @@ return { title: 'GVC - Software Engineer - MCSD' } + }, + mounted() { + this.$nextTick(() => { + this.$nuxt.$loading.start(); + setTimeout(() => this.$nuxt.$loading.finish(), 500); + }) } } diff --git a/Gvc.Web/VueHelper.cs b/Gvc.Web/VueHelper.cs index 3618c3d..57b31eb 100644 --- a/Gvc.Web/VueHelper.cs +++ b/Gvc.Web/VueHelper.cs @@ -17,7 +17,7 @@ public static class VueHelper // default port number of 'npm run serve' private static int Port { get; } = 3000; private static Uri DevelopmentServerEndpoint { get; } = new Uri($"http://localhost:{Port}"); - private static TimeSpan Timeout { get; } = TimeSpan.FromSeconds(30); + private static TimeSpan Timeout { get; } = TimeSpan.FromMinutes(1); // done message of 'npm run serve' command. private static string DoneMessage { get; } = "DONE Compiled successfully in";