Skip to content

Commit ccec20b

Browse files
authored
Merge pull request #1 from herozhou/master
doge update
2 parents 71279e3 + 9fc8f24 commit ccec20b

File tree

13 files changed

+575
-51
lines changed

13 files changed

+575
-51
lines changed

README.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# vue-framework-wz #
22

33

4-
[![TeamCity CodeBetter](https://img.shields.io/teamcity/codebetter/bt428.svg)]() [![npm](https://img.shields.io/npm/dw/localeval.svg)]() [![npm](https://img.shields.io/npm/v/npm.svg)]() [![Chrome Web Store](https://img.shields.io/chrome-web-store/stars/nimelepbpejjlbmoobocpfnjhihnpked.svg)]()
4+
[![TeamCity CodeBetter](https://img.shields.io/teamcity/codebetter/bt428.svg)]() [![npm](https://img.shields.io/npm/dw/localeval.svg)]() [![npm](https://img.shields.io/npm/v/npm.svg)]() [![Chrome Web Store](https://img.shields.io/chrome-web-store/stars/nimelepbpejjlbmoobocpfnjhihnpked.svg)]()[![Sourcegraph for Repo Reference Count](https://img.shields.io/sourcegraph/rrc//github.com/gorilla/mux.svg)]()[![GitHub watchers](https://img.shields.io/github/watchers/badges/shields.svg?style=social&label=Watch)]()
55

66
**[立即体验(国内)](http://herozhou.coding.me/vue-framework-wz/#/dashboard)**
77

@@ -18,6 +18,7 @@
1818
- **自适应布局**(完美适配大中小屏)
1919
- `登录/注销`
2020
- `权限验证`
21+
- **👉多TAB导航**(没有多TAB怎么能称为后台管理界面呢?)
2122
- `Tinymce 编辑器`
2223
- `Markdown 编辑器`
2324
- `动态侧边栏`(支持多级路由)
@@ -30,6 +31,39 @@
3031
- mock数据
3132
- 炫酷hover特效
3233

34+
35+
## Preview 效果图
36+
37+
#### 自适应布局
38+
39+
![自适应布局](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/index.gif)
40+
41+
#### 多TAB效果
42+
43+
![自适应布局](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/tab.gif)
44+
45+
#### 丰富功能表格
46+
47+
![丰富功能表格](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/table.gif)
48+
49+
#### 炫酷登录界面
50+
51+
![炫酷登录界面](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/login.gif)
52+
53+
#### 炫酷图表
54+
55+
![炫酷图表](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/echart.gif)
56+
57+
58+
#### 编辑器
59+
60+
![丰富功能表格](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/editor.gif)
61+
62+
63+
64+
**[更多demo](http://herozhou.coding.me/vue-framework-wz/#/dashboard)**
65+
66+
3367
## 系列教程
3468

3569
[《一步步带你做vue后台管理框架》第一课:介绍框架](http://www.cnblogs.com/herozhou/p/7434931.html)
@@ -119,31 +153,7 @@
119153
└── package.json // package.json
120154

121155
```
122-
## Preview 效果图
123-
124-
#### 自适应布局
125-
126-
![自适应布局](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/index.gif)
127-
128-
#### 丰富功能表格
129156

130-
![丰富功能表格](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/table.gif)
131-
#### 炫酷登录界面
132-
133-
![炫酷登录界面](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/login.gif)
134-
135-
#### 炫酷图表
136-
137-
![炫酷图表](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/echart.gif)
138-
139-
140-
#### 编辑器
141-
142-
![丰富功能表格](https://github.com/herozhou/JAVA-HTML-/blob/master/src/gifs/editor.gif)
143-
144-
145-
146-
**[更多demo](http://herozhou.coding.me/vue-framework-wz/#/dashboard)**
147157

148158
## About me 关于作者
149159

favicon.ico

-12 KB
Binary file not shown.

src/components/Header.vue

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,66 @@
88
</li>
99

1010
</ul>
11+
12+
<ul class="nav navbar-nav d-md-down-none">
13+
14+
<li class="nav-item header-item">
15+
16+
17+
<router-link tag="div" to='/' style="height:55px;" class="nav-link">
18+
<p><Icon type="compose" size='30' color="#2d8cf0"></Icon></p>
19+
<p style="color:white"> 留言管理 </p>
20+
</router-link>
21+
</li>
22+
<li class="nav-item header-item">
23+
24+
<router-link tag="div" to='/home1' style="height:55px;" class="nav-link">
25+
<p><Icon type="stats-bars" size='30' color="#2d8cf0"></Icon></p>
26+
<p style="color:white"> 浏览排行 </p>
27+
</router-link>
28+
29+
30+
</li>
31+
32+
<li class="nav-item header-item">
33+
<!-- -->
34+
35+
<Dropdown>
36+
<router-link tag="div" to='/' style="height:55px;" class="nav-link">
37+
<p><Icon type="android-cloud" size='30' color="#2d8cf0"></Icon></p>
38+
<p style="color:white"> 云服务器 </p>
39+
</router-link>
40+
<DropdownMenu slot="list">
41+
<DropdownItem>Linux</DropdownItem>
42+
<DropdownItem>Mac OS X</DropdownItem>
43+
<DropdownItem>Windows</DropdownItem>
44+
45+
<DropdownItem>Core OS</DropdownItem>
46+
</DropdownMenu>
47+
</Dropdown>
48+
49+
50+
51+
</li>
52+
53+
54+
<li class="nav-item header-item">
55+
56+
57+
<router-link tag="div" to='/home1' style="height:55px;" class="nav-link">
58+
<p><Icon type="trophy" size='30' color="#2d8cf0"></Icon></p>
59+
<p style="color:white"> 销量排行 </p>
60+
</router-link>
61+
62+
63+
</li>
64+
65+
66+
67+
68+
</ul>
69+
70+
1171
<ul class="nav navbar-nav ml-auto">
1272

1373
<li class="nav-item d-md-down-none">
@@ -100,10 +160,27 @@ export default {
100160
}
101161
</script>
102162

103-
<style type="text/css">
163+
<style type="text/css" scoped>
104164
.dropdown-itemp{
105165
text-align: left;
106166
font-size: 15px;
107167
padding: 10px;
108168
}
169+
.header-item .ivu-dropdown-item{
170+
padding: 15px;
171+
}
172+
.header-item{
173+
width: 130px;
174+
/*background-color: #20a8d8;*/
175+
/*background-color: white;*/
176+
177+
height: 55px;
178+
179+
180+
}
181+
.header-item a{
182+
color:white !important;
183+
184+
}
185+
109186
</style>

src/containers/Full2.vue

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<template>
2+
<div class="app">
3+
<AppHeader/>
4+
<div class="app-body">
5+
<Sidebar/>
6+
<main class="main">
7+
<breadcrumb :list="list"/>
8+
<div class="container-fluid">
9+
<router-view></router-view>
10+
</div>
11+
</main>
12+
<AppAside/>
13+
</div>
14+
<AppFooter/>
15+
</div>
16+
</template>
17+
18+
<script>
19+
import AppHeader from '../components/Header'
20+
import Sidebar from '../components/Sidebar'
21+
import AppAside from '../components/Aside'
22+
import AppFooter from '../components/Footer'
23+
import Breadcrumb from '../components/Breadcrumb'
24+
25+
export default {
26+
name: 'full',
27+
components: {
28+
AppHeader,
29+
Sidebar,
30+
AppAside,
31+
AppFooter,
32+
Breadcrumb
33+
},
34+
computed: {
35+
name () {
36+
return this.$route.name
37+
},
38+
39+
list () {
40+
return this.$route.matched
41+
}
42+
}
43+
}
44+
</script>

src/login.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import router from './router'
22
import store from './store'
3+
import vue from 'vue'
34
import NProgress from 'nprogress' // Progress 进度条
45
import 'nprogress/nprogress.css'// Progress 进度条样式
56

@@ -21,23 +22,28 @@ router.beforeEach((to, from, next) => {
2122
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
2223
store.dispatch('GetInfo').then(res => { // 拉取user_info
2324
const roles = res.data.role
25+
2426
store.dispatch('GenerateRoutes', { roles }).then(() => { // 生成可访问的路由表
2527
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
2628
next({ ...to }) // hack方法 确保addRoutes已完成
2729
})
30+
2831
}).catch(() => {
2932
store.dispatch('FedLogOut').then(() => {
3033
next({ path: '/login' })
3134
})
3235
})
3336
} else {
34-
// 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓
37+
38+
store.dispatch('getNowRoutes', to);
39+
3540
if (hasPermission(store.getters.roles, to.meta.role)) {
3641
next()//
42+
43+
console.log("has userinfo")
3744
} else {
3845
next({ path: '/', query: { noGoBack: true }})
3946
}
40-
// 可删 ↑
4147
}
4248
}
4349
} else {

src/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import App from './App';
33
import router from './router';
44
import store from './store';
55
import './mock/index.js'; // 该项目所有请求使用mockjs模拟
6-
76
import './login.js'
87
import './ui.js'
9-
108
Vue.config.productionTip = false;
11-
129
var vm=new Vue({
1310
el: '#app',
1411
router,

src/router/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import Vue from 'vue';
22
import Router from 'vue-router';
33
const _import = require('./_import_' + process.env.NODE_ENV);
44
import Full from '@/containers/Full'
5+
import Full2 from '@/containers/Full2'
6+
57
import Buttons from '@/views/components/Buttons'
68

79
// Views - Pages
@@ -79,6 +81,21 @@ export const asyncRouterMap = [
7981

8082
]
8183
},
84+
85+
{
86+
path: '/home1',
87+
redirect: '/home1/introduction',
88+
name: '首页2',
89+
component: Full2,
90+
hidden:false,
91+
children: [
92+
{path: '/home1/dashboard',name: 'Dashboard2',icon:'speedometer',component: _import('Dashboard2')},
93+
{path: '/home1/introduction',name: '介绍2',icon:'thumbsup',component: _import('Introduction')},
94+
95+
]
96+
},
97+
98+
8299
{ path: '*', redirect: '/pages/404', hidden: true }
83100

84101
];

src/store/modules/permission.js

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function hasPermission(roles, route) {
2121
function filterAsyncRouter(asyncRouterMap, roles) {
2222
const accessedRouters = asyncRouterMap.filter(route => {
2323
if (hasPermission(roles, route)) {
24+
2425
if (route.children && route.children.length) {
2526
route.children = filterAsyncRouter(route.children, roles)
2627
}
@@ -31,6 +32,21 @@ function filterAsyncRouter(asyncRouterMap, roles) {
3132
return accessedRouters
3233
}
3334

35+
36+
function getNowRouter(asyncRouterMap, to) {
37+
return asyncRouterMap.some(route => {
38+
if(to.path.indexOf(route.path) !==-1) {
39+
return true;
40+
}
41+
else if (route.children && route.children.length) { //如果有孩子就遍历孩子
42+
return getNowRouter(route.children, to)
43+
}
44+
})
45+
46+
}
47+
48+
49+
3450
const permission = {
3551
state: {
3652
routers: constantRouterMap,
@@ -41,15 +57,31 @@ const permission = {
4157
SET_ROUTERS: (state, routers) => {
4258
state.addRouters = routers;
4359
state.routers = constantRouterMap.concat(routers);
44-
state.routers.forEach(function(e){
45-
if(e.name==="首页"){
46-
state.siderbar_routers=e;
60+
// state.routers.forEach(function(e){
61+
// if(e.name==="首页"){
62+
// state.siderbar_routers=e;
4763

64+
// }
65+
66+
// })
67+
68+
},
69+
SET_NOW_ROUTERS: (state, to) => {
70+
71+
72+
// 递归访问 accessedRouters,找到包含to 的那个路由对象,设置给siderbar_routers
73+
console.log(state.addRouters)
74+
state.addRouters.forEach(e => {
75+
if(e.children&& e.children.length ){
76+
if( getNowRouter(e.children,to)===true)
77+
state.siderbar_routers=e;
4878
}
79+
80+
})
81+
4982

50-
})
83+
}
5184

52-
}
5385
},
5486
actions: {
5587
GenerateRoutes({ commit }, data) {
@@ -66,8 +98,16 @@ const permission = {
6698
commit('SET_ROUTERS', accessedRouters);
6799
resolve();
68100
})
69-
}
70-
}
101+
},
102+
103+
getNowRoutes({ commit }, data) {
104+
return new Promise(resolve => {
105+
//data => to
106+
commit('SET_NOW_ROUTERS', data);
107+
resolve();
108+
})
109+
},
110+
},
71111
};
72112

73113
export default permission;

0 commit comments

Comments
 (0)