Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
周远喜
Admin
Commits
e67f7a54
Commit
e67f7a54
authored
Mar 20, 2020
by
周远喜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打开页面设置,基本正常。
parent
f174bcba
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
16 deletions
+147
-16
index.vue
layouts/basic-layout/header-log/index.vue
+4
-3
default.vue
layouts/default.vue
+54
-4
nuxt.config.js
nuxt.config.js
+2
-1
route.js
plugins/route.js
+52
-0
routes.js
router/routes.js
+6
-2
page.js
store/admin/page.js
+1
-1
user.js
store/admin/user.js
+9
-4
index.js
store/index.js
+19
-1
No files found.
layouts/basic-layout/header-log/index.vue
View file @
e67f7a54
...
...
@@ -32,9 +32,10 @@
},
methods
:
{
handleOpenLog
()
{
this
.
$router
.
push
({
name
:
'log'
});
// this.$router.push({
// name: 'log'
// });
this
.
$router
.
push
(
"/system/log"
);
}
}
}
...
...
layouts/default.vue
View file @
e67f7a54
<
template
>
<MainLayout
/>
<MainLayout
/>
</
template
>
<
script
>
import
MainLayout
from
'./basic-layout'
import
MainLayout
from
"./basic-layout"
;
// 配置
import
Setting
from
"@/setting"
;
// 方法
import
{
getHeaderName
,
getMenuSider
,
getSiderSubmenu
}
from
"@/libs/system"
;
// 菜单和路由
import
router
from
'@/router'
;
import
menuHeader
from
'@/menu/header'
;
import
menuSider
from
'@/menu/sider'
;
import
{
frameInRoutes
}
from
'@/router/routes'
;
export
default
{
components
:{
MainLayout
}
}
components
:
{
MainLayout
},
created
()
{
// const filterMenuSider = getMenuSider(menuSider, "home");
// this.$store.commit("admin/menu/setSider", filterMenuSider);
console
.
warn
(
"menu"
,
menuSider
,
frameInRoutes
,
menuHeader
);
// 处理路由 得到每一级的路由设置
this
.
$store
.
commit
(
"admin/page/init"
,
frameInRoutes
);
// 设置顶栏菜单
this
.
$store
.
commit
(
"admin/menu/setHeader"
,
menuHeader
);
// 加载用户登录的数据
this
.
$store
.
dispatch
(
"admin/account/load"
);
// 初始化全屏监听
this
.
$store
.
dispatch
(
"admin/layout/listenFullscreen"
);
},
watch
:
{
// 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
$route
(
to
,
from
)
{
console
.
warn
(
"to,from"
,
to
,
from
);
let
path
=
to
.
matched
[
to
.
matched
.
length
-
1
].
path
;
if
(
!
Setting
.
dynamicSiderMenu
)
{
let
headerName
=
getHeaderName
(
path
,
menuSider
);
if
(
headerName
===
null
)
{
path
=
to
.
path
;
headerName
=
getHeaderName
(
path
,
menuSider
);
}
// 在 404 时,是没有 headerName 的
if
(
headerName
!==
null
)
{
this
.
$store
.
commit
(
"admin/menu/setHeaderName"
,
headerName
);
const
filterMenuSider
=
getMenuSider
(
menuSider
,
headerName
);
this
.
$store
.
commit
(
"admin/menu/setSider"
,
filterMenuSider
);
this
.
$store
.
commit
(
"admin/menu/setActivePath"
,
to
.
path
);
const
openNames
=
getSiderSubmenu
(
path
,
menuSider
);
this
.
$store
.
commit
(
"admin/menu/setOpenNames"
,
openNames
);
}
}
// this.appRouteChange(to, from);
}
}
};
</
script
>
\ No newline at end of file
nuxt.config.js
View file @
e67f7a54
...
...
@@ -54,7 +54,8 @@ export default {
** Plugins to load before mounting the App
*/
plugins
:
[
'@/plugins/iview'
'@/plugins/iview'
,
'@/plugins/route'
],
/*
** Nuxt.js dev-modules
...
...
plugins/route.js
0 → 100644
View file @
e67f7a54
import
iView
from
'view-design'
;
import
util
from
'@/libs/util'
import
Setting
from
'@/setting'
;
export
default
({
app
,
router
,
store
})
=>
{
/**
* 路由拦截
* 权限验证
*/
app
.
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
if
(
Setting
.
showProgressBar
)
iView
.
LoadingBar
.
start
();
// 判断是否需要登录才可以进入
if
(
to
.
matched
.
some
(
_
=>
_
.
meta
.
auth
))
{
// 这里依据 token 判断是否登录,可视情况修改
const
token
=
util
.
cookies
.
get
(
'token'
);
if
(
token
&&
token
!==
'undefined'
)
{
next
();
}
else
{
// 没有登录的时候跳转到登录界面
// 携带上登陆成功之后需要跳转的页面完整路径
next
({
name
:
'login'
,
query
:
{
redirect
:
to
.
fullPath
}
});
}
}
else
{
// 不需要身份校验 直接通过
next
();
}
});
app
.
router
.
afterEach
(
to
=>
{
if
(
Setting
.
showProgressBar
)
iView
.
LoadingBar
.
finish
();
// 多页控制 打开新的页面
store
.
dispatch
(
'admin/page/open'
,
to
);
console
.
info
(
"log"
,
to
)
// 更改标题
util
.
title
({
title
:
to
.
meta
.
title
});
// 返回页面顶端
window
.
scrollTo
(
0
,
0
);
});
}
router/routes.js
View file @
e67f7a54
...
...
@@ -16,13 +16,17 @@ const frameIn = [
{
path
:
'index'
,
name
:
'index'
,
meta
:
{
title
:
'首页'
,
auth
:
true
},
redirect
:
{
name
:
'dashboard-console'
}
},
{
path
:
'log'
,
name
:
'log'
,
path
:
'
/system/
log'
,
name
:
'
system-
log'
,
meta
:
{
title
:
'前端日志'
,
auth
:
true
...
...
store/admin/page.js
View file @
e67f7a54
...
...
@@ -9,7 +9,7 @@ import { getAllSiderMenu, includeArray } from '@/libs/system';
// 判定是否需要缓存
const
isKeepAlive
=
data
=>
get
(
data
,
'meta.cache'
,
false
);
export
const
strict
=
false
;
export
const
state
=
()
=>
({
// 可以在多页 tab 模式下显示的页面
pool
:
[],
...
...
store/admin/user.js
View file @
e67f7a54
...
...
@@ -4,6 +4,9 @@ export const state=()=>({
export
const
mutations
=
{
increment
(
state
){
state
.
counter
++
},
setUser
(
state
,
info
){
state
.
info
=
info
;
}
}
export
const
actions
=
{
...
...
@@ -13,10 +16,11 @@ export const actions={
* @param {Object} dispatch vuex dispatch
* @param {*} info info
*/
set
({
state
,
dispatch
},
info
)
{
set
({
state
,
dispatch
,
commit
},
info
)
{
return
new
Promise
(
async
resolve
=>
{
// store 赋值
state
.
info
=
info
;
// state.info = info;
commit
(
"setUser"
,
info
)
// 持久化
await
dispatch
(
'admin/db/set'
,
{
dbName
:
'sys'
,
...
...
@@ -33,15 +37,16 @@ export const actions={
* @param {Object} state vuex state
* @param {Object} dispatch vuex dispatch
*/
load
({
state
,
dispatch
})
{
load
({
state
,
dispatch
,
commit
})
{
return
new
Promise
(
async
resolve
=>
{
// store 赋值
state
.
info
=
await
dispatch
(
'admin/db/get'
,
{
let
info
=
await
dispatch
(
'admin/db/get'
,
{
dbName
:
'sys'
,
path
:
'user.info'
,
defaultValue
:
{},
user
:
true
},
{
root
:
true
});
commit
(
"setUser"
,
info
)
// end
resolve
();
})
...
...
store/index.js
View file @
e67f7a54
import
createVuexAlong
from
'vuex-along'
export
const
state
=
()
=>
({
counter
:
0
})
...
...
@@ -5,4 +6,21 @@ export const mutations={
increment
(
state
){
state
.
counter
++
}
}
\ No newline at end of file
}
export
const
plugins
=
[
createVuexAlong
({
// 设置保存的集合名字,避免同站点下的多项目数据冲突
name
:
"hyhmes"
,
local
:
{
list
:
[
"hyhmes"
],
// 过滤模块 ma 数据, 将其他的存入 localStorage
isFilter
:
true
,
},
session
:
{
// 保存模块 ma 中的 a1 到 sessionStorage
list
:
[
"hyhmes.session"
],
},
}),
]
//设置 strict 为不严格模式,即可在actions中修改state
export
const
strict
=
false
;
\ No newline at end of file
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