Skip to content

Commit c4356cd

Browse files
committed
Merge branch 'master' into deploy
2 parents 4079119 + 912c4eb commit c4356cd

File tree

16 files changed

+118
-28
lines changed

16 files changed

+118
-28
lines changed

README-zh.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212

1313
本项目基于`webpack4`开发,若还想使用`webpack3`开发,请使用该分支[webpack3](https://github.com/PanJiaChen/vue-admin-template/tree/webpack3)
1414

15+
如果你想使用基于 vue + typescript 的管理后台, 可以看看这个项目: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (鸣谢: [@Armour](https://github.com/Armour))
16+
1517
## 相关项目
1618

1719
[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
1820

1921
[electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
2022

23+
[vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template)
24+
2125
写了一个系列的教程配套文章,如何从零构建后一个完整的后台项目:
2226

2327
- [手摸手,带你用 vue 撸后台 系列一(基础篇)](https://juejin.im/post/59097cd7a22b9d0065fb61d2)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ If you want router permission && generate menu by user roles , you can use this
3535

3636
This project is based on `webpack4` development. If you want to use `webpack3` development, please use this branch [webpack3](https://github.com/PanJiaChen/vue-admin-template/tree/webpack3)
3737

38+
For `typescript` version, you can use [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (Credits: [@Armour](https://github.com/Armour))
39+
3840
## Related Project
3941

4042
[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
4143

4244
[electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
4345

46+
[vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template)
47+
4448
### Element-Ui using cdn tutorial
4549

4650
First find `index.html`([root directory](https://github.com/PanJiaChen/vue-admin-template/blob/element-ui-cdn/index.html))

build/webpack.dev.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
5757
template: 'index.html',
5858
inject: true,
5959
favicon: resolve('favicon.ico'),
60-
title: 'vue-element-admin'
60+
title: 'vue-admin-template'
6161
})
6262
]
6363
})

build/webpack.prod.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const webpackConfig = merge(baseWebpackConfig, {
5555
template: 'index.html',
5656
inject: true,
5757
favicon: resolve('favicon.ico'),
58-
title: 'vue-element-admin',
58+
title: 'vue-admin-template',
5959
minify: {
6060
removeComments: true,
6161
collapseWhitespace: true,

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "vue-admin-template",
3-
"version": "3.6.0",
3+
"version": "3.8.0",
44
"license": "MIT",
55
"description": "A vue admin template with Element UI & axios & iconfont & permission control & lint",
66
"author": "Pan <panfree23@gmail.com>",
77
"scripts": {
88
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
99
"start": "npm run dev",
1010
"build": "node build/build.js",
11-
"build:report": "npm_config_report=true node build/build.js",
11+
"build:report": "npm_config_report=true npm run build",
1212
"lint": "eslint --ext .js,.vue src",
1313
"test": "npm run lint",
1414
"deploy": "bash deploy.sh"
@@ -44,7 +44,7 @@
4444
"eventsource-polyfill": "0.9.6",
4545
"file-loader": "1.1.11",
4646
"friendly-errors-webpack-plugin": "1.7.0",
47-
"html-webpack-plugin": "^4.0.0-alpha",
47+
"html-webpack-plugin": "4.0.0-alpha",
4848
"mini-css-extract-plugin": "0.4.1",
4949
"node-notifier": "5.2.1",
5050
"node-sass": "^4.7.2",

src/icons/svg/link.svg

Lines changed: 1 addition & 0 deletions
Loading

src/permission.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ router.beforeEach((to, from, next) => {
3030
if (whiteList.indexOf(to.path) !== -1) {
3131
next()
3232
} else {
33-
next('/login')
33+
next(`/login?redirect=${to.path}`) // 否则全部重定向到登录页
3434
NProgress.done()
3535
}
3636
}

src/router/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Layout from '../views/layout/Layout'
1414
* alwaysShow: true if set true, will always show the root menu, whatever its child routes length
1515
* if not set alwaysShow, only more than one route under the children
1616
* it will becomes nested mode, otherwise not show the root menu
17-
* redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb
17+
* redirect: noredirect if `redirect:noredirect` will no redirect in the breadcrumb
1818
* name:'router-name' the name is used by <keep-alive> (must set!!!)
1919
* meta : {
2020
title: 'title' the name show in submenu and breadcrumb (recommend set)
@@ -130,6 +130,17 @@ export const constantRouterMap = [
130130
]
131131
},
132132

133+
{
134+
path: 'external-link',
135+
component: Layout,
136+
children: [
137+
{
138+
path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
139+
meta: { title: 'externalLink', icon: 'link' }
140+
}
141+
]
142+
},
143+
133144
{ path: '*', redirect: '/404', hidden: true }
134145
]
135146

src/styles/sidebar.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
.horizontal-collapse-transition {
2323
transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
2424
}
25+
.el-scrollbar__bar.is-vertical{
26+
right: 0px;
27+
}
2528
.scrollbar-wrapper {
2629
height: calc(100% + 15px);
2730
.el-scrollbar__view {

src/styles/transition.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
opacity: 0;
1212
}
1313

14+
/*fade-transform*/
15+
.fade-transform-leave-active,
16+
.fade-transform-enter-active {
17+
transition: all .5s;
18+
}
19+
.fade-transform-enter {
20+
opacity: 0;
21+
transform: translateX(-30px);
22+
}
23+
.fade-transform-leave-to {
24+
opacity: 0;
25+
transform: translateX(30px);
26+
}
27+
1428
/*fade*/
1529
.breadcrumb-enter-active,
1630
.breadcrumb-leave-active {

src/utils/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export function parseTime(time, cFormat) {
2525
}
2626
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
2727
let value = formatObj[key]
28-
if (key === 'a') { return ['一', '二', '三', '四', '五', '六', '日'][value - 1] }
28+
// Note: getDay() returns 0 on Sunday
29+
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
2930
if (result.length > 0 && value < 10) {
3031
value = '0' + value
3132
}

src/utils/request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getToken } from '@/utils/auth'
55

66
// 创建axios实例
77
const service = axios.create({
8-
baseURL: process.env.BASE_API, // api的base_url
8+
baseURL: process.env.BASE_API, // api 的 base_url
99
timeout: 5000 // 请求超时时间
1010
})
1111

@@ -24,7 +24,7 @@ service.interceptors.request.use(
2424
}
2525
)
2626

27-
// respone拦截器
27+
// response 拦截器
2828
service.interceptors.response.use(
2929
response => {
3030
/**

src/views/layout/components/AppMain.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<section class="app-main">
3-
<transition name="fade" mode="out-in">
3+
<transition name="fade-transform" mode="out-in">
4+
<!-- or name="fade" -->
45
<!-- <router-view :key="key"></router-view> -->
56
<router-view/>
67
</transition>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script>
2+
export default {
3+
name: 'MenuItem',
4+
functional: true,
5+
props: {
6+
icon: {
7+
type: String,
8+
default: ''
9+
},
10+
title: {
11+
type: String,
12+
default: ''
13+
}
14+
},
15+
render(h, context) {
16+
const { icon, title } = context.props
17+
const vnodes = []
18+
19+
if (icon) {
20+
vnodes.push(<svg-icon icon-class={icon}/>)
21+
}
22+
23+
if (title) {
24+
vnodes.push(<span slot='title'>{(title)}</span>)
25+
}
26+
return vnodes
27+
}
28+
}
29+
</script>

src/views/layout/components/Sidebar/SidebarItem.vue

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<template>
22
<div v-if="!item.hidden&&item.children" class="menu-wrapper">
33

4-
<router-link v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow" :to="resolvePath(onlyOneChild.path)">
5-
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
6-
<svg-icon v-if="onlyOneChild.meta&&onlyOneChild.meta.icon" :icon-class="onlyOneChild.meta.icon"/>
7-
<span v-if="onlyOneChild.meta&&onlyOneChild.meta.title" slot="title">{{ onlyOneChild.meta.title }}</span>
8-
</el-menu-item>
9-
</router-link>
4+
<template v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow">
5+
<a :href="onlyOneChild.path" target="_blank" @click="clickLink(onlyOneChild.path,$event)">
6+
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
7+
<item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon" :title="onlyOneChild.meta.title" />
8+
</el-menu-item>
9+
</a>
10+
</template>
1011

1112
<el-submenu v-else :index="item.name||item.path">
1213
<template slot="title">
13-
<svg-icon v-if="item.meta&&item.meta.icon" :icon-class="item.meta.icon"/>
14-
<span v-if="item.meta&&item.meta.title" slot="title">{{ item.meta.title }}</span>
14+
<item v-if="item.meta" :icon="item.meta.icon" :title="item.meta.title" />
1515
</template>
1616

1717
<template v-for="child in item.children" v-if="!child.hidden">
@@ -23,12 +23,11 @@
2323
:base-path="resolvePath(child.path)"
2424
class="nest-menu"/>
2525

26-
<router-link v-else :to="resolvePath(child.path)" :key="child.name">
26+
<a v-else :href="child.path" :key="child.name" target="_blank" @click="clickLink(child.path,$event)">
2727
<el-menu-item :index="resolvePath(child.path)">
28-
<svg-icon v-if="child.meta&&child.meta.icon" :icon-class="child.meta.icon"/>
29-
<span v-if="child.meta&&child.meta.title" slot="title">{{ child.meta.title }}</span>
28+
<item v-if="child.meta" :icon="child.meta.icon" :title="child.meta.title" />
3029
</el-menu-item>
31-
</router-link>
30+
</a>
3231
</template>
3332
</el-submenu>
3433

@@ -37,9 +36,12 @@
3736

3837
<script>
3938
import path from 'path'
39+
import { validateURL } from '@/utils/validate'
40+
import Item from './Item'
4041
4142
export default {
4243
name: 'SidebarItem',
44+
components: { Item },
4345
props: {
4446
// route配置json
4547
item: {
@@ -76,8 +78,18 @@ export default {
7678
}
7779
return false
7880
},
79-
resolvePath(...paths) {
80-
return path.resolve(this.basePath, ...paths)
81+
resolvePath(routePath) {
82+
return path.resolve(this.basePath, routePath)
83+
},
84+
isExternalLink(routePath) {
85+
return validateURL(routePath)
86+
},
87+
clickLink(routePath, e) {
88+
if (!this.isExternalLink(routePath)) {
89+
e.preventDefault()
90+
const path = this.resolvePath(routePath)
91+
this.$router.push(path)
92+
}
8193
}
8294
}
8395
}

src/views/login/index.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="login-container">
33
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
4-
<h3 class="title">vue-element-admin</h3>
4+
<h3 class="title">vue-admin-template</h3>
55
<el-form-item prop="username">
66
<span class="svg-container svg-container_login">
77
<svg-icon icon-class="user" />
@@ -66,7 +66,16 @@ export default {
6666
password: [{ required: true, trigger: 'blur', validator: validatePass }]
6767
},
6868
loading: false,
69-
pwdType: 'password'
69+
pwdType: 'password',
70+
redirect: undefined
71+
}
72+
},
73+
watch: {
74+
$route: {
75+
handler: function(route) {
76+
this.redirect = route.query && route.query.redirect
77+
},
78+
immediate: true
7079
}
7180
},
7281
methods: {
@@ -83,7 +92,7 @@ export default {
8392
this.loading = true
8493
this.$store.dispatch('Login', this.loginForm).then(() => {
8594
this.loading = false
86-
this.$router.push({ path: '/' })
95+
this.$router.push({ path: this.redirect || '/' })
8796
}).catch(() => {
8897
this.loading = false
8998
})
@@ -145,6 +154,7 @@ $light_gray:#eee;
145154
left: 0;
146155
right: 0;
147156
width: 520px;
157+
max-width: 100%;
148158
padding: 35px 35px 15px 35px;
149159
margin: 120px auto;
150160
}

0 commit comments

Comments
 (0)