【Vue3从入门到项目实现】RuoYi-Vue3若依框架前端学习——动态路由与菜单栏

在这里插入图片描述

菜单栏

若依框架的侧边栏组件通常由菜单项和子菜单组成。
登录后,会获取用户拥有的路由菜单
在这里插入图片描述

{"msg": "操作成功","code": 200,"data": [{"name": "System","path": "/system","hidden": false,"redirect": "noRedirect","component": "Layout","alwaysShow": true,"meta": {"title": "系统管理","icon": "system","noCache": false,"link": null},"children": [{"name": "User","path": "user","hidden": false,"component": "system/user/index","meta": {"title": "用户管理","icon": "user","noCache": false,"link": null}},{"name": "Role","path": "role","hidden": false,"component": "system/role/index","meta": {"title": "角色管理","icon": "peoples","noCache": false,"link": null}},{"name": "Menu","path": "menu","hidden": false,"component": "system/menu/index","meta": {"title": "菜单管理","icon": "tree-table","noCache": false,"link": null}},{"name": "Dept","path": "dept","hidden": false,"component": "system/dept/index","meta": {"title": "部门管理","icon": "tree","noCache": false,"link": null}},{"name": "Post","path": "post","hidden": false,"component": "system/post/index","meta": {"title": "岗位管理","icon": "post","noCache": false,"link": null}},{"name": "Dict","path": "dict","hidden": false,"component": "system/dict/index","meta": {"title": "字典管理","icon": "dict","noCache": false,"link": null}},{"name": "Config","path": "config","hidden": false,"component": "system/config/index","meta": {"title": "参数设置","icon": "edit","noCache": false,"link": null}},{"name": "Notice","path": "notice","hidden": false,"component": "system/notice/index","meta": {"title": "通知公告","icon": "message","noCache": false,"link": null}},{"name": "Log","path": "log","hidden": false,"redirect": "noRedirect","component": "ParentView","alwaysShow": true,"meta": {"title": "日志管理","icon": "log","noCache": false,"link": null},"children": [{"name": "Operlog","path": "operlog","hidden": false,"component": "monitor/operlog/index","meta": {"title": "操作日志","icon": "form","noCache": false,"link": null}},{"name": "Logininfor","path": "logininfor","hidden": false,"component": "monitor/logininfor/index","meta": {"title": "登录日志","icon": "logininfor","noCache": false,"link": null}}]}]},{"name": "Monitor","path": "/monitor","hidden": false,"redirect": "noRedirect","component": "Layout","alwaysShow": true,"meta": {"title": "系统监控","icon": "monitor","noCache": false,"link": null},"children": [{"name": "Online","path": "online","hidden": false,"component": "monitor/online/index","meta": {"title": "在线用户","icon": "online","noCache": false,"link": null}},{"name": "Job","path": "job","hidden": false,"component": "monitor/job/index","meta": {"title": "定时任务","icon": "job","noCache": false,"link": null}},{"name": "Druid","path": "druid","hidden": false,"component": "monitor/druid/index","meta": {"title": "数据监控","icon": "druid","noCache": false,"link": null}},{"name": "Server","path": "server","hidden": false,"component": "monitor/server/index","meta": {"title": "服务监控","icon": "server","noCache": false,"link": null}},{"name": "Cache","path": "cache","hidden": false,"component": "monitor/cache/index","meta": {"title": "缓存监控","icon": "redis","noCache": false,"link": null}},{"name": "CacheList","path": "cacheList","hidden": false,"component": "monitor/cache/list","meta": {"title": "缓存列表","icon": "redis-list","noCache": false,"link": null}}]},{"name": "Tool","path": "/tool","hidden": false,"redirect": "noRedirect","component": "Layout","alwaysShow": true,"meta": {"title": "系统工具","icon": "tool","noCache": false,"link": null},"children": [{"name": "Build","path": "build","hidden": false,"component": "tool/build/index","meta": {"title": "表单构建","icon": "build","noCache": false,"link": null}},{"name": "Gen","path": "gen","hidden": false,"component": "tool/gen/index","meta": {"title": "代码生成","icon": "code","noCache": false,"link": null}},{"name": "Swagger","path": "swagger","hidden": false,"component": "tool/swagger/index","meta": {"title": "系统接口","icon": "swagger","noCache": false,"link": null}}]},{"name": "Http://ruoyi.vip","path": "http://ruoyi.vip","hidden": true,"component": "Layout","meta": {"title": "若依官网","icon": "guide","noCache": false,"link": "http://ruoyi.vip"}}]
}

动态路由

打开src\router\index.js
在这里插入图片描述
公共路由主要包括登录、注册、首页、401、404等页面路由

既然是动态路由,并且后端接口会传过来用户拥有的路由信息。
找一找哪里实现了动态路由的构造。
src/permission.js
在这里插入图片描述
找到中src\store\modules\permission.js中的generateRoutes(roles)方法:
在这里插入图片描述
从后端获取到路由之后,遍历后台传来的路由字符串,转换为组件对象。遍历上面提到的dynamicRoutes,把有权限的加入菜单。

创建菜单

既然菜单与路由是由后端传过来的。那么就可以进行增删改查,自定义侧边栏的菜单显示了。
创建一个新的功能页面:
在这里插入图片描述
··················································································································································································

在这里插入图片描述
··················································································································································································
在这里插入图片描述
·························································································
创建好以后:
在这里插入图片描述
就可以看的菜单栏有我们新的菜单。(超级管理员角色登录)
我们在@/views 文件下创建对应的文件src\views\ai\chat\index.vue
随便加点内容。

<template>讯飞星火
</template><script></script>

点击我们新添加的菜单,发现可以访问。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/259587.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

进程、线程、线程池状态

线程几种状态和状态转换 进程主要写明三种基本状态&#xff1a; 线程池的几种状态&#xff1a;

oracle实验2023-12-8--触发器

第十四周实验 【例】功能要求&#xff1a;增加一新表XS_1&#xff0c;表结构和表XS相同&#xff0c;用来存放从XS表中删除的记录。 分析: 1、创建表 xs_1 SQL> create table xs_1 as select * from xs; Table created SQL> truncate table xs_1; Table truncated题目&a…

微信小程序 bindtap 事件多参数传递

在微信小程序中&#xff0c;我们无法直接通过 bindtap"handleClick(1,2,3)" 的方式传递参数&#xff0c;而是需要通过自定义属性 data- 的方式进行传递&#xff0c;并在事件回调函数中通过 event.currentTarget.dataset 来获取这些参数。然而&#xff0c;这种传参方式…

代理IP怎么使用?Mac苹果系统设置http代理IP教程

代理IP是一种通过将请求转发到另一个服务器&#xff0c;以隐藏自己的真实IP地址的服务器。使用代理IP可以保护您的隐私和安全&#xff0c;防止被跟踪或被攻击。在本文中&#xff0c;我们将介绍如何在Mac苹果系统上设置http代理IP教程。 一、了解代理IP 代理IP地址是一种可以用来…

自动化使用GradCAM处理图片(用于ViT和swin的变体)附链接

GradCAM_On_ViT 用于可视化模型结果的 GradCAM 自动脚本 如何在 GradCam 中调整 XXXFormer 请确保您的模型格式正确。 如果您应用的变压器是类似 swin&#xff08;无ClassToken&#xff09;或类似 ViT &#xff08;有ClassToken&#xff09; 张量的形状可能看起来像[Batc…

从根上理解elasticsearch(lucene)查询原理(1)-lucece查询逻辑介绍

大家好&#xff0c;我是蓝胖子&#xff0c;最近在做一些elasticsearch 慢查询优化的事情&#xff0c;通常用分析elasticsearch 慢查询的时候可以通过profile api 去分析&#xff0c;分析结果显示的底层lucene在搜索过程中使用到的函数调用。所以要想彻底弄懂elasticsearch慢查询…

UDP群聊

客户端 import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader…

hbuilder + uniapp +vue3 开发微信云小程序

1、创建项目&#xff1a; 2、创建项目完成的默认目录结构&#xff1a; 3、在根目录新建一个文件夹cloudFns&#xff08;文件名字随便&#xff09;&#xff0c;存放云函数源码&#xff1a; 4、修改manifest.json文件&#xff1a;添加 小程序 appid和cloudfunctionRoot&#xff0…

Docker安装Mysql数据库

1. 前言 XXXXX 2. Docker中安装MySQL服务 以下以mysql8.2版本为例&#xff0c;mysql5.7的步骤也是一样的 2.1. 查看可用的MySQL版本 # 搜索镜像 docker search mysql2.2. 拉取MySQL镜像 # 拉取镜像 docker pull mysql# 或者 docker pull mysql:latest2.3. 查看本地镜像 …

关于IDEA中maven的作用以及如何配置MAVEN

关于IDEA中maven的作用以及如何配置MAVEN 1、Maven是什么2、Idea中对于Maven的配置3、下载依赖时&#xff0c;Idea下方的显示3.1、Maven中央仓库的下载显示界面3.2、阿里云仓库的下载显示界面 4、Maven在Idea中的使用4.1、clean4.2、validate4.3、compile4.4、test&#xff08;…

数据结构-线性表的链式存储结构

术语&#xff1a; 1.结点&#xff1a;数据元素的存储映像。有数据域和指针域两部分组成。 2.链表&#xff1a;n个结点由指针组成一个链表 3.结点只有一个指针域的链表&#xff0c;成为单链表或线性链表。 4.结点有两个指针域的链表&#xff0c;成为双链表。 5.首尾相接的链…

8 个顶级的 PDF 转 Word 转换器

PDF 是跨不同平台分发信息而不影响内容格式的好方法。但这种安全级别确实有其缺点。没有直接的方法来编辑 PDF 上的文本或内容。编辑 PDF 文档的唯一方法是将其转换为 Word 文档或其他可以编辑的文件类型。将 PDF 转换为 Word 是根据需要编辑 PDF 内容的最快方法。有许多免费的…