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

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

@ -173,11 +173,8 @@ export default{
calcLastIndex(){ calcLastIndex(){
try{ try{
this.widthArr.forEach((item, index) => { 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 if (item > (this.widthBox - this.posiLeft)) { //posiLeft
this.lastIndex = index; this.lastIndex = index;
console.log(this.lastIndex , "lastIndexlastIndexlastIndexlastIndexlastIndexlastIndex")
// console.log(this.lastIndex , "this.lastIndex lastIndex lastIndex lastIndex") // console.log(this.lastIndex , "this.lastIndex lastIndex lastIndex lastIndex")
throw new Error('找到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 HeaderMenu from "./components/HeaderMenu/index.vue";
import Adaptation from "./components/Adaptation.vue"; import Adaptation from "./components/Adaptation.vue";
import getBoardBaseData from '@/common/getBoardBaseData' import getBoardBaseData from '@/common/getBoardBaseData'
import { mapState } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
name: "ji_ze_gao_su", name: "ji_ze_gao_su",
components: { components: {
@ -37,9 +37,9 @@ export default {
isRecentOpen:{ isRecentOpen:{
handler(newV){ handler(newV){
if(newV){ if(newV){
this.header.originH = 100; this.header.originH = 100;
}else{ }else{
this.header.originH = 68; this.header.originH = 68;
} }
this.calcHeaderScale(); this.calcHeaderScale();
}, },
@ -47,7 +47,7 @@ export default {
} }
}, },
computed:{ computed:{
...mapState("menu",["isRecentOpen"]), ...mapGetters("menu",["isRecentOpen"]),
headerStyle(){ headerStyle(){
return { return {
width : `${this.header.originW}px`, 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) => { formatter: (params) => {
let count = 0; let count = 0;
console.log("typeAnalysisData", typeAnalysisData);
typeAnalysisData.forEach((it) => { typeAnalysisData.forEach((it) => {
count += it.value; count += it.value;
}); });

Loading…
Cancel
Save