From 0cc80eec5cbbca7d292c4b6432697dd41475769f Mon Sep 17 00:00:00 2001 From: wang_yp <357754663@qq.com> Date: Sun, 16 Mar 2025 14:16:31 +0800 Subject: [PATCH] first commit --- src/components/layout/layout.tsx | 8 +-- src/components/layout/layout_config.ts | 62 ---------------------- src/components/layout/layout_config.tsx | 70 +++++++++++++++++++++++++ src/pages/login/login.tsx | 2 +- src/service/base.ts | 12 ++--- src/store/user.ts | 2 +- 6 files changed, 83 insertions(+), 73 deletions(-) delete mode 100644 src/components/layout/layout_config.ts create mode 100644 src/components/layout/layout_config.tsx diff --git a/src/components/layout/layout.tsx b/src/components/layout/layout.tsx index b69fb62..9b6d7ea 100644 --- a/src/components/layout/layout.tsx +++ b/src/components/layout/layout.tsx @@ -3,7 +3,7 @@ import "./layout.less"; import { inject, observer } from "mobx-react"; import { Store } from "antd/es/form/interface"; 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 Sider from "antd/es/layout/Sider"; import { items } from "./layout_config"; @@ -12,6 +12,7 @@ import { Outlet, useNavigate } from "react-router"; const LayOut = (props: Store) => { const { usrStore } = props; const [collapsed, setCollapsed] = useState(false); + const nav = useNavigate(); const { token: { colorBgContainer, borderRadiusLG }, @@ -40,13 +41,13 @@ const LayOut = (props: Store) => { // } // eslint-disable-next-line react-hooks/exhaustive-deps }, [usrStore.isNeedLogin]); - + return (
logo
{/* */} - } /> + } /> {/* */}
@@ -62,6 +63,7 @@ const LayOut = (props: Store) => { theme="dark" defaultSelectedKeys={["1"]} defaultOpenKeys={["sub1"]} + style={{ height: "100%", borderRight: 0 }} items={items} onClick={(e) => { diff --git a/src/components/layout/layout_config.ts b/src/components/layout/layout_config.ts deleted file mode 100644 index c29aa44..0000000 --- a/src/components/layout/layout_config.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { ItemType, MenuItemType } from 'antd/es/menu/interface'; - - -export const items:ItemType[] = [ - { - 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" }, - ], - }, -]; \ No newline at end of file diff --git a/src/components/layout/layout_config.tsx b/src/components/layout/layout_config.tsx new file mode 100644 index 0000000..c8d95ea --- /dev/null +++ b/src/components/layout/layout_config.tsx @@ -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[] = [ + { + key: "/", + label: `首页看板`, + + icon:, + }, + { + key: "/user", + label: `用户管理`, + icon: , + children: [{ key: "/user/list", label: `用户管理` }], + }, + { + key: "/sku", + label: `商品管理`, + icon: , + children: [ + { key: "/sku/list", label: `商品列表` }, + { key: "/sku/cat", label: `商品分类` }, + { key: "/sku/spec", label: `商品规格` }, + { key: "/sku/brand", label: `商品品牌` }, + ], + }, + { + key: "/order", + label: `订单管理`, + icon: , + children: [{ key: "/order/list", label: `订单列表` }], + }, + { + key: "/rbac", + label: `权限管理`, + icon: , + children: [ + { label: `角色管理`, key: "/rbac/role" }, + { label: `菜单管理`, key: "/rbac/menu" }, + { label: `部门管理`, key: "/rbac/dep" }, + { label: `机构管理`, key: "/rbac/org" }, + { label: `员工管理`, key: "/rbac/staff" }, + ], + }, + { + icon:, + key: "/city", + label: `区域管理`, + children: [{ label: `区域列表`, key: "/city/list" }], + }, + { + key: "/sys", + label: `系统管理`, + icon:, + children: [ + { label: `部门管理`, key: "/sys/dep" }, + { label: `数据字典`, key: "/sys/keywod" }, + { label: `版本管理`, key: "/sys/version" }, + { label: `捐赠管理`, key: "/sys/don" }, + { label: `通告管理`, key: "/sys/notic" }, + ], + }, +]; diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx index 874a1b8..973c0ea 100644 --- a/src/pages/login/login.tsx +++ b/src/pages/login/login.tsx @@ -10,10 +10,10 @@ const Login = (props) => { const navigate = useNavigate(); const onFinish = async (values: any) => { navigate("/", { replace: true }); - return; let status = await usrStore.login({ userName: values.account, passWord: values.password, + genre:1 }); if (status) { usrStore.closeLoginDilog(); diff --git a/src/service/base.ts b/src/service/base.ts index 1987361..a063b83 100644 --- a/src/service/base.ts +++ b/src/service/base.ts @@ -18,16 +18,16 @@ axios.interceptors.request.use((config) => { // 添加响应拦截器 axios.interceptors.response.use((res: AxiosResponse) => { if (res.data?.status === 401) { - // store.usrStore.openLoginDilog() - // store.usrStore.logOut() - // window.location.href = '#/login' + store.usrStore.openLoginDilog() + store.usrStore.logOut() + window.location.href = '#/login' } return res; }, (err) => { if (err.status === 401) { - // store.usrStore.openLoginDilog() - // store.usrStore.logOut() - // window.location.href = '#/login' + store.usrStore.openLoginDilog() + store.usrStore.logOut() + window.location.href = '#/login' } return Promise.reject(err); }); diff --git a/src/store/user.ts b/src/store/user.ts index 3f886d8..f847f51 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -44,7 +44,7 @@ class UserStore extends BaseStore { } try { let data = await base.post(UserConfig.LOGINURI, param) - if (data.code !== 0) { + if (data.code !== 200) { message.error(data.msg) return false }