File tree Expand file tree Collapse file tree 9 files changed +109
-21
lines changed Expand file tree Collapse file tree 9 files changed +109
-21
lines changed Original file line number Diff line number Diff line change
1
+ import Menus from './menus' ;
2
+
3
+ const components = {
4
+ Menus,
5
+ } ;
6
+
7
+ const install = ( Vue ) => {
8
+ Object . keys ( components ) . forEach ( ( component ) =>
9
+ Vue . component ( component , components [ component ] ) ,
10
+ ) ;
11
+ } ;
12
+
13
+ const API = {
14
+ install,
15
+ ...components ,
16
+ } ;
17
+
18
+ // auto install
19
+ if ( typeof window !== 'undefined' && window . Vue ) {
20
+ install ( window . Vue ) ;
21
+ }
22
+
23
+ export default API ;
Original file line number Diff line number Diff line change 22
22
23
23
import AppHeader from ' ./header/Index.vue' ;
24
24
import Sidebar from ' ./sidebar/Index.vue' ;
25
-
25
+ import { mapActions } from ' vuex ' ;
26
26
export default {
27
27
components: {
28
28
AppHeader ,
29
29
Sidebar ,
30
+ },
31
+ methods: {
32
+ ... mapActions ([' sidebarOpened' ])
30
33
}
31
34
}
32
- // @Component({
33
- // components: {
34
- // AppHeader,
35
- // Breadcrumb,
36
- // Sidebar,
37
- // },
38
- // })
39
- // export default class Layout extends Vue {
40
- // @Getter('viewStore/sidebarOpened') private sidebarOpened!: IViewState;
41
- // }
42
35
</script >
43
36
44
37
<style lang="scss">
Original file line number Diff line number Diff line change 6
6
<!-- 头部切换左侧菜单 -->
7
7
<div
8
8
class =" menus"
9
- @click =" toogleSidebar "
9
+ @click =" toggleSidebar "
10
10
>
11
11
<i class =" fas fa-bars" ></i >
12
12
</div >
@@ -50,7 +50,7 @@ export default {
50
50
storage .removeItem (currentUser);
51
51
this .$router .push ({ name: ' login' });
52
52
},
53
- ... mapActions ([' toogleSidebar ' ])
53
+ ... mapActions ([' toggleSidebar ' ])
54
54
},
55
55
mounted () {
56
56
this .username = storage .getItem (currentUser);
Original file line number Diff line number Diff line change
1
+ import Layout from './Layout.vue' ;
2
+ export default Layout ;
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ import 'element-ui/lib/theme-chalk/index.css';
18
18
Vue . use ( ElementUI ) ;
19
19
/******************************** 引入elementUi组件库 end ********************************/
20
20
21
+ // 配置自定义组件
22
+ // 使用自己定义的组件
23
+ import components from '@/components' ;
24
+ Vue . use ( components ) ;
25
+
21
26
Vue . config . productionTip = false ;
22
27
23
28
new Vue ( {
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue' ;
2
2
import Vuex from 'vuex' ;
3
+ const path = require ( 'path' ) ;
3
4
5
+ import { viewStore } from './view' ;
4
6
Vue . use ( Vuex ) ;
5
7
8
+ /********************************自动导包 start********************************/
9
+ const file = require . context ( './modules' , true , / \. t s / ) ;
10
+ const modules = { } ;
11
+ file . keys ( ) . forEach ( ( key ) => {
12
+ const name = path . basename ( key , '.js' ) ;
13
+ modules [ name ] = file ( key ) . default || file ( key ) ;
14
+ } ) ;
15
+ /********************************自动导包 end********************************/
16
+
17
+ const debug = process . env . NODE_ENV !== 'production' ;
18
+
6
19
export default new Vuex . Store ( {
7
- state : {
8
- } ,
9
- mutations : {
10
- } ,
11
- actions : {
12
- } ,
20
+ strict : debug ,
13
21
modules : {
14
- }
15
- } )
22
+ viewStore,
23
+ ...modules ,
24
+ } ,
25
+ } ) ;
Original file line number Diff line number Diff line change
1
+ export const OPEN_SIDEBAR = 'OPEN_SIDEBAR' ; // 打开侧边栏
2
+ export const CLOSE_SIDEBAR = 'CLOSE_SIDEBAR' ; // 关闭侧边栏
3
+ export const SET_TITLE = 'SET_TITLE' ;
4
+ export const SET_SIDE_MENU = 'SET_SIDE_MENU' ; // 设置左侧菜单
Original file line number Diff line number Diff line change
1
+ import * as types from './mutation-types' ;
2
+ const state = {
3
+ sidebarOpened : true ,
4
+ title : '主页' ,
5
+ menuList : [ ] ,
6
+ } ;
7
+
8
+ const getters = {
9
+ // tslint:disable-next-line:no-shadowed-variable
10
+ sidebarOpened : ( state ) => state . sidebarOpened ,
11
+ } ;
12
+
13
+ const mutations = {
14
+ [ types . OPEN_SIDEBAR ] ( s ) {
15
+ s . sidebarOpened = true ;
16
+ } ,
17
+ [ types . CLOSE_SIDEBAR ] ( s ) {
18
+ s . sidebarOpened = false ;
19
+ } ,
20
+ [ types . SET_TITLE ] ( s , title ) {
21
+ s . title = title ;
22
+ } ,
23
+ [ types . SET_SIDE_MENU ] : ( s , payload ) => {
24
+ s . menuList = payload ;
25
+ } ,
26
+ } ;
27
+
28
+ const actions = {
29
+ toggleSidebar ( { state, commit } ) {
30
+ state . sidebarOpened
31
+ ? commit ( types . CLOSE_SIDEBAR )
32
+ : commit ( types . OPEN_SIDEBAR ) ;
33
+ } ,
34
+
35
+ setTitle ( { commit } , params ) {
36
+ commit ( types . SET_TITLE , params ) ;
37
+ } ,
38
+ } ;
39
+
40
+ export const viewStore = {
41
+ namespaced : true ,
42
+ state,
43
+ getters,
44
+ mutations,
45
+ actions,
46
+ } ;
Original file line number Diff line number Diff line change 4
4
</div >
5
5
</template >
6
6
7
+ <script >
8
+ export default {
9
+
10
+ }
11
+ </script >
7
12
<style lang="scss">
8
13
</style >
You can’t perform that action at this time.
0 commit comments