antanklayout_vue2 0.0.213 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,2 +1,124 @@
1
- #tickethtml
2
- #seatstatus 1 正常 3 锁定 6 维修
1
+ # antanklayout
2
+
3
+ >
4
+ This component is only used in ANTANK SaaS, which will solve the scheduling problem between multiple systems and is suitable for the VUE2 environment
5
+
6
+ It is done in three steps:
7
+ 1) 安装组件(install the component)
8
+
9
+ ## Installation
10
+ ```bash
11
+
12
+ npm i antanklayout_vue2
13
+
14
+ ```
15
+
16
+ ## Usage
17
+ 2) 引入组件(introduce the component)
18
+
19
+ Ingest styles globally
20
+ main.ts
21
+ ```
22
+ import 'antanklayout_vue2/dist/antanklayout_vue2.css'
23
+
24
+ ```
25
+
26
+ 创建导入组件的页面(Create a Vue page "layout" layout.vue)
27
+
28
+ ```
29
+ <template>
30
+ <Antanklayout>
31
+ <transition appear name="fade-transform" mode="out-in">
32
+ <keep-alive :include="cachedViews">
33
+ <router-view :key="key" />
34
+ </keep-alive>
35
+ </transition>
36
+ </Antanklayout>
37
+ </template>
38
+ <script>
39
+ import Vue from 'vue'
40
+ import antanklayout from "antanklayout_vue2"
41
+ Vue.component('Antanklayout', antanklayout.Antanklayout)
42
+ export default {
43
+ name: 'Layout',
44
+ components: {
45
+ Antanklayout:antanklayout.Antanklayout
46
+ },
47
+ computed: {
48
+ cachedViews() {
49
+ return this.$store.state.tagsView.cachedViews
50
+ },
51
+ key() {
52
+ return this.$route.path
53
+ }
54
+ }
55
+ }
56
+ </script>
57
+ <style scoped lang="scss">
58
+ </style>
59
+
60
+
61
+ ```
62
+ 3) 动态路由(adjust the routing)
63
+
64
+
65
+ ```
66
+ 第一种方法
67
+ const DynameicMenuList = []
68
+ //路由扁平化处理
69
+ const getFlatMenuList = (menuList) => {
70
+ return menuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])]);
71
+ }
72
+ //过滤和动态添加路由
73
+ const setDynameicMenuListPath = (menuList) => {
74
+ for (const item of getFlatMenuList(menuList)) {
75
+ item.children && delete item.children
76
+ if (item.component && typeof item.component == 'string') {
77
+ if (item.component == 'Layout') {
78
+ item.component = Layout
79
+ } else if (item.component == 'SeatMenu') {
80
+ item.component = Layout
81
+ } else if (item.component == 'AsideMenu') {
82
+ item.component = Layout
83
+ } else if (item.component == 'AppMain') {
84
+ item.component = Layout
85
+ } else if (item.component == 'MainContent') {
86
+ item.component = Layout
87
+ }
88
+ }
89
+
90
+ if(item.path && !item.redirect){
91
+ DynameicMenuList.push({
92
+ path: "/layout",
93
+ name: "layout",
94
+ component: Layout,
95
+ redirect: item.path,
96
+ children:[
97
+ item
98
+ ]
99
+ })
100
+ }
101
+ }
102
+ }
103
+ setDynameicMenuListPath(venue.venue)//动态添加路由
104
+
105
+ const createRouter = () => new Router({
106
+ mode: 'hash',
107
+ scrollBehavior: () => ({ y: 0 }),
108
+ routes: [...DynameicMenuList,
109
+ {
110
+ path: '/',//开始进入系统
111
+ redirect: HOME_URL
112
+ },
113
+ {
114
+ path: "/layout",//调度当前系统的路由
115
+ name: "layout",
116
+ component: () => import("layout.vue"),//先前创建的页面
117
+ children: []
118
+ }]
119
+ })
120
+
121
+
122
+ 第二种方法,手动在路由表中把所有子路由的父级指向layout,然后正常添加路由即可
123
+
124
+ ```