Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
InJoyU
vue-element-admin
提交
97683051
V
vue-element-admin
项目概览
InJoyU
/
vue-element-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97683051
编写于
8月 21, 2017
作者:
P
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine main.js
上级
e912cea2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
146 addition
and
142 deletion
+146
-142
src/components/MdEditor/index.vue
src/components/MdEditor/index.vue
+1
-1
src/directive/waves.js
src/directive/waves.js
+39
-42
src/errorLog.js
src/errorLog.js
+14
-0
src/main.js
src/main.js
+16
-91
src/permission.js
src/permission.js
+56
-0
src/views/components/mixin.vue
src/views/components/mixin.vue
+4
-0
src/views/example/form.vue
src/views/example/form.vue
+11
-8
src/views/example/table/table.vue
src/views/example/table/table.vue
+4
-0
src/views/theme/index.vue
src/views/theme/index.vue
+1
-0
未找到文件。
src/components/MdEditor/index.vue
浏览文件 @
97683051
...
...
@@ -10,7 +10,7 @@
import
SimpleMDE
from
'
simplemde
'
;
export
default
{
name
:
'
Sticky
'
,
name
:
'
simplemde-md
'
,
props
:
{
value
:
String
,
id
:
{
...
...
src/directive/waves.js
浏览文件 @
97683051
import
'
./waves.css
'
;
const
vueWaves
=
{};
vueWaves
.
install
=
(
Vue
,
options
=
{})
=>
{
Vue
.
directive
(
'
waves
'
,
{
bind
(
el
,
binding
)
{
el
.
addEventListener
(
'
click
'
,
e
=>
{
const
customOpts
=
Object
.
assign
(
options
,
binding
.
value
);
const
opts
=
Object
.
assign
({
ele
:
el
,
// 波纹作用元素
type
:
'
hit
'
,
// hit点击位置扩散center中心点扩展
color
:
'
rgba(0, 0, 0, 0.15)
'
// 波纹颜色
},
customOpts
),
target
=
opts
.
ele
;
if
(
target
)
{
target
.
style
.
position
=
'
relative
'
;
target
.
style
.
overflow
=
'
hidden
'
;
const
rect
=
target
.
getBoundingClientRect
();
let
ripple
=
target
.
querySelector
(
'
.waves-ripple
'
);
if
(
!
ripple
)
{
ripple
=
document
.
createElement
(
'
span
'
);
ripple
.
className
=
'
waves-ripple
'
;
ripple
.
style
.
height
=
ripple
.
style
.
width
=
Math
.
max
(
rect
.
width
,
rect
.
height
)
+
'
px
'
;
target
.
appendChild
(
ripple
);
}
else
{
ripple
.
className
=
'
waves-ripple
'
;
}
switch
(
opts
.
type
)
{
case
'
center
'
:
ripple
.
style
.
top
=
(
rect
.
height
/
2
-
ripple
.
offsetHeight
/
2
)
+
'
px
'
;
ripple
.
style
.
left
=
(
rect
.
width
/
2
-
ripple
.
offsetWidth
/
2
)
+
'
px
'
;
break
;
default
:
ripple
.
style
.
top
=
(
e
.
pageY
-
rect
.
top
-
ripple
.
offsetHeight
/
2
-
document
.
body
.
scrollTop
)
+
'
px
'
;
ripple
.
style
.
left
=
(
e
.
pageX
-
rect
.
left
-
ripple
.
offsetWidth
/
2
-
document
.
body
.
scrollLeft
)
+
'
px
'
;
}
ripple
.
style
.
backgroundColor
=
opts
.
color
;
ripple
.
className
=
'
waves-ripple z-active
'
;
return
false
;
export
default
{
bind
(
el
,
binding
)
{
el
.
addEventListener
(
'
click
'
,
e
=>
{
const
customOpts
=
Object
.
assign
({},
binding
.
value
);
const
opts
=
Object
.
assign
({
ele
:
el
,
// 波纹作用元素
type
:
'
hit
'
,
// hit点击位置扩散center中心点扩展
color
:
'
rgba(0, 0, 0, 0.15)
'
// 波纹颜色
},
customOpts
),
target
=
opts
.
ele
;
if
(
target
)
{
target
.
style
.
position
=
'
relative
'
;
target
.
style
.
overflow
=
'
hidden
'
;
const
rect
=
target
.
getBoundingClientRect
();
let
ripple
=
target
.
querySelector
(
'
.waves-ripple
'
);
if
(
!
ripple
)
{
ripple
=
document
.
createElement
(
'
span
'
);
ripple
.
className
=
'
waves-ripple
'
;
ripple
.
style
.
height
=
ripple
.
style
.
width
=
Math
.
max
(
rect
.
width
,
rect
.
height
)
+
'
px
'
;
target
.
appendChild
(
ripple
);
}
else
{
ripple
.
className
=
'
waves-ripple
'
;
}
},
false
);
}
})
};
switch
(
opts
.
type
)
{
case
'
center
'
:
ripple
.
style
.
top
=
(
rect
.
height
/
2
-
ripple
.
offsetHeight
/
2
)
+
'
px
'
;
ripple
.
style
.
left
=
(
rect
.
width
/
2
-
ripple
.
offsetWidth
/
2
)
+
'
px
'
;
break
;
default
:
ripple
.
style
.
top
=
(
e
.
pageY
-
rect
.
top
-
ripple
.
offsetHeight
/
2
-
document
.
body
.
scrollTop
)
+
'
px
'
;
ripple
.
style
.
left
=
(
e
.
pageX
-
rect
.
left
-
ripple
.
offsetWidth
/
2
-
document
.
body
.
scrollLeft
)
+
'
px
'
;
}
ripple
.
style
.
backgroundColor
=
opts
.
color
;
ripple
.
className
=
'
waves-ripple z-active
'
;
return
false
;
}
},
false
);
}
}
export
default
vueWaves
;
src/errorLog.js
0 → 100644
浏览文件 @
97683051
import
Vue
from
'
vue
'
import
errLog
from
'
@/store/errLog
'
// 生产环境错误日志
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
Vue
.
config
.
errorHandler
=
function
(
err
,
vm
)
{
console
.
log
(
err
,
window
.
location
.
href
);
errLog
.
pushLog
({
err
,
url
:
window
.
location
.
href
,
vm
})
};
}
src/main.js
浏览文件 @
97683051
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import
Vue
from
'
vue
'
;
import
App
from
'
./App
'
;
import
router
from
'
./router
'
;
import
store
from
'
./store
'
;
import
ElementUI
from
'
element-ui
'
;
import
'
element-ui/lib/theme-default/index.css
'
;
import
'
assets/custom-theme/index.css
'
;
// 换肤版本element-ui css
import
NProgress
from
'
nprogress
'
;
// Progress 进度条
import
'
nprogress/nprogress.css
'
;
// Progress 进度条 样式
import
'
normalize.css/normalize.css
'
;
// normalize.css 样式格式化
import
'
assets/iconfont/iconfont
'
;
// iconfont 具体图标见https://github.com/PanJiaChen/vue-element-admin/wiki
import
*
as
filters
from
'
./filters
'
;
// 全局vue filter
import
Multiselect
from
'
vue-multiselect
'
;
// 使用的一个多选框组件,element-ui的select不能满足所有需求
import
'
vue-multiselect/dist/vue-multiselect.min.css
'
;
// 多选框组件css
import
Sticky
from
'
components/Sticky
'
;
// 粘性header组件
import
IconSvg
from
'
components/Icon-svg
'
;
// svg 组件
import
vueWaves
from
'
./directive/waves
'
;
// 水波纹指令
import
errLog
from
'
store/errLog
'
;
// error log组件
import
'
./mock/index.js
'
;
// 该项目所有请求使用mockjs模拟
import
{
getToken
}
from
'
utils/auth
'
;
import
Vue
from
'
vue
'
import
App
from
'
./App
'
import
router
from
'
./router
'
import
store
from
'
./store
'
import
'
normalize.css/normalize.css
'
// normalize.css 样式格式化
import
ElementUI
from
'
element-ui
'
import
'
element-ui/lib/theme-default/index.css
'
import
'
@/assets/iconfont/iconfont
'
// iconfont 具体图标见https://github.com/PanJiaChen/vue-element-admin/wiki
import
IconSvg
from
'
@/components/Icon-svg
'
// svg组件
import
*
as
filters
from
'
@/filters
'
// 全局filter
import
'
@/errorLog
'
// error log
import
'
@/permission
'
// 权限
import
'
@/mock/index.js
'
// 该项目所有请求使用mockjs模拟
// register globally
Vue
.
component
(
'
multiselect
'
,
Multiselect
);
Vue
.
component
(
'
Sticky
'
,
Sticky
);
Vue
.
component
(
'
icon-svg
'
,
IconSvg
)
Vue
.
use
(
ElementUI
);
Vue
.
use
(
vueWaves
);
Vue
.
use
(
ElementUI
)
// register global utility filters.
Object
.
keys
(
filters
).
forEach
(
key
=>
{
Vue
.
filter
(
key
,
filters
[
key
])
});
// permissiom judge
function
hasPermission
(
roles
,
permissionRoles
)
{
if
(
roles
.
indexOf
(
'
admin
'
)
>=
0
)
return
true
;
// admin权限 直接通过
if
(
!
permissionRoles
)
return
true
;
return
roles
.
some
(
role
=>
permissionRoles
.
indexOf
(
role
)
>=
0
)
}
// register global progress.
const
whiteList
=
[
'
/login
'
,
'
/authredirect
'
,
'
/reset
'
,
'
/sendpwd
'
];
// 不重定向白名单
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
();
// 开启Progress
if
(
getToken
())
{
// 判断是否有token
if
(
to
.
path
===
'
/login
'
)
{
next
({
path
:
'
/
'
});
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'
GetInfo
'
).
then
(
res
=>
{
// 拉取user_info
const
roles
=
res
.
data
.
role
;
store
.
dispatch
(
'
GenerateRoutes
'
,
{
roles
}).
then
(()
=>
{
// 生成可访问的路由表
router
.
addRoutes
(
store
.
getters
.
addRouters
)
// 动态添加可访问路由表
next
({
...
to
});
// hack方法 确保addRoutes已完成
})
}).
catch
(()
=>
{
store
.
dispatch
(
'
FedLogOut
'
).
then
(()
=>
{
next
({
path
:
'
/login
'
});
})
})
}
else
{
// 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓
if
(
hasPermission
(
store
.
getters
.
roles
,
to
.
meta
.
role
))
{
next
();
//
}
else
{
next
({
path
:
'
/401
'
,
query
:
{
noGoBack
:
true
}
});
}
// 可删 ↑
}
}
}
else
{
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
()
}
else
{
next
(
'
/login
'
);
// 否则全部重定向到登录页
NProgress
.
done
();
// 在hash模式下 改变手动改变hash 重定向回来 不会触发afterEach 暂时hack方案 ps:history模式下无问题,可删除该行!
}
}
});
router
.
afterEach
(()
=>
{
NProgress
.
done
();
// 结束Progress
});
Vue
.
config
.
productionTip
=
false
;
})
// 生产环境错误日志
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
Vue
.
config
.
errorHandler
=
function
(
err
,
vm
)
{
console
.
log
(
err
,
window
.
location
.
href
);
errLog
.
pushLog
({
err
,
url
:
window
.
location
.
href
,
vm
})
};
}
Vue
.
config
.
productionTip
=
false
new
Vue
({
el
:
'
#app
'
,
...
...
src/permission.js
0 → 100644
浏览文件 @
97683051
import
router
from
'
./router
'
import
store
from
'
./store
'
import
NProgress
from
'
nprogress
'
// Progress 进度条
import
'
nprogress/nprogress.css
'
// Progress 进度条样式
import
{
getToken
}
from
'
@/utils/auth
'
// 验权
// permissiom judge
function
hasPermission
(
roles
,
permissionRoles
)
{
if
(
roles
.
indexOf
(
'
admin
'
)
>=
0
)
return
true
// admin权限 直接通过
if
(
!
permissionRoles
)
return
true
return
roles
.
some
(
role
=>
permissionRoles
.
indexOf
(
role
)
>=
0
)
}
// register global progress.
const
whiteList
=
[
'
/login
'
,
'
/authredirect
'
,
'
/reset
'
,
'
/sendpwd
'
]
// 不重定向白名单
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
()
// 开启Progress
if
(
getToken
())
{
// 判断是否有token
if
(
to
.
path
===
'
/login
'
)
{
next
({
path
:
'
/
'
})
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'
GetInfo
'
).
then
(
res
=>
{
// 拉取user_info
const
roles
=
res
.
data
.
role
store
.
dispatch
(
'
GenerateRoutes
'
,
{
roles
}).
then
(()
=>
{
// 生成可访问的路由表
router
.
addRoutes
(
store
.
getters
.
addRouters
)
// 动态添加可访问路由表
next
({
...
to
})
// hack方法 确保addRoutes已完成
})
}).
catch
(()
=>
{
store
.
dispatch
(
'
FedLogOut
'
).
then
(()
=>
{
next
({
path
:
'
/login
'
})
})
})
}
else
{
// 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓
if
(
hasPermission
(
store
.
getters
.
roles
,
to
.
meta
.
role
))
{
next
()
//
}
else
{
next
({
path
:
'
/401
'
,
query
:
{
noGoBack
:
true
}
})
}
// 可删 ↑
}
}
}
else
{
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
()
}
else
{
next
(
'
/login
'
)
// 否则全部重定向到登录页
NProgress
.
done
()
// 在hash模式下 改变手动改变hash 重定向回来 不会触发afterEach 暂时hack方案 ps:history模式下无问题,可删除该行!
}
}
})
router
.
afterEach
(()
=>
{
NProgress
.
done
()
// 结束Progress
})
src/views/components/mixin.vue
浏览文件 @
97683051
...
...
@@ -24,9 +24,13 @@
<
script
>
import
MdInput
from
'
components/MDinput
'
;
import
PanThumb
from
'
components/PanThumb
'
;
import
waves
from
'
@/directive/waves.js
'
;
// 水波纹指令
export
default
{
components
:
{
MdInput
,
PanThumb
},
directives
:
{
waves
},
data
()
{
return
{
title
:
''
...
...
src/views/example/form.vue
浏览文件 @
97683051
...
...
@@ -2,7 +2,7 @@
<div
class=
"createPost-container"
>
<el-form
class=
"form-container"
:model=
"postForm"
:rules=
"rules"
ref=
"postForm"
>
<
S
ticky
:className=
"'sub-navbar '+postForm.status"
>
<
s
ticky
:className=
"'sub-navbar '+postForm.status"
>
<template
v-if=
"fetchSuccess"
>
<div
style=
"display:inline-block"
>
...
...
@@ -57,7 +57,7 @@
<el-tag>
发送异常错误,刷新页面,或者联系程序员
</el-tag>
</
template
>
</
S
ticky>
</
s
ticky>
<div
class=
"createPost-main-container"
>
<el-row>
...
...
@@ -107,7 +107,7 @@
</el-form-item>
<div
class=
"editor-container"
>
<
Tinymce
:height=
400
ref=
"editor"
v-model=
"postForm.content"
></T
inymce>
<
tinymce
:height=
400
ref=
"editor"
v-model=
"postForm.content"
></t
inymce>
</div>
<div
style=
"margin-bottom: 20px;"
>
...
...
@@ -122,14 +122,17 @@
<
script
>
import
Tinymce
from
'
components/Tinymce
'
import
Upload
from
'
components/Upload/singleImage3
'
import
MDinput
from
'
components/MDinput
'
;
import
{
validateURL
}
from
'
utils/validate
'
;
import
{
getArticle
}
from
'
api/article
'
;
import
{
userSearch
}
from
'
api/remoteSearch
'
;
import
MDinput
from
'
components/MDinput
'
import
Multiselect
from
'
vue-multiselect
'
// 使用的一个多选框组件,element-ui的select不能满足所有需求
import
'
vue-multiselect/dist/vue-multiselect.min.css
'
// 多选框组件css
import
Sticky
from
'
components/Sticky
'
// 粘性header组件
import
{
validateURL
}
from
'
utils/validate
'
import
{
getArticle
}
from
'
api/article
'
import
{
userSearch
}
from
'
api/remoteSearch
'
export
default
{
name
:
'
articleDetail
'
,
components
:
{
Tinymce
,
MDinput
,
Upload
},
components
:
{
Tinymce
,
MDinput
,
Upload
,
Multiselect
,
Sticky
},
data
()
{
const
validateRequire
=
(
rule
,
value
,
callback
)
=>
{
if
(
value
===
''
)
{
...
...
src/views/example/table/table.vue
浏览文件 @
97683051
...
...
@@ -151,6 +151,7 @@
<
script
>
import
{
fetchList
,
fetchPv
}
from
'
api/article_table
'
;
import
waves
from
'
@/directive/waves.js
'
;
// 水波纹指令
import
{
parseTime
}
from
'
utils
'
;
const
calendarTypeOptions
=
[
...
...
@@ -168,6 +169,9 @@
export
default
{
name
:
'
table_demo
'
,
directives
:
{
waves
}
,
data
()
{
return
{
list
:
null
,
...
...
src/views/theme/index.vue
浏览文件 @
97683051
...
...
@@ -46,6 +46,7 @@
<
script
>
import
{
toggleClass
}
from
'
utils
'
;
import
'
@/assets/custom-theme/index.css
'
;
// 换肤版本element-ui css
export
default
{
data
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录