修改token超时后判断

This commit is contained in:
GGJ
2024-12-18 11:31:33 +08:00
parent 38aadcac32
commit 8cdf4ca8b6
5 changed files with 309 additions and 142 deletions

View File

@@ -33,7 +33,9 @@ export async function pwdSm3(pwd: any, loginName?: string) {
//登录获取token
export async function login(params: any) {
params.password = await pwdSm3(params.password, params.username)
if (params.refresh_token == undefined) {
params.password = await pwdSm3(params.password, params.username)
}
params.username = encrypt(params.username)
return request({
url: '/pqs-auth/oauth/token',
@@ -147,7 +149,7 @@ export function existMonitorDeptTree() {
})
}
// 获取用户
export function getUserByRoleType(data:any) {
export function getUserByRoleType(data: any) {
return request({
url: '/user-boot/user/getUserByRoleType?roleType=' + data,
method: 'GET'
@@ -155,7 +157,7 @@ export function getUserByRoleType(data:any) {
}
// 获取部门下所有用户
export function listAllUserByDeptId(data:any) {
export function listAllUserByDeptId(data: any) {
return request({
url: '/user-boot/user/listAllUserByDeptId?deptId=' + data,
method: 'GET'
@@ -163,7 +165,7 @@ export function listAllUserByDeptId(data:any) {
}
// 根据id获取所有用户信息
export function getUserListByIds(data:any) {
export function getUserListByIds(data: any) {
return request({
url: '/user-boot/user/getUserListByIds',
method: 'POST',
@@ -176,7 +178,7 @@ export function getUserListByIds(data:any) {
*/
export const getUserSimpleList = () => {
return request({
url: '/user-boot/user/simpleList',
url: '/user-boot/user/simpleList',
method: 'GET'
})
}
@@ -186,18 +188,14 @@ export const getUserSimpleList = () => {
*/
export const getAllUserSimpleList = () => {
return request({
url: '/user-boot/user/getAllUserSimpleList',
url: '/user-boot/user/getAllUserSimpleList',
method: 'GET'
})
}
export const getSysConfig =()=> {
export const getSysConfig = () => {
return request({
url: "/system-boot/config/getSysConfig",
method: "get",
});
url: '/system-boot/config/getSysConfig',
method: 'get'
})
}

View File

@@ -506,6 +506,7 @@ export default {
colors.push('#CC0000')
break
}
if (waveDatas[0].unit === '电压') {
if (this.value === 1) {

View File

@@ -1,13 +1,18 @@
<template>
<div>
<MyEChart style="height: 400px;width: 100%" v-for="item in echartsList" :options="item" />
<!-- <MyEChart style="height: 400px;width: 100%" v-for="item in echartsList" :options="item" /> -->
<div id="container0" style="height:400px;width:100%;"></div>
<div id="container1" style="height:400px;width:100%;"></div>
</div>
</template>
<script setup lang='ts'>
import MyEChart from '@/components/echarts/MyEchart.vue'
import { ref, reactive } from 'vue'
import Highcharts from 'highcharts';
import { ref, reactive, onUnmounted } from 'vue'
const props = defineProps({
wp: {
type: Object,
@@ -23,155 +28,315 @@ const props = defineProps({
},
})
// let data = [[-100, -3.41, -3.39, -3.34, 1, 2, 3], [-99.92, -5.19, -5.23, -5.19, 4, 5, 6], [-99.84, -7.28, -7.26, -7.26, 10, 20, 30]]
const echartsList: any = ref([])
const SA:any = ref([])
const SB:any = ref([])
const SC:any = ref([])
const info = () => {
let result = props.wp?.listWaveData.map(item => {
let A = [[item[0], item[1]], [item[0], item[4]],];
let B = [[item[0], item[2]], [item[0], item[5]],]; // 注意item[7] 会是 undefined需要确保数据长度或调整索引
let C = [[item[0], item[3]], [item[0], item[6]],]; // 根据要求,这里 C 的第二个和第三个子数组的第二个元素取自 subArray[4] 和 subArray[6]
// 由于 subArray[7] 在原始数据中不存在,我们可以使用 subArray[5] 的下一个有效索引 subArray[6](对于 B 的第三个子数组的第二个元素)
return { A, B, C };
}).reduce((acc, { A, B, C }) => {
acc.A[0].push(A[0]);
acc.A[1].push(A[1]);
acc.B[0].push(B[0]);
acc.B[1].push(B[1]);
acc.C[0].push(C[0]);
acc.C[1].push(C[1]);
return acc;
}, { A: [[],[]], B: [[],[]], C: [[],[]] });
SA.value = result.A;
SB.value = result.B;
SC.value = result.C;
console.log( SA.value );
console.log( SB.value );
console.log( SC.value);
let num = (props.wp?.waveTitle.length - 1) / 3
for (let i = 0; i < num; i++) {
let A: any = [], B: any = [], C: any = []
props.wp?.listWaveData.forEach((item: any,) => {
A.push([item[0], item[i * 3 + 1]])
B.push([item[0], item[i * 3 + 2]])
C.push([item[0], item[i * 3 + 3]])
})
// A.value = []
// B.value = []
// C.value = []
// props.wp?.listWaveData.forEach((item: any,) => {
// A.value.push([item[0], item[i * 3 + 1]])
// B.value.push([item[0], item[i * 3 + 2]])
// C.value.push([item[0], item[i * 3 + 3]])
// })
setTimeout(() => {
console.log("🚀 ~ info ~ A:", A)
echartsList.value.push({
title: {
text: i == 0 ? '123' : '',
x: 'center',
},
tooltip: {
axisPointer: {
type: 'cross',
label: {
color: '#fff',
fontSize: 16
}
},
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
fontSize: 14
},
backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0,
},
dataZoom: [
{
type: 'inside',
height: 13,
start: 0,
bottom: '20px',
end: 25
},
{
start: 0,
height: 13,
bottom: '20px',
end: 25
// echartsList.value.push({
// title: {
// text: i == 0 ? '123' : '',
// x: 'center',
// },
// tooltip: {
// axisPointer: {
// type: 'cross',
// label: {
// color: '#fff',
// fontSize: 16
// }
// },
// textStyle: {
// color: '#fff',
// fontStyle: 'normal',
// opacity: 0.35,
// fontSize: 14
// },
// backgroundColor: 'rgba(0,0,0,0.55)',
// borderWidth: 0,
// },
// dataZoom: [
// {
// type: 'inside',
// height: 13,
// start: 0,
// bottom: '20px',
// end: 25
// },
// {
// start: 0,
// height: 13,
// bottom: '20px',
// end: 25
// }
// ],
// xAxis: {
// // data: data.filter(item => item.phaseType == 'A').map(item => item.time),
// name: '时间',
// type: 'value',
// axisLine: {
// show: true,
// onZero: false //-----------重点
// },
// // splitLine: {
// // show: false,
// // }
// },
// yAxis: {
// type: 'value',
// name: name,
// // splitLine: {
// // show: false,
// // }
// // max: max,
// // min: min
// },
// // legend: {
// // data: ['A', 'B', 'C']
// // // selectedMode: false,
// // },
// grid: {
// top: '30px',
// left: '30px'
// },
// color: ['#FFCC00', '#009900', '#CC0000'],
// series: [
// {
// name: 'A相',
// type: 'line',
// smooth: true,
// symbol: 'none',
// // 开启渐进式渲染
// progressive: 2000,
// // 渲染阈值,大于此值则启动渐进渲染
// progressiveThreshold: 5000,
// sampling: 'average',
// data: A
// },
// {
// name: 'B相',
// type: 'line',
// smooth: true,
// symbol: 'none',
// // 开启渐进式渲染
// progressive: 2000,
// // 渲染阈值,大于此值则启动渐进渲染
// progressiveThreshold: 5000,
// sampling: 'average',
// data: B
// },
// {
// name: 'C相',
// type: 'line',
// smooth: true,
// symbol: 'none',
// // 开启渐进式渲染
// progressive: 2000,
// // 渲染阈值,大于此值则启动渐进渲染
// progressiveThreshold: 5000,
// sampling: 'average',
// data: C
// }
// ],
// options: {
// animation: false,
// dataZoom: [{
// type: 'inside',
// height: 13,
// start: 0,
// bottom: '20px',
// end: 10
// },
// {
// start: 0,
// height: 13,
// bottom: '20px',
// end: 10
// }]
// }
// })
Highcharts.chart(`container${i}`, {
chart: {
zooming: {
type: 'x'
}
],
},
title: {
text: '123',
align: 'left'
},
subtitle: {
text: 'Using the Boost module',
align: 'left'
},
accessibility: {
screenReaderSection: {
beforeChartFormat: '<{headingTagName}>' +
'{chartTitle}</{headingTagName}><div>{chartSubtitle}</div>' +
'<div>{chartLongdesc}</div><div>{xAxisDescription}</div><div>' +
'{yAxisDescription}</div>'
}
},
tooltip: {
},
xAxis: {
// data: data.filter(item => item.phaseType == 'A').map(item => item.time),
name: '时间',
type: 'value',
axisLine: {
show: true,
onZero: false //-----------重点
},
// splitLine: {
// show: false,
// }
type: 'datetime'
},
yAxis: {
type: 'value',
name: name,
// splitLine: {
// show: false,
// }
// max: max,
// min: min
},
// legend: {
// data: ['A', 'B', 'C']
// // selectedMode: false,
// },
grid: {
top: '30px',
left: '30px'
},
color: ['#FFCC00', '#009900', '#CC0000'],
series: [
{
name: 'A相',
type: 'line',
smooth: true,
symbol: 'none',
// 开启渐进式渲染
progressive: 2000,
// 渲染阈值,大于此值则启动渐进渲染
progressiveThreshold: 5000,
sampling: 'average',
data: A
lineWidth: 0.5,
data: SA.value[i]
},
{
name: 'B相',
type: 'line',
smooth: true,
symbol: 'none',
// 开启渐进式渲染
progressive: 2000,
// 渲染阈值,大于此值则启动渐进渲染
progressiveThreshold: 5000,
sampling: 'average',
data: B
lineWidth: 0.5,
data: SB.value[i]
},
{
name: 'C相',
type: 'line',
smooth: true,
symbol: 'none',
// 开启渐进式渲染
progressive: 2000,
// 渲染阈值,大于此值则启动渐进渲染
progressiveThreshold: 5000,
sampling: 'average',
data: C
lineWidth: 0.5,
data: SC.value[i]
}
],
options: {
animation: false,
dataZoom: [{
type: 'inside',
height: 13,
start: 0,
bottom: '20px',
end: 10
},
{
start: 0,
height: 13,
bottom: '20px',
end: 10
}]
}
})
});
}, 0);
}
}
var init = () => {
Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Snow depth at Vikjafjellet, Norway'
},
subtitle: {
text: 'Irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
// don't display the year
month: '%e. %b',
year: '%b'
},
title: {
text: 'Date'
}
},
yAxis: {
title: {
text: 'Snow depth (m)'
},
min: 0
},
// tooltip: {
// headerFormat: '<b>{series.name}</b><br>',
// pointFormat: '{point.x:%e. %b}: {point.y:.2f} m'
// },
plotOptions: {
series: {
marker: {
symbol: 'circle',
fillColor: '#FFFFFF',
enabled: true,
radius: 2.5,
lineWidth: 1,
lineColor: null
}
}
},
colors: ['#6CF', '#39F', '#06C', '#036', '#000'],
series: [
]
});
}
onMounted(() => {
info()
// init();
})
onUnmounted(() => {
SA.value = []
SB.value = []
SC.value = []
})

View File

@@ -92,7 +92,7 @@ export const useAdminInfo = defineStore('adminInfo', {
this.refresh_token = ''
},
setToken(token: string, type: 'auth' | 'refresh') {
const field = type == 'auth' ? 'token' : 'refresh_token'
const field = type == 'auth' ? 'access_token' : 'refresh_token'
this[field] = token
},
getToken(type: 'auth' | 'refresh' = 'auth') {

View File

@@ -64,7 +64,6 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
if (
!(
config.url == '/system-boot/file/upload' ||
config.url == '/harmonic-boot/grid/getAssessOverview' ||
config.url == '/system-boot/file/getFileVO' ||
config.url == '/harmonic-boot/gridDiagram/getGridDiagramAreaData'
@@ -89,6 +88,9 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
config.headers.Authorization = 'Basic bmpjbnRlc3Q6bmpjbnBxcw=='
}
}
if (config.url == '/user-boot/user/generateSm2Key' || config.url == '/pqs-auth/oauth/token') {
config.headers.Authorization = 'Basic bmpjbnRlc3Q6bmpjbnBxcw=='
}
return config
},
@@ -120,12 +122,13 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
} else if (response.data.code == 'A0202') {
if (!window.tokenRefreshing) {
window.tokenRefreshing = true
return refreshToken()
.then(res => {
adminInfo.setToken(res.data.token, 'auth')
response.headers.Authorization = `${res.data.token}`
window.requests.forEach(cb => cb(res.data.token))
adminInfo.setToken(res.data.access_token, 'auth')
window.requests.forEach(cb => cb(res.data.access_token))
window.requests = []
return Axios(response.config)
})
.catch(err => {
@@ -147,10 +150,10 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
}
} else if (response.data.code == 'A0024') {
// // 登录失效
// ElNotification({
// type: 'error',
// message: response.data.message
// })
ElNotification({
type: 'error',
message: response.data.message
})
adminInfo.removeToken()
router.push({ name: 'login' })
return Promise.reject(response.data)