diff --git a/src/components/table/DisasterTable.vue b/src/components/table/DisasterTable.vue index 2af37ad..7e2c667 100644 --- a/src/components/table/DisasterTable.vue +++ b/src/components/table/DisasterTable.vue @@ -86,7 +86,6 @@ const getDictBizData = () => { const getDisasterTable = () => { convert(); let userData = Session.get('userInfo'); - console.log(userData,"userDatauserData"); state.search.chiefIdEquals = userData.id; state.search.roleName = userData.roles[0]; getPage(state.disasterData.param.pageNum, state.disasterData.param.pageSize, state.search).then(res => { diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index 2982b2e..47f65c0 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -235,7 +235,7 @@ onMounted(() => { if ((now - dateTime) / 1000 > website.value.tokenTime) { // 刷新token refreshToken(rt, website.value.tenantId).then(res => { - Session.set('token', res.access_token); + Session.setEx('token', res.access_token); Session.set('token-time', new Date().getTime()); Session.set('refresh-token', res.refresh_token); }) diff --git a/src/router/backEnd.js b/src/router/backEnd.js index a4b2ab7..5f0b1e8 100644 --- a/src/router/backEnd.js +++ b/src/router/backEnd.js @@ -36,7 +36,7 @@ export async function initBackEndControlRoutes() { // 界面 loading 动画开始执行 if (window.nextLoading === undefined) NextLoading.start(); // 无 token 停止执行下一步 - if (!Session.get('token')) return false; + if (!Session.getEx('token')) return false; // 触发初始化用户信息 pinia // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP await useUserInfo().setUserInfos(); diff --git a/src/router/frontEnd.js b/src/router/frontEnd.js index 098898f..e861649 100644 --- a/src/router/frontEnd.js +++ b/src/router/frontEnd.js @@ -21,7 +21,7 @@ export async function initFrontEndControlRoutes() { // 界面 loading 动画开始执行 if (window.nextLoading === undefined) NextLoading.start(); // 无 token 停止执行下一步 - if (!Session.get('token')) return false; + if (!Session.getEx('token')) return false; // 触发初始化用户信息 pinia // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP await useUserInfo(pinia).setUserInfos(); diff --git a/src/router/index.js b/src/router/index.js index f8c0696..64813a5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -94,7 +94,7 @@ export function formatTwoStageRoutes(arr) { router.beforeEach(async (to, from, next) => { NProgress.configure({ showSpinner: false }); if (to.meta.title) NProgress.start(); - const token = Session.get('token'); + const token = Session.getEx('token'); if (to.path === '/login' && !token) { next(); NProgress.done(); diff --git a/src/utils/request.js b/src/utils/request.js index ec0f205..46a61b6 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -22,8 +22,8 @@ service.interceptors.request.use( (config) => { config.headers['Authorization'] = 'Basic Vm9SRE1BZG1pbjp2b3JkbV9hZG1pbl9zZWNyZXQ='; // 在发送请求之前做些什么 token - if (Session.get('token')) { - config.headers['Blade-Auth'] = `Bearer ${Session.get('token')}`; + if (Session.getEx('token')) { + config.headers['Blade-Auth'] = `Bearer ${Session.getEx('token')}`; } return config; }, diff --git a/src/utils/storage.js b/src/utils/storage.js index bcba5dc..a4ac8bb 100644 --- a/src/utils/storage.js +++ b/src/utils/storage.js @@ -42,18 +42,38 @@ export const Local = { export const Session = { // 设置临时缓存 set(key, val) { - if (key === 'token') return Cookies.set(key, val); + // if (key === 'token') return Cookies.set(key, val); window.sessionStorage.setItem(Local.setKey(key), JSON.stringify(val)); }, // 获取临时缓存 get(key) { - if (key === 'token') return Cookies.get(key); + // if (key === 'token') return Cookies.get(key); let json = window.sessionStorage.getItem(Local.setKey(key)); return JSON.parse(json); + }, + // 设置临时缓存 + setEx(key,val) { + let curTime = new Date().getTime(); + window.sessionStorage.setItem(Local.setKey(key), JSON.stringify({data:val,time:curTime})); + }, + //如果缓存过期则返回null + getEx(key,time = 6*60*1000) { + let data = window.sessionStorage.getItem(Local.setKey(key)); + let dataObj = JSON.parse(data); + //如果dataObj为null,表示该数据从未设置过期时间 + if (dataObj == null) { + return null; + } + if (new Date().getTime() - dataObj.time > time) { + window.sessionStorage.removeItem(Local.setKey(key)); + return null; + } else { + return dataObj.data; + } }, // 移除临时缓存 remove(key) { - if (key === 'token') return Cookies.remove(key); + // if (key === 'token') return Cookies.remove(key); window.sessionStorage.removeItem(Local.setKey(key)); }, // 移除全部临时缓存 diff --git a/src/views/dataService/remoteSensingData/components/searchCondition.vue b/src/views/dataService/remoteSensingData/components/searchCondition.vue index b81abb0..a1e2c7f 100644 --- a/src/views/dataService/remoteSensingData/components/searchCondition.vue +++ b/src/views/dataService/remoteSensingData/components/searchCondition.vue @@ -35,7 +35,12 @@ - Select a region + Select a region
@@ -125,6 +130,7 @@ const disabledDate = (time) => { // 初始化数据 const map = ref() const state = reactive({ + switch:true, startTime: '', endTime: '', addCoord: false, @@ -264,19 +270,32 @@ const changeLatLon = (e) => { // 添加坐标点 const addCoordinate = () => { state.addCoord = !state.addCoord; - if (state.addCoord && state.coordinateList.length <= 2) { - map.value.mapOperations.drawRectangle() - map.value.mapOperations.on("click", onMapClick) - document.getElementsByClassName('coordinateBtn')[0].innerText = 'Stop'; - } - else { - map.value.mapOperations.off("click", onMapClick) - document.getElementsByClassName('coordinateBtn')[0].innerText = 'Add coordinates'; + if(state.switch){ + if (state.addCoord && state.coordinateList.length <= 2) { + map.value.mapOperations.drawRectangle() + map.value.mapOperations.on("click", onMapClick) + document.getElementsByClassName('coordinateBtn')[0].innerText = 'Stop'; + } + else { + map.value.mapOperations.off("click", onMapClick) + document.getElementsByClassName('coordinateBtn')[0].innerText = 'Add coordinates'; + } + }else{ + map.value.mapOperations.off("click", onMapClick) + map.value.mapOperations.drawPolygon() + map.value.mapOperations.drawCreated() } } +const mapClick = (res) => { + map.value.mapOperations.addInteractMarker(res.latlng.lat.toFixed(3), res.latlng.lng.toFixed(3)) +} // 清空坐标点 const clearCoordinate = () => { + if(!state.switch){ + map.value.mapOperations.clearPolygon() + return; + } state.coordinateList = []; state.startTime = ''; state.endTime = ''; diff --git a/src/views/dataService/visualData/component/hotspotForm.vue b/src/views/dataService/visualData/component/hotspotForm.vue index 552aba1..2d6889f 100644 --- a/src/views/dataService/visualData/component/hotspotForm.vue +++ b/src/views/dataService/visualData/component/hotspotForm.vue @@ -8,7 +8,7 @@ - +