Commit aac45bf6 authored by guxukai's avatar guxukai

chore: 登录代理

parent 9e9aa79e
...@@ -22,6 +22,7 @@ const routes = [ ...@@ -22,6 +22,7 @@ const routes = [
path: '/', path: '/',
name: 'default', name: 'default',
component: () => import('@shared/layouts/default-layout.vue'), component: () => import('@shared/layouts/default-layout.vue'),
props: { enableRouteFilter: false },
children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES], children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES],
}, },
...FIXED_ROUTES, ...FIXED_ROUTES,
......
...@@ -94,7 +94,7 @@ const handleSubmitForm = async () => { ...@@ -94,7 +94,7 @@ const handleSubmitForm = async () => {
authStore.$patch({ authStore.$patch({
loginInfo: res.data, loginInfo: res.data,
}) })
$router.push({ name: 'home' }) $router.push({ name: 'proxy' })
} else { } else {
MessageUtils.warning(res?.message) MessageUtils.warning(res?.message)
} }
......
...@@ -33,11 +33,11 @@ const { ...@@ -33,11 +33,11 @@ const {
consoleTypeId: '1', consoleTypeId: '1',
}, },
}) })
window.location.replace(`${origin}/super/proxy`) window.location.replace(`${origin}/super`)
return return
} }
//其余跳转 //其余跳转
window.location.replace(`${origin}/account/proxy`) window.location.replace(`${origin}/account`)
} }
return res return res
}), }),
......
import { useRoute, useRouter } from 'vue-router'
//重定向至刷新页面或者首页
export const useRedirect = () => {
const $router = useRouter()
const $route = useRoute()
const redirect = () => {
if ($route.query.path) {
$router.replace($route.query.path as string)
} else {
$router.replace({ name: 'home' })
}
}
return { redirect }
}
import { useRoute, useRouter } from 'vue-router'
// 刷新页面跳转到proxy页面
export const useRefresh = () => {
const $router = useRouter()
const $route = useRoute()
const key = 'refresh'
window.onbeforeunload = () => {
sessionStorage.setItem(key, '1')
}
if (sessionStorage.getItem(key)) {
$router.replace({
name: 'proxy',
query: {
path: $route.fullPath,
},
})
sessionStorage.removeItem(key)
}
}
...@@ -51,6 +51,7 @@ const { ...@@ -51,6 +51,7 @@ const {
$router.removeRoute(_.name as string) $router.removeRoute(_.name as string)
} }
}) })
const restRoutes = $router.getRoutes() const restRoutes = $router.getRoutes()
$router.options.routes = filterAsyncRoutes($router.options.routes, restRoutes) $router.options.routes = filterAsyncRoutes($router.options.routes, restRoutes)
} }
......
<template> <template>
<el-container class="h-screen"> <el-container class="h-screen">
{{ enableRouterFilter }}
<el-aside <el-aside
:width="isCollapse ? '96px' : '260px'" :width="isCollapse ? '96px' : '260px'"
class=" class="
......
<!--权限代理页面-->
<template>
<g-query-wrapper :data="menuData" :loading="menuLoading" :error="menuError" :run="menuRun" />
</template>
<script lang="ts" setup>
import { useRoute, useRouter } from 'vue-router'
import { useRequest } from 'vue-request'
import { AuthMenuInfo } from '@shared/models/auth-service/AuthMenuInfo'
import { useUser } from '@shared/store/modules/user'
import { useAuth } from '@shared/store/modules/auth'
import { GATEWAY_CODE } from '@shared/http/constants'
import { filterAsyncRoutes, hasPermission } from '@shared/utils/route-utils'
import { useRedirect } from '@shared/hooks/useRedirect'
const $router = useRouter()
const $route = useRoute()
const userStore = useUser()
const authStore = useAuth()
const { redirect } = useRedirect()
const {
data: menuData,
loading: menuLoading,
error: menuError,
run: menuRun,
} = useRequest(() =>
AuthMenuInfo.get({
objectId: authStore.consoleInfo.consoleObjectId,
userId: userStore.userInfo.id,
}).then(res => {
if (res.code === GATEWAY_CODE.success) {
const menuList = res.data
$router.getRoutes().forEach(_ => {
if (!hasPermission(_, menuList)) {
$router.removeRoute(_.name as string)
}
})
const restRoutes = $router.getRoutes()
$router.options.routes = filterAsyncRoutes($router.options.routes, restRoutes)
redirect()
}
return res
}),
)
</script>
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