Browse Source

发布渠道管理提交

wangqin
Joe 11 months ago
parent
commit
1923ca1e8e
  1. 2
      ruoyi-ui/src/views/JiHeExpressway/components/Buttons/Button.vue
  2. 5
      ruoyi-ui/src/views/JiHeExpressway/images/TrafficAccidents.svg
  3. 2
      ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/utils/layerImages.js
  4. 67
      ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditDetails/DetailCard.vue
  5. 6
      ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditDetails/index.vue
  6. 18
      ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditLists/ListItem.vue
  7. 19
      ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditLists/index.vue
  8. 101
      ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Card.vue
  9. 94
      ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Switcher.vue
  10. 60
      ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/index.vue
  11. 58
      ruoyi-ui/src/views/JiHeExpressway/utils/axios/auth.js

2
ruoyi-ui/src/views/JiHeExpressway/components/Buttons/Button.vue

@ -19,7 +19,7 @@ export default {
<style lang='scss' scoped>
.Button {
height: 24px;
padding: 0 9px;
padding: 0 15px;
background: #00B3CC;
border-radius: 48px 48px 48px 48px;
display: flex;

5
ruoyi-ui/src/views/JiHeExpressway/images/TrafficAccidents.svg

@ -0,0 +1,5 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Frame">
<path id="Vector" d="M1.7147 10.2794C1.89474 9.41173 2.07478 8.63926 2.25483 7.86679C2.27319 7.77593 2.31651 7.69183 2.38003 7.6237C2.44354 7.55557 2.52481 7.50605 2.61491 7.48055C2.96289 7.3398 3.3273 7.24264 3.69968 7.19132C4.69532 7.09521 5.78008 6.99821 6.77572 6.99821C6.85677 6.69463 6.97784 6.4029 7.1358 6.13051C6.77572 6.13051 6.41563 6.03351 6.05014 6.03351C5.29081 5.95362 4.52302 6.01919 3.7888 6.22663C3.42871 6.32363 3.15865 6.41974 2.88858 6.51586C2.48816 6.58989 2.12247 6.78933 1.84557 7.0847C1.56868 7.38008 1.39528 7.75569 1.35101 8.15602C1.26099 8.73537 1.08095 9.31294 0.990924 9.89318C0.954149 10.002 0.892546 10.1009 0.81088 10.1824C0.58695 10.1914 0.375809 10.288 0.223879 10.4509C0.0719499 10.6138 -0.00833177 10.8296 0.000685151 11.051V11.3402C0.180729 11.3402 0.450794 11.4363 0.540815 11.4363C0.630837 12.3049 0.630837 13.1735 0.720859 14.1391C0.720859 14.6214 0.81088 15.1038 0.81088 15.5861C0.796106 15.6981 0.813618 15.8118 0.8614 15.9143C0.909181 16.0168 0.985286 16.1039 1.08095 16.1655C1.66144 16.2402 2.25162 16.174 2.80036 15.9724C2.88348 15.5906 2.9436 15.2043 2.9804 14.8155L4.88076 14.6232C4.97078 13.4663 5.0608 12.3094 5.15083 11.2414C5.2458 10.9272 5.30617 10.6038 5.33087 10.2767C4.12655 10.3733 2.91631 10.3733 1.712 10.2767L1.7147 10.2794ZM2.89128 12.9822C2.72261 13.0596 2.53656 13.0927 2.35115 13.0783H1.54096C1.18087 13.0783 1.09085 12.7891 1.09085 12.2106C1.09085 11.8244 1.36091 11.8244 1.63098 11.8244C2.09767 11.9421 2.55194 12.1036 2.9876 12.3067C3.05672 12.3497 3.11629 12.406 3.16271 12.4724C3.20913 12.5388 3.24144 12.6138 3.25767 12.6929C3.17922 12.8311 3.05045 12.9345 2.89758 12.9822H2.89128ZM8.3583 2.46039L7.40857 2.04212L7.61202 4.33728L8.3583 2.4595V2.46039ZM5.57663 1L4.49097 2.04301L7.1367 4.26786L5.57663 1ZM17.9996 10.7635C18.007 10.493 17.9069 10.2304 17.7208 10.032C17.5347 9.83351 17.2774 9.71501 17.004 9.70185C16.8684 9.61089 16.7721 9.47314 16.7339 9.31561C16.5306 8.62017 16.3802 7.9107 16.2838 7.1931C16.2237 6.71449 16.0188 6.26499 15.6959 5.90342C15.3731 5.54185 14.9473 5.28508 14.4744 5.16671L13.3878 4.87658C12.4735 4.63754 11.5273 4.53997 10.5827 4.58735C9.92634 4.72475 9.26187 4.82135 8.59325 4.87658C8.3416 4.92704 8.10817 5.04308 7.91712 5.2127C7.72608 5.38231 7.58438 5.59933 7.50669 5.84128C7.14661 6.70986 6.87654 7.48144 6.51645 8.35092C6.42224 8.47507 6.29858 8.5744 6.15637 8.64015C5.89696 8.59066 5.62827 8.64389 5.40819 8.78838C5.18811 8.93287 5.03426 9.15705 4.97978 9.41262C4.93463 9.48514 4.91072 9.56863 4.91072 9.65379C4.91072 9.73895 4.93463 9.82244 4.97978 9.89496C5.22591 9.97591 5.46647 10.0725 5.69996 10.1842C5.59668 10.4633 5.536 10.756 5.51991 11.0528C5.42989 12.4037 5.24985 13.7546 5.24985 15.2026C5.22325 15.4417 5.28741 15.6821 5.42989 15.8772C6.07019 16.0888 6.75057 16.1548 7.42027 16.0703C7.9604 15.781 7.69034 15.1056 7.87038 14.7202L14.2043 15.2987C14.212 15.7926 14.3033 16.2817 14.4744 16.7457C15.1683 16.9969 15.9167 17.0635 16.6448 16.9389C16.7428 16.8365 16.8176 16.7146 16.8642 16.5814C16.9107 16.4482 16.928 16.3067 16.9149 16.1664C17.0049 15.5879 17.0049 15.0095 17.0949 14.4301C17.1849 13.3693 17.2749 12.3067 17.2749 11.1489C17.455 11.1489 17.7251 11.0528 17.9951 11.0528V10.7635H17.9996ZM8.40961 12.4998H7.50939C7.1686 12.4364 6.83506 12.3395 6.51375 12.2106C6.06364 12.0175 6.15367 11.6312 6.24369 11.2459C6.23903 11.1768 6.25027 11.1076 6.27656 11.0434C6.30286 10.9792 6.34352 10.9217 6.3955 10.8753C6.44748 10.8289 6.50943 10.7947 6.57668 10.7754C6.64394 10.756 6.71476 10.752 6.78382 10.7635C7.43774 11.0801 8.07228 11.4343 8.68418 11.8244C8.7217 11.8844 8.74453 11.9522 8.75085 12.0225C8.75717 12.0927 8.7468 12.1635 8.72057 12.2291C8.69434 12.2947 8.65297 12.3533 8.59977 12.4003C8.54656 12.4473 8.48299 12.4814 8.41411 12.4998H8.40961ZM7.32305 8.92938C7.59311 8.15691 7.9532 7.38533 8.13864 6.70986C8.18774 6.44515 8.33611 6.20853 8.5541 6.04732C8.77208 5.88611 9.0436 5.81221 9.31433 5.84039C10.671 5.9374 12.0285 5.9374 13.386 6.13051C13.8594 6.16866 14.3204 6.29998 14.7417 6.51675C14.9103 6.62235 15.062 6.75223 15.1918 6.90209C15.4619 7.86679 15.642 8.73537 15.912 9.79707C13.018 10.1944 10.0698 9.89675 7.31675 8.92938H7.32305ZM16.0092 13.1753H15.0136C14.7435 13.1753 14.5635 13.0783 14.2934 13.0783C14.2032 13.053 14.1219 13.0035 14.0583 12.9353C13.9948 12.8672 13.9515 12.783 13.9333 12.6921C13.9497 12.6131 13.982 12.5383 14.0285 12.472C14.0749 12.4058 14.1344 12.3496 14.2034 12.3067C14.7715 12.0995 15.3448 11.9066 15.9228 11.7282C15.9893 11.6952 16.0632 11.6796 16.1375 11.6828C16.2118 11.6861 16.2841 11.7082 16.3473 11.7469C16.4105 11.7857 16.4626 11.8398 16.4986 11.9042C16.5346 11.9685 16.5534 12.0409 16.553 12.1145C16.643 12.7891 16.4629 13.1744 16.0128 13.1744L16.0092 13.1753Z" fill="white"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

2
ruoyi-ui/src/views/JiHeExpressway/pages/Home/components/RoadAndEvents/utils/layerImages.js

@ -1,6 +1,6 @@
export function getLayerData() {
const layerData = require.context(
"./../../../../../images/layer",
"@screen/images/layer",
true,
/^\.\/[^_a-zA-Z]+\.svg$/
);

67
ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditDetails/DetailCard.vue

@ -3,26 +3,33 @@
<div class="header">
<div class="left">
<div class="title">{{ data.title || '-' }}</div>
<div class="state">{{ data.state || '-' }}</div>
<div class="state" :style="{ backgroundColor: status[data.state].color }">{{ status[data.state].text }}</div>
</div>
<div class="right">
<span>icon</span>
<span>
<i class="el-icon-time"></i>
</span>
<span>{{ data.time || '-' }}</span>
</div>
</div>
<div class="body">
<div class="content">
因改扩建施工接交警通知G3京台高速崮山泰安西站双向入口临时关闭万德站北京方向入口临时关闭崮山站北京方向出口临时关闭济南崮山服务区台北方向入口临时关闭泰安服务区北京方向入口临时关闭泰山枢纽G22青兰高速兰州方向转G3京台高速北京方向匝道G22青兰高速青岛方向转G3京台高速北京方向匝道临时关闭
{{ data.desc }}
</div>
<div class="people">
<img src="@screen/images/form/people.svg" alt="">
<span>s</span>
<img src="@screen/images/people.svg" alt="">
<span>发布对象: 甘易玫</span>
</div>
<div class="people">
<img src="@screen/images/people.svg" alt="">
<span>当前管制: 甘易玫</span>
</div>
<div class="suffix remark">
备注:
</div>
<div class="suffix share-with">
分享至
<img v-for="item in shareWithData" :key="item" :src="require(`@screen/images/shareWith/${item}.svg`)">
</div>
</div>
<div class="footer">
@ -32,7 +39,13 @@
</template>
<script>
import Button from "@screen/components/Buttons/Button.vue"
import Button from "@screen/components/Buttons/Button.vue";
const shareWith = require.context(
"@screen/images/shareWith",
true,
/^\.\/[^-/]+\.svg$/
);
export default {
name: 'DetailCard',
@ -45,8 +58,27 @@ export default {
default: () => ({
title: "事件详情",
state: 0,
desc: ''
})
desc: '因改扩建施工,接交警通知,G3京台高速崮山(辅)、泰安西站双向入口临时关闭,万德站北京方向入口临时关闭,崮山(主)站北京方向出口临时关闭;济南崮山服务区(台北方向)入口临时关闭。泰安服务区(北京方向)入口临时关闭。泰山枢纽(G22青兰高速兰州方向转G3京台高速北京方向匝道、G22青兰高速青岛方向转G3京台高速北京方向匝道)临时关闭。'
}),
}
},
data() {
return {
shareWithData: shareWith.keys().map(item => item.match(/[^./]+/)[0]),
status: {
0: {
text: "进行中",
color: '#00B1A0'
},
1: {
text: "待审核",
color: '#C55253'
},
2: {
text: "已审核",
color: '#057DD3'
},
}
}
}
}
@ -58,7 +90,6 @@ export default {
flex-direction: column;
background: rgba(6, 66, 88, 0.8);
border-radius: 4px 4px 4px 4px;
opacity: 1;
border: 1px solid;
border-image: linear-gradient(180deg, rgba(9, 60, 80, 0), rgba(0, 134, 187, 1)) 1 1;
@ -76,6 +107,20 @@ export default {
gap: 6px;
}
.left {
.state {
font-size: 14px;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #FFFFFF;
border-radius: 18px;
height: 24px;
display: flex;
align-items: center;
padding: 6px;
}
}
align-items: center;
justify-content: space-between;
}
@ -101,6 +146,10 @@ export default {
color: #05D3BF;
line-height: 16px;
padding: 6px;
display: flex;
gap: 6px;
align-items: center;
}
}

6
ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditDetails/index.vue

@ -25,8 +25,10 @@ export default {
timeLine2List: Array.from({ length: 6 }).map(() => ({
time: "2023-12-21 16:35:44",
name: "甘易玫",
desc: "描述性文字文字文字文字文字文字文字文字描述性文字文字文字文字文字文字文字文字",
posts: '淄博发展公司管理员'
// title: "xxx",
desc: "因改扩建施工,接交警通知,G3京台高速崮山(辅)、泰安西站双向入口临时关闭,万德站北京方向入口临时关闭,崮山(主)站北京方向出口临时关闭;济南崮山服务区(台北方向)入口临时关闭。泰安服务区(北京方向)入口临时关闭。泰山枢纽(G22青兰高速兰州方向转G3京台高速北京方向匝道、G22青兰高速青岛方向转G3京台高速北京方向匝道)临时关闭。",
posts: '淄博发展公司管理员',
state: 0,
})),
}
}

18
ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditLists/ListItem.vue

@ -1,14 +1,15 @@
<template>
<div class='ListItem'>
<img class="prefix" :src="require(`@screen/images/ListItem/${eventTypeIcon[data.type]}.svg`)" />
<img class="prefix" :src="require(`@screen/images/ListItem/${eventTypeIcon[1]}.svg`)" />
<div class="center">
<div class="header">
<span class="title">{{ data.title || '-' }}</span>
<span class="state" :style="{ backgroundColor: state[data.state].color }">{{ state[data.state].text }}</span>
<span class="state" :style="{ backgroundColor: state[data.isverify].color }">{{ state[data.isverify].text
}}</span>
</div>
<div class="content">{{ data.desc || '-' }}</div>
<div class="content">{{ data.content || '-' }}</div>
</div>
<img class="suffix" :src="require(`@screen/images/ListItem/${state[data.state].icon}.svg`)" />
<img class="suffix" :src="require(`@screen/images/ListItem/${state[data.isverify].icon}.svg`)" />
</div>
</template>
@ -33,18 +34,18 @@ export default {
state: {
0: {
color: "#00B1A0",
text: "处理中",
text: "待审核",
icon: 'ToBeReviewed'
},
1: {
color: "#057DD3",
text: "已处理",
text: "已审核",
icon: 'Reviewed'
},
2: {
color: "#057DD3",
text: "已处理",
color: "#C55253",
text: "未通过",
icon: 'Failed'
},
}
@ -62,6 +63,7 @@ export default {
border: 1px solid;
padding: 21px;
border-image: linear-gradient(180deg, rgba(9, 60, 80, 0), rgba(0, 134, 187, .72)) 1 1;
cursor: pointer;
display: flex;
align-items: center;

19
ruoyi-ui/src/views/JiHeExpressway/pages/service/InformationReleaseManagement/Cards/AuditLists/index.vue

@ -2,7 +2,7 @@
<Card2 class='Auditlists' title="审核列表">
<InputSearch style="width: 100%;" />
<div class="body">
<ListItem v-for="(item, index) in list" :key="index" :data="item" />
<ListItem v-for="item in list" :key="item.id" :data="item" />
</div>
<div class="footer">
<Pagination :total="90" />
@ -15,6 +15,7 @@ import Card2 from "@screen/components/Card2/Card.vue";
import Pagination from '@screen/components/Pagination.vue';
import InputSearch from '@screen/components/InputSearch/index.vue';
import ListItem from "./ListItem.vue";
import { axiosIns } from "@screen/utils/axios/auth.js";
export default {
name: 'Auditlists',
@ -28,19 +29,31 @@ export default {
return {
list: Array.from({ length: 20 }).map(() => ({
title: "异常天气",
desc: "2023.12.23 13:00:00 济南方向K100+000 交通事故",
content: "2023.12.23 13:00:00 济南方向K100+000 交通事故",
type: (() => {
const min = 0;
const max = 1;
return Math.floor(Math.random() * (max - min + 1)) + min;
})(),
state: (() => {
isverify: (() => {
const min = 0;
const max = 2;
return Math.floor(Math.random() * (max - min + 1)) + min;
})()
})),
}
},
created() {
// axiosIns.get("/business/dcPublishInfo/list")
// .then((result) => {
// console.log("%c [ result ]-39-index.vue", "font-size:15px; background:#4bd543; color:#8fff87;", result);
// if (result.code !== 200) return this.list = [];
// this.list = result.rows;
// }).catch((err) => {
// });
}
}
</script>

101
ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Card.vue

@ -0,0 +1,101 @@
<template>
<div class='Card'>
<div class="header">
<BackgroundClip class="left" clipPath="inset(0 0 0 0 round 24px)"
borderColor="linear-gradient(90deg, rgba(251, 19, 19, 1), rgba(214, 0, 0, 0))"
bgColor="linear-gradient(270deg, rgba(243, 0, 0, 0) 0%, #6B0000 100%)">
<img src="@screen/images/TrafficAccidents.svg" />
交通事故
</BackgroundClip>
<div class="right">
<Switcher />
<!-- <ElSwitch active-color="#fff" inactive-color="#48B0CB" /> -->
</div>
</div>
<Descriptions :list="list" style="gap: 15px; flex: 1; margin-top: 9px;" column="1" />
<div class="footer">
<Button>修改</Button>
</div>
</div>
</template>
<script>
import Button from '@screen/components/Buttons/Button.vue';
import BackgroundClip from '@screen/components/Decorations/BackgroundClip.vue';
import Descriptions from '@screen/components/Descriptions.vue';
import Switcher from './Switcher.vue';
export default {
name: 'Card',
components: {
Button,
BackgroundClip,
Descriptions,
Switcher
},
data() {
return {
list: [
{
label: '信息级别',
text: '影响通行',
},
{
label: '发布渠道',
text: '情报板、微博',
},
{
label: '审核方式',
text: '双人审核',
},
{
label: '启用日期',
text: '2023.12.22 13:00:00',
}
]
}
}
}
</script>
<style lang='scss' scoped>
.Card {
height: 226px;
background: #133242;
border-radius: 2px;
border: 1px solid;
padding: 15px 21px;
border-image: linear-gradient(360deg, rgba(55, 231, 255, .42), rgba(55, 231, 255, 0)) 1 1;
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 9px;
.header {
display: flex;
align-items: center;
justify-content: space-between;
.left {
// height: 28px;
display: flex;
align-items: center;
gap: 6px;
padding: 1px 6px;
padding-right: 24px;
// border: 1px solid;
// border-image: linear-gradient(90deg, rgba(251, 19, 19, 1), rgba(214, 0, 0, 0)) 1 1;
}
}
.footer {
display: flex;
width: 100%;
align-items: center;
justify-content: flex-end;
}
}
</style>

94
ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/components/Switcher.vue

@ -0,0 +1,94 @@
<template>
<div class='Switcher' :style="{
'--unActive-color': getActiveOptions.unActive.color,
'--unActive-text-color': getActiveOptions.unActive.textColor,
'--active-color': getActiveOptions.active.color,
'--active-text-color': getActiveOptions.active.textColor,
}" @click="toggle">
<span :style="{ opacity: +!active }">{{ getActiveOptions.active.text }}</span>
<span :style="{ opacity: +active }">{{ getActiveOptions.unActive.text }}</span>
<div class="active" :style="{ left: active ? '0%' : '50%' }">{{ getActiveOptions[active ? 'active' :
'unActive'].text }}</div>
</div>
</template>
<script>
export default {
name: 'Switcher',
props: {
activeOption: {
type: Object,
default: () => null
}
},
data() {
return {
active: true
}
},
computed: {
getActiveOptions() {
return {
active: {
text: "启用",
color: "#fff",
textColor: "#00B3CC",
...this.activeOption?.active
},
unActive: {
text: "停用",
color: "#00B3CC",
textColor: "#fff",
...this.activeOption?.unActive
}
}
}
},
methods: {
toggle() {
this.active = !this.active
}
},
}
</script>
<style lang='scss' scoped>
.Switcher {
--content: var(--active-text);
position: relative;
background-color: var(--unActive-color);
transition: all .24s ease-in-out;
cursor: pointer;
border-radius: 41px;
padding: 3px 6px;
display: flex;
align-items: center;
font-size: 14px;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
line-height: 24px;
letter-spacing: 1px;
color: var(--unActive-text-color);
gap: 12px;
>span {
transition: all .15s ease-in-out;
}
.active {
content: var(--content);
border-radius: 41px;
position: absolute;
transition: all .24s ease-in-out;
display: flex;
align-items: center;
color: var(--active-text-color);
padding: 3px 6px;
top: 0;
height: 100%;
width: 50%;
background-color: var(--active-color);
}
}
</style>

60
ruoyi-ui/src/views/JiHeExpressway/pages/service/PublishingChannelManagement/index.vue

@ -1,15 +1,71 @@
<template>
<div class='PublishingChannelManagement'>
PublishingChannelManagement
<!-- 搜索栏 -->
<div class="filter">
<InputSearch style="width: 402px;" />
</div>
<!-- 内容 -->
<div class="body">
<Card v-for="item in 8" :key="item" />
</div>
<!-- 分页 -->
<div class="footer">
<Pagination :total="90" />
</div>
</div>
</template>
<script>
import Pagination from '@screen/components/Pagination.vue';
import InputSearch from '@screen/components/InputSearch/index.vue';
import Card from './components/Card';
export default {
name: 'PublishingChannelManagement',
components: {
Pagination,
InputSearch,
Card
},
}
</script>
<style lang='scss' scoped>
.PublishingChannelManagement {}
.PublishingChannelManagement {
padding: 21px;
height: 100%;
display: flex;
flex-direction: column;
z-index: 6;
width: 100%;
.filter {
height: 60px;
display: flex;
justify-content: flex-end;
}
.body {
flex: 1;
overflow: hidden;
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-gap: 24px;
// grid-row-gap: 9px;
// grid-column-gap: 9px;
grid-auto-rows: min-content;
}
.footer {
margin-top: 15px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>

58
ruoyi-ui/src/views/JiHeExpressway/utils/axios/auth.js

@ -1,21 +1,44 @@
import axios from "axios";
const RequestURL = `http://10.168.65.211:3000`;
// 摄像头
// const RequestURL = `http://10.168.65.211:3000`;
const UN = "jhgskj",
PD = "jhgskj@2023",
// 后台
const RequestURL = `http://10.168.77.209:1024/dev-api`;
// const UN = "jhgskj",
// PD = "jhgskj@2023",
const UN = "admin",
PD = "admin123",
tokeKey = "LOCAL_TOKEN";
let continueRefreshToken = true;
function getToken() {
return axios
.post(`${RequestURL}/apiLogin`, {
const token = localStorage.getItem(tokeKey);
if (token) return Promise.resolve(token);
return new Promise((resolve, reject) => {
axios
.post(`${RequestURL}/login`, {
username: UN,
password: PD,
})
.then((res) => {
localStorage.setItem(tokeKey, res.data.token);
return res.data.token;
if (res.data.code === 200) {
localStorage.setItem(tokeKey, `Bearer ${res.data.token}`);
console.log("get token success");
resolve(res.data.token);
} else {
console.log("get token failed");
reject(void 0);
}
})
.catch((e) => {
console.log("get token failed", error);
reject(e);
});
});
}
@ -28,11 +51,9 @@ axiosIns.defaults.baseURL = RequestURL;
// request拦截器
axiosIns.interceptors.request.use(
async (config) => {
// let token = localStorage.getItem(tokeKey);
// if (!token) token = await getToken();
const token = await getToken();
// config.headers["Authorization"] = token;
config.headers["Authorization"] = token;
return config;
},
@ -44,7 +65,18 @@ axiosIns.interceptors.request.use(
// response拦截器
axiosIns.interceptors.response.use(
async (response) => {
// if (response.data.code === 401) {}
if (response.data.code === 401 && continueRefreshToken) {
localStorage.removeItem(tokeKey);
return getToken()
.then(async () => {
return await axiosIns.request(response.config);
})
.catch((e) => {
continueRefreshToken = false;
return null;
});
}
return response.data;
},

Loading…
Cancel
Save