Vue前端框架的基础配置

ops/2024/10/21 14:21:09/

登录界面添加背景图

通过在登录界面的vue文件中,设置div标签的background-image属性,加载背景图

<style scoped>
.myvue{width:100%;height: 750px;
//添加背景图的地址background-image: url(../assets/oa.jpeg);background-size: cover;background-position: center;
//相对布局position: relative;
}.loginContainer{margin-top:200px;border-radius: 15px;background-clip: padding-box;margin: 0px auto;width:350px;padding:15px 35px 15px 35px;background-color: #fff;border: 1px solid #eaeaea;box-shadow: 0 0 25px #cac6c6;position: relative;}.loginTitle{margin: 0px auto 40px auto;text-align: center;}#main{padding-top:200px}.loginRemember{text-align: left;margin: 0px 0px 15px 0px;}.el-form-item__content{display:flex;align-items: center;}.code{width:80px;height:30px;display: inline-block;font-family:Arial;font-style:italic;color:blue;border:1px solid #dedede;border-radius:5px;padding:2px 3px;letter-spacing:1px;font-weight:bolder;                      cursor:pointer;text-align:center;vertical-align:middle;}
</style>
<template><div class="myvue"><div id="main"><el-form ref="loginForm" :model="loginForm" class="loginContainer" :rules="rules"><h3 class="loginTitle">系统登录</h3><el-form-item prop="username"><el-input type='text' auto-complete="false" v-model="loginForm.username" placeholder="请输入用户名"></el-input></<el-form-item></el-form></div>
</div>
</template>

根据用户身份动态设置路由

在router文件夹下的index.js中,添加路由表及每个路由对应的用户身份,将其与选择结构结合,根据逐级判断,让用户与路由表对应起来。前端设计部分,利用vue框架的特点{{}}获取属性值,实现动态路由效果

<el-container><el-aside width="300px"><!-- 导航栏 --><!--设置导航栏的选项跳转,根据不同的index跳转到不同的界面 --><el-menu router ><el-submenu  v-for="(item,index1) in this.$router.options.routes" :key="index1" v-if="!item.hidden" :index="index1"><!-- <el-submenu  v-for="(item,index1) in routes" :key="index1"  :index="index1"> --><template slot="title"><i class="el-icon-location" style="color:#1accff;margin-right:5px"></i><span>{{item.name}}</span></template><el-menu-item :index="children.path" v-for="(children,indexj) in item.children">{{children.name}}</el-menu-item></el-submenu></el-menu></el-aside><el-main><!-- 在右上方设置面包屑效果,并增加超链接 --><el-breadcrumb v-if="this.$router.currentRoute.path!='/home'" separator-class="el-icon-arrow-right"><el-breadcrumb-item :to="{path:'/home'}">首页</el-breadcrumb-item><el-breadcrumb-item >{{this.$router.currentRoute.name}}</el-breadcrumb-item></el-breadcrumb><div class='welcome' v-if="this.$router.currentRoute.path=='/home'"><div class="wer"><el-card class="box-card" style="width:400px"><div slot="header" class="clearfix"><i class="el-icon-location" style="color:#1accff;margin-right:5px" ></i><span id="text">正在定位..</span></div><div id="weather" ><el-empty :image-size="50"></el-empty></div></el-card></div><div class="news"><el-card class="box-card" style="width:400px"><div slot="header" class="clearfix" ><i class="el-icon-location" style="color:#1accff;margin-right:5px;margin-botton:10px" ></i><span class="news-text">时政新闻</span></div><div id="content" style="text-decoration: none;"><el-empty :image-size="50"></el-empty></div></el-card></div></div>                   <router-view class="routerView"></router-view></el-main></el-container></el-container>
var routes;
routes = [{path: '/',
//设置每个模块的用户身份meta:{roles:['admin1','admin2']},name: 'Login',component: Login,hidden:true},{path: '/home',// name属性和网页点击的文字相关联,动态地渲染组件name: '个人中心',component:Home,hidden:true,children:[//     // 设置子路由{path: '/userinfo',name: '个人中心',component:AdminInfo},]},{path: '/home',// name属性和网页点击的文字相关联,动态地渲染组件name: '新闻管理',component: Home,hidden:true,children:[// 设置子路由{path: '/NewsList',name: '时政新闻',component: superAdmin},{path: '/inform',name: '通知内容',component: SysData},]},{path: '/home',name: '常用服务',component:Home,meta:{roles:['admin2','admin1','user']},hidden:false,children:[{path: '/mail',name: '邮件发送',component:Mail},{path: '/sys/config',name: '我的通知',component:SysConfig},]},{path: '/home',name: '常用服务-员工',component:Home,meta:{roles:['admin2','admin1']},hidden:false,children:[{path: '/mail',name: '邮件发送',component:Mail},{path: '/sign',name: '签到管理',component:Sign},{path: '/sys/admin',name: '重要通知',component:SysAdmin}]},{path: '/home',// name属性和网页点击的文字相关联,动态地渲染组件name: '请假管理',meta:{roles:['admin2','admin1']},component: Home,hidden:false,children:[// 设置子路由{path: '/apply/applyUp',name: '请假申请',component: ApplyUp}]},{path: '/home',// name属性和网页点击的文字相关联,动态地渲染组件name: '员工管理',component: Home,hidden:false,meta:{roles:['admin2']},children:[{path: '/emp/basic',name: '基本资料',component: EmpBasic}]},{path: '/home',// name属性和网页点击的文字相关联,动态地渲染组件name: '薪资管理',component: Home,hidden:false,meta:{roles:['admin1','admin2']},children:[// 设置子路由{path: '/sal/table',name: '工资表管理',component: SalTable}]},{path: '/home',meta:{roles:['admin1']},// name属性和网页点击的文字相关联,动态地渲染组件name: '统计管理',component: Home,hidden:false,children:[// 设置子路由{path: '/sta/all',name: '员工信息统计',component:chart}]}]} 
]export const getRole=()=>{var name=JSON.parse(window.sessionStorage.getItem('username'));getRequest('/role?name='+name).then(resp=>{// 获取当前用户的角色var role=resp.role;var human=resp.human;window.sessionStorage.setItem('role',role);window.sessionStorage.setItem('human',human);// 根据角色,设置动态路由if(role==='admin1'){var roleList=[false,true,false,true,true,true,false,true,false,true,true];var index=0;for(var i=3;i<routes.length;i++){routes[i].hidden=roleList[index++];}}else if((role==='admin2')){var roleList=[false,true,false,true,false,false,true,true,true,true,true];var index=0;for(var i=3;i<routes.length;i++){routes[i].hidden=roleList[index++];}}      else if((role==='user')){var roleList=[true,false,true,false,true,true,true,true,false,true,false];var index=0;for(var i=3;i<routes.length;i++){routes[i].hidden=roleList[index++];}}})

面包屑效果(首页>邮件发送) 


http://www.ppmy.cn/ops/124017.html

相关文章

ECharts 实现气象数据可视化的教程

ECharts 是一个由百度开源的强大的数据可视化库&#xff0c;它能够通过简单的配置和灵活的扩展生成交互式图表。对于气象数据的可视化&#xff0c;ECharts 提供了丰富的图表类型&#xff0c;如热力图、雷达图、折线图、风场图等&#xff0c;适用于展示温度、降雨量、风速、风向…

Elasticsearch 索引数据预处理

pipeline 在文档写入 ES 之前&#xff0c;对数据进行预处理&#xff08;ingest&#xff09;工作通过定义 pipeline 和 processors 实现。 注意&#xff1a;数据预处理必须在 Ingest node 节点处理&#xff0c;ES 默认所有节点都是 Ingest node。 如果需要禁用 Ingest &#x…

云栖实录 | 大模型驱动,开源融合的 AI 搜索产品发布

本文根据2024云栖大会实录整理而成&#xff0c;演讲信息如下&#xff1a; 演讲人&#xff1a; 郭瑞杰 | 阿里云智能集团资深技术专家&#xff0c;阿里云 AI 搜索负责人 邹 宽&#xff5c;阿里云智能集团高级产品专家&#xff0c;阿里云 AI 搜索产品负责人 活动&#xff1a;…

Nginx从入门到实战(八):版本平滑无感知,不停机升级

一、查看旧版本信息 可以通过nginx -V命令&#xff0c;来查看当前nginx的版本信息&#xff0c;和配置参数。 [rootnb001 sbin]# nginx -V -bash: nginx: command not found [rootnb001 sbin]# ./nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat …

1024程序员节活动——「爱码士找Bug」第二弹

下面是用Java写一个关于冒泡排序的算法&#xff1a; public class BubbleSort {public static void sort(int[] array) {int n array.length;for (int i 0; i < n - 1; i) {boolean swapped false;for (int j 0; j < n - i - 1; j) {if (array[j] > array[j 1])…

基于Vue3+Ts+Vite项目中grpc-Web的应用以及其中的坑

背景&#xff1a; 最近项目中有一个需求&#xff1a;在新项目中使用grpc进行前后端通信。我便基于此需求开始了新的研究。 首先我是想抄作业的&#xff0c;但是翻了很多相关grpc-web的文章&#xff0c;写的都不是很详细&#xff0c;再涉及到grpc-web服务的升级迭代&#xff0…

Dolma:包含三万亿Token的语言模型预训练研究开放语料库

前言 原论文&#xff1a;Dolma: an Open Corpus of Three Trillion Tokens for Language Model Pretraining Research 摘要 关于训练当前最佳性能语言模型的预训练语料库的信息很少被讨论——商业模型很少详细说明它们的数据&#xff0c;即使是开源模型也往往在没有训练数据…

[uni-app]小兔鲜-08云开发

uniCloud可以通过JS开发服务端,包含云数据库, 云函数, 云存储等功能, uniCloud可结合 uni-ui 组件库使用 效果展示: <picker>城市选择组件不支持h5端和APP端, 所以我们使用 <uni-data-picker>组件进行兼容处理 <uni-data-picker>的数据使用云数据库的数据 云…