Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
SHR
/
tFIMS
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 514cbb36
authored
Aug 28, 2019
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完善权限功能
1 parent
3063533b
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
378 additions
and
248 deletions
babel.config.js
package-lock.json
run.js
src/api/request.js
src/api/request.methods.js
src/api/sign.js
src/api/sys.login.js
src/assets/style/animate/vue-transition.scss
src/components/d2-auth/d2-auth-btn.vue
src/components/index.js
src/layout/header-aside/components/hamburger/index.vue
src/layout/header-aside/components/header-user/index.vue
src/layout/header-aside/components/menu-side/index.js
src/layout/header-aside/components/personal-panel/index.vue
src/layout/header-aside/components/tabs/index.vue
src/layout/header-aside/layout.vue
src/libs/util.js
src/libs/util.permision.js
src/main.js
src/plugin/d2admin/index.js
src/resources/index.js
src/router/index.js
src/router/routes.js
src/store/modules/d2admin/modules/account.js
src/store/modules/d2admin/modules/auth.js
src/store/modules/d2admin/modules/page.js
src/views/demo/page1/index.vue
src/views/demo/page2/index.vue
src/views/system/login/page.vue
src/views/systemMonitor/index.vue
vue.config.js
babel.config.js
View file @
514cbb3
package-lock.json
View file @
514cbb3
...
...
@@ -4939,6 +4939,14 @@
"safer-buffer"
:
"2.1.2"
}
},
"echarts"
:
{
"version"
:
"4.2.1"
,
"resolved"
:
"https://registry.npmjs.org/echarts/-/echarts-4.2.1.tgz"
,
"integrity"
:
"sha512-pw4xScRPsLegD/cqEcoXRKeA2SD4+s+Kyo0Na166NamOWhzNl2yI5RZ2rE97tBlAopNmhyMeBVpAeD5qb+ee1A=="
,
"requires"
:
{
"zrender"
:
"4.0.7"
}
},
"editorconfig"
:
{
"version"
:
"0.15.3"
,
"resolved"
:
"https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.3.tgz"
,
...
...
@@ -15446,6 +15454,11 @@
"dev"
:
true
}
}
},
"zrender"
:
{
"version"
:
"4.0.7"
,
"resolved"
:
"https://registry.npmjs.org/zrender/-/zrender-4.0.7.tgz"
,
"integrity"
:
"sha512-TNloHe0ums6zxbHfnaCryM61J4IWDajZwNq6dHk9vfWhhysO/OeFvvR0drBs/nbXha2YxSzfQj2FiCd6RVBe+Q=="
}
}
}
run.js
View file @
514cbb3
...
...
@@ -3,7 +3,7 @@ var app = express()
app
.
use
(
express
.
static
(
'./dist'
))
app
.
get
(
'/'
,
function
(
req
,
res
)
{
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'Hello Vue'
)
})
...
...
src/api/request.js
View file @
514cbb3
...
...
@@ -7,7 +7,7 @@
import
axios
from
'@/plugin/axios'
import
sign
from
'./sign'
const
request
=
(
params
,
method
)
=>
{
const
request
=
(
params
,
method
)
=>
{
params
.
source
=
''
params
.
app_key
=
'48e5e13229b82c1b4e6e8c96151f0637'
params
.
timestamp
=
new
Date
().
getTime
()
...
...
@@ -17,8 +17,8 @@ const request = (params,method) => {
// return axios.post(url, { 'params': sign(params) })
return
axios
({
url
,
method
:
method
||
'get'
,
data
:
sign
(
params
)
method
:
method
||
'get'
,
data
:
sign
(
params
)
})
}
export
default
request
src/api/request.methods.js
View file @
514cbb3
...
...
@@ -5,9 +5,9 @@
* @Last Modified time: 2019-08-26 18:02:32
*/
const
RequestMethods
=
{
POST
:
'post'
,
GET
:
'get'
,
PUT
:
'put'
,
DELETE
:
'delete'
POST
:
'post'
,
GET
:
'get'
,
PUT
:
'put'
,
DELETE
:
'delete'
}
export
default
RequestMethods
src/api/sign.js
View file @
514cbb3
src/api/sys.login.js
View file @
514cbb3
...
...
@@ -6,7 +6,7 @@
*/
import
request
from
'./request'
import
RequestMethods
from
"./request.methods"
;
import
RequestMethods
from
'./request.methods'
const
path
=
''
// export function AccountLogin (data) {
// return request({
...
...
@@ -16,6 +16,6 @@ const path = ''
// })
// }
export
function
AccountLogin
(
data
)
{
data
.
method
=
`
${
path
}
login`
return
request
(
data
,
RequestMethods
.
POST
)
data
.
method
=
`
${
path
}
login`
return
request
(
data
,
RequestMethods
.
POST
)
}
src/assets/style/animate/vue-transition.scss
View file @
514cbb3
// 过渡动画 横向渐变
.fade-transverse-leave-active
,
.fade-transverse-enter-active
{
transition
:
all
.
5
s
;
transition
:
all
.
2
s
;
}
.fade-transverse-enter
{
opacity
:
0
;
...
...
src/components/d2-auth/d2-auth-btn.vue
View file @
514cbb3
...
...
@@ -10,15 +10,15 @@
<
script
>
export
default
{
name
:
"AuthButton"
,
name
:
'AuthButton'
,
props
:
{
label
:
{
type
:
String
,
default
:
"Button"
default
:
'Button'
},
size
:
{
type
:
String
,
default
:
"mini"
default
:
'mini'
},
type
:
{
type
:
String
,
...
...
@@ -37,20 +37,20 @@ export default {
default
:
null
}
},
data
()
{
return
{}
;
data
()
{
return
{}
},
beforeCreate
()
{
this
.
$vrm
.
setRoles
([
"1"
,
"2"
,
"3"
]);
beforeCreate
()
{
this
.
$vrm
.
setRoles
([
'1'
,
'2'
,
'3'
])
},
methods
:
{
handleClick
:
function
()
{
this
.
$emit
(
"e-auth-click"
,
{});
handleClick
:
function
()
{
this
.
$emit
(
'e-auth-click'
,
{})
}
},
mounted
()
{
mounted
()
{
}
}
;
}
</
script
>
<
style
scoped
>
...
...
src/components/index.js
View file @
514cbb3
src/layout/header-aside/components/hamburger/index.vue
View file @
514cbb3
...
...
@@ -24,7 +24,7 @@ export default {
}
},
methods
:
{
click
()
{
click
()
{
this
.
onClick
&&
this
.
onClick
()
}
}
...
...
src/layout/header-aside/components/header-user/index.vue
View file @
514cbb3
...
...
@@ -17,25 +17,25 @@
<
/template
>
<
script
>
import
{
mapState
,
mapActions
}
from
"vuex"
;
import
PersonalPanel
from
"../personal-panel"
;
import
{
mapState
,
mapActions
}
from
'vuex'
import
PersonalPanel
from
'../personal-panel'
export
default
{
components
:
{
PersonalPanel
}
,
computed
:
{
...
mapState
(
"d2admin/user"
,
[
"info"
])
...
mapState
(
'd2admin/user'
,
[
'info'
])
}
,
methods
:
{
...
mapActions
(
"d2admin/account"
,
[
"logout"
]),
...
mapActions
(
'd2admin/account'
,
[
'logout'
]),
/**
* @description 登出
*/
logOff
()
{
logOff
()
{
this
.
logout
({
confirm
:
true
}
)
;
}
)
}
}
}
;
}
<
/script
>
src/layout/header-aside/components/menu-side/index.js
View file @
514cbb3
...
...
@@ -9,7 +9,7 @@ export default {
menuMixin
],
render
(
createElement
)
{
return
createElement
(
'div'
,
{
attrs
:
{
class
:
'd2-layout-header-aside-menu-side'
}
,
return
createElement
(
'div'
,
{
attrs
:
{
class
:
'd2-layout-header-aside-menu-side'
}
},
[
createElement
(
'el-menu'
,
{
props
:
{
collapse
:
this
.
asideCollapse
,
uniqueOpened
:
true
,
defaultActive
:
this
.
active
},
...
...
@@ -71,7 +71,7 @@ export default {
// }
})
},
test
()
{
test
()
{
alert
(
111
)
},
scrollDestroy
()
{
...
...
src/layout/header-aside/components/personal-panel/index.vue
View file @
514cbb3
...
...
@@ -56,12 +56,12 @@
</
template
>
<
script
>
import
Cookies
from
"js-cookie"
import
Cookies
from
'js-cookie'
// import Backup from "@/views/Backup/Backup"
import
Avatar
from
'vue-avatar'
export
default
{
name
:
'PersonalPanel'
,
components
:{
components
:
{
// Backup
Avatar
},
...
...
@@ -69,53 +69,53 @@ export default {
user
:
{
type
:
Object
,
default
:
{
name
:
"admin"
,
avatar
:
"@/assets/user.png"
,
role
:
"超级管理员"
,
registeInfo
:
"注册时间:2018-12-25 "
name
:
'admin'
,
avatar
:
'@/assets/user.png'
,
role
:
'超级管理员'
,
registeInfo
:
'注册时间:2018-12-25 '
}
}
},
data
()
{
data
()
{
return
{
}
},
methods
:
{
// 退出登录
logout
:
function
()
{
this
.
$confirm
(
"确认退出吗?"
,
"提示"
,
{
type
:
"warning"
logout
:
function
()
{
this
.
$confirm
(
'确认退出吗?'
,
'提示'
,
{
type
:
'warning'
})
.
then
(()
=>
{
sessionStorage
.
removeItem
(
"user"
)
this
.
deleteCookie
(
"token"
)
this
.
$router
.
push
(
"/login"
)
sessionStorage
.
removeItem
(
'user'
)
this
.
deleteCookie
(
'token'
)
this
.
$router
.
push
(
'/login'
)
this
.
$api
.
login
.
logout
().
then
((
res
)
=>
{
}).
catch
(
function
(
res
)
{
}).
catch
(
function
(
res
)
{
})
})
.
catch
(()
=>
{})
},
// 删除cookie
deleteCookie
:
function
(
name
)
{
deleteCookie
:
function
(
name
)
{
Cookies
.
remove
(
name
)
},
// 打开备份还原界面
showBackupDialog
:
function
()
{
showBackupDialog
:
function
()
{
this
.
$refs
.
backupDialog
.
setBackupVisible
(
true
)
},
// 成功还原之后,重新登录
afterRestore
:
function
()
{
afterRestore
:
function
()
{
this
.
$refs
.
backupDialog
.
setBackupVisible
(
false
)
sessionStorage
.
removeItem
(
"user"
)
this
.
deleteCookie
(
"token"
)
this
.
$router
.
push
(
"/login"
)
sessionStorage
.
removeItem
(
'user'
)
this
.
deleteCookie
(
'token'
)
this
.
$router
.
push
(
'/login'
)
this
.
$api
.
login
.
logout
().
then
((
res
)
=>
{
}).
catch
(
function
(
res
)
{
}).
catch
(
function
(
res
)
{
})
}
},
mounted
()
{
mounted
()
{
}
}
</
script
>
...
...
src/layout/header-aside/components/tabs/index.vue
View file @
514cbb3
...
...
@@ -21,7 +21,7 @@
<el-tab-pane
v-for=
"page in opened"
:key=
"page.fullPath"
:label=
"
page.meta.title
|| '未命名'"
:label=
"
(page.meta && page.meta.title)
|| '未命名'"
:name=
"page.fullPath"
/>
</el-tabs>
</div>
...
...
src/layout/header-aside/layout.vue
View file @
514cbb3
...
...
@@ -69,7 +69,7 @@
</div>
<!-- 页面 -->
<div
class=
"d2-theme-container-main-body"
flex-box=
"1"
>
<transition
:name=
"transitionActive ? 'fade-transverse' : ''"
>
<transition
:name=
"transitionActive ? 'fade-transverse' : ''"
mode=
"in-out"
>
<keep-alive
:include=
"keepAlive"
>
<router-view/>
</keep-alive>
...
...
src/libs/util.js
View file @
514cbb3
import
cookies
from
'./util.cookies'
import
db
from
'./util.db'
import
log
from
'./util.log'
import
permision
from
'./util.permision'
const
util
=
{
cookies
,
db
,
log
log
,
permision
}
/**
...
...
@@ -54,24 +55,63 @@ util.deepClone = (obj) => {
return
copy
}
throw
new
Error
(
"Unable to clone obj! Its type isn't supported."
)
}
}
/**
* 深度递归搜索
* @param {Array} arr 你要搜索的数组
* @param {Function} condition 回调函数,必须返回谓词,判断是否找到了。会传入(item, index, level)三个参数
* @param {String} children 子数组的key
*/
util
.
deepFind
=
function
(
menus
,
id
)
{
const
cloneMenus
=
util
.
deepClone
(
menus
)
util
.
deepFind
=
function
(
menus
,
id
)
{
const
cloneMenus
=
util
.
deepClone
(
menus
)
for
(
let
menu
of
cloneMenus
)
{
if
(
menu
.
id
===
id
)
{
if
(
menu
.
id
===
id
)
{
delete
menu
.
children
return
menu
}
if
(
menu
.
children
)
{
return
util
.
deepFind
(
menu
.
children
,
id
)
return
util
.
deepFind
(
menu
.
children
,
id
)
}
}
return
null
}
util
.
packRoutes
=
function
(
resources
,
idsInPermision
)
{
if
(
!
resources
||
!
idsInPermision
||
!
idsInPermision
.
length
)
{
throw
new
Error
(
'参数错误'
)
}
let
__aRouteInPermision
=
[]
idsInPermision
.
forEach
(
obj
=>
{
__aRouteInPermision
.
push
(
resources
[
obj
.
id
])
})
return
__aRouteInPermision
}
util
.
packAsideMenus
=
function
(
resources
,
idsInPermision
)
{
if
(
!
resources
||
!
idsInPermision
||
!
idsInPermision
.
length
)
{
throw
new
Error
(
'参数错误'
)
}
let
__aMenusInPermision
=
[]
let
__aSub
=
[]
idsInPermision
.
forEach
(
obj
=>
{
const
{
icon
,
path
,
meta
}
=
resources
[
obj
.
id
]
const
{
title
,
id
,
pid
}
=
meta
if
(
obj
.
pid
===
'0'
)
{
__aMenusInPermision
.
push
({
title
,
icon
,
path
,
id
,
pid
})
}
else
{
__aSub
.
push
({
title
,
icon
,
path
,
id
,
pid
})
}
})
let
__parent
=
null
__aSub
.
forEach
(
obj
=>
{
__parent
=
__aMenusInPermision
.
find
(
menu
=>
menu
.
id
===
obj
.
pid
)
if
(
__parent
.
children
)
{
__parent
.
children
.
push
(
obj
)
}
else
{
__parent
.
children
=
[
obj
]
}
})
return
__aMenusInPermision
}
export
default
util
src/libs/util.permision.js
0 → 100644
View file @
514cbb3
/*
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 12:15:51
*/
const
permision
=
{
}
permision
.
packRoutes
=
function
(
resources
,
idsInPermision
)
{
if
(
!
resources
||
!
idsInPermision
||
!
idsInPermision
.
length
)
{
throw
new
Error
(
'参数错误'
)
}
let
__aRouteInPermision
=
[]
idsInPermision
.
forEach
(
obj
=>
{
__aRouteInPermision
.
push
(
resources
[
obj
.
id
])
})
return
__aRouteInPermision
}
permision
.
packAsideMenus
=
function
(
resources
,
idsInPermision
)
{
if
(
!
resources
||
!
idsInPermision
||
!
idsInPermision
.
length
)
{
throw
new
Error
(
'参数错误'
)
}
let
__aMenusInPermision
=
[]
let
__aSub
=
[]
idsInPermision
.
forEach
(
obj
=>
{
const
__oMenu
=
permision
.
format2Menu
(
resources
[
obj
.
id
])
if
(
obj
.
pid
===
'0'
)
{
__aMenusInPermision
.
push
(
__oMenu
)
}
else
{
__aSub
.
push
(
__oMenu
)
}
})
let
__parent
=
null
__aSub
.
forEach
(
obj
=>
{
__parent
=
__aMenusInPermision
.
find
(
menu
=>
menu
.
id
===
obj
.
pid
)
if
(
__parent
.
children
)
{
__parent
.
children
.
push
(
obj
)
}
else
{
__parent
.
children
=
[
obj
]
}
})
return
__aMenusInPermision
}
/**
* 格式化菜单 封装成系统所需格式
*/
permision
.
format2Menu
=
function
(
oMenu
){
const
{
icon
,
path
,
meta
}
=
oMenu
const
{
title
,
id
,
pid
}
=
meta
return
{
title
,
icon
,
path
,
id
,
pid
}
}
export
default
permision
src/main.js
View file @
514cbb3
...
...
@@ -12,15 +12,14 @@ import D2Crud from '@d2-projects/d2-crud'
import
router
from
'./router'
// import menuHeader from '@/menu/header'
// import menuAside from '@/menu/aside'
import
menuAside
from
'@/resources'
import
{
frameInRoutes
}
from
'@/router/routes'
// import { frameInRoutes } from '@/router/routes'
import
echarts
from
'echarts'
import
VRM
from
'vue-role-manager'
Vue
.
use
(
VRM
,
{
router
,
redirect
:
'403'
,
enabled
:
false
enabled
:
false
})
// 核心插件
Vue
.
use
(
d2Admin
)
...
...
@@ -33,11 +32,11 @@ new Vue({
render
:
h
=>
h
(
App
),
created
()
{
// 处理路由 得到每一级的路由设置
this
.
$store
.
commit
(
'd2admin/page/init'
,
frameInRoutes
)
//
this.$store.commit('d2admin/page/init', frameInRoutes)
// 设置顶栏菜单 (暂时不需要)
// this.$store.commit('d2admin/menu/headerSet', menuHeader)
// 设置侧边栏菜单 (TODO 进行过滤)
this
.
$store
.
commit
(
'd2admin/menu/asideSet'
,
menuAside
)
//
this.$store.commit('d2admin/menu/asideSet', menuAside)
// 初始化菜单搜索功能
// this.$store.commit('d2admin/search/init', menuHeader)
},
...
...
src/plugin/d2admin/index.js
View file @
514cbb3
...
...
@@ -26,7 +26,7 @@ export default {
Vue
.
prototype
.
$version
=
process
.
env
.
VUE_APP_VERSION
// 构建时间
Vue
.
prototype
.
$buildTime
=
process
.
env
.
VUE_APP_BUILD_TIME
//事件传递
//
事件传递
Vue
.
prototype
.
$event
=
new
Vue
()
// Element
Vue
.
use
(
ElementUI
)
...
...
src/resources/index.js
deleted
100644 → 0
View file @
3063533
/*
* @Author: limin
* @Date: 2019-08-26 18:03:10
* @Last Modified by: limin
* @Last Modified time: 2019-08-26 21:45:31
*/
// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
const
_import
=
require
(
'@/libs/util.import.'
+
process
.
env
.
NODE_ENV
)
const
resources
=
[{
id
:
'101'
,
path
:
'/index'
,
title
:
'首页'
,
icon
:
'desktop'
},
{
id
:
'102'
,
title
:
'页面'
,
path
:
''
,
icon
:
'folder-o'
,
children
:
[{
id
:
'10201'
,
path
:
'/page1'
,
title
:
'页面 1'
,
component
:
_import
(
'demo/page1'
)
},
{
id
:
'10202'
,
path
:
'/page2'
,
title
:
'页面 2'
,
component
:
_import
(
'demo/page2'
),
auth
:
{
'operation'
:
[{
//列表操作
id
:
'1020101'
,
name
:
'查看'
,
},
{
//
id
:
'1020102'
,
name
:
'编辑'
,
}],
'action'
:
[]
//按钮操作
}
},
{
id
:
'10203'
,
path
:
'/page3'
,
title
:
'页面 3'
,
component
:
_import
(
'demo/page3'
)
}
]
}
]
export
default
resources
\ No newline at end of file
src/router/index.js
View file @
514cbb3
...
...
@@ -12,6 +12,10 @@ import util from '@/libs/util.js'
// 路由数据
import
routes
from
'./routes'
const
originalPush
=
VueRouter
.
prototype
.
push
// 解决连续点击路由异常问题 limin
VueRouter
.
prototype
.
push
=
function
push
(
location
)
{
return
originalPush
.
call
(
this
,
location
).
catch
(
err
=>
err
)
}
Vue
.
use
(
VueRouter
)
// 导出路由 在 main.js 里使用
...
...
@@ -24,6 +28,7 @@ const router = new VueRouter({
* 权限验证
*/
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
const
source
=
store
.
state
.
d2admin
.
auth
.
source
// 确认已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
await
store
.
dispatch
(
'd2admin/page/isLoaded'
)
// 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
...
...
@@ -32,8 +37,10 @@ router.beforeEach(async (to, from, next) => {
NProgress
.
start
()
// 关闭搜索面板
store
.
commit
(
'd2admin/search/set'
,
false
)
// 验证当前路由所有的匹配中是否需要有登录验证的
if
(
to
.
matched
.
some
(
r
=>
r
.
meta
.
auth
))
{
if
(
from
.
name
===
null
&&
to
.
path
!==
'/login'
&&
!
source
){
//页面刷新 动态路由会失效 初始化路由与左侧菜单栏
await
store
.
dispatch
(
'd2admin/auth/init'
)
next
(
to
.
path
)
}
else
if
(
to
.
matched
.
some
(
r
=>
r
.
meta
.
auth
))
{
// 验证当前路由所有的匹配中是否需要有登录验证的
// 这里暂时将cookie里是否存有token作为验证是否登录的条件
// 请根据自身业务需要修改
const
token
=
util
.
cookies
.
get
(
'token'
)
...
...
@@ -64,7 +71,7 @@ router.afterEach(to => {
store
.
dispatch
(
'd2admin/page/open'
,
to
)
// 更改标题
util
.
title
(
to
.
meta
.
title
)
store
.
dispatch
(
'd2admin/auth/set'
,
to
.
meta
.
title
)
//
store.dispatch('d2admin/auth/set', to.meta.title)
})
export
default
router
src/router/routes.js
View file @
514cbb3
...
...
@@ -4,88 +4,90 @@ import layoutHeaderAside from '@/layout/header-aside'
const
_import
=
require
(
'@/libs/util.import.'
+
process
.
env
.
NODE_ENV
)
/**
* 在主框架内显示
* 在主框架内显示
(children 由后台返回资源点集合 从 resources 中动态过滤加载)
*/
const
frameIn
=
[
{
const
frameIn
=
[{
path
:
'/'
,
redirect
:
{
name
:
'index'
},
component
:
layoutHeaderAside
,
children
:
[
// 首页
{
children
:
[]
}
]
/**
* 首页
*/
export
const
home
=
{
path
:
'index'
,
name
:
'index'
,
icon
:
'desktop'
,
meta
:
{
auth
:
true
auth
:
true
,
title
:
'首页'
,
id
:
'101'
,
pid
:
'0'
},
component
:
_import
(
'system/index'
)
}
/**
* 所有需动态过滤的资源点
*/
export
const
resources
=
{
'102'
:
{
path
:
'page'
,
icon
:
'folder-o'
,
name
:
'页面'
,
meta
:
{
auth
:
true
,
title
:
'页面'
,
id
:
'102'
,
pid
:
'0'
}
},
// 演示页面
{
path
:
'page1'
,
name
:
'page1'
,
'10201'
:
{
path
:
'/page1'
,
name
:
'页面 1'
,
meta
:
{
auth
:
true
,
title
:
'页面 1'
,
auth
:
true
id
:
'10201'
,
pid
:
'102'
},
component
:
_import
(
'demo/page1'
)
},
{
path
:
'
page2'
,
name
:
'page
2'
,
'10202'
:
{
path
:
'/
page2'
,
name
:
'页面
2'
,
meta
:
{
auth
:
true
,
title
:
'页面 2'
,
auth
:
true
id
:
'10202'
,
pid
:
'102'
},
component
:
_import
(
'demo/page2'
)
component
:
_import
(
'demo/page2'
),
auth
:
{
'operation'
:
[{
// 列表操作
id
:
'1020101'
,
name
:
'查看'
},
{
//
id
:
'1020102'
,
name
:
'编辑'
}],
'action'
:
[]
// 按钮操作
}
},
{
path
:
'
page3'
,
name
:
'page
3'
,
'10203'
:
{
path
:
'/
page3'
,
name
:
'页面
3'
,
meta
:
{
auth
:
true
,
title
:
'页面 3'
,
auth
:
true
id
:
'10203'
,
pid
:
'102'
},
component
:
_import
(
'demo/page3'
)
},
// 系统监控
{
path
:
'systemMonitor'
,
name
:
'systemMonitor'
,
meta
:
{
title
:
'系统监控'
,
auth
:
true
},
component
:
_import
(
'systemMonitor'
)
},
// 系统 前端日志
{
path
:
'log'
,
name
:
'log'
,
meta
:
{
title
:
'前端日志'
,
auth
:
true
},
component
:
_import
(
'system/log'
)
},
// 刷新页面 必须保留
{
path
:
'refresh'
,
name
:
'refresh'
,
hidden
:
true
,
component
:
_import
(
'system/function/refresh'
)
},
// 页面重定向 必须保留
{
path
:
'redirect/:route*'
,
name
:
'redirect'
,
hidden
:
true
,
component
:
_import
(
'system/function/redirect'
)
}
]
}
]
}
/**
* 在主框架之外显示
...
...
@@ -102,20 +104,20 @@ const frameOut = [
/**
* 错误页面
*/
const
errorPage
=
[
{
export
const
errorPage
=
{
path
:
'*'
,
name
:
'404'
,
component
:
_import
(
'system/error/404'
)
}
]
}
// 导出需要显示菜单的
export
const
frameInRoutes
=
frameIn
// 重新组织后导出
export
default
[
...
frameIn
,
// ...resources,
// ...frameIn,
// dashboard,
...
frameOut
,
...
errorPage
errorPage
]
src/store/modules/d2admin/modules/account.js
View file @
514cbb3
...
...
@@ -2,8 +2,6 @@ import { Message, MessageBox } from 'element-ui'
import
util
from
'@/libs/util.js'
import
router
from
'@/router'
import
{
AccountLogin
}
from
'@api/sys.login'
import
routesAll
from
'@/resources'
import
{
frameInRoutes
}
from
"@/router/routes.js"
;
export
default
{
namespaced
:
true
,
actions
:
{
...
...
@@ -14,7 +12,7 @@ export default {
* @param {Object} payload password {String} 密码
* @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
*/
login
({
dispatch
},
{
login
({
dispatch
,
commit
},
{
username
=
''
,
password
=
''
}
=
{})
{
...
...
@@ -33,16 +31,14 @@ export default {
// 如有必要 token 需要定时更新,默认保存一天
util
.
cookies
.
set
(
'uuid'
,
res
.
uuid
)
util
.
cookies
.
set
(
'token'
,
res
.
token
)
const
{
user
,
resources
}
=
res
// // console.log(resources,routesAll);
// const __routes = []
// resources.forEach(obj => {
// frameInRoutes[0].children.push(util.deepFind(routesAll,obj.id))
// });
// frameInRoutes[0].children.push(...__routes);
// console.log(frameInRoutes[0].children.push(...__routes));
const
{
user
,
resources
}
=
res
// const __aRoutesInPermisions= util.permision.packRoutes(sources,resources)
// frameInRoutes[0].children=[dashboard,...__aRoutesInPermisions];
// router.addRoutes(frameInRoutes)
// const __aMenusInPermisions = util.permision.packAsideMenus(sources,resources)
// await commit('d2admin/page/init', frameInRoutes, { root: true })
// await commit('d2admin/menu/asideSet', [dashboard,...__aMenusInPermisions], { root: true })
await
dispatch
(
'd2admin/auth/set'
,
resources
,
{
root
:
true
})
// 设置 vuex 用户信息
await
dispatch
(
'd2admin/user/set'
,
{
name
:
user
.
name
...
...
@@ -119,6 +115,7 @@ export default {
// DB -> store 持久化数据加载全局尺寸
await
dispatch
(
'd2admin/size/load'
,
null
,
{
root
:
true
})
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
// end
resolve
()
})
...
...
src/store/modules/d2admin/modules/auth.js
View file @
514cbb3
// 设置文件
import
setting
from
'@/setting.js'
/*
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 14:25:41
*/
import
util
from
'@/libs/util.js'
import
router
from
'@/router'
import
{
resources
as
sources
,
home
,
frameInRoutes
,
errorPage
}
from
'@/router/routes'
export
default
{
namespaced
:
true
,
state
:
{
activePage
:
''
,
source
:
''
},
getters
:
{
/**
* @description 返回当前
的主题信息 不是一个名字 而是当前激活主题的所有数据
* @description 返回当前
登录用户权限资源
* @param {Object} state state
*/
activePage
(
state
)
{
return
state
.
activePag
e
source
(
state
,
dispatch
)
{
return
state
.
sourc
e
}
},
actions
:
{
save2db
({
state
,
dispatch
})
{
return
new
Promise
(
async
resolve
=>
{
// 设置数据
dispatch
(
'd2admin/db/set'
,
{
dbName
:
'sys'
,
path
:
'source'
,
value
:
state
.
source
,
user
:
true
},
{
root
:
true
})
// end
resolve
()
})
},
/**
* @description
激活一个主题
* @param {
String} themeValue 需要激活的主题名称
* @description
保存当前角色权限资源
* @param {
obj} source 需要保存的权限资源
*/
set
({
state
,
commit
,
dispatch
},
currentPag
e
)
{
set
({
state
,
commit
,
dispatch
},
sourc
e
)
{
return
new
Promise
(
async
resolve
=>
{
// 检查这个主题在主题列表里是否存在
state
.
activePage
=
currentPage
console
.
log
(
state
.
activePage
)
state
.
source
=
source
// 持久化数据 防止刷新 数据 丢失
await
dispatch
(
'save2db'
)
// end
resolve
()
})
},
/**
* @description 从持久化数据加载主题设置 * @param {Object} context
* @description 从持久化数据加载资源数据
* @param {Object} context
*/
load
({
state
,
commit
,
dispatch
})
{
return
new
Promise
(
async
resolve
=>
{
if
(
!
state
.
source
)
{
state
.
source
=
await
dispatch
(
'd2admin/db/get'
,
{
dbName
:
'sys'
,
path
:
'source'
,
user
:
true
},
{
root
:
true
})
// console.log(document.querySelector('html').getAttribute('login')==='1');
// if( document.querySelector('html').getAttribute('login')==='1'){
// await dispatch('init')
// router.replace(router.currentRoute.path || '/')
// }
// 用户登录后从持久化数据加载一系列的设置
// await dispatch('d2admin/account/load', { root: true })
}
// end
resolve
()
resolve
(
state
.
source
)
})
}
},
mutations
:
{
/**
*
@description
* @param {
Object} state state
*
过滤并初始化路由与左侧菜单栏
* @param {
*} param0
*/
dom
(
state
)
{
init
({
state
,
commit
,
dispatch
})
{
return
new
Promise
(
async
resolve
=>
{
// 获取权限资源点
const
__source
=
await
dispatch
(
'load'
)
// 过滤资源点 并动态添加到路由
const
__aRoutesInPermisions
=
util
.
permision
.
packRoutes
(
sources
,
__source
)
frameInRoutes
[
0
].
children
=
[
home
,
...
__aRoutesInPermisions
]
router
.
addRoutes
(
frameInRoutes
)
// router.addRoutes(errorPage)
await
commit
(
'd2admin/page/init'
,
frameInRoutes
,
{
root
:
true
})
// 过滤左侧菜单栏
const
__aMenusInPermisions
=
util
.
permision
.
packAsideMenus
(
sources
,
__source
)
const
__oHome
=
util
.
permision
.
format2Menu
(
home
)
await
commit
(
'd2admin/menu/asideSet'
,
[
__oHome
,
...
__aMenusInPermisions
],
{
root
:
true
})
// DB -> store 加载用户名
// await dispatch('d2admin/user/load', null, { root: true })
// // DB -> store 加载主题
// await dispatch('d2admin/theme/load', null, { root: true })
// // DB -> store 加载页面过渡效果设置
// await dispatch('d2admin/transition/load', null, { root: true })
// // DB -> store 持久化数据加载上次退出时的多页列表
// await dispatch('d2admin/page/openedLoad', null, { root: true })
// // DB -> store 持久化数据加载侧边栏折叠状态
// await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// // DB -> store 持久化数据加载全局尺寸
// await dispatch('d2admin/size/load', null, { root: true })
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
// end
resolve
(
state
.
source
)
})
}
},
mutations
:
{
}
}
src/store/modules/d2admin/modules/page.js
View file @
514cbb3
...
...
@@ -53,6 +53,7 @@ export default {
// 如果页面过多的话可能需要优化算法
// valid 有效列表 1, 1, 0, 1 => 有效, 有效, 失效, 有效
const
valid
=
[]
const
__oSource
=
await
dispatch
(
'd2admin/auth/load'
,
null
,
{
root
:
true
})
// 处理数据
state
.
opened
=
value
.
map
(
opened
=>
{
// 忽略首页
...
...
@@ -61,7 +62,9 @@ export default {
return
opened
}
// 尝试在所有的支持多标签页的页面里找到 name 匹配的页面
const
find
=
state
.
pool
.
find
(
item
=>
item
.
name
===
opened
.
name
)
const
find
=
state
.
pool
.
find
(
item
=>
{
return
item
.
name
===
opened
.
name
&&
__oSource
.
some
(
obj
=>
obj
.
id
===
item
.
meta
.
id
)
})
// 记录有效或无效信息
valid
.
push
(
find
?
1
:
0
)
// 返回合并后的数据 新的覆盖旧的
...
...
src/views/demo/page1/index.vue
View file @
514cbb3
...
...
@@ -13,13 +13,13 @@
export
default
{
name
:
'page1'
,
render
:
function
(
createElement
)
{
return
createElement
(
'div'
,
{
attrs
:
{
class
:
'd2-layout-header-aside-menu-side'
}
,
return
createElement
(
'div'
,
{
attrs
:
{
class
:
'd2-layout-header-aside-menu-side'
}
},
[
createElement
(
'el-menu'
,
{
props
:
{
collapse
:
this
.
asideCollapse
,
uniqueOpened
:
true
,
defaultActive
:
this
.
active
},
ref
:
'menu'
,
on
:
{
select
:
this
.
handleMenuSelect
}
}
,
),
}),
...
this
.
aside
.
length
===
0
&&
!
this
.
asideCollapse
?
[
createElement
(
'div'
,
{
attrs
:
{
class
:
'd2-layout-header-aside-menu-empty'
,
flex
:
'dir:top main:center cross:center'
}
},
[
createElement
(
'd2-icon'
,
{
props
:
{
name
:
'inbox'
}
}),
...
...
src/views/demo/page2/index.vue
View file @
514cbb3
...
...
@@ -52,27 +52,27 @@
<
script
>
export
default
{
export
default
{
methods
:
{
handleClick
(
row
)
{
console
.
log
(
row
);
handleClick
(
row
)
{
console
.
log
(
row
)
},
test
(
row
)
{
console
.
log
(
row
);
test
(
row
)
{
console
.
log
(
row
)
}
},
components
:
{
},
mounted
()
{
this
.
$event
.
$on
(
"e-auth-click"
,
function
()
{
this
.
$event
.
$on
(
'e-auth-click'
,
function
()
{
alert
(
1
)
});
})
},
data
()
{
data
()
{
return
{
btn
:
{
lable
:
'测试'
,
action
:
'test'
,
btn
:
{
lable
:
'测试'
,
action
:
'test'
},
tableData
:
[{
date
:
'2016-05-03'
,
...
...
@@ -105,5 +105,5 @@
}]
}
}
}
}
</
script
>
src/views/system/login/page.vue
View file @
514cbb3
...
...
@@ -220,9 +220,11 @@ export default {
password
:
this
.
formLogin
.
password
})
.
then
(()
=>
{
this
.
$store
.
dispatch
(
'd2admin/auth/init'
).
then
(
_
=>
{
// 重定向对象不存在则返回顶层路径
this
.
$router
.
replace
(
this
.
$route
.
query
.
redirect
||
'/'
)
})
})
}
else
{
// 登录表单校验失败
this
.
$message
.
error
(
'表单校验失败,请检查'
)
...
...
src/views/systemMonitor/index.vue
View file @
514cbb3
...
...
@@ -89,7 +89,7 @@
<
script
>
export
default
{
name
:
'systemMonitor'
,
data
()
{
data
()
{
return
{
subSystemRadio
:
'全部'
,
systemTypeArr
:
[{
...
...
@@ -215,25 +215,25 @@ export default {
},
{
label
:
'子系统状态'
,
prop
:
'subSystemStatus'
}
,
{
},
{
label
:
'车辆编号'
,
prop
:
'carNum'
}
,
{
},
{
label
:
'归属车辆段'
,
prop
:
'belongCar'
}
,
{
},
{
label
:
'故障内容'
,
prop
:
'text'
}]
}
},
mounted
()
{
mounted
()
{
this
.
drawPie
()
},
methods
:
{
drawPie
()
{
drawPie
()
{
this
.
totalECharts
=
this
.
$echarts
.
init
(
document
.
getElementById
(
'totalEcharts'
))
this
.
totalOptions
.
series
[
0
].
data
[
0
].
value
=
400
this
.
totalOptions
.
series
[
0
].
data
[
1
].
value
=
45
...
...
@@ -244,18 +244,18 @@ export default {
this
.
totalECharts
.
setOption
(
this
.
totalOptions
)
},
radioChange
(
label
)
{
radioChange
(
label
)
{
console
.
log
(
label
)
// 请求后端数据--参数
var
value
=
''
for
(
var
i
in
this
.
systemTypeArr
)
{
if
(
this
.
systemTypeArr
[
i
].
label
==
label
)
{
for
(
var
i
in
this
.
systemTypeArr
)
{
if
(
this
.
systemTypeArr
[
i
].
label
==
label
)
{
value
=
this
.
systemTypeArr
[
i
].
value
break
}
}
// 调接口
if
(
value
==
'1'
)
{
if
(
value
==
'1'
)
{
this
.
totalOptions
.
series
[
0
].
data
[
0
].
value
=
400
this
.
totalOptions
.
series
[
0
].
data
[
1
].
value
=
45
...
...
@@ -271,7 +271,7 @@ export default {
this
.
totalECharts
.
setOption
(
this
.
totalOptions
)
},
handleSearch
()
{
handleSearch
()
{
console
.
log
(
this
.
searchForm
)
// 调接口
}
...
...
vue.config.js
View file @
514cbb3
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment