Hooks-Admin
🚀🚀🚀 Hooks Admin,基于 React18、React-Router V6、React-Hooks、Redux、TypeScript、Vite2、Ant-Design 开源的一套后台管理框架。
Top Related Projects
👨🏻💻👩🏻💻 Use Ant Design like a Pro!
:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
Vue 2.0 admin management system template based on iView
🎉 vue admin,vue3 admin,vue3.0 admin,vue后台管理,vue-admin,vue3.0-admin,admin,vue-admin,vue-element-admin,ant-design,vab admin pro,vab admin plus,vue admin plus,vue admin pro
A framework in react community ✨
Quick Overview
Hooks-Admin is a modern React-based admin template built with TypeScript, Vite, and Ant Design. It offers a clean, responsive interface with various pre-built components and features, making it an excellent starting point for developing admin panels and dashboards.
Pros
- Built with modern technologies (React, TypeScript, Vite) for improved performance and developer experience
- Comprehensive set of pre-built components and layouts for rapid development
- Responsive design that works well on various screen sizes
- Includes dark mode and internationalization support out of the box
Cons
- Limited documentation, which may make it challenging for beginners to get started
- Heavily reliant on Ant Design, which might not suit projects requiring a more custom design
- Some components and features may be overkill for simpler admin panel needs
Code Examples
- Using the ProTable component:
import { ProTable } from "@/components/ProTable";
const UserList = () => {
return (
<ProTable
columns={[
{ title: "Name", dataIndex: "name" },
{ title: "Email", dataIndex: "email" },
]}
request={async (params) => {
// Fetch data from API
const response = await fetchUsers(params);
return {
data: response.data,
success: response.success,
total: response.total,
};
}}
/>
);
};
- Implementing a custom hook for data fetching:
import { useState, useEffect } from "react";
import { message } from "antd";
const useApiData = (apiFunction) => {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchData = async () => {
try {
const result = await apiFunction();
setData(result);
} catch (error) {
message.error("Failed to fetch data");
} finally {
setLoading(false);
}
};
fetchData();
}, [apiFunction]);
return { data, loading };
};
- Using the AuthButton component for role-based access control:
import { AuthButton } from "@/components/AuthButton";
const AdminPanel = () => {
return (
<div>
<h1>Admin Panel</h1>
<AuthButton auth="user:add">
<button>Add User</button>
</AuthButton>
<AuthButton auth="user:delete">
<button>Delete User</button>
</AuthButton>
</div>
);
};
Getting Started
-
Clone the repository:
git clone https://github.com/HalseySpicy/Hooks-Admin.git
-
Install dependencies:
cd Hooks-Admin npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
to see the admin template in action.
Competitor Comparisons
👨🏻💻👩🏻💻 Use Ant Design like a Pro!
Pros of Ant Design Pro
- More comprehensive and feature-rich, offering a complete enterprise-level React solution
- Larger community and ecosystem, with extensive documentation and support
- Provides a wide range of pre-built components and templates for rapid development
Cons of Ant Design Pro
- Steeper learning curve due to its complexity and extensive features
- Heavier and potentially slower performance compared to lighter alternatives
- Less flexibility for customization without extensive configuration
Code Comparison
Ant Design Pro (TypeScript):
import { PageContainer } from '@ant-design/pro-components';
import { Card, Alert, Typography } from 'antd';
import styles from './Welcome.module.less';
const Welcome: React.FC = () => {
return (
<PageContainer>
<Card>
<Alert
message="Faster and stronger heavy-duty components have been released."
type="success"
showIcon
banner
style={{
margin: -12,
marginBottom: 24,
}}
/>
<Typography.Text strong>
<a
href="https://procomponents.ant.design/components/table"
rel="noopener noreferrer"
target="__blank"
>
Welcome
</a>
</Typography.Text>
</Card>
</PageContainer>
);
};
export default Welcome;
Hooks-Admin (JavaScript):
import { useEffect } from "react";
import { Layout } from "antd";
import { setAuthButtons } from "@/redux/modules/auth/action";
import { updateCollapse } from "@/redux/modules/menu/action";
import { connect } from "react-redux";
import LayoutMenu from "./components/Menu";
import LayoutHeader from "./components/Header";
import LayoutTabs from "./components/Tabs";
import LayoutFooter from "./components/Footer";
import "./index.less";
const LayoutIndex = (props) => {
const { Sider, Content } = Layout;
const { isCollapse, updateCollapse, setAuthButtons } = props;
// 获取按钮权限列表
useEffect(() => {
setAuthButtons();
}, []);
return (
// Layout code...
);
};
const mapStateToProps = (state) => state.menu;
const mapDispatchToProps = { setAuthButtons, updateCollapse };
export default connect(mapStateToProps, mapDispatchToProps)(LayoutIndex);
:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
Pros of vue-element-admin
- More mature and widely adopted project with a larger community
- Extensive documentation and examples available
- Comprehensive set of pre-built components and layouts
Cons of vue-element-admin
- Based on Vue 2, which may be considered outdated for new projects
- Steeper learning curve due to its complexity and extensive features
- Heavier bundle size due to the inclusion of many features
Code Comparison
vue-element-admin (Vue 2):
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export const constantRoutes = [
{
path: '/login',
component: () => import('@/views/login/index'),
hidden: true
}
]
Hooks-Admin (React with TypeScript):
import { lazy } from "react";
import { RouteObject } from "@/routers/interface";
const Login = lazy(() => import("@/views/login/index"));
const loginRouter: Array<RouteObject> = [
{
path: "/login",
element: <Login />,
meta: {
requiresAuth: false,
title: "登录页",
key: "login"
}
}
];
The code comparison shows the difference in routing setup between the two projects. vue-element-admin uses Vue Router with Vue 2 syntax, while Hooks-Admin utilizes React Router with TypeScript and lazy loading for components.
A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
Pros of vue-vben-admin
- More comprehensive documentation and examples
- Larger community and more frequent updates
- Built-in internationalization support
Cons of vue-vben-admin
- Steeper learning curve due to its complexity
- Heavier bundle size, which may impact initial load times
- More opinionated structure, potentially limiting flexibility
Code Comparison
vue-vben-admin:
<template>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleCreate">Create</a-button>
</template>
</BasicTable>
</template>
Hooks-Admin:
<ProTable
columns={columns}
request={getTableList}
rowKey="id"
pagination={{
pageSize: 10
}}
toolBarRender={() => [
<Button key="button" icon={<PlusOutlined />} type="primary">
New
</Button>
]}
/>
Both projects offer robust admin templates, but vue-vben-admin provides a more feature-rich environment with better documentation and community support. However, this comes at the cost of increased complexity and potentially slower initial load times. Hooks-Admin, while less comprehensive, offers a simpler and more flexible approach that may be preferable for smaller projects or developers who prioritize customization.
Vue 2.0 admin management system template based on iView
Pros of iview-admin
- More mature and established project with a larger community
- Comprehensive documentation and examples
- Built-in support for internationalization (i18n)
Cons of iview-admin
- Based on older Vue 2 technology
- Less frequent updates and maintenance
- Heavier and potentially slower performance due to older architecture
Code Comparison
iview-admin (Vue 2):
<template>
<div>
<Table :columns="columns" :data="data"></Table>
</div>
</template>
<script>
export default {
data() {
return {
columns: [...],
data: [...]
}
}
}
</script>
Hooks-Admin (React with Hooks):
import React from 'react';
import { Table } from 'antd';
const MyTable = () => {
const columns = [...];
const data = [...];
return <Table columns={columns} dataSource={data} />;
};
export default MyTable;
The code comparison highlights the difference in syntax and structure between Vue 2 (used in iview-admin) and React with Hooks (used in Hooks-Admin). iview-admin uses Vue's template syntax and options API, while Hooks-Admin leverages React's functional components and hooks for a more modern and concise approach.
🎉 vue admin,vue3 admin,vue3.0 admin,vue后台管理,vue-admin,vue3.0-admin,admin,vue-admin,vue-element-admin,ant-design,vab admin pro,vab admin plus,vue admin plus,vue admin pro
Pros of vue-admin-better
- More comprehensive documentation and examples
- Larger community and more frequent updates
- Includes built-in internationalization support
Cons of vue-admin-better
- Steeper learning curve due to more complex architecture
- Heavier bundle size, potentially impacting performance
- Less flexibility for customization compared to Hooks-Admin
Code Comparison
vue-admin-better:
<template>
<el-config-provider :locale="locale">
<router-view />
</el-config-provider>
</template>
Hooks-Admin:
const App: React.FC = () => {
return (
<BrowserRouter>
<AuthRouter>
<Router />
</AuthRouter>
</BrowserRouter>
);
};
vue-admin-better uses Vue.js with Element Plus components, while Hooks-Admin is built with React and custom components. The vue-admin-better example shows the use of internationalization, while Hooks-Admin focuses on routing and authentication.
Both projects aim to provide admin dashboard templates, but they differ in their approach and technology stack. vue-admin-better offers a more feature-rich solution out of the box, while Hooks-Admin provides a simpler, more customizable foundation for building admin interfaces.
A framework in react community ✨
Pros of umi
- More comprehensive framework with built-in routing, state management, and plugins
- Larger community and ecosystem, with extensive documentation and examples
- Better performance optimization and code splitting capabilities
Cons of umi
- Steeper learning curve due to its extensive feature set
- Less flexibility for custom configurations compared to Hooks-Admin
- Potentially overkill for smaller projects or simple admin interfaces
Code Comparison
umi routing configuration:
export default {
routes: [
{ path: '/', component: '@/pages/index' },
{ path: '/users', component: '@/pages/users' },
],
};
Hooks-Admin routing configuration:
const routes = [
{ path: '/', element: <Home /> },
{ path: '/users', element: <Users /> },
];
Both repositories provide React-based admin interfaces, but umi offers a more comprehensive framework with additional features and optimizations. Hooks-Admin, on the other hand, provides a simpler and more flexible approach, which may be preferable for developers who want more control over their project structure and dependencies. The choice between the two depends on the specific requirements of the project and the developer's preferences regarding framework complexity and customization options.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Hooks-Admin ð
ä»ç» ð
ððð Hooks Adminï¼åºäº React18ãReact-Router v6ãReact-HooksãRedux && Redux-ToolkitãTypeScriptãVite2ãAnt-Design å¼æºçä¸å¥åå°ç®¡çæ¡æ¶ã
ð Redux-Toolkit çæ¬è¯·åæ¢å° Redux-Toolkit åæ¯ä¸
项ç®ç¸å ³ææ¡£ ð
- 项ç®æ´æ°æ¥å¿ï¼CHANGELOG.md
Pro ä»è´¹çæ¬ ð¥
-
æéè¦è¯·å åºé¨å¾®ä¿¡äºè§£ãè´ä¹°
-
Linkï¼https://pro.spicyboy.cn
ä¸ãå¨çº¿é¢è§å°å ð
- Linkï¼https://hooks.spicyboy.cn
äºãGit ä»åºå°å (æ¬¢è¿ Starâ)
ä¸ãð¨ð¨ð¨ 项ç®åè½
- ð éç¨ææ°ææ¯æ¾å¼åï¼React18ãReact-Router v6ãReact-HooksãTypeScriptãVite2
- ð éç¨ Vite2 ä½ä¸ºé¡¹ç®å¼åãæå å·¥å ·ï¼é ç½®äº Gzip æå ãè·¨å代çãæå é¢è§å·¥å ·â¦ï¼
- ð æ´ä¸ªé¡¹ç®éæäº TypeScript ï¼å®å ¨æ¯ä¸ºäºæ³å¦ä¹ ð¤£ï¼
- ð ä½¿ç¨ redux åç¶æ管çï¼éæ immerãreact-reduxãredux-persist å¼å
- ð éæäºä¸¤å¥ç¶æ管çï¼master åæ¯ä½¿ç¨çæ¯ redux || redux-toolkit åæ¯ä½¿ç¨çæ¯ redux-toolkit
- ð ä½¿ç¨ TypeScript 对 Axios äºæ¬¡å°è£ ï¼é误æ¦æªã常ç¨è¯·æ±å°è£ ãå ¨å±è¯·æ± Loadingãåæ¶éå¤è¯·æ±â¦ï¼
- ð æ¯æ Antd ç»ä»¶å¤§å°åæ¢ãæé» && ç°è² && è²å¼±æ¨¡å¼ãi18n å½é åï¼i18n ææ¶æ²¡é ç½®æææ件ï¼
- ð ä½¿ç¨ èªå®ä¹é«é¶ç»ä»¶ è¿è¡è·¯ç±æéæ¦æªï¼403 页é¢ï¼ã页é¢æé®æéé ç½®
- ð æ¯æ React-Router v6 è·¯ç±æå è½½é ç½®ãèåæé£ç´æ¨¡å¼ãæ é级èåãå¤æ ç¾é¡µãé¢å å±å¯¼èª
- ð ä½¿ç¨ Prettier ç»ä¸æ ¼å¼å代ç ï¼éæ EslintãStylelint 代ç æ ¡éªè§èï¼é¡¹ç®è§èé ç½®ï¼
- ð ä½¿ç¨ huskyãlint-stagedãcommitlintãcommitizenãcz-git è§èæ交信æ¯ï¼é¡¹ç®è§èé ç½®ï¼
åãå®è£ 使ç¨æ¥éª¤ ð
- Cloneï¼
# Gitee
git clone https://gitee.com/HalseySpicy/Hooks-Admin.git
# GitHub
git clone https://github.com/HalseySpicy/Hooks-Admin.git
- Installï¼
npm install
cnpm install
# npm install å®è£
失败ï¼è¯·å级 nodejs å° 16 以ä¸ï¼æå°è¯ä½¿ç¨ä»¥ä¸å½ä»¤ï¼
npm install --registry=https://registry.npm.taobao.org
- Runï¼
npm run dev
npm run serve
- Buildï¼
# å¼åç¯å¢
npm run build:dev
# æµè¯ç¯å¢
npm run build:test
# ç产ç¯å¢
npm run build:pro
- Lintï¼
# eslint æ£æµä»£ç
npm run lint:eslint
# prettier æ ¼å¼å代ç
npm run lint:prettier
# stylelint æ ¼å¼åæ ·å¼
lint:stylelint
- commitï¼
# æ交代ç ï¼ä¼èªå¨æ§è¡ lint:lint-staged å½ä»¤ï¼
npm run commit
äºã项ç®æªå¾
1ãç»å½é¡µï¼
2ãé¦é¡µï¼
å ãæ件èµæºç®å½ ð
Hooks-Admin
ââ .vscode # vscodeæ¨èé
ç½®
ââ public # éæèµæºæ件ï¼å¿½ç¥æå
ï¼
ââ src
â ââ api # API æ¥å£ç®¡ç
â ââ assets # éæèµæºæ件
â ââ components # å
¨å±ç»ä»¶
â ââ config # å
¨å±é
置项
â ââ enums # 项ç®æ举
â ââ hooks # å¸¸ç¨ Hooks
â ââ language # è¯è¨å½é
å
â ââ layouts # æ¡æ¶å¸å±
â ââ routers # è·¯ç±ç®¡ç
â ââ redux # redux store
â ââ styles # å
¨å±æ ·å¼
â ââ typings # å
¨å± ts 声æ
â ââ utils # å·¥å
ጼ
â ââ views # 项ç®ææ页é¢
â ââ App.tsx # å
¥å£é¡µé¢
â ââ main.tsx # å
¥å£æ件
â ââ env.d.ts # vite 声ææ件
ââ .editorconfig # ç¼è¾å¨é
ç½®ï¼æ ¼å¼åï¼
ââ .env # vite 常ç¨é
ç½®
ââ .env.development # å¼åç¯å¢é
ç½®
ââ .env.production # ç产ç¯å¢é
ç½®
ââ .env.test # æµè¯ç¯å¢é
ç½®
ââ .eslintignore # å¿½ç¥ Eslint æ ¡éª
ââ .eslintrc.js # Eslint æ ¡éªé
ç½®
ââ .gitignore # git æ交忽ç¥
ââ .prettierignore # å¿½ç¥ prettier æ ¼å¼å
ââ .prettierrc.js # prettier é
ç½®
ââ .stylelintignore # å¿½ç¥ stylelint æ ¼å¼å
ââ .stylelintrc.js # stylelint æ ·å¼æ ¼å¼åé
ç½®
ââ CHANGELOG.md # 项ç®æ´æ°æ¥å¿
ââ commitlint.config.js # git æ交è§èé
ç½®
ââ index.html # å
¥å£ html
ââ LICENSE # å¼æºåè®®æ件
ââ lint-staged.config # lint-staged é
ç½®æ件
ââ package-lock.json # ä¾èµå
å
çæ¬é
ââ package.json # ä¾èµå
管ç
ââ postcss.config.js # postcss é
ç½®
ââ README.md # README ä»ç»
ââ tsconfig.json # typescript å
¨å±é
ç½®
ââ vite.config.ts # vite é
ç½®
ä¸ãæµè§å¨æ¯æ
- æ¬å°å¼åæ¨èä½¿ç¨ Chrome ææ°çæµè§å¨ Downloadã
- ç产ç¯å¢æ¯æç°ä»£æµè§å¨ï¼ä¸å¨æ¯æ IE æµè§å¨ï¼æ´å¤æµè§å¨å¯ä»¥æ¥ç Can I Use Es Moduleã
not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
å «ã项ç®åå°æ¥å£ ð§©
项ç®åå°æ¥å£å®å ¨éç¨ Mock æ°æ®ï¼æè°¢ä»¥ä¸ Mock å¹³å°æ¯æï¼
- FastMockï¼ https://www.fastmock.site/
- EasyMockï¼https://mock.mengxuegu.com/
ä¹ã微信交æµç¾¤
å¾®ä¿¡ç¾¤å·²è¶ è¿ 200 人ï¼éè¦å æ好åï¼æ大家è¿ç¾¤ ð¤ª
微信äºç»´ç |
---|
åãæèµ ðµ
å¦æä½ æ£å¨ä½¿ç¨è¿ä¸ªé¡¹ç®æè å欢è¿ä¸ªé¡¹ç®çï¼å¯ä»¥éè¿ä»¥ä¸æ¹å¼æ¯ææï¼
- StarãForkãWatch ä¸é®ä¸è¿ ð
- éè¿å¾®ä¿¡ãæ¯ä»å®ä¸æ¬¡æ§æ款 â¤
微信 | æ¯ä»å® |
---|---|
Top Related Projects
👨🏻💻👩🏻💻 Use Ant Design like a Pro!
:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin
A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
Vue 2.0 admin management system template based on iView
🎉 vue admin,vue3 admin,vue3.0 admin,vue后台管理,vue-admin,vue3.0-admin,admin,vue-admin,vue-element-admin,ant-design,vab admin pro,vab admin plus,vue admin plus,vue admin pro
A framework in react community ✨
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot