Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
ka-manager-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
ka-manager-ui
Commits
61b5d082
Commit
61b5d082
authored
Aug 26, 2020
by
suntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ww
parent
2e8ad844
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
30 deletions
+44
-30
main.js
src/main.js
+1
-0
index.vue
src/modules/dashboard/index.vue
+7
-8
AppMain.vue
src/modules/layout/components/AppMain.vue
+4
-4
index.vue
src/modules/layout/components/Sidebar/index.vue
+10
-5
index.vue
src/modules/login/index.vue
+1
-1
getters.js
src/store/getters.js
+4
-0
index.js
src/store/index.js
+6
-4
app.js
src/store/modules/app.js
+3
-0
permission.js
src/store/modules/permission.js
+8
-8
No files found.
src/main.js
View file @
61b5d082
...
@@ -28,6 +28,7 @@ router.beforeEach(({meta, path}, from, next) => {
...
@@ -28,6 +28,7 @@ router.beforeEach(({meta, path}, from, next) => {
if
(
whiteList
.
indexOf
(
path
)
!==
-
1
)
{
if
(
whiteList
.
indexOf
(
path
)
!==
-
1
)
{
next
()
next
()
}
else
{
}
else
{
store
.
dispatch
(
'
GenerateRoutes
'
)
let
{
auth
=
true
}
=
meta
let
{
auth
=
true
}
=
meta
let
isLogin
=
Boolean
(
store
.
state
.
login
.
tokens
!=
''
)
//true用户已登录, false用户未登录
let
isLogin
=
Boolean
(
store
.
state
.
login
.
tokens
!=
''
)
//true用户已登录, false用户未登录
...
...
src/modules/dashboard/index.vue
View file @
61b5d082
<
template
>
<
template
>
<div
class=
"dashboard-container"
>
<div
class=
"dashboard-container"
>
<div
class=
"dashboard-text"
>
name:
{{
name
}}
</div>
<div
class=
"dashboard-text"
>
name:
{{
user
name
}}
</div>
<div
class=
"dashboard-text"
>
roles:
<span
v-for=
"role in roles"
:key=
"role"
>
{{
role
}}
</span></div
>
<!--
<div
class=
"dashboard-text"
>
roles:
<span
v-for=
"role in roles"
:key=
"role"
>
{{
role
}}
</span></div>
--
>
</div>
</div>
</
template
>
</
template
>
...
@@ -10,12 +10,11 @@ import { mapGetters } from 'vuex'
...
@@ -10,12 +10,11 @@ import { mapGetters } from 'vuex'
export
default
{
export
default
{
name
:
'
Dashboard
'
,
name
:
'
Dashboard
'
,
computed
:
{
computed
:
// ...mapGetters([
mapGetters
([
// 'name',
'
username
'
// 'roles'
])
// ])
}
}
}
</
script
>
</
script
>
...
...
src/modules/layout/components/AppMain.vue
View file @
61b5d082
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<section
class=
"app-main"
>
<section
class=
"app-main"
>
<transition
name=
"fade-transform"
mode=
"out-in"
>
<transition
name=
"fade-transform"
mode=
"out-in"
>
<!-- or name="fade" -->
<!-- or name="fade" -->
<!--
<router-view
:key=
"key"
></router-view>
--
>
<router-view
:key=
"key"
></router-view
>
<router-view/>
<router-view/>
</transition>
</transition>
</section>
</section>
...
@@ -12,9 +12,9 @@
...
@@ -12,9 +12,9 @@
export
default
{
export
default
{
name
:
'
AppMain
'
,
name
:
'
AppMain
'
,
computed
:
{
computed
:
{
//
key() {
key
()
{
// return this.$route.name !== undefined ? this.$route.
name + +new Date() : this.$route + +new Date()
return
this
.
$route
.
username
!==
undefined
?
this
.
$route
.
user
name
+
+
new
Date
()
:
this
.
$route
+
+
new
Date
()
//
}
}
}
}
}
}
</
script
>
</
script
>
...
...
src/modules/layout/components/Sidebar/index.vue
View file @
61b5d082
...
@@ -15,23 +15,28 @@
...
@@ -15,23 +15,28 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapGetters
}
from
'
vuex
'
import
SidebarItem
from
'
./SidebarItem
'
import
SidebarItem
from
'
./SidebarItem
'
import
variables
from
'
@/styles/variables.scss
'
import
variables
from
'
@/styles/variables.scss
'
export
default
{
export
default
{
components
:
{
SidebarItem
},
components
:
{
SidebarItem
},
computed
:
{
computed
:
{
sidebar
:
mapGetters
([
sidebar
()
{
'
permission_routers
'
,
return
this
.
$store
.
state
.
app
.
sidebar
'
sidebar
'
},
]),
permission_routers
()
{
return
this
.
$store
.
state
.
permission
.
routers
},
variables
()
{
variables
()
{
return
variables
return
variables
},
},
isCollapse
()
{
isCollapse
()
{
return
!
this
.
sidebar
.
opened
return
!
this
.
sidebar
.
opened
}
}
},
created
()
{
}
}
}
}
</
script
>
</
script
>
src/modules/login/index.vue
View file @
61b5d082
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
]),
]),
watch
:
{
watch
:
{
tokens
:
function
(
val
)
{
tokens
:
function
(
val
)
{
this
.
$router
.
push
(
'
/
home/channels
'
);
this
.
$router
.
push
(
'
/
channel
'
);
}
}
},
},
created
()
{
created
()
{
...
...
src/store/getters.js
View file @
61b5d082
const
getters
=
{
const
getters
=
{
sidebar
:
state
=>
state
.
app
.
sidebar
,
device
:
state
=>
state
.
app
.
device
,
tokens
:
state
=>
state
.
login
.
tokens
,
tokens
:
state
=>
state
.
login
.
tokens
,
username
:
state
=>
state
.
login
.
username
,
username
:
state
=>
state
.
login
.
username
,
permission_routers
:
state
=>
state
.
permission
.
routers
,
addRouters
:
state
=>
state
.
permission
.
addRouters
,
}
}
export
default
getters
export
default
getters
src/store/index.js
View file @
61b5d082
...
@@ -7,8 +7,10 @@ import createLogger from 'vuex/dist/logger'
...
@@ -7,8 +7,10 @@ import createLogger from 'vuex/dist/logger'
import
createPersistedState
from
'
vuex-persistedstate
'
//vuex持久化localstorage插件
import
createPersistedState
from
'
vuex-persistedstate
'
//vuex持久化localstorage插件
import
*
as
Cookies
from
'
js-cookie
'
;
import
*
as
Cookies
from
'
js-cookie
'
;
import
*
as
state
from
'
./state
'
import
*
as
state
from
'
./state
'
import
*
as
mutations
from
'
./mutations
'
// import * as mutations from './mutations'
import
*
as
actions
from
'
./actions
'
// import * as actions from './actions'
import
permission
from
'
./modules/permission
'
import
app
from
'
./modules/app
'
import
getters
from
'
./getters
'
import
getters
from
'
./getters
'
import
menu
from
'
./modules/menu
'
import
menu
from
'
./modules/menu
'
import
login
from
'
./modules/login
'
import
login
from
'
./modules/login
'
...
@@ -25,10 +27,10 @@ let persistedState = {
...
@@ -25,10 +27,10 @@ let persistedState = {
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
state
,
state
,
mutations
,
actions
,
getters
,
getters
,
modules
:
{
modules
:
{
app
,
permission
,
menu
,
menu
,
login
login
},
},
...
...
src/store/modules/app.js
View file @
61b5d082
...
@@ -11,14 +11,17 @@ const app = {
...
@@ -11,14 +11,17 @@ const app = {
mutations
:
{
mutations
:
{
TOGGLE_SIDEBAR
:
state
=>
{
TOGGLE_SIDEBAR
:
state
=>
{
if
(
state
.
sidebar
.
opened
)
{
if
(
state
.
sidebar
.
opened
)
{
console
.
log
(
"
sidebarStatus=1
"
)
Cookies
.
set
(
'
sidebarStatus
'
,
1
)
Cookies
.
set
(
'
sidebarStatus
'
,
1
)
}
else
{
}
else
{
Cookies
.
set
(
'
sidebarStatus
'
,
0
)
Cookies
.
set
(
'
sidebarStatus
'
,
0
)
}
}
console
.
log
(
"
sidebarStatus=out
"
)
state
.
sidebar
.
opened
=
!
state
.
sidebar
.
opened
state
.
sidebar
.
opened
=
!
state
.
sidebar
.
opened
state
.
sidebar
.
withoutAnimation
=
false
state
.
sidebar
.
withoutAnimation
=
false
},
},
CLOSE_SIDEBAR
:
(
state
,
withoutAnimation
)
=>
{
CLOSE_SIDEBAR
:
(
state
,
withoutAnimation
)
=>
{
console
.
log
(
"
sidebarStatus=CLOSE_SIDEBAR
"
)
Cookies
.
set
(
'
sidebarStatus
'
,
1
)
Cookies
.
set
(
'
sidebarStatus
'
,
1
)
state
.
sidebar
.
opened
=
false
state
.
sidebar
.
opened
=
false
state
.
sidebar
.
withoutAnimation
=
withoutAnimation
state
.
sidebar
.
withoutAnimation
=
withoutAnimation
...
...
src/store/modules/permission.js
View file @
61b5d082
...
@@ -22,13 +22,13 @@ function filterAsyncRouter(routes, roles) {
...
@@ -22,13 +22,13 @@ function filterAsyncRouter(routes, roles) {
const
res
=
[]
const
res
=
[]
routes
.
forEach
(
route
=>
{
routes
.
forEach
(
route
=>
{
const
tmp
=
{
...
route
}
const
tmp
=
{
route
}
if
(
hasPermission
(
roles
,
tmp
))
{
//
if (hasPermission(roles, tmp)) {
if
(
tmp
.
children
)
{
if
(
tmp
.
children
)
{
tmp
.
children
=
filterAsyncRouter
(
tmp
.
children
,
roles
)
tmp
.
children
=
filterAsyncRouter
(
tmp
.
children
,
roles
)
}
}
res
.
push
(
tmp
)
res
.
push
(
tmp
)
}
//
}
})
})
return
res
return
res
...
@@ -48,14 +48,14 @@ const permission = {
...
@@ -48,14 +48,14 @@ const permission = {
actions
:
{
actions
:
{
GenerateRoutes
({
commit
},
data
)
{
GenerateRoutes
({
commit
},
data
)
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
const
{
roles
}
=
data
//
const { roles } = data
let
accessedRouters
let
accessedRouters
if
(
roles
.
includes
(
'
admin
'
))
{
//
if (roles.includes('admin')) {
accessedRouters
=
asyncRouterMap
accessedRouters
=
asyncRouterMap
}
else
{
//
} else {
accessedRouters
=
filterAsyncRouter
(
asyncRouterMap
,
roles
)
//
accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
}
//
}
commit
(
'
SET_ROUTERS
'
,
accessedRouters
)
commit
(
'
SET_ROUTERS
'
,
accessedRouters
)
resolve
()
resolve
()
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment