From 6c8c6088d186c77f561a2d55ec3cdd90f6b17389 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Fri, 5 Jan 2024 13:51:38 +0800 Subject: [PATCH] Optimize file name --- .../SidebarFooter.tsx => Sidebar/Footer.tsx} | 4 +- .../SidebarItem.tsx => Sidebar/Item.tsx} | 10 +- src/components/common/Sidebar/ItemList.tsx | 7 ++ .../SidebarScroll.tsx => Sidebar/Scroll.tsx} | 4 +- .../Separate.tsx} | 4 +- .../Submenu.tsx} | 4 +- .../common/{sidebar_ => Sidebar}/index.tsx | 30 ++++-- .../common/sidebar_/SidebarItemList.tsx | 7 -- src/pages/{sign_ => Sign}/Forget.tsx | 0 src/pages/{sign_ => Sign}/SignIn.tsx | 0 src/pages/{sign_ => Sign}/SignUp.tsx | 0 src/pages/{sign_ => Sign}/Verify.tsx | 0 src/pages/{sign_ => Sign}/index.tsx | 8 +- src/pages/{system_ => System}/Group.tsx | 0 src/pages/{system_ => System}/Log.tsx | 0 src/pages/{system_ => System}/Role.tsx | 0 .../Settings/Base.tsx} | 6 +- .../Settings/Mail.tsx} | 6 +- .../Settings/SensitiveWord.tsx} | 6 +- .../settings_ => System/Settings}/index.tsx | 12 +-- .../Statistics}/ActiveInfo.tsx | 4 +- .../Statistics}/CPUInfo.tsx | 4 +- .../Statistics}/HardwareInfo.tsx | 2 +- .../Statistics}/OnlineInfo.tsx | 4 +- .../Statistics}/SoftwareInfo.tsx | 2 +- .../Statistics}/StorageInfo.tsx | 4 +- .../Statistics}/index.tsx | 12 +-- .../Statistics}/shared.ts | 0 src/pages/{system_ => System}/User.tsx | 0 src/pages/{system_ => System}/index.tsx | 0 src/pages/SystemFramework.tsx | 10 +- src/pages/{tools_ => Tools}/All.tsx | 0 src/pages/{tools_ => Tools}/Translation.tsx | 0 src/pages/{tools_ => Tools}/index.tsx | 0 src/pages/ToolsFramework.tsx | 31 +++--- src/pages/{user_ => User}/index.tsx | 0 src/pages/UserFramework.tsx | 22 ++-- src/router/index.tsx | 2 +- src/router/system.tsx | 28 ++--- src/router/tools.tsx | 102 +++++++++--------- src/router/user.tsx | 4 +- 41 files changed, 177 insertions(+), 162 deletions(-) rename src/components/common/{sidebar_/SidebarFooter.tsx => Sidebar/Footer.tsx} (97%) rename src/components/common/{sidebar_/SidebarItem.tsx => Sidebar/Item.tsx} (87%) create mode 100644 src/components/common/Sidebar/ItemList.tsx rename src/components/common/{sidebar_/SidebarScroll.tsx => Sidebar/Scroll.tsx} (86%) rename src/components/common/{sidebar_/SidebarSeparate.tsx => Sidebar/Separate.tsx} (78%) rename src/components/common/{sidebar_/SidebarSubmenu.tsx => Sidebar/Submenu.tsx} (80%) rename src/components/common/{sidebar_ => Sidebar}/index.tsx (62%) delete mode 100644 src/components/common/sidebar_/SidebarItemList.tsx rename src/pages/{sign_ => Sign}/Forget.tsx (100%) rename src/pages/{sign_ => Sign}/SignIn.tsx (100%) rename src/pages/{sign_ => Sign}/SignUp.tsx (100%) rename src/pages/{sign_ => Sign}/Verify.tsx (100%) rename src/pages/{sign_ => Sign}/index.tsx (93%) rename src/pages/{system_ => System}/Group.tsx (100%) rename src/pages/{system_ => System}/Log.tsx (100%) rename src/pages/{system_ => System}/Role.tsx (100%) rename src/pages/{system_/settings_/BaseSettings.tsx => System/Settings/Base.tsx} (95%) rename src/pages/{system_/settings_/MailSettings.tsx => System/Settings/Mail.tsx} (97%) rename src/pages/{system_/settings_/SensitiveWordSettings.tsx => System/Settings/SensitiveWord.tsx} (97%) rename src/pages/{system_/settings_ => System/Settings}/index.tsx (88%) rename src/pages/{system_/statistics_ => System/Statistics}/ActiveInfo.tsx (98%) rename src/pages/{system_/statistics_ => System/Statistics}/CPUInfo.tsx (98%) rename src/pages/{system_/statistics_ => System/Statistics}/HardwareInfo.tsx (97%) rename src/pages/{system_/statistics_ => System/Statistics}/OnlineInfo.tsx (98%) rename src/pages/{system_/statistics_ => System/Statistics}/SoftwareInfo.tsx (98%) rename src/pages/{system_/statistics_ => System/Statistics}/StorageInfo.tsx (98%) rename src/pages/{system_/statistics_ => System/Statistics}/index.tsx (86%) rename src/pages/{system_/statistics_ => System/Statistics}/shared.ts (100%) rename src/pages/{system_ => System}/User.tsx (100%) rename src/pages/{system_ => System}/index.tsx (100%) rename src/pages/{tools_ => Tools}/All.tsx (100%) rename src/pages/{tools_ => Tools}/Translation.tsx (100%) rename src/pages/{tools_ => Tools}/index.tsx (100%) rename src/pages/{user_ => User}/index.tsx (100%) diff --git a/src/components/common/sidebar_/SidebarFooter.tsx b/src/components/common/Sidebar/Footer.tsx similarity index 97% rename from src/components/common/sidebar_/SidebarFooter.tsx rename to src/components/common/Sidebar/Footer.tsx index 196686f..64e0901 100644 --- a/src/components/common/sidebar_/SidebarFooter.tsx +++ b/src/components/common/Sidebar/Footer.tsx @@ -6,7 +6,7 @@ import { useUpdatedEffect } from '@/util/hooks' import { getAvatar, getLoginStatus, getNickname, removeToken } from '@/util/auth' import { r_auth_logout } from '@/services/auth' -const SidebarFooter: React.FC = () => { +const Footer: React.FC = () => { const matches = useMatches() const lastMatch = matches.reduce((_, second) => second) const location = useLocation() @@ -94,4 +94,4 @@ const SidebarFooter: React.FC = () => { ) } -export default SidebarFooter +export default Footer diff --git a/src/components/common/sidebar_/SidebarItem.tsx b/src/components/common/Sidebar/Item.tsx similarity index 87% rename from src/components/common/sidebar_/SidebarItem.tsx rename to src/components/common/Sidebar/Item.tsx index 6289ac2..87bd2ea 100644 --- a/src/components/common/sidebar_/SidebarItem.tsx +++ b/src/components/common/Sidebar/Item.tsx @@ -1,6 +1,6 @@ import React from 'react' import Icon from '@ant-design/icons' -import SidebarSubmenu from '@/components/common/sidebar_/SidebarSubmenu' +import Submenu from '@/components/common/Sidebar/Submenu' type ItemProps = { icon?: IconComponent @@ -10,7 +10,7 @@ type ItemProps = { end?: boolean } -const SidebarItem: React.FC = (props) => { +const Item: React.FC = (props) => { const [submenuTop, setSubmenuTop] = useState(0) const [submenuLeft, setSubmenuLeft] = useState(0) @@ -50,12 +50,12 @@ const SidebarItem: React.FC = (props) => { {props.children ? ( - + {props.children} - + ) : undefined} ) } -export default SidebarItem +export default Item diff --git a/src/components/common/Sidebar/ItemList.tsx b/src/components/common/Sidebar/ItemList.tsx new file mode 100644 index 0000000..661e94d --- /dev/null +++ b/src/components/common/Sidebar/ItemList.tsx @@ -0,0 +1,7 @@ +import React from 'react' + +const ItemList: React.FC = (props) => { + return
    {props.children}
+} + +export default ItemList diff --git a/src/components/common/sidebar_/SidebarScroll.tsx b/src/components/common/Sidebar/Scroll.tsx similarity index 86% rename from src/components/common/sidebar_/SidebarScroll.tsx rename to src/components/common/Sidebar/Scroll.tsx index 4a7c8d7..6fc0c1f 100644 --- a/src/components/common/sidebar_/SidebarScroll.tsx +++ b/src/components/common/Sidebar/Scroll.tsx @@ -5,7 +5,7 @@ export interface SidebarScrollElement { refreshLayout(): void } -const SidebarScroll = forwardRef((props, ref) => { +const Scroll = forwardRef((props, ref) => { useImperativeHandle(ref, () => { return { refreshLayout() { @@ -30,4 +30,4 @@ const SidebarScroll = forwardRef( ) }) -export default SidebarScroll +export default Scroll diff --git a/src/components/common/sidebar_/SidebarSeparate.tsx b/src/components/common/Sidebar/Separate.tsx similarity index 78% rename from src/components/common/sidebar_/SidebarSeparate.tsx rename to src/components/common/Sidebar/Separate.tsx index 84070ef..6e626e7 100644 --- a/src/components/common/sidebar_/SidebarSeparate.tsx +++ b/src/components/common/Sidebar/Separate.tsx @@ -1,9 +1,9 @@ import React from 'react' -const SidebarSeparate: React.FC< +const Separate: React.FC< React.DetailedHTMLProps, HTMLDivElement> > = ({ className, ...props }) => { return
} -export default SidebarSeparate +export default Separate diff --git a/src/components/common/sidebar_/SidebarSubmenu.tsx b/src/components/common/Sidebar/Submenu.tsx similarity index 80% rename from src/components/common/sidebar_/SidebarSubmenu.tsx rename to src/components/common/Sidebar/Submenu.tsx index ed2039b..6d7afdc 100644 --- a/src/components/common/sidebar_/SidebarSubmenu.tsx +++ b/src/components/common/Sidebar/Submenu.tsx @@ -5,7 +5,7 @@ interface SidebarSubmenuProps extends React.PropsWithChildren { submenuLeft: number } -const SidebarSubmenu: React.FC = (props) => { +const Submenu: React.FC = (props) => { return (
    = (props) => { ) } -export default SidebarSubmenu +export default Submenu diff --git a/src/components/common/sidebar_/index.tsx b/src/components/common/Sidebar/index.tsx similarity index 62% rename from src/components/common/sidebar_/index.tsx rename to src/components/common/Sidebar/index.tsx index 96e3a90..f12716b 100644 --- a/src/components/common/sidebar_/index.tsx +++ b/src/components/common/Sidebar/index.tsx @@ -2,8 +2,12 @@ import React from 'react' import Icon from '@ant-design/icons' import '@/assets/css/components/common/sidebar.scss' import { getLocalStorage, setLocalStorage } from '@/util/browser' -import SidebarSeparate from '@/components/common/sidebar_/SidebarSeparate' -import SidebarFooter from '@/components/common/sidebar_/SidebarFooter' +import Item from '@/components/common/Sidebar/Item' +import ItemList from '@/components/common/Sidebar/ItemList' +import Scroll from '@/components/common/Sidebar/Scroll' +import Separate from '@/components/common/Sidebar/Separate' +import Submenu from '@/components/common/Sidebar/Submenu' +import Footer from '@/components/common/Sidebar/Footer' interface SidebarProps extends React.PropsWithChildren { title: string @@ -12,7 +16,14 @@ interface SidebarProps extends React.PropsWithChildren { bottomFixed?: React.ReactNode } -const Sidebar: React.FC = (props) => { +const Sidebar: React.FC & { + Item: typeof Item + ItemList: typeof ItemList + Scroll: typeof Scroll + Separate: typeof Separate + Submenu: typeof Submenu + Footer: typeof Footer +} = (props) => { const [hideSidebar, setHideSidebar] = useState(getLocalStorage('HIDE_SIDEBAR') === 'true') const switchSidebar = () => { @@ -33,16 +44,23 @@ const Sidebar: React.FC = (props) => { {props.title}
- +
{props.children}
{props.bottomFixed}
- - + +