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

react_16

主页

import {DownCircleOutlined,MenuFoldOutlined,VerticalAlignTopOutlined,
} from "@ant-design/icons";
import { Button, Layout, Menu } from "antd";
import { ItemType } from "antd/es/menu/hooks/useItems";
import { Link, Navigate, Outlet, useNavigate } from "react-router-dom";
import Icon from "../store/Icon";
import StudentStore from "../store/StudentStore";
import RoutesStore from "../store/RoutesStore";
import { observer } from "mobx-react-lite";
import { useEffect } from "react";function A8Main() {const items: ItemType[] = [{label: <Link to="/student">学生管理</Link>,key: 1,icon: <DownCircleOutlined />,},{label: <Link to="/teacher">教师管理</Link>,key: 2,icon: <VerticalAlignTopOutlined />,},{label: "用户管理",key: 3,icon: <MenuFoldOutlined />,children: [{label: "功能一",key: 31,icon: <Icon name="PicLeftOutlined"></Icon>,},{label: "功能二",key: 32,icon: <Icon name="BorderHorizontalOutlined"></Icon>,},],},];const nav = useNavigate();//点击注销按钮,清空localStorage里面和state数据,跳转到登录页面function onClick() {RoutesStore.reset();nav("/login");}//useEffect()的执行时机是先生成了jsx代码,然后执行了副作用,然后再渲染,正在渲染的时候执行了调转,所以看到//主页一闪而过,/* useEffect(() => {if (RoutesStore.username === "") {nav("/login");}}, []); */if (RoutesStore.username === "") {return <Navigate to={"/login"}></Navigate>;}return (<Layout><Layout.Header><span>欢迎您【{RoutesStore.username}】</span><Button onClick={onClick}>注销</Button></Layout.Header><Layout><Layout.Sider><Menu items={RoutesStore.menus} theme="dark" mode="inline"></Menu></Layout.Sider><Layout.Content><Outlet></Outlet></Layout.Content></Layout></Layout>);
}
export default observer(A8Main);

R.ts文件

export default interface R<T>{code:number,data:T,message?:string}

Student.ts文件

export interface Student {id: number;name: string;sex?: string;age?: number;photo?: string;}export interface PageResp<T>{total: number,list : T[],}export interface StudentQueryForm{name?:string,sex?:string,age?:string}export interface Route{path:string,element:string}// 服务器返回的菜单数据
export interface Menu {key: string,label: string,children?: Menu[],icon: string,routePath: string
}// 路由 + 菜单
export interface MenuAndRoute {routeList: Route[]menuTree: Menu[]
}// 登录请求
export interface LoginReq {username: string,password: string
}// 登录响应
export interface LoginResp {token: string
}

http://www.lryc.cn/news/217276.html

相关文章:

  • 前端性能分析工具
  • 根据Aurora发送时序,造Aurora 数据包,从而进行AXIS接口数据位宽转换仿真
  • java后端响应结果Result
  • react_11
  • AI:52-基于深度学习的垃圾分类
  • [shell,hive] 在shell脚本中将hiveSQL分离出去
  • 求两个(法)向量之间的rpy夹角
  • [100天算法】-每个元音包含偶数次的最长子字符串(day 53)
  • 从科幻走向现实,LLM Agent 做到哪一步了?
  • [笔记] 数据类型
  • QT学习之QT概述
  • 编写shell脚本,利用mysqldump实现MySQL数据库分库分表备份
  • 本地部署Jellyfin影音服务器并实现远程访问影音库
  • 【数据结构】希尔排序
  • 使用VBA打印PDF文件
  • 分布式ID系统设计(2)
  • http和https的区别,以及https涉及到的加密过程
  • 使用php打印时间精确到毫秒及毫秒转成11位时间戳
  • uni-app离线打包在android studio创建的.jks证书,签名文件获取MD5问题
  • 333333333333
  • Python:字符串格式化
  • 虹科示波器 | 汽车免拆检修 | 2010款江铃陆风X8车发动机怠速抖动、加速无力
  • 左和右,激进与保守,都是相对概念,但是都会滑向同一种
  • js中的遍历
  • Python算法——快速排序
  • 操作系统备考学习 day12 (第五章)
  • Elasticsearch删除映射类型
  • 网络工程师进阶课:华为HCIP认证课程介绍
  • 单行自动横向滚动——css实现
  • 多线程基础