Blame view

api/dashboard/src/App.vue 1.49 KB
0d8c0f816   Thanasis Naskos   initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  <template>
    <div id="app">
      <loading ref="loading" />
      <transition name="page" mode="out-in">
        <component :is="layout" v-if="layout" />
      </transition>
    </div>
  </template>
  
  <script>
      import Loading from './Loading'
  
      // Load layout components dynamically.
      const requireContext = require.context('~/layouts', false, /.*\.vue$/)
  
      const layouts = requireContext.keys()
          .map(file =>
              [file.replace(/(^.\/)|(\.vue$)/g, ''), requireContext(file)]
          )
          .reduce((components, [name, component]) => {
              components[name] = component.default || component
              return components
          }, {})
  
      export default {
          el: '#app',
  
          components: {
              Loading
          },
  
          data: () => ({
              layout: null,
              defaultLayout: 'default'
          }),
  
          metaInfo () {
              const appName = process.env.VUE_APP_NAME
  
              return {
                  title: appName,
                  titleTemplate: `%s ยท ${appName}`
              }
          },
  
          mounted () {
              this.$loading = this.$refs.loading
          },
  
          methods: {
              /**
               * Set the application layout.
               *
               * @param {String} layout
               */
              setLayout (layout) {
                  if (!layout || !layouts[layout]) {
                      layout = this.defaultLayout
                  }
  
                  this.layout = layouts[layout]
              }
          }
      }
  </script>