From b18350e2f06c55f6aaae957631238bf02bb07b63 Mon Sep 17 00:00:00 2001 From: 石广澎 <shiguangpeng@163.com> Date: 星期六, 02 十二月 2023 11:56:14 +0800 Subject: [PATCH] fix: 修复标签页 主页刷新后消失的问题 --- admin-web/src/layout/components/TagsView/index.vue | 42 +++++++++++++++++++++++++++++++----------- admin-web/src/views/dashboard/index.vue | 3 +-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/admin-web/src/layout/components/TagsView/index.vue b/admin-web/src/layout/components/TagsView/index.vue index 0354595..6ba6830 100644 --- a/admin-web/src/layout/components/TagsView/index.vue +++ b/admin-web/src/layout/components/TagsView/index.vue @@ -13,7 +13,7 @@ @contextmenu.prevent.native="openMenu(tag, $event)" > {{ tag.title }} - <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" /> + <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)"/> </router-link> </scroll-pane> <ul v-show="visible" :style="{ left: (openAside?left+170:left) + 'px', top: top + 'px' }" class="contextmenu"> @@ -39,13 +39,13 @@ import path from 'path'; export default { - props:{ - openAside:{ + props: { + openAside: { type: Boolean, default: false } }, - components: { ScrollPane }, + components: {ScrollPane}, data() { return { fullWidth: document.body.clientWidth, @@ -59,7 +59,19 @@ }, computed: { visitedViews() { - return this.$store.state.tagsView.visitedViews; + let visitedViews = this.$store.state.tagsView.visitedViews + if (visitedViews&&visitedViews[0]&&visitedViews[0].title !== '涓婚〉') { + visitedViews.unshift({ + title: '涓婚〉', + path: '/dashboard', + query: {}, + fullPath: '/dashboard', + meta:{ + affix: true + } + }) + } + return visitedViews; }, routes() { return this.$store.state.permission.routes; @@ -112,7 +124,7 @@ fullPath: tagPath, path: tagPath, name: route.name, - meta: { ...route.meta }, + meta: {...route.meta}, }); } if (route.children) { @@ -151,7 +163,7 @@ }); }, addTags() { - const { name } = this.$route; + const {name} = this.$route; if (name) { this.$store.dispatch('tagsView/addView', this.$route); } @@ -174,7 +186,7 @@ }, refreshSelectedTag(view) { this.$store.dispatch('tagsView/delCachedView', view).then(() => { - const { fullPath } = view; + const {fullPath} = view; this.$nextTick(() => { this.$router.replace({ path: '/redirect' + fullPath, @@ -183,7 +195,7 @@ }); }, closeSelectedTag(view) { - this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { + this.$store.dispatch('tagsView/delView', view).then(({visitedViews}) => { if (this.isActive(view)) { this.toLastView(visitedViews, view); } @@ -196,7 +208,7 @@ }); }, closeAllTags(view) { - this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => { + this.$store.dispatch('tagsView/delAllViews').then(({visitedViews}) => { if (this.affixTags.some((tag) => tag.path === view.path)) { return; } @@ -212,7 +224,7 @@ // you can adjust it according to your needs. if (view.name === 'Dashboard') { // to reload home page - this.$router.replace({ path: '/redirect' + view.fullPath }); + this.$router.replace({path: '/redirect' + view.fullPath}); } else { this.$router.push('/dashboard'); } @@ -261,12 +273,15 @@ font-size: 14px; margin-left: 10px; border-radius: 3px; + &:first-of-type { margin-left: 20px; } + &:last-of-type { margin-right: 20px; } + &.active { background-color: #fff; color: #333333; @@ -284,6 +299,7 @@ } } } + .contextmenu { margin: 0; background: #fff; @@ -296,10 +312,12 @@ font-weight: 400; color: #333; box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3); + li { margin: 0; padding: 7px 16px; cursor: pointer; + &:hover { background: #eee; } @@ -318,10 +336,12 @@ text-align: center; transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); transform-origin: 100% 50%; + &:before { transform: scale(0.6); display: inline-block; } + &:hover { background-color: #b4bccc; color: #fff; diff --git a/admin-web/src/views/dashboard/index.vue b/admin-web/src/views/dashboard/index.vue index 25a5676..eb6551d 100644 --- a/admin-web/src/views/dashboard/index.vue +++ b/admin-web/src/views/dashboard/index.vue @@ -34,7 +34,7 @@ </el-table-column> <el-table-column prop="date" label="鎿嶄綔" fixed="right" align="center" width="80"> <template slot-scope="scope"> - <el-button style="padding: 4.5px 15px" @click.native.prevent="aduitThis(scope.row)" size="mini" type="primary">澶勭悊</el-button> + <el-button style="padding: 4px 15px" @click.native.prevent="aduitThis(scope.row)" size="mini" type="primary">澶勭悊</el-button> </template> </el-table-column> <el-empty slot="empty" description="鏆傛棤鏁版嵁"></el-empty> @@ -182,7 +182,6 @@ }; }, created() { - console.log(this.userInfo) this.getAuditList() this.getWarningList() getGoodsNumPrice().then(res => { -- Gitblit v1.9.1