From 571b67bc84cc8f34f9c506c708bd0dcc51daee34 Mon Sep 17 00:00:00 2001 From: avele <34437766+avele@users.noreply.github.com> Date: Tue, 26 Nov 2019 17:21:20 +0400 Subject: [PATCH] Client preload rewritten (#417) --- front/client/App.vue | 25 ++++-- .../components/ClientServerPrefetch.vue | 76 +++++++++++++++++++ front/client/components/SearchBar.vue | 30 ++++---- front/client/entry.client.ts | 67 ---------------- front/client/entry.server.ts | 2 + front/client/page/CategoryPage.vue | 10 --- front/client/page/Index.vue | 6 +- front/client/page/Page404.vue | 4 - front/client/page/SearchResults.vue | 23 ++---- front/client/router/index.ts | 41 ++++++++-- front/client/store/index.ts | 2 +- front/client/store/modules/wiki.ts | 6 +- front/index.html | 2 +- 13 files changed, 157 insertions(+), 137 deletions(-) create mode 100644 front/client/components/ClientServerPrefetch.vue diff --git a/front/client/App.vue b/front/client/App.vue index 54ad1cf..261131a 100644 --- a/front/client/App.vue +++ b/front/client/App.vue @@ -2,7 +2,9 @@
- + + +
@@ -14,24 +16,21 @@ import Component from 'vue-class-component' import { Watch } from 'vue-property-decorator' import AFooter from 'client/components/AFooter.vue' import Toolbar from 'client/components/Toolbar.vue' +import ClientServerPrefetch from 'client/components/ClientServerPrefetch.vue' import * as nprogress from 'nprogress' import 'nprogress/nprogress.css' +import { getRouteDocumentTitle } from 'client/router' nprogress.configure({ showSpinner: false }) @Component({ components: { Toolbar, - AFooter + AFooter, + ClientServerPrefetch } }) export default class RootComponent extends Vue { - beforeMount () { - // This package can only be loaded after mounted (on client only) cause it uses "document" - // it is used in MarkdownEditor.vue and to make it work faster in that component we preload it here - import('easymde') - } - get isPageLoading () { return this.$store.state.isPageLoading } @@ -39,6 +38,16 @@ export default class RootComponent extends Vue { @Watch('isPageLoading') toogleLoading (isPageLoading: boolean) { isPageLoading ? nprogress.start() : nprogress.done() + + if (!isPageLoading) { + document.title = getRouteDocumentTitle(this.$route) + } + } + + beforeMount () { + // This package can only be loaded after mounted (on client only) cause it uses "document" + // it is used in MarkdownEditor.vue and to make it work faster in that component we preload it here + import('easymde') } } diff --git a/front/client/components/ClientServerPrefetch.vue b/front/client/components/ClientServerPrefetch.vue new file mode 100644 index 0000000..e975d0a --- /dev/null +++ b/front/client/components/ClientServerPrefetch.vue @@ -0,0 +1,76 @@ + \ No newline at end of file diff --git a/front/client/components/SearchBar.vue b/front/client/components/SearchBar.vue index 91adaf1..03841ef 100644 --- a/front/client/components/SearchBar.vue +++ b/front/client/components/SearchBar.vue @@ -1,7 +1,7 @@