【更新】前端登录跳转至退出前的界面调整

pull/109/MERGE
小诺 2023-04-22 13:24:15 +08:00 committed by 俞宝山
parent 6afe3835b1
commit ac84f7376a
3 changed files with 20 additions and 6 deletions

View File

@ -25,7 +25,7 @@ const routes = {
children: []
}
],
// 默认首页、用户中心
// 默认首页、个人中心
menu: [
{
id: '001',
@ -42,11 +42,11 @@ const routes = {
},
{
id: '002',
name: 'usercenter',
path: '/usercenter12',
component: 'userCenter/index',
name: 'userCenter',
path: '/userCenter',
component: 'sys/user/userCenter',
meta: {
title: '用户中心',
title: '个人中心',
type: 'menu',
hidden: true
},

View File

@ -25,6 +25,20 @@ export const afterLogin = async (loginToken) => {
// 如果有缓存,将其登录跳转到最后访问的路由
indexMenu = tool.data.get('LAST_VIEWS_PATH')
}
// 如果存在退出后换新账号登录,进行重新匹配,匹配无果则默认首页
if (menu) {
let routerTag = 0
menu.forEach((item) => {
if (item.children) {
if (JSON.stringify(item.children).indexOf(indexMenu) > -1) {
routerTag++
}
}
})
if (routerTag === 0) {
indexMenu = menu[0].children[0].path
}
}
await router.replace({
path: indexMenu
})

View File

@ -62,7 +62,7 @@
<CropUpload ref="cropUpload" :img-src="userInfo.avatar" @successful="cropUploadSuccess" />
</template>
<script setup>
<script setup name="userCenter">
import { onMounted } from 'vue'
import { useRoute } from 'vue-router'
import tool from '@/utils/tool'