first commit

This commit is contained in:
wang_yp 2025-03-16 14:16:31 +08:00
parent a583668f29
commit 0cc80eec5c
6 changed files with 83 additions and 73 deletions

View File

@ -3,7 +3,7 @@ import "./layout.less";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { Store } from "antd/es/form/interface"; import { Store } from "antd/es/form/interface";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Avatar, Breadcrumb, Layout, Menu, theme } from "antd"; import { Avatar, Breadcrumb, Layout, Menu, MenuProps, theme } from "antd";
import { UserOutlined } from "@ant-design/icons"; import { UserOutlined } from "@ant-design/icons";
import Sider from "antd/es/layout/Sider"; import Sider from "antd/es/layout/Sider";
import { items } from "./layout_config"; import { items } from "./layout_config";
@ -12,6 +12,7 @@ import { Outlet, useNavigate } from "react-router";
const LayOut = (props: Store) => { const LayOut = (props: Store) => {
const { usrStore } = props; const { usrStore } = props;
const [collapsed, setCollapsed] = useState(false); const [collapsed, setCollapsed] = useState(false);
const nav = useNavigate(); const nav = useNavigate();
const { const {
token: { colorBgContainer, borderRadiusLG }, token: { colorBgContainer, borderRadiusLG },
@ -40,13 +41,13 @@ const LayOut = (props: Store) => {
// } // }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [usrStore.isNeedLogin]); }, [usrStore.isNeedLogin]);
return ( return (
<Layout> <Layout>
<Header style={headStyle}> <Header style={headStyle}>
<div style={logoStyle}>logo</div> <div style={logoStyle}>logo</div>
{/* <Dropdown menu={{ items }}> */} {/* <Dropdown menu={{ items }}> */}
<Avatar icon={<UserOutlined />} /> <Avatar icon={<UserOutlined />} />
{/* </Dropdown> */} {/* </Dropdown> */}
</Header> </Header>
<Layout> <Layout>
@ -62,6 +63,7 @@ const LayOut = (props: Store) => {
theme="dark" theme="dark"
defaultSelectedKeys={["1"]} defaultSelectedKeys={["1"]}
defaultOpenKeys={["sub1"]} defaultOpenKeys={["sub1"]}
style={{ height: "100%", borderRight: 0 }} style={{ height: "100%", borderRight: 0 }}
items={items} items={items}
onClick={(e) => { onClick={(e) => {

View File

@ -1,62 +0,0 @@
import { ItemType, MenuItemType } from 'antd/es/menu/interface';
export const items:ItemType<MenuItemType>[] = [
{
key: "/",
label: `首页看板`,
},
{
key: "/user",
label: `用户管理`,
children: [
{ key: "/user/list", label: `用户管理` },
],
},
{
key: "/sku",
label: `商品管理`,
children: [
{ key: "/sku/list", label: `商品列表` },
{ key: "/sku/cat", label: `商品分类` },
{ key: "/sku/spec", label: `商品规格` },
{ key: "/sku/brand", label: `商品品牌` },
],
},
{
key: "/order",
label: `订单管理`,
children: [
{ key: "/order/list", label: `订单列表` },
],
},
{
key: "/rbac",
label: `权限管理`,
children: [
{ label: `角色管理`, key: "/rbac/role" },
{ label: `菜单管理`, key: "/rbac/menu" },
{ label: `部门管理`, key: "/rbac/dep" },
{ label: `机构管理`, key: "/rbac/org" },
{ label: `员工管理`, key: "/rbac/staff" },
],
},
{
key: "/city",
label: `区域管理`,
children: [
{ label: `区域列表`, key: "/city/list" },
],
},
{
key: "/sys",
label: `系统管理`,
children: [
{ label: `部门管理`, key: "/sys/dep" },
{ label: `数据字典`, key: "/sys/keywod" },
{ label: `版本管理`, key: "/sys/version" },
{ label: `捐赠管理`, key: "/sys/don" },
{ label: `通告管理`, key: "/sys/notic" },
],
},
];

View File

@ -0,0 +1,70 @@
import { ItemType, MenuItemType } from "antd/es/menu/interface";
import {
UserOutlined,
NotificationOutlined,
PaperClipOutlined,
FileSyncOutlined,
DashboardOutlined
} from "@ant-design/icons";
export const items: ItemType<MenuItemType>[] = [
{
key: "/",
label: `首页看板`,
icon:<DashboardOutlined />,
},
{
key: "/user",
label: `用户管理`,
icon: <UserOutlined />,
children: [{ key: "/user/list", label: `用户管理` }],
},
{
key: "/sku",
label: `商品管理`,
icon: <NotificationOutlined />,
children: [
{ key: "/sku/list", label: `商品列表` },
{ key: "/sku/cat", label: `商品分类` },
{ key: "/sku/spec", label: `商品规格` },
{ key: "/sku/brand", label: `商品品牌` },
],
},
{
key: "/order",
label: `订单管理`,
icon: <NotificationOutlined />,
children: [{ key: "/order/list", label: `订单列表` }],
},
{
key: "/rbac",
label: `权限管理`,
icon: <PaperClipOutlined />,
children: [
{ label: `角色管理`, key: "/rbac/role" },
{ label: `菜单管理`, key: "/rbac/menu" },
{ label: `部门管理`, key: "/rbac/dep" },
{ label: `机构管理`, key: "/rbac/org" },
{ label: `员工管理`, key: "/rbac/staff" },
],
},
{
icon:<FileSyncOutlined />,
key: "/city",
label: `区域管理`,
children: [{ label: `区域列表`, key: "/city/list" }],
},
{
key: "/sys",
label: `系统管理`,
icon:<FileSyncOutlined />,
children: [
{ label: `部门管理`, key: "/sys/dep" },
{ label: `数据字典`, key: "/sys/keywod" },
{ label: `版本管理`, key: "/sys/version" },
{ label: `捐赠管理`, key: "/sys/don" },
{ label: `通告管理`, key: "/sys/notic" },
],
},
];

View File

@ -10,10 +10,10 @@ const Login = (props) => {
const navigate = useNavigate(); const navigate = useNavigate();
const onFinish = async (values: any) => { const onFinish = async (values: any) => {
navigate("/", { replace: true }); navigate("/", { replace: true });
return;
let status = await usrStore.login({ let status = await usrStore.login({
userName: values.account, userName: values.account,
passWord: values.password, passWord: values.password,
genre:1
}); });
if (status) { if (status) {
usrStore.closeLoginDilog(); usrStore.closeLoginDilog();

View File

@ -18,16 +18,16 @@ axios.interceptors.request.use((config) => {
// 添加响应拦截器 // 添加响应拦截器
axios.interceptors.response.use((res: AxiosResponse) => { axios.interceptors.response.use((res: AxiosResponse) => {
if (res.data?.status === 401) { if (res.data?.status === 401) {
// store.usrStore.openLoginDilog() store.usrStore.openLoginDilog()
// store.usrStore.logOut() store.usrStore.logOut()
// window.location.href = '#/login' window.location.href = '#/login'
} }
return res; return res;
}, (err) => { }, (err) => {
if (err.status === 401) { if (err.status === 401) {
// store.usrStore.openLoginDilog() store.usrStore.openLoginDilog()
// store.usrStore.logOut() store.usrStore.logOut()
// window.location.href = '#/login' window.location.href = '#/login'
} }
return Promise.reject(err); return Promise.reject(err);
}); });

View File

@ -44,7 +44,7 @@ class UserStore extends BaseStore<UserDataType> {
} }
try { try {
let data = await base.post(UserConfig.LOGINURI, param) let data = await base.post(UserConfig.LOGINURI, param)
if (data.code !== 0) { if (data.code !== 200) {
message.error(data.msg) message.error(data.msg)
return false return false
} }