feature: add vue3

This commit is contained in:
laker
2025-04-29 22:27:52 +08:00
parent 50e3d840f4
commit d715a94da1
3 changed files with 26 additions and 26 deletions

View File

@@ -4,19 +4,6 @@
</template>
<script setup>
import {onMounted} from 'vue';
import {useRouter} from 'vue-router';
const router = useRouter();
// 在组件挂载时检查登录状态
onMounted(() => {
// 获取本地存储中的登录状态
const isLoggedIn = localStorage.getItem('isLoggedIn');
// 如果没有登录状态,则跳转到登录页面
if (!isLoggedIn) {
router.push('/login');
}
});
</script>
<style scoped>

View File

@@ -181,7 +181,7 @@ import {ElMessageBox} from "element-plus";
const route = useRoute();
// 获取路由信息,过滤出需要的路由供应菜单使用
const routes = router.getRoutes().filter(route => {
return route.meta && route.meta.title && route.meta.icon && route.meta.showInMenu;
return route.meta && route.meta.showInMenu;
});
const icons = {
House,
@@ -427,4 +427,12 @@ const handleLogout = () => {
.footer-content {
font-size: 12px; /* 设置字体大小为12px */
}
/* 外层容器禁止滚动 */
.layout-container,
.el-container {
height: 100vh;
overflow: hidden; /* 禁止整体滚动 */
}
</style>

View File

@@ -7,26 +7,31 @@ import {ElMessage} from "element-plus";
const routes = [
{
path: '/', // 根路径对应的路由配置
redirect: '/workspace', // 显式重定向到 /workspace
redirect: '/workspace/home', // 显式重定向到 /workspace/home
component: Layout, // 该路由对应的组件为 Layout通常 Layout 组件作为应用的整体布局,包含侧边栏、导航栏等
// 子路由配置数组,这些子路由会在 Layout 组件的 <router-view> 中渲染
children: [
{
// 子路由的路径为空字符串,表示当访问根路径时默认显示该子路由对应的组件
path: 'workspace',
path: 'workspace', // 实际上是 /
// 该子路由的名称为 'Home',可用于路由导航时通过名称跳转
name: 'Home',
name: 'Workspace',
// meta中的属性是自己扩展的用于存储路由的元信息showInMenu 用于控制是否在菜单中显示该路由仅一级菜单需要配置
meta: {title: '工作空间', icon: 'House', showInMenu: true},
// 使用懒加载的方式引入 Home 组件,只有在访问该路由时才会加载对应的组件,提高应用性能
// '@' 是项目中配置的别名,通常指向 src 目录
component: () => import('@/views/Home.vue'),
children: [
{
path: 'users', // 实际上是 /system/users
name: 'Users',
meta: {title: '用户管理', icon: 'User'},
component: Users
path: 'home', // 实际上是 /home
name: 'Home',
meta: {title: 'DashBoard', icon: 'House'},
// 使用懒加载的方式引入 Home 组件,只有在访问该路由时才会加载对应的组件,提高应用性能
// '@' 是项目中配置的别名,通常指向 src 目录
component: () => import('@/views/Home.vue'),
},
{
path: '404', // 实际上是 /system/users
name: 'Home404',
meta: {title: '404页面', icon: 'User'},
component: () => import('@/views/NotFound.vue')
}
]
},
@@ -39,13 +44,13 @@ const routes = [
children: [
{
path: 'users', // 实际上是 /system/users
name: 'Users',
name: 'SystemUsers',
meta: {title: '用户管理', icon: 'User'},
component: Users
},
{
path: 'dicts', // 实际上是 /system/dicts
name: 'Dicts',
name: 'SystemDicts',
meta: {title: '字典管理', icon: 'Plus'},
component: () => import('@/views/Dicts.vue') // 使用懒加载的方式引入 Dicts 组件
}