Browse Source

本地存储"最近访问"状态

wangqin
hui 8 months ago
parent
commit
8f2512d941
  1. 25
      ruoyi-ui/src/store/modules/menu.js
  2. 3
      ruoyi-ui/src/views/JiHeExpressway/components/RecentPages/index.vue
  3. 10
      ruoyi-ui/src/views/JiHeExpressway/index.vue
  4. 1
      ruoyi-ui/src/views/JiHeExpressway/pages/perception/eventDetection/components/typeAnalysis/assets/charts.js

25
ruoyi-ui/src/store/modules/menu.js

@ -1,12 +1,17 @@
const state = {
recentPages: [],
isRecentOpen:false,
isRecentOpen:"",
}
const mutations = {
saveRecent(state){
localStorage.setItem("recentPages", JSON.stringify(state.recentPages));
},
addRecent(state, item) {
if(state.recentPages.length == 0 ){
state.recentPages = JSON.parse(localStorage.getItem("recentPages") || "[]");
}
let temp;
state.recentPages.forEach((unit,index)=>{
if(unit.path == item.path){
@ -21,22 +26,38 @@ const state = {
state.recentPages.push(item);
}
mutations.saveRecent(state);
},
openRecent(state){
state.isRecentOpen = true;
localStorage.setItem("isRecentOpen", true);
},
closeRecent(state){
state.isRecentOpen = false;
localStorage.setItem("isRecentOpen", false);
},
removeRecent(state, item) {
let i = state.recentPages.findIndex(unit => unit.path == item.path);
state.recentPages.splice(i, 1);
mutations.saveRecent(state);
}
}
const getters = {
isRecentOpen(state){
if (state.isRecentOpen === ""){
state.isRecentOpen = localStorage.getItem("isRecentOpen") || false;
}
console.log(state.isRecentOpen);
return state.isRecentOpen;
}
}
export default {
namespaced: true,
state,
getters,
mutations,
}

3
ruoyi-ui/src/views/JiHeExpressway/components/RecentPages/index.vue

@ -173,11 +173,8 @@ export default{
calcLastIndex(){
try{
this.widthArr.forEach((item, index) => {
console.log(this.widthArr , "this.widthArrthis.widthArr");
console.log(index, item, this.widthBox - this.posiLeft , item > (this.widthBox - this.posiLeft));
if (item > (this.widthBox - this.posiLeft)) { //posiLeft
this.lastIndex = index;
console.log(this.lastIndex , "lastIndexlastIndexlastIndexlastIndexlastIndexlastIndex")
// console.log(this.lastIndex , "this.lastIndex lastIndex lastIndex lastIndex")
throw new Error('找到lastIndex,退出循环')
}

10
ruoyi-ui/src/views/JiHeExpressway/index.vue

@ -14,7 +14,7 @@
import HeaderMenu from "./components/HeaderMenu/index.vue";
import Adaptation from "./components/Adaptation.vue";
import getBoardBaseData from '@/common/getBoardBaseData'
import { mapState } from "vuex";
import { mapGetters } from "vuex";
export default {
name: "ji_ze_gao_su",
components: {
@ -37,9 +37,9 @@ export default {
isRecentOpen:{
handler(newV){
if(newV){
this.header.originH = 100;
}else{
this.header.originH = 68;
this.header.originH = 100;
}else{
this.header.originH = 68;
}
this.calcHeaderScale();
},
@ -47,7 +47,7 @@ export default {
}
},
computed:{
...mapState("menu",["isRecentOpen"]),
...mapGetters("menu",["isRecentOpen"]),
headerStyle(){
return {
width : `${this.header.originW}px`,

1
ruoyi-ui/src/views/JiHeExpressway/pages/perception/eventDetection/components/typeAnalysis/assets/charts.js

@ -57,7 +57,6 @@ var options = {
},
formatter: (params) => {
let count = 0;
console.log("typeAnalysisData", typeAnalysisData);
typeAnalysisData.forEach((it) => {
count += it.value;
});

Loading…
Cancel
Save