diff --git a/src/App.tsx b/src/App.tsx index d0da5d0..53552c2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -36,30 +36,29 @@ const App = (props: Store) => { <> + {}} + onOk={() => { + formRef.current?.submit(); + }} + onCancel={() => { + usrStore.closeLoginDilog(); + }} + > + + - - {}} - onOk={() => { - formRef.current?.submit(); - }} - onCancel={() => { - usrStore.closeLoginDilog(); - }} - > - - ); }; diff --git a/src/components/ali_upload.tsx b/src/components/ali_upload.tsx index 238ec12..b607140 100644 --- a/src/components/ali_upload.tsx +++ b/src/components/ali_upload.tsx @@ -2,6 +2,7 @@ import Modal from "antd/lib/modal"; import { PlusOutlined } from "@ant-design/icons"; import Upload, { RcFile, UploadFile, UploadProps } from "antd/lib/upload"; import { useEffect, useState } from "react"; +import Config from "@/util/config"; interface UploadFileProps { imgList: Array; @@ -14,6 +15,7 @@ interface UploadFileEx extends UploadFile { redictUrl?: string; id?: number; } + const getBase64 = (file: RcFile): Promise => new Promise((resolve, reject) => { const reader = new FileReader(); @@ -45,7 +47,7 @@ const AliUpload = (props: UploadFileProps) => { const handleChange: UploadProps["onChange"] = ({ fileList: newFileList }) => { newFileList.forEach((i)=>{ - i.url = "http://127.0.0.1:12214/uploads/"+i.name + i.url = `${Config.uploadUrl}uploads/`+i.name }) setFileList(newFileList); props.onChnage(newFileList) @@ -62,7 +64,7 @@ const AliUpload = (props: UploadFileProps) => { { - +import { Menu } from "antd"; +import { Footer } from "antd/lib/layout/layout"; +import { Outlet, useNavigate } from "react-router"; +import { HomeTwoTone } from "@ant-design/icons"; +import { inject, observer } from "mobx-react"; +import { Store } from "antd/es/form/interface"; +import { useEffect } from "react"; +const LayOut = (props: Store) => { + const { usrStore } = props; + const nav = useNavigate(); + console.log(usrStore.isNeedLogin); + useEffect(() => { + if (usrStore.isNeedLogin) { + nav("/login"); + } + }, [usrStore,nav]); + const items = [ + { + key: "/admin/user", + label: `用户管理`, + }, + { + key: "/admin/dep", + label: `部门管理`, + }, + { + key: "/admin/archives", + label: `档案管理`, + }, + { + key: "/admin/whseMgmt", + label: `仓库管理`, + }, + { + key: "/admin/leaveApproval", + label: `请假审批`, + }, + { + key: "/admin/politicalStudy", + label: `政治学习`, + }, + { + key: `/admin/polRegulations`, + label: `政治法规管理`, + }, + { + key: "/admin/materialMgmt", + label: `物资管理`, + }, + { + key: "/admin/teamMgmt", + label: `队伍属性管理`, + }, + { + key: "/admin/persMgmt", + label: `个人身份管理`, + }, + ]; return (
- +
+ nav("/")} + style={{ fontSize: "36px", marginRight: "10px" }} + /> + { + nav(e.key); + }} + style={{ flex: 1, minWidth: 0 }} + /> +
+ + + +
+ Ant Design ©{new Date().getFullYear()} Created by Ant UED +
); }; -export default LayOut; +export default inject("usrStore")(observer(LayOut)); diff --git a/src/index.less b/src/index.less index 0a6b531..fa7db9a 100644 --- a/src/index.less +++ b/src/index.less @@ -1,3 +1,7 @@ +html{ + width: 100%; + height: 100%; +} body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', diff --git a/src/pages/home/homeLeft/home_left.tsx b/src/pages/home/homeLeft/home_left.tsx index 03540e3..7db6377 100644 --- a/src/pages/home/homeLeft/home_left.tsx +++ b/src/pages/home/homeLeft/home_left.tsx @@ -18,7 +18,7 @@ const HomeLeft = () => { MapUtl.makerList[0].setIcon(newIcon); }; const jumpToUser = () => { - navigate("/user"); + navigate("admin/user"); }; return ( diff --git a/src/pages/leaveApproval/index.tsx b/src/pages/leaveApproval/index.tsx new file mode 100644 index 0000000..a63572e --- /dev/null +++ b/src/pages/leaveApproval/index.tsx @@ -0,0 +1,9 @@ +const LeaveApproval = () => { + return ( + <> +

leaveApproval

+ + ); +}; + +export default LeaveApproval; diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx index c6565ac..c8994db 100644 --- a/src/pages/login/login.tsx +++ b/src/pages/login/login.tsx @@ -10,17 +10,17 @@ const Login = (props) => { const navigate = useNavigate(); const onFinish = (values: any) => { usrStore.login({ - userName: values.username, + userName: values.account, passWord: values.password, }); - navigate("/", { replace: true }); + navigate("/admin/user", { replace: true }); }; const onFinishFailed = () => {}; const loginForm = [ { type: "input", label: "用户名", - name: "username", + name: "account", value: "", rules: [{ required: true, message: "请输入用户名!" }], }, @@ -42,7 +42,7 @@ const Login = (props) => { { formRef.current?.submit(); }} > - Login + 登录 diff --git a/src/pages/materialMgmt/index.tsx b/src/pages/materialMgmt/index.tsx new file mode 100644 index 0000000..f966d78 --- /dev/null +++ b/src/pages/materialMgmt/index.tsx @@ -0,0 +1,10 @@ +const MaterialMgmt = () => { + return ( + <> +

MaterialMgmt

+ + ); + }; + + export default MaterialMgmt; + \ No newline at end of file diff --git a/src/pages/persMgmt/index.tsx b/src/pages/persMgmt/index.tsx new file mode 100644 index 0000000..d3e3345 --- /dev/null +++ b/src/pages/persMgmt/index.tsx @@ -0,0 +1,10 @@ +const PersMgmt = () => { + return ( + <> +

PersMgmt

+ + ); + }; + + export default PersMgmt; + \ No newline at end of file diff --git a/src/pages/polRegulations/index.tsx b/src/pages/polRegulations/index.tsx new file mode 100644 index 0000000..dfe2734 --- /dev/null +++ b/src/pages/polRegulations/index.tsx @@ -0,0 +1,10 @@ +const PolRegulations = () => { + return ( + <> +

PolRegulations

+ + ); + }; + + export default PolRegulations; + \ No newline at end of file diff --git a/src/pages/politicalStudy/index.tsx b/src/pages/politicalStudy/index.tsx new file mode 100644 index 0000000..164e269 --- /dev/null +++ b/src/pages/politicalStudy/index.tsx @@ -0,0 +1,10 @@ +const PoliticalStudy = () => { + return ( + <> +

PoliticalStudy

+ + ); + }; + + export default PoliticalStudy; + \ No newline at end of file diff --git a/src/pages/teamMgmt/index.tsx b/src/pages/teamMgmt/index.tsx new file mode 100644 index 0000000..e3fa6cc --- /dev/null +++ b/src/pages/teamMgmt/index.tsx @@ -0,0 +1,10 @@ +const TeamMgmt = () => { + return ( + <> +

TeamMgmt

+ + ); + }; + + export default TeamMgmt; + \ No newline at end of file diff --git a/src/pages/user/user.tsx b/src/pages/user/user.tsx index f2ec4e9..e0e4d30 100644 --- a/src/pages/user/user.tsx +++ b/src/pages/user/user.tsx @@ -164,7 +164,6 @@ const User = (props: Store) => { > 添加用户 - - - - - - - - - - diff --git a/src/pages/whseMgmt/index.tsx b/src/pages/whseMgmt/index.tsx new file mode 100644 index 0000000..85e689c --- /dev/null +++ b/src/pages/whseMgmt/index.tsx @@ -0,0 +1,10 @@ +const WhseMgmt = () => { + return ( + <> +

WhseMgmt

+ + ); + }; + + export default WhseMgmt; + \ No newline at end of file diff --git a/src/router/index.tsx b/src/router/index.tsx index b706511..bf3e0cb 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -1,27 +1,17 @@ import { createHashRouter } from "react-router-dom"; import App from "@/App"; -import ErrorPage from "@/pages/errorPage"; import Login from "@/pages/login/login"; -import { homeRouter } from "@/router/routers/home_router" +import { homeRouter } from "@/router/routers/home_router"; const routers = createHashRouter([ { path: "/", element: , - children: [ - ...homeRouter, - ] }, { path: "/login", element: , }, - { - path: "/404", - element: , - }, + ...homeRouter ]); - - - -export { routers }; \ No newline at end of file +export { routers }; diff --git a/src/router/routers/home_router.tsx b/src/router/routers/home_router.tsx index 6bc2a51..a3f8b74 100644 --- a/src/router/routers/home_router.tsx +++ b/src/router/routers/home_router.tsx @@ -1,38 +1,86 @@ +import LayOut from "@/components/layout/layout"; import Archives from "@/pages/archives"; import Dep from "@/pages/dep"; import Home from "@/pages/home/home"; +import LeaveApproval from "@/pages/leaveApproval"; +import MaterialMgmt from "@/pages/materialMgmt"; +import PersMgmt from "@/pages/persMgmt"; +import PoliticalStudy from "@/pages/politicalStudy"; +import PolRegulations from "@/pages/polRegulations"; import Tag from "@/pages/tag/tag"; +import TeamMgmt from "@/pages/teamMgmt"; import User from "@/pages/user/user"; +import WhseMgmt from "@/pages/whseMgmt"; export const homeRouter = [ { path: "/", index: true, - element: - // element: + element: , }, { path: "/dashbord", index: false, - element: + element: , }, { - path: "/user", - index: true, - element: + path: "/admin", + element: , + children: [ + { + path: "/admin/user", + index: true, + element: , + }, + { + path: "/admin/tag", + index: true, + element: , + }, + { + path: "/admin/dep", + index: true, + element: , + }, + { + path: "/admin/archives", + index: true, + element: , + }, + { + path: "/admin/leaveApproval", + index: true, + element: , + }, + { + path: "/admin/materialMgmt", + index: true, + element: , + }, + { + path: "/admin/persMgmt", + index: true, + element: , + }, + { + path: "/admin/politicalStudy", + index: true, + element: , + }, + { + path: "/admin/polRegulations", + index: true, + element: , + }, + { + path: "/admin/teamMgmt", + index: true, + element: , + }, + { + path: "/admin/whseMgmt", + index: true, + element: , + }, + ], }, - { - path: "/tag", - index: true, - element: - }, - { - path: "/dep", - index: true, - element: - }, - { - path: "/archives", - index: true, - element: - }, -]; \ No newline at end of file +]; diff --git a/src/service/base.ts b/src/service/base.ts index 3b05c7f..36ca4e8 100644 --- a/src/service/base.ts +++ b/src/service/base.ts @@ -1,11 +1,11 @@ import store from "@/store"; +import Config from "@/util/config"; import axios, { AxiosResponse } from "axios"; // 添加请求拦截器 -// axios.defaults.headers.common["CommonType"] = "shouka"; axios.defaults.headers.common["Content-Type"] = "application/json; charset=utf8"; axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest"; axios.interceptors.request.use((config) => { - config.baseURL = "http://127.0.0.1:12214/v1/"; + config.baseURL = `${Config.baseUrl}v1/`; config.timeout = 5000; let token = window.localStorage.getItem("token") config.headers.Authorization = token ?? "1" @@ -18,6 +18,7 @@ axios.interceptors.request.use((config) => { // 添加响应拦截器 axios.interceptors.response.use((res: AxiosResponse) => { if (res.data.status === 401) { + console.log("res.data.status",res.data.status); store.usrStore.openLoginDilog() store.usrStore.logOut() } diff --git a/src/store/archives.ts b/src/store/archives.ts index dedf065..2c61308 100644 --- a/src/store/archives.ts +++ b/src/store/archives.ts @@ -15,5 +15,5 @@ class ArchivesStore extends BaseStore { makeObservable(this, {}) } } -const archivesStore = new ArchivesStore() -export default archivesStore; +export const archivesStore = new ArchivesStore() + diff --git a/src/store/archives_category.ts b/src/store/archives_category.ts index 4faed96..9e8b3af 100644 --- a/src/store/archives_category.ts +++ b/src/store/archives_category.ts @@ -16,5 +16,5 @@ class ArchivesCategoryStore extends BaseStore { makeObservable(this, {}) } } -const acStore = new ArchivesCategoryStore() -export default acStore; +export const acStore = new ArchivesCategoryStore() + diff --git a/src/store/dep.ts b/src/store/dep.ts index 7d4a976..ff06be0 100644 --- a/src/store/dep.ts +++ b/src/store/dep.ts @@ -16,6 +16,5 @@ class DepStore extends BaseStore { } } -// eslint-disable-next-line import/no-anonymous-default-export -export default new DepStore(); +export const depStore = new DepStore(); \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index bed25ee..3ca9f61 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,9 +1,9 @@ import usrStore from '@/store/user' import tagStore from '@/store/tag' -import depStore from '@/store/dep' -import archivesStore from '@/store/archives' +import { depStore } from '@/store/dep' +import { archivesStore } from '@/store/archives' import folderStore from '@/store/folder'; -import acStore from '@/store/archives_category'; +import { acStore } from '@/store/archives_category'; const store = { usrStore, diff --git a/src/store/tag.ts b/src/store/tag.ts index 333f1d2..8bb7353 100644 --- a/src/store/tag.ts +++ b/src/store/tag.ts @@ -16,6 +16,6 @@ class TagStore extends BaseStore { } } -// eslint-disable-next-line import/no-anonymous-default-export -export default new TagStore(); +export const tagStore = new TagStore(); +export default tagStore; \ No newline at end of file diff --git a/src/store/user.ts b/src/store/user.ts index d79bb33..3589517 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -43,9 +43,14 @@ class UserStore extends BaseStore { password: params.passWord, genre: 1 } - let data =await baseHttp.post(UserConfig.LOGINURI, param) - window.localStorage.setItem("token", data.data.token ?? ""); - this.closeLoginDilog() + try { + let data = await baseHttp.post(UserConfig.LOGINURI, param) + window.localStorage.setItem("token", data.data.token ?? ""); + return true + } catch (error) { + console.log(error) + return false + } } openLoginDilog() { this.isNeedLogin = true; diff --git a/src/util/config.ts b/src/util/config.ts new file mode 100644 index 0000000..8cbfc15 --- /dev/null +++ b/src/util/config.ts @@ -0,0 +1,5 @@ +class Config { + static baseUrl = "http://127.0.0.1:12214/"; + static uploadUrl = "http://127.0.0.1:12214/"; +} +export default Config; \ No newline at end of file