Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcdj-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
f7049097
authored
2023-06-01 16:22:05 +0800
by
renchao@pashanhoo.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
style:cas部署
1 parent
219c12d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
15 deletions
src/layout/components/Navbar.vue
src/permission.js
src/utils/request.js
src/layout/components/Navbar.vue
View file @
f704909
...
...
@@ -28,6 +28,7 @@
</
template
>
<
script
>
import
axios
from
'axios'
import
Cookies
from
'js-cookie'
import
{
mapGetters
}
from
'vuex'
import
NoticeBar
from
'@/components/NoticeBar/index'
import
{
...
...
@@ -64,7 +65,6 @@
window
.
removeEventListener
(
'message'
)
},
methods
:
{
queryNoticeList
()
{
getHomeNoticeList
().
then
(
res
=>
{
if
(
res
.
result
)
{
...
...
@@ -74,7 +74,11 @@
},
logout
()
{
axios
.
post
(
this
.
BASE_API
.
ip
+
"/management/logout"
).
then
(()
=>
{
localStorage
.
removeItem
(
'token'
)
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
localStorage
.
removeItem
(
'token'
)
}
else
{
Cookies
.
remove
(
'token'
)
}
if
(
window
.
_config
.
casEnable
)
{
window
.
location
.
href
=
window
.
_config
.
casBaseURL
+
'/logout?service='
+
encodeURIComponent
(
window
.
location
.
href
);
}
else
{
...
...
src/permission.js
View file @
f704909
/*
* @Description: 项目权限
* @Autor: renchao
* @LastEditTime: 2023-0
5-31 15:55:1
4
* @LastEditTime: 2023-0
6-01 16:16:0
4
*/
import
Vue
from
'vue'
import
axios
from
'axios'
import
router
from
'./router'
import
store
from
'./store'
import
axios
from
'axios
'
import
Cookies
from
'js-cookie
'
import
{
getMenuInfo
}
from
'@/api/user'
import
{
getUrlParam
}
from
'@/utils/operation'
import
NProgress
from
'nprogress'
// progress bar
import
'nprogress/nprogress.css'
// progress bar style
import
getPageTitle
from
'@/utils/get-page-title'
import
Cookies
from
'js-cookie'
NProgress
.
configure
({
showSpinner
:
false
})
// NProgress Configuration
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
...
...
@@ -42,7 +42,11 @@ router.beforeEach(async (to, from, next) => {
'service'
:
locationUrl
}
}).
then
(
async
(
res
)
=>
{
localStorage
.
setItem
(
'token'
,
res
.
data
.
content
.
accessToken
)
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
localStorage
.
setItem
(
'token'
,
res
.
data
.
content
.
accessToken
)
}
else
{
Cookies
.
set
(
'ACCESS_TOKEN'
,
res
.
data
.
content
.
accessToken
)
}
window
.
location
.
href
=
localStorage
.
getItem
(
'location'
)
}).
catch
(
e
=>
{
...
...
src/utils/request.js
View file @
f704909
/*
* @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
* @Autor: renchao
* @LastEditTime: 2023-06-01
09:20:24
* @LastEditTime: 2023-06-01
16:05:00
*/
import
axios
from
'axios'
import
Cookies
from
'js-cookie'
import
{
Message
}
from
'element-ui'
import
{
endLoadingSubCount
}
from
'./requestLoading'
...
...
@@ -23,14 +24,16 @@ const service = axios.create({
// request interceptor
service
.
interceptors
.
request
.
use
(
config
=>
{
const
token
=
localStorage
.
getItem
(
'token'
)
// 添加请求头
if
(
token
)
{
config
.
headers
[
'Authorization'
]
=
"Bearer "
+
token
}
else
{
config
.
headers
.
delete
(
'Authorization'
)
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
const
token
=
localStorage
.
getItem
(
'token'
)
// 添加请求头
if
(
token
)
{
config
.
headers
[
'Authorization'
]
=
'Bearer '
+
token
}
else
{
config
.
headers
.
delete
(
'Authorization'
)
}
}
return
config
;
return
config
},
error
=>
{
// do something with request error
...
...
@@ -62,7 +65,12 @@ service.interceptors.response.use(
window
.
__isNeedLogin
=
false
Message
.
error
(
'token失效,请重新登录'
);
let
locationUrl
=
window
.
location
.
protocol
+
'//'
+
window
.
location
.
host
+
window
.
location
.
pathname
;
localStorage
.
removeItem
(
'token'
)
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
localStorage
.
removeItem
(
'token'
)
}
else
{
Cookies
.
remove
(
'token'
)
}
if
(
window
.
_config
.
casEnable
)
{
window
.
location
.
href
=
window
.
_config
.
casBaseURL
+
'/logout?service='
+
encodeURIComponent
(
locationUrl
);
}
else
{
...
...
Please
register
or
sign in
to post a comment