Commit 20f6def6 authored by zL's avatar zL

修改路由跳转导致的侧边导航栏不刷新的问题

parent 2ba2ee83
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div <div
class="menu-item menu-item_first" class="menu-item menu-item_first"
:class="{ 'js-menu-item_active': currentRoute === 0 }" :class="{ 'js-menu-item_active': currentRoute === 0 }"
@click="selectPage(0, 'categoryManage')" @click="selectPage(0, '/categoryManage')"
> >
<div class="menu-item_subject-icon"> <div class="menu-item_subject-icon">
<i class="iconfont">&#xe62b;</i> <i class="iconfont">&#xe62b;</i>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div <div
class="menu-item menu-item_template" class="menu-item menu-item_template"
:class="{ 'js-menu-item_active': currentRoute === 2 }" :class="{ 'js-menu-item_active': currentRoute === 2 }"
@click="selectPage(2, 'userCenter')" @click="selectPage(2, '/userCenter')"
> >
<div class="menu-item_template-icon"> <div class="menu-item_template-icon">
<i class="iconfont">&#xe62a;</i> <i class="iconfont">&#xe62a;</i>
...@@ -40,22 +40,25 @@ ...@@ -40,22 +40,25 @@
<script> <script>
let UrlPrefixObj = require("@/config/UrlPrefix"); let UrlPrefixObj = require("@/config/UrlPrefix");
export default { export default {
data() { computed: {
return { currentRoute() {
currentRoute: Number(sessionStorage.getItem("currentRoute")), return this.$store.getters.get_currentRoute;
}; },
}, },
mounted() {},
methods: { methods: {
// 路由切换
selectPage(idnex, path) { selectPage(idnex, path) {
if (idnex === 1) { this.$store
window.open(UrlPrefixObj.model.CHAIN_BROWSER_URL_PREFIX); .dispatch("selectPage", idnex)
} else { .then(() => {
if (this.currentRoute === idnex) return; if (idnex === 1) {
sessionStorage.setItem("currentRoute", idnex); window.open(UrlPrefixObj.model.CHAIN_BROWSER_URL_PREFIX);
this.currentRoute = idnex; } else {
this.$router.push({ path: path }); if (this.$route.path === path) return;
} this.$router.push({ path: path });
}
})
.catch(() => {});
}, },
}, },
}; };
......
...@@ -12,25 +12,29 @@ ...@@ -12,25 +12,29 @@
<button class="g-btn_primary btn_confirm" @click="$emit('confirm')"> <button class="g-btn_primary btn_confirm" @click="$emit('confirm')">
取消 取消
</button> </button>
<button class="g-btn_primary btn_cancel" @click="$emit('cancel')"> <button class="g-btn_primary btn_cancel" @click="cancel">去认证</button>
去认证
</button>
</div> </div>
</div> </div>
</common-dialog> </common-dialog>
</template> </template>
<script lang="ts"> <script>
import { Component, Prop, Vue } from "vue-property-decorator";
import CommonDialog from "@/components/CommonDialog.vue"; import CommonDialog from "@/components/CommonDialog.vue";
@Component({ export default {
components: { components: {
CommonDialog, CommonDialog,
}, },
}) methods: {
export default class Uncertified extends Vue { cancel() {
@Prop() tip!: string; this.$store
} .dispatch("selectPage", 2)
.then(() => {
this.$emit("cancel");
})
.catch(() => {});
},
},
};
</script> </script>
<style scoped> <style scoped>
...@@ -41,13 +45,13 @@ export default class Uncertified extends Vue { ...@@ -41,13 +45,13 @@ export default class Uncertified extends Vue {
} }
.g-btn_primary { .g-btn_primary {
border: none; border: none;
background: #5779F4; background: #5779f4;
font-size: 14px; font-size: 14px;
color: #fff; color: #fff;
outline: none; outline: none;
cursor: pointer; cursor: pointer;
border-radius: 8px; border-radius: 8px;
} }
.title { .title {
margin: 0; margin: 0;
......
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { GO_URLS } from "@/config/URLS";
import { Component, Vue, Watch } from "vue-property-decorator"; import { Component, Vue, Watch } from "vue-property-decorator";
// 模板管理部分 // 模板管理部分
import TemplateManage from "./TemplateManage.vue"; import TemplateManage from "./TemplateManage.vue";
......
import {StateTypes} from "./types"; import { StateTypes } from "./types";
import {ActionTree} from "vuex"; import { ActionTree } from "vuex";
const actions: ActionTree<StateTypes, any> = { const actions: ActionTree<StateTypes, any> = {
selectPage({ commit }, idnex) {
return new Promise<void>((resolve) => {
sessionStorage.setItem("currentRoute", idnex);
commit('setCurrentRoute', idnex)
resolve()
})
},
}; };
export default actions; export default actions;
...@@ -4,6 +4,7 @@ import { GetterTree } from "vuex"; ...@@ -4,6 +4,7 @@ import { GetterTree } from "vuex";
const getters: GetterTree<StateTypes, any> = { const getters: GetterTree<StateTypes, any> = {
get_templateType: state => state.templateType, get_templateType: state => state.templateType,
get_templateData: state => state.templateData, get_templateData: state => state.templateData,
get_currentRoute: state => state.currentRoute,
}; };
export default getters; export default getters;
...@@ -57,7 +57,9 @@ const mutations: MutationTree<StateTypes> = { ...@@ -57,7 +57,9 @@ const mutations: MutationTree<StateTypes> = {
setTemplateData(state, data) { setTemplateData(state, data) {
state.templateData = data state.templateData = data
}, },
// templateData setCurrentRoute: (state, currentRoute) => {
state.currentRoute = currentRoute
},
}; };
export default mutations; export default mutations;
...@@ -16,7 +16,8 @@ const state: StateTypes = { ...@@ -16,7 +16,8 @@ const state: StateTypes = {
theAnchor: -1, theAnchor: -1,
chainStatus: '', chainStatus: '',
templateType: 0, templateType: 0,
templateData: {} templateData: {},
currentRoute: Number(sessionStorage.getItem("currentRoute")) || 0
}; };
export default state; export default state;
...@@ -15,6 +15,7 @@ export interface StateTypes { ...@@ -15,6 +15,7 @@ export interface StateTypes {
theAnchor: number, //用于记录增量列表的展开 theAnchor: number, //用于记录增量列表的展开
chainStatus: string, chainStatus: string,
templateType: number, templateType: number,
templateData:any templateData: any,
currentRoute: number
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment