当前位置: 首页 > news >正文

群控系统服务端开发模式-应用开发-前端个人资料开发

一、总结

        其实程序开发到现在,简单的后端框架就只剩下获取登录账号信息及获取登录账号菜单这两个功能咯。详细见下图:

        1、未登录时总业务流程图

        2、登录后总业务流程图

二、获取登录账号信息对接

        在根目录下src文件夹下store文件夹下modules文件夹下的user.js文件中,修改代码如下:

const state = {token: getToken(),username: '',avatar: '',email: '',realname: '',department_title: '',grade_title: '',rolename: '',roles: [],butts: []
}const mutations = {SET_TOKEN: (state, token) => {state.token = token},SET_EMAIL: (state, email) => {state.email = email},SET_USERNAME: (state, username) => {state.username = username},SET_AVATAR: (state, avatar) => {state.avatar = avatar},SET_REALNAME: (state, realname) => {state.realname = realname},SET_DEPARTMENT_TITLE: (state, department_title) => {state.department_title = department_title},SET_GRADE_TITLE: (state, grade_title) => {state.grade_title = grade_title},SET_ROLENAME: (state, rolename) => {state.rolename = rolename},SET_BUTTS: (state, butts) => {state.butts = butts},SET_ROLES: (state, roles) => {state.roles = roles}
}
// get user info
getInfo({commit, state}) {return new Promise((resolve, reject) => {getInfo().then(response => {const {data} = responseif (!data) {reject('验证失败,请重新登录。')}const { butt, key, username, avatar, email, realname, department_title, grade_title, rolename } = dataif (!butt || butt.length <= 0) {reject('您权限不足,请联系系统管理员')}commit('SET_BUTTS', butt)commit('SET_ROLES', key)commit('SET_USERNAME', username)commit('SET_AVATAR', avatar)commit('SET_EMAIL', email)commit('SET_REALNAME', realname)commit('SET_DEPARTMENT_TITLE', department_title)commit('SET_GRADE_TITLE', grade_title)commit('SET_ROLENAME', rolename)resolve(key)}).catch(error => {reject(error)})})
},

三、获取登录账号菜单信息对接

       获取菜单这块,需要更改两部分,第一部分就是路由修改,第二部分才是菜单转换成路由

        1、路由修改

                在根目录下src文件夹下route文件夹下,修改index.js文件,代码如下

import Vue from 'vue'
import Router from 'vue-router'/* Layout */
import Layout from '@/layout'Vue.use(Router)/*** Note: sub-menu only appear when route children.length >= 1* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html** hidden: true                   if set true, item will not show in the sidebar(default is false)* alwaysShow: true               if set true, will always show the root menu*                                if not set alwaysShow, when item has more than one children route,*                                it will becomes nested mode, otherwise not show the root menu* redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb* name:'router-name'             the name is used by <keep-alive> (must set!!!)* meta : {roles: ['admin','editor']    control the page roles (you can set multiple roles)title: 'title'               the name show in sidebar and breadcrumb (recommend set)icon: 'svg-name'/'el-icon-x' the icon show in the sidebarnoCache: true                if set true, the page will no be cached(default is false)affix: true                  if set true, the tag will affix in the tags-viewbreadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set}*//*** constantRoutes* a base page that does not have permission requirements* all roles can be accessed*/
export const constantRoutes = [{path: '/redirect',component: Layout,hidden: true,children: [{path: '/redirect/:path(.*)',component: () => import('@/views/redirect/index')}]},{path: '/login',component: () => import('@/views/login/index'),hidden: true},{path: '/404',component: () => import('@/views/error-page/404'),hidden: true},{path: '/401',component: () => import('@/views/error-page/401'),hidden: true},{path: '/',component: Layout,redirect: '/dashboard',children: [{path: 'dashboard',component: () => import('@/views/dashboard/index'),name: '首页',meta: { title: '首页', icon: 'dashboard', affix: true }}]},{path: '/profile',component: Layout,redirect: '/profile/index',hidden: true,children: [{path: 'index',component: () => import('@/views/profile/index'),name: 'Profile',meta: { title: 'Profile', icon: 'user', noCache: true }}]}
]/*** asyncRoutes* the routes that need to be dynamically loaded based on user roles*/
export const asyncRoutes = [// 404 page must be placed at the end !!!{ path: '*', redirect: '/404', hidden: true }
]const createRouter = () => new Router({// mode: 'history', // require service supportscrollBehavior: () => ({ y: 0 }),routes: constantRoutes
})const router = createRouter()// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {const newRouter = createRouter()router.matcher = newRouter.matcher // reset router
}export default router

        2、登录者菜单转换成路由

                在根目录下src文件夹下store文件夹下modules文件夹下,修改permission.js文件,代码如下

import {asyncRoutes, constantRoutes} from '@/router'
import {getPersonalMenu} from '@/api/common'
import {warn} from '@/utils/message'
import Layout from '@/layout'/*** Use meta.role to determine if the current user has permission* @param roles* @param route*/
function hasPermission(roles, route) {if (route.meta && route.meta.roles) {return roles.some(role => route.meta.roles.includes(role))} else {return true}
}/*** Filter asynchronous routing tables by recursion* @param routes asyncRoutes* @param roles*/
export function filterAsyncRoutes(routes, roles) {const res = []routes.forEach(route => {const tmp = {...route}if (hasPermission(roles, tmp)) {if (tmp.children) {tmp.children = filterAsyncRoutes(tmp.children, roles)}res.push(tmp)}})return res
}const state = {routes: [],addRoutes: []
}const mutations = {SET_ROUTES: (state, routes) => {state.addRoutes = routesstate.routes = constantRoutes.concat(routes)}
}/*** 后台查询的菜单数据拼装成路由格式的数据* @param routes*/
export function generaMenu(routes, data) {data.forEach(item => {const menu = {path: item.path === '#' ? item.id + '_key' : item.path,component: item.component === '#' ? Layout : resolve => require([`@/views/${item.component}`], resolve),hidden: item.is_hidden,redirect: item.redirect,children: [],name: 'menu_' + item.menuname,alwaysShow: item.always_show,meta: {title: item.title,id: item.id,icon: item.is_icon === 1 ? item.icon : '',/* affix: item.affix,*/noCache: item.is_cache}}// 一级路由if (!item.children && item.pid === 0) {menu.name = undefinedmenu.children = [{path: item.path,component: resolve => require([`@/views/${item.path}`], resolve),name: 'menu_' + item.menuname,meta: {title: item.title,icon: item.is_icon === 1 ? item.icon : '',noCache: item.is_cache,//affix: item.affix}}]}// 二级路由if (item.children) {generaMenu(menu.children, item.children)}routes.push(menu)})
}function filterMenus(localMenus, remoteMenus) {const res = []localMenus.forEach(local => {remoteMenus.forEach(remote => {if (remote.path === local.path) {local.meta.roles = remote.roleSlugsif (local.children && remote.children) {local.children = filterMenus(local.children, remote.children)}res.push(local)}})})return res
}const actions = {generateRoutes({commit, state}, key) {return new Promise(resolve => {const loadMenuData = []getPersonalMenu().then(res => {if (res.code === 50034) {reject(res.message)} else if (res.code === 50000) {warn(res.message)} else {const remoteRoutes = res.data.menuObject.assign(loadMenuData, remoteRoutes)const tempAsyncRoutes = Object.assign([], asyncRoutes)generaMenu(tempAsyncRoutes, loadMenuData)let accessedRoutes/*if (key == 'admin') {accessedRoutes = tempAsyncRoutes || []} else {accessedRoutes = filterAsyncRoutes(tempAsyncRoutes, key)}*/accessedRoutes = filterAsyncRoutes(tempAsyncRoutes, key)commit('SET_ROUTES', accessedRoutes)resolve(accessedRoutes)}}).catch(error => {reject(error)})})}
}export default {namespaced: true,state,mutations,actions
}

四、提前说明

        此时就已经可以登录到系统里面去了,结果如下图。明天将完成个人资料页面、退出及后端过期退出自动更新数据库的退出数据。

相关文章:

群控系统服务端开发模式-应用开发-前端个人资料开发

一、总结 其实程序开发到现在&#xff0c;简单的后端框架就只剩下获取登录账号信息及获取登录账号菜单这两个功能咯。详细见下图&#xff1a; 1、未登录时总业务流程图 2、登录后总业务流程图 二、获取登录账号信息对接 在根目录下src文件夹下store文件夹下modules文件夹下的us…...

动态规划技巧点

动规五部曲&#xff08;来自b站卡哥&#xff09;&#xff1a;1、确定DP数组中i、j…的含义。2、确定DP推导式。3、DP数组初始化。4、DP数组遍历顺序。5、DP数组打印校验。 父问题、子问题有些许区别&#xff1a;LeetCode343.整数拆分 今天在哔哩哔哩上刷到了一个非常有意思的l…...

深度学习之pytorch常见的学习率绘制

文章目录 0. Scope1. StepLR2. MultiStepLR3. ExponentialLR4. CosineAnnealingLR5. ReduceLROnPlateau6. CyclicLR7. OneCycleLR小结参考文献 https://blog.csdn.net/coldasice342/article/details/143435848 0. Scope 在深度学习中&#xff0c;学习率&#xff08;Learning R…...

Spring Boot集成SQL Server快速入门Demo

1.什么是SQL Server&#xff1f; SQL Server是由Microsoft开发和推广的以客户/服务器&#xff08;c/s&#xff09;模式访问、使用Transact-SQL语言的关系数据库管理系统&#xff08;DBMS&#xff09;&#xff0c;它最初是由Microsoft、Sybase和Ashton-Tate三家公司共同开发的&…...

低代码牵手 AI 接口:开启智能化开发新征程

一、低代码与 AI 接口的结合趋势 低代码开发平台近年来在软件开发领域迅速崛起。随着企业数字化转型的需求不断增长&#xff0c;低代码开发平台以其快速构建应用程序的优势&#xff0c;满足了企业对高效开发的需求。例如&#xff0c;启效云低代码平台通过范式化和高颗粒度的可配…...

【已解决】git push一直提示输入用户名及密码、fatal: Could not read from remote repository的问题

问题描述&#xff1a; 在实操中&#xff0c;git push代码到github上一直提示输入用户名及密码&#xff0c;并且跳出的输入框输入用户名和密码后&#xff0c;报错找不到远程仓库 实际解决中&#xff0c;发现我环境有两个问题解决&#xff1a; git push一直提示输入用户名及密码…...

python语言基础-4 常用模块-4.13 其他模块

声明&#xff1a;本内容非盈利性质&#xff0c;也不支持任何组织或个人将其用作盈利用途。本内容来源于参考书或网站&#xff0c;会尽量附上原文链接&#xff0c;并鼓励大家看原文。侵删。 4.13 其他模块 除此之外python中还有大量的功能模块&#xff0c;如&#xff1a; pill…...

微信小程序=》基础=》常见问题=》性能总结

文章目录 微信小程序开发应用 实例小程序生命周期 以及 各生命周期应用实例小程序图片 展示方案 小程序打包应用方案技术细节&#xff08;分包应用实例&#xff09;技术细节&#xff08;压缩处理&#xff09;一、准备工作二、JavaScript 代码压缩三、WXML 文件优化&#xff08…...

JWT深度解析:Java Web中的安全传输与身份验证

标题&#xff1a;JWT深度解析&#xff1a;Java Web中的安全传输与身份验证 引言 JSON Web Token&#xff08;JWT&#xff09;是一种轻量级的身份验证和授权标准&#xff0c;它允许在各方之间安全地传输信息。在Java Web开发中&#xff0c;JWT因其无状态、可扩展性和跨域支持而…...

使用Java爬虫获取商品订单详情:从API到数据存储

在电子商务日益发展的今天&#xff0c;获取商品订单详情成为了许多开发者和数据分析师的需求。无论是为了分析用户行为&#xff0c;还是为了优化库存管理&#xff0c;订单数据的获取都是至关重要的。本文将详细介绍如何使用Java编写爬虫&#xff0c;通过API获取商品订单详情&am…...

Mybatis中批量插入foreach优化

数据库批量入库方常见方式&#xff1a;Java中foreach和xml中使用foreach 两者的区别&#xff1a; 通过Java的foreach循环批量插入&#xff1a; 当我们在Java通过foreach循环插入的时候&#xff0c;是一条一条sql执行然后将事物统一交给spring的事物来管理&#xff08;Transa…...

Word VBA如何间隔选中多个(非连续)段落

实例需求&#xff1a;Word文档中的有多个段落&#xff0c;段落总数量不确定&#xff0c;现在需要先选中所有基数段落&#xff0c;即&#xff1a;段落1&#xff0c;段落3 … &#xff0c;然后一次性设置粗体格式。 也许有的读者会认为这个无厘头的需求&#xff0c;循环遍历遍历文…...

Linux系统常用操作与命令指南

一、快捷分类 1、移动光标 h&#xff0c; j&#xff0c; k&#xff0c; l 左&#xff0c; 下&#xff0c; 上&#xff0c; 右 Ctrl-F:下翻一页 Ctrl-B:上翻一页 Ctrl-U:上翻半页 Ctrl-d:下翻半页 0:跳至行首&#xff0c;不管有无缩进&#xff0c;就是跳到第0个字…...

StructuredStreaming (一)

一、sparkStreaming的不足 1.基于微批,延迟高不能做到真正的实时 2.DStream基于RDD,不直接支持SQL 3.流批处理的API应用层不统一,(流用的DStream-底层是RDD,批用的DF/DS/RDD) 4.不支持EventTime事件时间&#xff08;一般流处理都会有两个时间&#xff1a;事件发生的事件&am…...

由播客转向个人定制的音频频道(1)平台搭建

项目的背景 最近开始听喜马拉雅播客的内容&#xff0c;但是发现许多不方便的地方。 休息的时候收听喜马拉雅&#xff0c;但是还需要不断地选择喜马拉雅的内容&#xff0c;比较麻烦&#xff0c;而且黑灯操作反而伤眼睛。 喜马拉雅为代表的播客平台都是VOD 形式的&#xff0…...

[自然语言处理] [AI]深入理解语言与情感分类:从基础到深度学习的进展

语言是人类智能的核心组成部分,具有极高的复杂性和多样性。理解语言,尤其是语言中的隐含部分,向来是人工智能研究的一个巨大挑战。图灵测试本身便是一场关于语言生成与理解的比赛,旨在检验机器是否能够模拟人类的语言能力。随着深度学习的飞速发展,语音识别、情感分析等自…...

【GPTs】Gif-PT:DALL·E制作创意动图与精灵动画

博客主页&#xff1a; [小ᶻZ࿆] 本文专栏: AIGC | GPTs应用实例 文章目录 &#x1f4af;GPTs指令&#x1f4af;前言&#x1f4af;Gif-PT主要功能适用场景优点缺点 &#x1f4af;小结 &#x1f4af;GPTs指令 中文翻译&#xff1a; 使用Dalle生成用户请求的精灵图动画&#…...

云原生周刊:Istio 1.24.0 正式发布

云原生周刊&#xff1a;Istio 1.24.0 正式发布 开源项目推荐 Kopf Kopf 是一个简洁高效的 Python 框架&#xff0c;只需几行代码即可编写 Kubernetes Operator。Kubernetes&#xff08;K8s&#xff09;作为强大的容器编排系统&#xff0c;虽自带命令行工具&#xff08;kubec…...

Linux设置jar包开机启动

操作系统环境&#xff1a;CentOS 7 【需要 root 权限&#xff0c;使用 root 用户进行操作 或 普通用户使用 sudo 进行操作】 一、系统服务的方式 原理&#xff1a;利用系统服务管理应用程序的生命周期&#xff0c; systemctl 为系统服务管理工具 systemctl start applicati…...

计算机视觉和机器人技术中的下一个标记预测与视频扩散相结合

一种新方法可以训练神经网络对损坏的数据进行分类&#xff0c;同时预测下一步操作。 它可以为机器人制定灵活的计划&#xff0c;生成高质量的视频&#xff0c;并帮助人工智能代理导航数字环境。 Diffusion Forcing 方法可以对嘈杂的数据进行分类&#xff0c;并可靠地预测任务的…...

C语言之简单的获取命令行参数和环境变量

C语言之简单的获取命令行参数和环境变量 本人的开发环境为WIN10操作系统用VMWARE虚拟的UBUNTU LINUX 18.04LTS&#xff01;&#xff01;&#xff01; 所有代码的编辑、编译、运行都在虚拟机上操作&#xff0c;初学的朋友要注意这一点&#xff01;&#xff01;&#xff01; 详细…...

STL之vecor的使用(超详解)

目录 1. C/C中的数组 1.1. C语言中的数组 1.2. C中的数组 2. vector的接口 2.1. vector的迭代器 2.2. vector的初始化与销毁 2.3. vector的容量操作 2.4. vector的访问操作 2.5. vector的修改操作 &#x1f493; 博客主页&#xff1a;C-SDN花园GGbond ⏩ 文章专栏…...

SystemVerilog学习笔记(一):数据类型

在systemverilog中&#xff0c;主要包含以下数据类型&#xff1a; 4值类型2值类型数组字符串结构体和联合体枚举自定义类型 无符号数&#xff1a;无符号数的符号不使用任何标志&#xff0c;即无符号数只能存储正数。无符号二进制数的范围从 0 到 ((2^n) - 1)&#xff0c;n 表…...

Linux软件包管理与Vim编辑器使用指南

目录 一、Linux软件包管理器yum 1.什么是软件包&#xff1f; 2.什么是软件包管理器&#xff1f; 3.查看软件包 4.安装软件 ​编辑 5.卸载软件 Linux开发工具&#xff1a; 二、Linux编辑器---vim 1.vim的基本概念 (1) 正常/普通模式&#xff08;Normal mode&#xff0…...

每日一练 | 包过滤防火墙的工作原理

01 真题题目 包过滤防火墙对哪一层的数据报文进行检查&#xff1f; A. 应用层 B. 物理层 C. 网络层 D. 链路层 02 真题答案 C 03 答案解析 包过滤防火墙是一种基本的安全设备&#xff0c;它通过检查进出网络的数据包来决定是否允许该数据包通过。 这种类型的防火墙主要关注…...

AR眼镜方案_AR智能眼镜阵列/衍射光波导显示方案

在当今AR智能眼镜的发展中&#xff0c;显示和光学组件成为了技术攻坚的主要领域。由于这些组件的高制造难度和成本&#xff0c;其光学显示模块在整个设备的成本中约占40%。 采用光波导技术的AR眼镜显示方案&#xff0c;核心结构通常由光机、波导和耦合器组成。光机内的微型显示…...

SpringBoot(十九)创建多模块Springboot项目(完整版)

之前我有记录过一次SpringBoot多模块项目的搭建,但是那一次只是做了一个小小的测试。只是把各模块联通之后就结束了。 最近要增加业务开发,要将目前的单模块项目改成多模块项目,我就参照了一下我上次搭建的流程,发现总是有报错。上次搭建的比较顺利,很多细枝末节也没有仔细…...

Navicat 17 功能简介 | 单元格编辑器

Navicat 17 功能简介 | 单元格编辑器 本期&#xff0c;我们一起了解 Navicat 17 出色的数据操作功能的单元格编辑器。单元格编辑器支持文本、十六进制、图像和网页四种格式的数据编辑&#xff0c;位于底部的编辑器窗格&#xff0c;为你编辑更大容量的数据信息提供足够的显示和操…...

MySQL【四】

插入数据 向数据表中插入一行数据 INSERT|REPLACE INTO 表名[(字段列表)] VALUES(值列表); ########## 在s表中插入一条记录&#xff1a;学号为s011,姓名为李思&#xff0c;性别为默认值&#xff0c;计算机专业 ########## insert into s(sno,sname,dept)values(s011,李思,计…...

简单叙述 Spring Boot 启动过程

文章目录 1. 准备阶段&#xff1a;应用启动的入口2. 创建 SpringApplication 对象&#xff1a;开始启动工作3. 配置环境&#xff08;Environment&#xff09;&#xff1a;识别开发环境与生产环境4. 启动监听器和初始化器&#xff1a;感知启动的关键事件5. 创建 ApplicationCont…...