From 6e7ee4d38fb3630a13d31592f0f6ae9bbe8e1bd6 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 21 Dec 2019 03:32:20 +0100 Subject: Implemented global components registration Moved the fullscreen button as a global component (as demonstration) Improved the layout CSS --- viewer/src/components/LdButtonFullscreen.vue | 25 +++++++++++ viewer/src/components/index.ts | 22 ++++++++++ viewer/src/main.ts | 1 + viewer/src/views/LdGallery.vue | 66 +++++++++++++--------------- 4 files changed, 78 insertions(+), 36 deletions(-) create mode 100644 viewer/src/components/LdButtonFullscreen.vue create mode 100644 viewer/src/components/index.ts diff --git a/viewer/src/components/LdButtonFullscreen.vue b/viewer/src/components/LdButtonFullscreen.vue new file mode 100644 index 0000000..2302a27 --- /dev/null +++ b/viewer/src/components/LdButtonFullscreen.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/viewer/src/components/index.ts b/viewer/src/components/index.ts new file mode 100644 index 0000000..1406b34 --- /dev/null +++ b/viewer/src/components/index.ts @@ -0,0 +1,22 @@ +import Vue from 'vue' + +const requireComponent = require.context( + '@/components', + false, // Whether or not to look in subfolders + // The regular expression used to match base component filenames + /Ld[A-Z]\w+\.vue$/ +) + +requireComponent.keys().forEach(fileName => { + const componentConfig = requireComponent(fileName) + const componentName = fileName.split('/').pop()!.replace(/\.vue$/, ''); + + // Register component globally + Vue.component( + componentName, + // Look for the component options on `.default`, which will + // exist if the component was exported with `export default`, + // otherwise fall back to module's root. + componentConfig.default || componentConfig + ) +}) \ No newline at end of file diff --git a/viewer/src/main.ts b/viewer/src/main.ts index 3a3593c..ca439bc 100644 --- a/viewer/src/main.ts +++ b/viewer/src/main.ts @@ -1,5 +1,6 @@ import Vue from "vue"; import "@/assets/scss/global.scss"; +import "@/components" import "@/plugins/fontawesome"; import "@/plugins/buefy"; import store from '@/plugins/vuex' diff --git a/viewer/src/views/LdGallery.vue b/viewer/src/views/LdGallery.vue index d22bfa6..ecdfa1b 100644 --- a/viewer/src/views/LdGallery.vue +++ b/viewer/src/views/LdGallery.vue @@ -1,13 +1,9 @@ @@ -19,61 +15,59 @@ export default class LdGallery extends Vue {}