App.vue 2.49 KB
Newer Older
1
2
<template>
    <div id="app">
3
        <Navbar/>
4
5
6
7
8
        <div id="wrapper">
            <div id="page-content-wrapper">
                <div class="container">
                    <b-breadcrumb :items="breadcrumbs"/>
                    <router-view/>
9
                    <Footer/>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
                </div>
            </div>
        </div>
    </div>
</template>

<style lang="scss">
    @import '../node_modules/bootstrap/scss/bootstrap.scss';
    @import '../node_modules/bootstrap-vue/dist/bootstrap-vue.css';
    @import 'assets/css/net-suite.css';
    @import 'assets/css/net-suite-devel.css';
    @import 'assets/css/net-suite-test.css';
</style>

<script>
25
    import LoginService from '@/api-services/login.service'
26
    import Navbar from "./components/Navbar";
27
    import Footer from "./components/Footer";
28

29
    export default {
30
        components: {Footer, Navbar},
31
32
        data() {
            return {
33
                breadcrumbs: [],
34
35
36
            }
        },
        watch: {
37
            $route() {
38
39
                var m = this.$router.currentRoute.matched
                m = m[m.length - 1]
40
41
42
43
44
                this.breadcrumbs = this.gen_bread(m)
            }
        },
        methods: {
            gen_bread(m) {
45
                var res = [{text: m.meta.resolveName(this.$route.params), path: m.path}]
46
47
48
                while ((m.meta && m.meta.resolveParents) || m.parent) {
                    if (m.meta && m.meta.resolveParents) {
                        let parents = m.meta.resolveParents(this.$route.params)
49
50
                        for (let i = 0; i < parents.length; i++) {
                            if (typeof parents[i] === 'object' && 'text' in parents[i] && 'to' in parents[i]) {
51
52
53
54
55
56
57
                                res.unshift(parents[i])
                                continue
                            }
                            m = this.$router.resolve(parents[i]).resolved.matched
                            m = m[m.length - 1]
                            res.unshift({text: m.meta.resolveName(this.$route.params), to: parents[i]})
                        }
58
59
                    } else {
                        m = m.parent
60
                        res.unshift({text: m.meta.resolveName(this.$route.params), to: m.path})
61
62
                    }
                }
63
                return res
64
65
66
67
68
            },
            logout() {
                LoginService.logout(this.$store.state.token.pk)
                this.$store.commit('logout')
                this.$router.push('/login')
69
70
71
72
            }
        }
    }
</script>