Skip to content

Commit c37a000

Browse files
committed
update some
- 新增 标签导航功能(tagsView) 动态路由(addRoutes) 重定向页面(redirect) - 修改 拆分store使用vuex的module模式 权限验证逻辑(permission.js) - 修复 表单格式传输多文件的时候,嵌套的对象数据不能转换问题(request.js)
1 parent 74274a3 commit c37a000

File tree

27 files changed

+734
-293
lines changed

27 files changed

+734
-293
lines changed

README.md

+31-62
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,56 @@
1-
# vue-blog-template
1+
# vueBlog-template
22

3-
[![image](https://img.shields.io/badge/vue-2.6.8-brightgreen.svg)](https://github.com/vuejs/vue)
4-
[![image](https://img.shields.io/badge/vue--router-3.0.2-brightgreen.svg)](https://github.com/vuejs/vue-router)
5-
[![image](https://img.shields.io/badge/vuex-3.1.0-brightgreen.svg)](https://github.com/vuejs/vuex)
6-
[![image](https://img.shields.io/badge/vue--cli-3.x-brightgreen.svg)](https://cli.vuejs.org/zh/)
7-
[![image](https://img.shields.io/badge/element--ui-2.7.0-9cf.svg)](https://github.com/ElemeFE/element)
8-
[![GitHub release](https://img.shields.io/github/release/uncleLian/vue-blog-template.svg)](https://github.com/uncleLian/vue-blog/releases)
3+
![image](https://img.shields.io/badge/vue-2.6.8-green.svg)
4+
![image](https://img.shields.io/badge/vue--router-3.0.2-green.svg)
5+
![image](https://img.shields.io/badge/vuex-3.1.0-green.svg)
6+
![image](https://img.shields.io/badge/element--ui-2.10.0-blue.svg)
97

10-
##### 注:master分支基于 vue-cli-3.x,vue-cli-2.x请移步到v1.0分支
118

129
> 这是一个极简的管理后台模板,它只包含了搭建管理后台的一些必要功能
1310
11+
##### 注:master分支基于 vue-cli-3.x,vue-cli-2.x请移步到[v1.0分支](https://github.com/uncleLian/vueBlog-template/tree/v1.0)
12+
1413
- [在线演示](http://template.liansixin.win)
15-
- [使用文档](https://unclelian.github.io/vue-blog-docs/)
14+
- [使用文档](http://liansixin.win/vue-blog-book)
1615

17-
<img src="http://poci6sbqi.bkt.clouddn.com/vue-blog-template.png" width="900px" style="max-width: 100%;"/>
16+
<img src="https://github.com/uncleLian/vueBlog-template/raw/gh-pages/screenshots/dashboard.png" width="900px" style="max-width: 100%;"/>
1817

1918
## 功能
20-
功能持续迭代中,欢迎 [pr](https://github.com/uncleLian/vue-blog/pulls)[issue](https://github.com/uncleLian/vue-blog/issues)
21-
22-
```
23-
- 登录/注销
24-
- 权限验证
25-
- 页面级权限
26-
- 按钮级权限
27-
- 多环境
28-
- dev
29-
- prod
30-
- stage
31-
- 动态侧边栏
32-
- 动态面包屑
33-
- 错误处理
34-
- 401
35-
- 404
36-
- 错误日志
37-
- 其他处理
38-
- axios封装
39-
- cache封装
40-
- 页面平滑过渡
41-
- css预处理器全局变量
42-
- 包体积优化
43-
- svg icon / iconfont
44-
- mock
45-
- 进度条
46-
```
47-
48-
## 开发
19+
- [x] 登录/注销
20+
- [x] 权限验证(页面级)
21+
- [x] 动态侧边栏
22+
- [x] 动态面包屑
23+
- [x] 导航标签
24+
- [x] 401、404、全局错误捕捉
25+
- [x] 多环境(dev、sit、prod)
26+
- [x] svg icon / iconfont
27+
- [x] 进度条
28+
- [x] element-ui
29+
- [x] axios封装(统一处理请求、拦截、报错等)
30+
- [x] cache封装
31+
32+
33+
## 开发和发布
4934
```bash
5035
# 克隆项目
51-
git clone https://github.com/uncleLian/vue-blog-template.git
36+
git clone https://github.com/uncleLian/vueBlog-template.git
5237

5338
# 安装依赖
5439
npm install
5540

56-
# 启动服务:localhost:8003
41+
# 启动服务
5742
npm run dev
58-
```
59-
60-
## 发布
61-
```bash
62-
# 构建测试环境
63-
npm run build:stage
6443

65-
# 构建生产环境
44+
# 发布
6645
npm run build
6746

68-
# 查看构建报告
47+
# 测试环境
48+
npm run build:stage
49+
50+
# 报告
6951
npm run build:report
7052
```
7153

72-
## 版本日志
73-
[发行说明](https://github.com/uncleLian/vue-blog-template/releases)中记录了每个版本的详细更改。
74-
75-
## Browsers support
76-
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
77-
| --------- | --------- | --------- | --------- | --------- |
78-
| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
79-
80-
## 捐赠
81-
如果觉得这个项目帮助到了你,你可以请作者喝杯饮料表示支持 :green_heart:
82-
83-
![image](http://poci6sbqi.bkt.clouddn.com/donate.jpg)
84-
8554
## 交流
8655
欢迎热爱学习、忠于分享的朋友一起来交流
8756
- Vue交流群:338241465

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-blog-template",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"private": true,
55
"scripts": {
66
"dev": "vue-cli-service serve",
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"axios": "^0.18.0",
14-
"element-ui": "^2.7.2",
14+
"element-ui": "^2.10.0",
1515
"js-cookie": "^2.2.0",
1616
"mockjs": "^1.0.1-beta3",
1717
"normalize.css": "^8.0.1",

src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div id="app">
3-
<app-view />
3+
<app-pageView />
44
<vue-progress-bar />
55
</div>
66
</template>

src/api/login.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export function getLogin(form) {
77
}
88
// 用户信息
99
export function getUser(token) {
10-
let res = request('/api/user', 'GET', token)
10+
let res = request('/api/user', 'POST', token)
1111
return res
1212
}

src/components/UserSelect/index.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
import { mapState } from 'vuex'
1515
export default {
1616
computed: {
17-
...mapState([
18-
'user'
19-
]),
17+
...mapState('login', {
18+
user: state => state.user
19+
}),
2020
version() {
2121
return 'v' + require('../../../package.json').version
2222
}
2323
},
2424
methods: {
2525
onSelected(val) {
2626
if (val === 'exit') {
27-
this.$store.commit('SET_LOGOUT')
28-
this.$router.push('/login')
27+
this.$store.dispatch('login/logout').then(() => {
28+
this.$router.push('/login')
29+
})
2930
}
3031
}
3132
}

src/components/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Vue from 'vue'
2-
import view from '@/layout/view'
2+
import PageView from '@/layout/PageView'
33

44
const components = {
5-
'app-view': view
5+
'app-pageView': PageView
66
}
77

88
// 注册全局组件

src/filters/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import Vue from 'vue'
22

33
const filters = {
4-
devide_10k: function (num) {
5-
return num >= 10000 ? (num / 10000).toFixed(1) + '万' : num
6-
},
74
// 时间格式化
85
formatTime: function (time, formatType) {
96
if (arguments.length === 0) {

src/layout/NavBar/index.vue

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<template>
2+
<div id="navBar">
3+
<div class="navBar-left">
4+
<!-- 侧边栏伸缩按钮 -->
5+
<Cola class="left-item ishover" />
6+
<!-- 面包屑 -->
7+
<breadcrumb class="left-item" />
8+
</div>
9+
<div class="navBar-right">
10+
<!-- 错误日志 -->
11+
<error-log class="right-item ishover" />
12+
<!-- 用户选项 -->
13+
<user-select class="right-item ishover" />
14+
</div>
15+
</div>
16+
</template>
17+
<script>
18+
import Cola from '@/components/Cola'
19+
import Breadcrumb from '@/components/Breadcrumb'
20+
import UserSelect from '@/components/UserSelect'
21+
import ErrorLog from '@/components/ErrorLog'
22+
export default {
23+
components: {
24+
Cola,
25+
Breadcrumb,
26+
UserSelect,
27+
ErrorLog
28+
}
29+
}
30+
</script>
31+
<style lang='stylus' scoped>
32+
#navBar {
33+
position: relative;
34+
width: 100%;
35+
height: 50px;
36+
display: flex;
37+
align-items: center;
38+
justify-content: space-between;
39+
box-shadow: 0 1px 2px rgba(0, 21, 41, 0.08);
40+
.navBar-left {
41+
display: flex;
42+
align-items: center;
43+
height: 100%;
44+
}
45+
.navBar-right {
46+
display: flex;
47+
align-items: center;
48+
height: 100%;
49+
margin-right: 30px;
50+
}
51+
.left-item, .right-item {
52+
flex-center();
53+
height: 100%;
54+
font-size: 18px;
55+
padding: 0 10px;
56+
cursor: pointer;
57+
>>> .item-container {
58+
flex-center();
59+
height: 100%;
60+
}
61+
}
62+
}
63+
</style>
File renamed without changes.

src/layout/Sidebar/index.vue

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</template>
1212
<script>
1313
import sideItem from './sideItem'
14-
import { sideRoutes } from '@/router'
1514
export default {
1615
components: { sideItem },
1716
data() {
@@ -21,20 +20,24 @@ export default {
2120
}
2221
},
2322
computed: {
23+
sideRoutes() {
24+
return this.$store.state.routes.sideRoutes[0].children
25+
},
2426
isCollapse() {
2527
return !this.$store.state.sidebarStatus
2628
},
2729
minWidth() {
28-
return this.isCollapse ? '36px' : this.$style.menuWidth
30+
return this.isCollapse ? this.$style.menuIconWidth : this.$style.menuWidth
2931
}
3032
},
3133
created() {
32-
this.filterRoutes = this.handleRoutes(sideRoutes)
34+
this.filterRoutes = this.handleRoutes(this.sideRoutes)
3335
},
3436
methods: {
3537
// 递归过滤路由
3638
handleRoutes(Arr) {
3739
const Routes = Arr.filter(route => {
40+
// 侧边栏路由强制写name,不然会导致很多问题(缓存、跳转等问题)
3841
if (route.name) {
3942
if (route.meta) {
4043
if (route.meta.hidden) {
@@ -50,6 +53,9 @@ export default {
5053
}
5154
return true
5255
} else {
56+
if (!route.path.includes('redirect')) {
57+
console.warn(`路由【${route.path}】:缺少name属性,存在bug隐患`)
58+
}
5359
return false
5460
}
5561
})
@@ -62,7 +68,8 @@ export default {
6268
:export {
6369
menuBg: #304156;
6470
menuText: #f5f5f5;
65-
menuWidth: 180px;
71+
menuWidth: 210px;
72+
menuIconWidth: 36px;
6673
}
6774
</style>
6875
<style lang="stylus">

src/layout/Sidebar/sideLink.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { isExternal } from '@/utils/validate'
23
export default {
34
name: 'sideLink',
45
functional: true,
@@ -10,8 +11,7 @@ export default {
1011
render(h, context) {
1112
const { to } = context.props
1213
const vnodes = []
13-
const isExternal = /^(https?:|mailto:|tel:)/.test(to.path)
14-
if (isExternal) {
14+
if (isExternal(to.path)) {
1515
vnodes.push(<a href={to.path} target='_blank'>{context.children}</a>)
1616
} else {
1717
vnodes.push(<router-link to={{ 'name': to.name }}>{context.children}</router-link>)

0 commit comments

Comments
 (0)