diff --git a/mining-pool/src/components/content.vue b/mining-pool/src/components/content.vue index a68887f..df6aee8 100644 --- a/mining-pool/src/components/content.vue +++ b/mining-pool/src/components/content.vue @@ -296,13 +296,12 @@ export default { let url = `/${lang}/AccessMiningPool` // 使用 name 进行导航,避免重复的路由参数 this.$router.push({ - path:url, - query: { - lang: lang, + name:'AccessMiningPool', + params: { coin: this.activeItemCoin.value, imgUrl: this.activeItemCoin.imgUrl - }, + replace: false // 保留历史记录,允许回退 }); diff --git a/mining-pool/src/main.js b/mining-pool/src/main.js index dac86ca..88d1bd0 100644 --- a/mining-pool/src/main.js +++ b/mining-pool/src/main.js @@ -28,7 +28,7 @@ Vue.use(ElementUI, { }); Vue.prototype.$axios = axios -// console.log = ()=>{} //全局关闭打印 +console.log = ()=>{} //全局关闭打印 // 全局注册混入 Vue.mixin(loadingStateMixin);//loading状态管理 Vue.mixin(networkRecoveryMixin);//网络恢复后数据刷新 diff --git a/mining-pool/src/views/AccessMiningPool/index.js b/mining-pool/src/views/AccessMiningPool/index.js index 0c60bc3..db760fc 100644 --- a/mining-pool/src/views/AccessMiningPool/index.js +++ b/mining-pool/src/views/AccessMiningPool/index.js @@ -283,8 +283,8 @@ export default { this.currentRoutePath =to.path.split(`/`)[3] - this.activeItem = this.currencyList.find(item => { return item.path == this.currentRoutePath }) - this.$addStorageEvent(1, `activeItem`, JSON.stringify( this.activeItem)) + // this.activeItem = this.currencyList.find(item => { return item.path == this.currentRoutePath }) + // this.$addStorageEvent(1, `activeItem`, JSON.stringify( this.activeItem)) @@ -293,94 +293,21 @@ export default { }, mounted() { - - // if (this.$route.name =="AccessMiningPool" ) { - // this.$router.go(-1); - // } - this.fetchAllList(this.listParams) - - console.log(this.$route, "this.$route.query.coin"); - - if (this.$route.query.coin) { - this.activeCoin = this.$route.query.coin - // this.currencyPath = this.$route.query.imgUrl - this.imgUrl = this.$route.query.imgUrl - this.currencyPath = this.$route.query.imgUrl - this.params.coin = this.$route.query.coin - this.$addStorageEvent(1, `activeCoin`, JSON.stringify(this.activeCoin)) - this.activeItem = this.currencyList.find(item => { return item.value == this.params.coin }) - const item = this.navList.find(item => { return item.coin == this.params.coin }) - console.log(item, "item65656565",this.navList,this.$route.query.coin); - - if (item && item.coin) { - this.clickJump(item) - // const mockEvent = { - // stopPropagation: () => {}, - // currentTarget: document.getElementById('menu1') - // }; - // this.changeMenuName(mockEvent, item) - } + // 优先级:路由参数 > localStorage > 默认 + let coinFromRoute = this.$route.params && this.$route.params.coin; + let localActiveCoin = localStorage.getItem('activeCoin') ? JSON.parse(localStorage.getItem('activeCoin')) : null; + let targetCoin = coinFromRoute || localActiveCoin || (this.currencyList[0] && this.currencyList[0].value); + this.activeCoin = targetCoin; + this.activeItem = this.currencyList.find(item => item.value === targetCoin) || this.currencyList[0]; + this.params.coin = targetCoin; + // 如果是路由参数,记忆到localStorage + if (coinFromRoute) { + localStorage.setItem('activeCoin', JSON.stringify(coinFromRoute)); } - - - - let activeCoin = localStorage.getItem("activeCoin") - this.activeCoin = JSON.parse(activeCoin) - let currencyList = localStorage.getItem("currencyList") - this.currencyList = JSON.parse(currencyList) - window.addEventListener("setItem", () => { - let activeCoin = localStorage.getItem("activeCoin") - this.activeCoin = JSON.parse(activeCoin) - let currencyList = localStorage.getItem("currencyList") - this.currencyList = JSON.parse(currencyList) - }); - - - - if (!this.activeCoin) { - this.activeCoin = "nexa" - this.imgUrl = `${this.$baseApi}/img/nexa.png` - this.currencyPath = `${this.$baseApi}/img/nexa.png` - this.params.coin = "nexa" - this.$addStorageEvent(1, `activeCoin`, JSON.stringify(this.activeCoin)) - this.openAPI = true - } else { - - // this.openAPI =true - try { - this.pageTitle = this.currencyList.find(item => item.value == this.activeCoin).name - this.imgUrl = this.currencyList.find(item => item.value == this.activeCoin).imgUrl - } catch (error) { - console.log(error); - - } - - } - // 从本地存储获取activeItem - // const savedActiveItem = localStorage.getItem('activeItem'); - // if (savedActiveItem) { - // try { - // this.activeItem = JSON.parse(savedActiveItem); - // } catch (error) { - // console.error('Parse activeItem failed:', error); - // // 使用默认值 - // this.activeItem = this.currencyList[0]; - // } - // } else { - // // 没有存储值时使用默认值 - // this.activeItem = this.currencyList[0]; - // } - - - - - - - - + this.fetchAllList(this.listParams); }, methods: { async fetchAllList(params){ @@ -444,7 +371,8 @@ export default { }, changeMenuName(e, item) { - + console.log(`走移动端了?`); + if (!e) return; if (!item.path) return; // 添加路径检查 @@ -481,6 +409,7 @@ export default { this.DetailsParams.id = item.id this.DetailsParams.coin = item.coin this.activeCoin = item.coin + localStorage.setItem('activeCoin', JSON.stringify(this.activeCoin)) this.fetchProblemDetails(this.DetailsParams) // if (!item.path) return; // 添加路径检查 // this.activeCoin = item.value diff --git a/mining-pool/src/views/AccessMiningPool/index.vue b/mining-pool/src/views/AccessMiningPool/index.vue index fe2ffb8..41aab38 100644 --- a/mining-pool/src/views/AccessMiningPool/index.vue +++ b/mining-pool/src/views/AccessMiningPool/index.vue @@ -50,10 +50,10 @@