Convert Figma logo to code with AI

HalseySpicy logoHooks-Admin

🚀🚀🚀 Hooks Admin,基于 React18、React-Router V6、React-Hooks、Redux、TypeScript、Vite2、Ant-Design 开源的一套后台管理框架。

1,755
400
1,755
21

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

15,336

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

  1. 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,
        };
      }}
    />
  );
};
  1. 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 };
};
  1. 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

  1. Clone the repository:

    git clone https://github.com/HalseySpicy/Hooks-Admin.git
    
  2. Install dependencies:

    cd Hooks-Admin
    npm install
    
  3. Start the development server:

    npm run dev
    
  4. 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.

15,336

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Hooks-Admin 🚀

介绍 📖

🚀🚀🚀 Hooks Admin,基于 React18、React-Router v6、React-Hooks、Redux && Redux-Toolkit、TypeScript、Vite2、Ant-Design 开源的一套后台管理框架。

🌈 Redux-Toolkit 版本请切换到 Redux-Toolkit 分支上

项目相关文档 📚

Pro 付费版本 🔥

  • 有需要请加底部微信了解、购买

  • Link:https://pro.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、登录页:

hooks-login-light

hooks-login-dark

2、首页:

hooks-home-light

hooks-home-dark

六、文件资源目录 📚

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。
IEEdgeFirefoxChromeSafari
not supportlast 2 versionslast 2 versionslast 2 versionslast 2 versions

八、项目后台接口 🧩

项目后台接口完全采用 Mock 数据,感谢以下 Mock 平台支持:

九、微信交流群

微信群已超过 200 人,需要加我好友,拉大家进群 🤪

微信二维码

十、捐赠 🍵

如果你正在使用这个项目或者喜欢这个项目的,可以通过以下方式支持我:

  • Star、Fork、Watch 一键三连 🚀
  • 通过微信、支付宝一次性捐款 ❤
微信支付宝
Alipay QRcodeWechat QRcode