Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
md-vue-chc
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
何鹏程
md-vue-chc
Commits
8fa1f8c8
Commit
8fa1f8c8
authored
Jul 01, 2021
by
何鹏程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改路由配置
parent
ce37020f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
152 additions
and
69 deletions
+152
-69
index.js
config/index.js
+1
-0
prod.env.js
config/prod.env.js
+2
-1
dist.zip
dist.zip
+0
-0
index.html
index.html
+3
-1
index.vue
src/page/siteQuery/index.vue
+21
-2
index.js
src/router/index.js
+114
-58
staticRoute.js
src/router/staticRoute.js
+1
-2
ajax.js
src/util/ajax.js
+10
-5
No files found.
config/index.js
View file @
8fa1f8c8
...
...
@@ -8,6 +8,7 @@ module.exports = {
'/api'
:
{
target
:
'http://172.16.15.117:8084/'
,
// 开发环境地址
// target: 'http://172.16.15.100:801',
// target: 'http://122.51.94.140/teamwork', // 测试环境
changeOrigin
:
true
,
pathRewrite
:
{
'^/api'
:
'/api'
...
...
config/prod.env.js
View file @
8fa1f8c8
'use strict'
module
.
exports
=
{
NODE_ENV
:
'"production"'
NODE_ENV
:
'"production"'
,
BASE_API
:
'"http://40.1.2.84/teamwork/"'
}
dist.zip
0 → 100644
View file @
8fa1f8c8
File added
index.html
View file @
8fa1f8c8
...
...
@@ -10,7 +10,9 @@
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1.0"
>
<title>
区域急危重症救治协同平台
</title>
<!-- 引入阿里云oss-sdk -->
<script
src=
"https://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"
></script>
<!-- <script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script> -->
<!-- 引入百度DuGIS -->
<!-- <script src="http://40.1.2.251:8219/bmapgl/"></script> -->
</head>
<body>
...
...
src/page/siteQuery/index.vue
View file @
8fa1f8c8
...
...
@@ -6,14 +6,20 @@
style=
"height: 100%"
:span=
"12"
>
<baidu-map
<
!--
<
baidu-map
class=
"map"
:center=
"center"
:zoom=
"zoom"
@
ready=
"handler"
ak=
"OdRZ7iA9KGrKwFqufVTI3eTHOHDriGV7"
>
</baidu-map>
</baidu-map>
-->
<div
class=
"map"
id=
"allmap"
>
</div>
</el-col>
<el-col
style=
"height: 100%"
...
...
@@ -142,7 +148,20 @@ export default {
}
},
mounted
()
{
var
map
=
new
BMapGL
.
map
(
'allmap'
)
map
.
centerAndZoom
(
new
BMapGL
.
Point
(
defaultCenterPoint
[
0
],
defaultCenterPoint
[
1
]))
map
.
enableScrollWheelZoom
(
true
);
var
darkStyle
=
[
{
featureType
:
'land'
,
elementType
:
'ge'
}
]
map
.
setOptions
({
style
:
'default'
,
styleUrl
:
''
})
},
methods
:
{
handler
({
BMap
,
map
})
{
...
...
src/router/index.js
View file @
8fa1f8c8
...
...
@@ -3,11 +3,21 @@ import VueRouter from 'vue-router'
import
NProgress
from
'nprogress'
import
'nprogress/nprogress.css'
import
whiteList
from
'./whiteList'
import
{
Auth
,
Cache
}
from
'@/util/auth'
import
{
Auth
,
Cache
}
from
'@/util/auth'
import
store
from
'../store'
import
{
staticRoute
,
routeHandle
}
from
'./staticRoute'
import
{
login
}
from
'../api/common'
NProgress
.
configure
({
showSpinner
:
false
})
import
{
staticRoute
,
routeHandle
}
from
'./staticRoute'
import
{
login
}
from
'../api/common'
NProgress
.
configure
({
showSpinner
:
false
})
Vue
.
use
(
VueRouter
)
//以下代码解决路由地址重复的报错问题
...
...
@@ -15,85 +25,131 @@ const originalPush = VueRouter.prototype.push
VueRouter
.
prototype
.
push
=
function
push
(
location
)
{
return
originalPush
.
call
(
this
,
location
).
catch
(
err
=>
err
)
}
const
router
=
new
VueRouter
({
mode
:
'hash'
,
routes
:
staticRoute
})
// 路由跳转前验证
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
// 开启进度条
NProgress
.
start
()
// 判断是否传入token
// const token = 12332
// store.dispatch('clearStore')
// login({token: token}).then(res => {
// if (res.msg === 201) {
// store.dispatch('saveMenuMap', res.respData.menuMap.parentMenuList)
// router.addRoutes(routeHandle(res.respData.menuMap.parentMenuList))
// store.dispatch('saveUserInfo', res.respData.userDto)
// Auth.setLoginInfo(res.respData.token)
// next()
// } else {
// next({path: '/error/404', replace: true})
// }
// })
if
(
to
.
query
&&
to
.
query
.
token
)
{
const
token
=
to
.
query
.
token
const
_token
=
Auth
.
getLoginInfo
()
if
(
_token
===
token
)
{
const
token
=
to
.
query
.
token
const
_token
=
Auth
.
getLoginInfo
()
// const userInfo = store.getters.userInfo
// const menu = store.getters.menuMap
const
routers
=
router
.
getRoutes
()
// console.log('router', routers)
// console.log('token', token)
// console.log('_token', _token)
// console.log('userInfo', userInfo)
// console.log('menu', menu)
if
(
token
&&
token
!==
_token
)
{
// 重新登录
store
.
dispatch
(
'clearStore'
)
login
({
token
:
token
}).
then
(
res
=>
{
if
(
res
.
msg
===
201
)
{
store
.
dispatch
(
'saveMenuMap'
,
res
.
respData
.
menuMap
.
parentMenuList
)
router
.
addRoutes
(
routeHandle
(
res
.
respData
.
menuMap
.
parentMenuList
))
store
.
dispatch
(
'saveUserInfo'
,
res
.
respData
.
userDto
)
Auth
.
setLoginInfo
(
res
.
respData
.
token
)
next
({
...
to
,
replace
:
true
})
}
else
{
this
.
$message
.
error
(
res
.
content
)
next
({
path
:
'/error/404'
,
replace
:
true
})
}
})
}
else
{
if
(
routers
.
length
>
7
)
{
next
()
}
else
{
store
.
dispatch
(
'clearStore'
)
login
({
token
:
token
}).
then
(
res
=>
{
login
({
token
:
token
||
_token
}).
then
(
res
=>
{
if
(
res
.
msg
===
201
)
{
store
.
dispatch
(
'saveMenuMap'
,
res
.
respData
.
menuMap
.
parentMenuList
)
router
.
addRoutes
(
routeHandle
(
res
.
respData
.
menuMap
.
parentMenuList
))
store
.
dispatch
(
'saveUserInfo'
,
res
.
respData
.
userDto
)
// console.log(router.getRoutes())
// console.log(to.path)
Auth
.
setLoginInfo
(
res
.
respData
.
token
)
next
()
next
({
...
to
,
replace
:
true
})
}
else
{
// next({path: '/error/404', replace: true})
this
.
$message
.
error
(
res
.
content
)
next
({
path
:
'/error/404'
,
replace
:
true
})
}
})
}
}
else
{
// 判断是否登录过
if
(
Auth
.
getLoginInfo
()
&&
store
.
getters
.
userInfo
&&
store
.
getters
.
menuMap
){
next
()
}
else
{
if
(
Auth
.
getLoginInfo
())
{
const
token
=
Auth
.
getLoginInfo
()
store
.
dispatch
(
'clearStore'
)
login
({
token
:
token
}).
then
(
res
=>
{
if
(
res
.
msg
===
201
)
{
store
.
dispatch
(
'saveMenuMap'
,
res
.
respData
.
menuMap
.
parentMenuList
)
router
.
addRoutes
(
routeHandle
(
res
.
respData
.
menuMap
.
parentMenuList
))
store
.
dispatch
(
'saveUserInfo'
,
res
.
respData
.
userDto
)
Auth
.
setLoginInfo
(
res
.
respData
.
token
)
next
()
}
else
{
next
({
path
:
'/error/404'
,
replace
:
true
})
}
})
}
else
{
// 判断是否为白名单页面
if
(
whiteList
.
indexOf
(
to
.
path
)
>=
0
)
{
next
()
}
else
{
store
.
dispatch
(
'clearStore'
)
next
({
path
:
'/error/404'
,
replace
:
true
})
}
}
}
}
// if (token) {
// if (_token === token) {
// next()
// } else {
// store.dispatch('clearStore')
// login({token: token}).then(res => {
// if (res.msg === 201) {
// store.dispatch('saveMenuMap', res.respData.menuMap.parentMenuList)
// router.addRoutes(routeHandle(res.respData.menuMap.parentMenuList))
// store.dispatch('saveUserInfo', res.respData.userDto)
// Auth.setLoginInfo(res.respData.token)
// next()
// } else {
// this.$message.error(res.content)
// next({path: '/error/404', replace: true})
// }
// })
// }
// } else {
// // 判断是否登录过
// if (Auth.getLoginInfo() && store.getters.userInfo && store.getters.menuMap){
// next()
// } else {
// if (Auth.getLoginInfo()) {
// const token = Auth.getLoginInfo()
// store.dispatch('clearStore')
// login({token: token}).then(res => {
// if (res.msg === 201) {
// store.dispatch('saveMenuMap', res.respData.menuMap.parentMenuList)
// router.addRoutes(routeHandle(res.respData.menuMap.parentMenuList))
// store.dispatch('saveUserInfo', res.respData.userDto)
// Auth.setLoginInfo(res.respData.token)
// next()
// } else {
// next({path: '/error/404', replace: true})
// }
// })
// } else {
// // 判断是否为白名单页面
// if (whiteList.indexOf(to.path) >= 0) {
// next()
// } else {
// store.dispatch('clearStore')
// next({path: '/error/404', replace: true})
// }
// }
// }
// }
})
router
.
afterEach
(()
=>
{
...
...
src/router/staticRoute.js
View file @
8fa1f8c8
...
...
@@ -38,10 +38,9 @@ const routeHandle = (map) => {
if
(
item
.
secondMenuList
||
item
.
secondMenuList
.
length
>
0
)
{
const
children
=
[]
item
.
secondMenuList
.
forEach
(
_item
=>
{
let
url
=
_item
.
url
.
split
(
'/'
)[
2
]
children
.
push
({
path
:
_item
.
url
,
component
:
()
=>
import
(
`@/page/
${
url
}
`
)
component
:
()
=>
import
(
`@/page/
${
_item
.
keyName
}
`
)
})
})
routers
.
push
({
...
...
src/util/ajax.js
View file @
8fa1f8c8
...
...
@@ -4,16 +4,21 @@
*/
import
axios
from
'axios'
import
router
from
'../router'
import
{
Message
}
from
'element-ui'
import
{
Auth
}
from
'@/util/auth'
import
{
Message
}
from
'element-ui'
import
{
Auth
}
from
'@/util/auth'
// import {Encrypt} from '../util/secret'
const
CancelToken
=
axios
.
CancelToken
//
const CancelToken = axios.CancelToken
// 超时设置
const
service
=
axios
.
create
({
// 请求超时时间
timeout
:
30000
timeout
:
30000
,
baseURL
:
process
.
env
.
NODE_ENV
===
'production'
?
process
.
env
.
BASE_API
:
''
,
})
// http request 拦截器
...
...
@@ -46,7 +51,7 @@ service.interceptors.response.use(
store
.
dispatch
(
'clearStore'
)
router
.
push
(
'/login'
)
break
case
403
:
case
403
:
router
.
push
(
'error/403'
)
break
case
404
:
...
...
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