mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 09:43:17 +08:00
feat: 应用配置增加 home.fullPath
框架中所有跳转到主页的操作均改成取该配置设置的路由地址
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
|
||||
defineOptions({
|
||||
name: 'NotAllowed',
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
const data = ref({
|
||||
inter: Number.NaN,
|
||||
countdown: 5,
|
||||
@@ -25,7 +29,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
function goBack() {
|
||||
router.push('/')
|
||||
router.push(settingsStore.settings.home.fullPath)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -22,11 +22,7 @@ const settingsStore = useSettingsStore()
|
||||
const title = ref(import.meta.env.VITE_APP_TITLE)
|
||||
const logo = ref(imgLogo)
|
||||
|
||||
const to = computed(() => {
|
||||
return {
|
||||
...(settingsStore.settings.home.enable && { name: 'home' }),
|
||||
}
|
||||
})
|
||||
const to = computed(() => settingsStore.settings.home.enable ? settingsStore.settings.home.fullPath : '')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -76,7 +76,8 @@ watch(() => userStore.avatar, () => {
|
||||
<HDropdownMenu
|
||||
:items="[
|
||||
[
|
||||
{ label: settingsStore.settings.home.title, handle: () => router.push({ name: 'home' }), hide: !settingsStore.settings.home.enable },
|
||||
{ label: settingsStore.settings.home.title, handle: () => router.push({ path: settingsStore.settings.home.fullPath }), hide: !settingsStore.settings.home.enable },
|
||||
{ label: '个人设置', handle: () => router.push({ name: 'personalSetting' }) },
|
||||
],
|
||||
[
|
||||
{ label: '快捷键介绍', handle: () => eventBus.emit('global-hotkeys-intro-toggle'), hide: settingsStore.mode !== 'pc' },
|
||||
|
||||
@@ -21,7 +21,7 @@ const breadcrumbList = computed(() => {
|
||||
const breadcrumbList = []
|
||||
if (settingsStore.settings.home.enable) {
|
||||
breadcrumbList.push({
|
||||
path: '/',
|
||||
path: settingsStore.settings.home.fullPath,
|
||||
title: settingsStore.settings.home.title,
|
||||
})
|
||||
}
|
||||
|
||||
+3
-3
@@ -34,12 +34,12 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 如果已登录状态下,进入登录页会强制跳转到主页
|
||||
if (to.name === 'login') {
|
||||
next({
|
||||
name: 'home',
|
||||
path: settingsStore.settings.home.fullPath,
|
||||
replace: true,
|
||||
})
|
||||
}
|
||||
// 如果未开启主页,但进入的是主页,则会进入侧边栏导航第一个模块
|
||||
else if (!settingsStore.settings.home.enable && to.name === 'home') {
|
||||
else if (!settingsStore.settings.home.enable && to.fullPath === settingsStore.settings.home.fullPath) {
|
||||
if (menuStore.sidebarMenus.length > 0) {
|
||||
next({
|
||||
path: menuStore.sidebarMenusFirstDeepestPath,
|
||||
@@ -105,7 +105,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
next({
|
||||
name: 'login',
|
||||
query: {
|
||||
redirect: to.fullPath !== '/' ? to.fullPath : undefined,
|
||||
redirect: to.fullPath !== settingsStore.settings.home.fullPath ? to.fullPath : undefined,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ const systemRoutes: RouteRecordRaw[] = [
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'home',
|
||||
component: () => import('@/views/index.vue'),
|
||||
meta: {
|
||||
title: () => useSettingsStore().settings.home.title,
|
||||
|
||||
@@ -14,6 +14,7 @@ const globalSettingsDefault: RecursiveRequired<Settings.all> = {
|
||||
home: {
|
||||
enable: true,
|
||||
title: '主页',
|
||||
fullPath: '/',
|
||||
},
|
||||
layout: {
|
||||
enableMobileAdaptation: false,
|
||||
|
||||
@@ -64,7 +64,7 @@ const useMenuStore = defineStore(
|
||||
const sidebarMenusFirstDeepestPath = computed(() => {
|
||||
return sidebarMenus.value.length > 0
|
||||
? getDeepestPath(sidebarMenus.value[0])
|
||||
: '/'
|
||||
: settingsStore.settings.home.fullPath
|
||||
})
|
||||
function getDeepestPath(menu: Menu.recordRaw, rootPath = '') {
|
||||
let retnPath = ''
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import useSettingsStore from './settings'
|
||||
import useRouteStore from './route'
|
||||
import useMenuStore from './menu'
|
||||
import router from '@/router'
|
||||
@@ -7,6 +8,7 @@ const useUserStore = defineStore(
|
||||
// 唯一ID
|
||||
'user',
|
||||
() => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const routeStore = useRouteStore()
|
||||
const menuStore = useMenuStore()
|
||||
|
||||
@@ -56,7 +58,7 @@ const useUserStore = defineStore(
|
||||
router.push({
|
||||
name: 'login',
|
||||
query: {
|
||||
...(router.currentRoute.value.path !== '/' && router.currentRoute.value.name !== 'login' && { redirect }),
|
||||
...(router.currentRoute.value.path !== settingsStore.settings.home.fullPath && router.currentRoute.value.name !== 'login' && { redirect }),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -55,6 +55,11 @@ declare namespace Settings {
|
||||
* @默认值 `'主页'`
|
||||
*/
|
||||
title?: string
|
||||
/**
|
||||
* 主页完整路径
|
||||
* @默认值 `'/'`
|
||||
*/
|
||||
fullPath?: string
|
||||
}
|
||||
interface layout {
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,12 @@ meta:
|
||||
</route>
|
||||
|
||||
<script setup lang="ts">
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
const data = ref({
|
||||
inter: Number.NaN,
|
||||
countdown: 5,
|
||||
@@ -29,7 +33,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
function goBack() {
|
||||
router.push('/')
|
||||
router.push(settingsStore.settings.home.fullPath)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@ meta:
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import Copyright from '@/layouts/components/Copyright/index.vue'
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
defineOptions({
|
||||
@@ -18,6 +19,7 @@ defineOptions({
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const banner = new URL('../assets/images/login-banner.png', import.meta.url).href
|
||||
@@ -27,7 +29,7 @@ const title = import.meta.env.VITE_APP_TITLE
|
||||
// 表单类型,login 登录,register 注册,reset 重置密码
|
||||
const formType = ref('login')
|
||||
const loading = ref(false)
|
||||
const redirect = ref(route.query.redirect?.toString() ?? '/')
|
||||
const redirect = ref(route.query.redirect?.toString() ?? settingsStore.settings.home.fullPath)
|
||||
|
||||
// 登录
|
||||
const loginFormRef = ref<FormInstance>()
|
||||
|
||||
Reference in New Issue
Block a user