cool-admin-midway
🔥 cool-admin(midway版)一个很酷的后台权限管理框架,Ai编码、流程编排、模块化、插件化、CRUD极速开发,永久开源免费,基于midway.js 3.x、typescript、typeorm、mysql、jwt、vue3、vite、element-ui等构建
Top Related Projects
🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
The API and real-time application framework
Quick Overview
Cool Admin Midway is a comprehensive admin platform based on Node.js Midway.js, Vue.js, and Element Plus. It provides a robust backend management system with features like RBAC permissions, code generation, and a flexible plugin system. The project aims to simplify the development of admin interfaces for various applications.
Pros
- Comprehensive solution combining backend (Midway.js) and frontend (Vue.js) technologies
- Modular architecture with a plugin system for easy customization and extension
- Built-in RBAC (Role-Based Access Control) for fine-grained permission management
- Code generation tools to speed up development process
Cons
- Steep learning curve due to the integration of multiple technologies
- Limited documentation in English, which may pose challenges for non-Chinese speakers
- Potential over-engineering for simpler projects that don't require all features
- Dependency on specific versions of frameworks may require careful management during updates
Code Examples
- Entity definition using TypeORM:
import { Entity, Column } from 'typeorm';
import { BaseEntity } from '@cool-midway/core';
@Entity('sys_user')
export class SysUserEntity extends BaseEntity {
@Column({ comment: 'Username' })
username: string;
@Column({ comment: 'Password' })
password: string;
}
- Controller example with decorators:
import { Provide, Controller, Get, Inject } from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { UserService } from '../service/user';
@Provide()
@Controller('/admin/sys/user')
@CoolController({
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
entity: SysUserEntity,
})
export class SysUserController extends BaseController {
@Inject()
userService: UserService;
@Get('/info')
async info() {
return this.ok(await this.userService.info());
}
}
- Service example:
import { Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
@Provide()
export class UserService extends BaseService {
async info() {
// Implement user info retrieval logic
return { /* user info */ };
}
}
Getting Started
-
Clone the repository:
git clone https://github.com/cool-team-official/cool-admin-midway.git
-
Install dependencies:
cd cool-admin-midway yarn install
-
Configure the database in
src/config/config.local.ts
-
Run the development server:
yarn dev
-
Access the admin panel at
http://localhost:8001
Competitor Comparisons
🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
Pros of Midway
- More comprehensive and mature framework with broader ecosystem support
- Better documentation and community resources
- Stronger TypeScript integration and decorators support
Cons of Midway
- Steeper learning curve for beginners
- Less opinionated, requiring more configuration for complex setups
- May be overkill for smaller projects or simple APIs
Code Comparison
Midway:
import { Provide, Inject, Controller, Get } from '@midwayjs/decorator';
@Provide()
@Controller('/api')
export class APIController {
@Inject()
ctx: Context;
@Get('/data')
async getData() {
return { success: true, data: 'Hello from Midway' };
}
}
Cool Admin Midway:
import { Provide, Controller, Get } from '@cool-midway/core';
@Provide()
@Controller('/api')
export class APIController {
@Get('/data')
async getData() {
return this.ok('Hello from Cool Admin Midway');
}
}
The code comparison shows that while both frameworks use similar decorators, Cool Admin Midway provides a more streamlined approach with built-in response helpers like this.ok()
. Midway offers more flexibility but requires more boilerplate code for context handling and response formatting.
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
Pros of Nest
- More mature and widely adopted framework with a larger community
- Extensive documentation and ecosystem of plugins/modules
- Built-in support for TypeScript and decorators
Cons of Nest
- Steeper learning curve for developers new to TypeScript or decorators
- Can be overkill for smaller projects or microservices
- Opinionated architecture may not suit all project structures
Code Comparison
Nest:
@Controller('cats')
export class CatsController {
@Get()
findAll(): string {
return 'This action returns all cats';
}
}
Cool Admin Midway:
@Provide()
@Controller('/api/admin/sys/user')
export class SysUserController {
@Inject()
sysUserService: SysUserService;
@Get('/page')
async page(@Query(ALL) query) {
return this.sysUserService.page(query);
}
}
Key Differences
- Nest uses a more Angular-like approach with decorators
- Cool Admin Midway is built on top of Midway.js, which is based on Egg.js
- Nest has a more modular structure, while Cool Admin Midway focuses on admin panel functionality
- Cool Admin Midway provides more out-of-the-box features for admin systems
Conclusion
Nest is a versatile framework suitable for various applications, while Cool Admin Midway is more specialized for admin panel development. Choose based on your project requirements and team expertise.
🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
Pros of egg
- More mature and established framework with a larger community
- Extensive plugin ecosystem for easy extensibility
- Built-in security features and best practices
Cons of egg
- Steeper learning curve for beginners
- Less opinionated, requiring more configuration
- May be overkill for smaller projects
Code Comparison
egg:
// app/controller/home.js
const Controller = require('egg').Controller;
class HomeController extends Controller {
async index() {
this.ctx.body = 'Hello World';
}
}
cool-admin-midway:
// src/controller/home.ts
import { Provide, Controller, Get } from '@midwayjs/decorator';
@Provide()
@Controller('/')
export class HomeController {
@Get('/')
async home() {
return 'Hello World';
}
}
Both frameworks use a similar controller-based structure, but cool-admin-midway leverages TypeScript and decorators for a more modern approach. egg uses a more traditional class-based structure with less syntactic sugar.
egg is generally more flexible and customizable, while cool-admin-midway provides a more opinionated and streamlined development experience. The choice between the two depends on project requirements, team preferences, and the desired level of control over the application structure.
ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Pros of TypeORM
- More mature and widely adopted ORM with extensive documentation
- Supports multiple database systems, offering greater flexibility
- Active community and frequent updates
Cons of TypeORM
- Steeper learning curve for beginners
- Can be overkill for smaller projects or simple database operations
- Performance may be slower compared to raw SQL queries in some cases
Code Comparison
TypeORM:
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number
@Column()
firstName: string
}
Cool Admin Midway:
import { EntityModel } from '@midwayjs/orm';
import { PrimaryGeneratedColumn, Column } from 'typeorm';
@EntityModel()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstName: string;
}
Both repositories use TypeORM as the underlying ORM, but Cool Admin Midway is built on top of the Midway framework, providing additional features and abstractions. TypeORM offers more flexibility and direct control over database operations, while Cool Admin Midway provides a more opinionated structure and additional built-in functionalities for rapid development of admin systems.
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
Pros of Prisma
- More mature and widely adopted ORM with extensive documentation
- Supports multiple databases (PostgreSQL, MySQL, SQLite, etc.)
- Type-safe database access with auto-generated TypeScript types
Cons of Prisma
- Steeper learning curve for developers new to ORM concepts
- Less flexibility in complex database operations compared to raw SQL
- Requires additional setup and configuration for each project
Code Comparison
Prisma schema definition:
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}
Cool Admin Midway entity definition:
@EntityModel('user')
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ unique: true })
email: string;
@Column({ nullable: true })
name: string;
}
Both projects aim to simplify database operations, but Prisma offers a more comprehensive ORM solution with broader database support. Cool Admin Midway, on the other hand, provides a full-stack admin panel solution built on Midway.js, which may be more suitable for rapid development of admin interfaces. The choice between the two depends on the specific project requirements and the developer's familiarity with the respective ecosystems.
The API and real-time application framework
Pros of Feathers
- More mature and widely adopted framework with a larger community
- Supports real-time functionality out of the box
- Flexible and modular architecture allowing for easy customization
Cons of Feathers
- Steeper learning curve for developers new to its concepts
- Less opinionated, which may require more setup and configuration
- Limited built-in admin interface compared to Cool Admin Midway
Code Comparison
Feathers service creation:
const feathers = require('@feathersjs/feathers');
const app = feathers();
app.use('messages', {
async find() {
return [{ id: 1, text: 'Hello' }];
}
});
Cool Admin Midway controller:
import { Provide, Controller, Get } from '@midwayjs/decorator';
@Provide()
@Controller('/api/user')
export class UserController {
@Get('/')
async getUser() {
return { id: 1, name: 'John' };
}
}
Both frameworks offer different approaches to creating services or controllers. Feathers focuses on a service-based architecture, while Cool Admin Midway uses a more traditional controller-based approach with decorators.
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
cool-admin(midwayç)ä¸ä¸ªå¾é ·çåå°æé管çç³»ç»ï¼å¼æºå è´¹ï¼æ¨¡ååãæ件åãæéå¼åCRUDï¼æ¹ä¾¿å¿«éæ建è¿ä»£åå°ç®¡çç³»ç»ï¼æ¯æserverlessãdockerãæ®éæå¡å¨çå¤ç§æ¹å¼é¨ç½² å° å®ç½ è¿ä¸æ¥äºè§£ã
ç¹æ§
Aiæ¶ä»£ï¼å¾å¤èæ§çæ¡æ¶å·²ç»æ æ³æ»¡è¶³ç°ä»£åçå¼åéæ±ï¼Cool-Adminå¼åäºä¸ç³»åçåè½ï¼è®©å¼ååå¾æ´ç®åãæ´å¿«éãæ´é«æã
- Aiç¼ç ï¼éè¿å¾®è°å¤§æ¨¡åå¦ä¹ æ¡æ¶ç¹æåæ³ï¼å®ç°ç®ååè½ä»Apiæ¥å£å°å端页é¢çä¸é®çæ
- æµç¨ç¼æï¼éè¿ææ½ç¼ææ¹å¼ï¼å³å¯å®ç°ç±»ä¼¼åæºè½å®¢æè¿æ ·çåè½
- 模ååï¼ä»£ç æ¯æ¨¡ååçï¼æ¸ æ°æäºï¼æ¹ä¾¿ç»´æ¤
- æ件åï¼æ件åç设计ï¼å¯ä»¥éè¿å®è£ æ件çæ¹å¼æ©å±å¦ï¼æ¯ä»ãçä¿¡ãé®ä»¶çåè½
ææ¯æ
- å端ï¼**
node.js
midway.js
koa.js
typescript
** - å端ï¼**
vue.js
element-plus
jsx
pinia
vue-router
** - æ°æ®åºï¼**
mysql
postgresql
sqlite
**
å¦æä½ æ¯å端ï¼å端çè¿äºææ¯éåå¯¹ä½ æ¯ç¹å«å好çï¼å端å¼åè å¯ä»¥è¾å¿«éå°ä¸æã å¦æä½ æ¯å端ï¼Typescript çè¯æ³åè· javaãphp çç¹å«ç±»ä¼¼ï¼ä¸åçèµ·æ¥ä¹æ¯é£ä¹å¾çæã
å¦æä½ æ³ä½¿ç¨ java çæ¬å端ï¼è¯·ç§»æ¥cool-admin-java
å®ç½
è§é¢æç¨
æ¼ç¤º
- è´¦æ·ï¼admin
- å¯ç ï¼123456
项ç®å端
https://github.com/cool-team-official/cool-admin-vue
æ
https://gitee.com/cool-team-official/cool-admin-vue
æ
https://gitcode.com/cool_team/cool-admin-vue
微信群
è¿è¡
ä¿®æ¹æ°æ®åºé
ç½®ï¼é
ç½®æ件ä½äºsrc/config/config.local.ts
以 Mysql 为ä¾ï¼å ¶ä»æ°æ®åºè¯·åèæ°æ®åºé ç½®ææ¡£
Mysql(>=5.7çæ¬
)ï¼å»ºè®® 8.0ï¼node çæ¬(>=16.x
)ï¼å»ºè®® 18.xï¼é¦æ¬¡å¯å¨ä¼èªå¨åå§å并导å
¥æ°æ®
// mysqlï¼é©±å¨å·²ç»å
ç½®ï¼æ éå®è£
typeorm: {
dataSource: {
default: {
type: 'mysql',
host: '127.0.0.1',
port: 3306,
username: 'root',
password: '123456',
database: 'cool',
// èªå¨å»ºè¡¨ 注æï¼çº¿ä¸é¨ç½²çæ¶åä¸è¦ä½¿ç¨ï¼æå¯è½å¯¼è´æ°æ®ä¸¢å¤±
synchronize: true,
// æå°æ¥å¿
logging: false,
// å符é
charset: 'utf8mb4',
// æ¯å¦å¼å¯ç¼å
cache: true,
// å®ä½è·¯å¾
entities: ['**/modules/*/entity'],
},
},
},
å®è£ ä¾èµå¹¶è¿è¡
$ npm i
$ npm run dev
$ open http://localhost:8001/
æ³¨ï¼ npm i
å¦æå®è£
失败å¯ä»¥å°è¯ä½¿ç¨cnpmï¼æè
åæ¢æ¨çéåæºï¼æ¨è使ç¨pnpm
CURD(å¿«éå¢å æ¹æ¥)
大é¨åçåå°ç®¡çç³»ç»ï¼æè API æå¡é½æ¯å¯¹æ°æ®è¿è¡ç®¡çï¼æ以å¯ä»¥çå°å¤§éç CRUD åºæ¯(å¢å æ¹æ¥)ï¼cool-admin 对æ¤è¿è¡äºå¤§éå°å°è£ ï¼è®©è¿åçç¼ç éåå¾æå ¶å°å°ã
æ°å»ºä¸ä¸ªæ°æ®è¡¨
src/modules/demo/entity/goods.ts
ï¼é¡¹ç®å¯å¨æ°æ®åºä¼èªå¨å建该表ï¼æ éæå¨å建
import { BaseEntity } from '@cool-midway/core';
import { Column, Entity, Index } from 'typeorm';
/**
* åå
*/
@Entity('demo_app_goods')
export class DemoAppGoodsEntity extends BaseEntity {
@Column({ comment: 'æ é¢' })
title: string;
@Column({ comment: 'å¾ç' })
pic: string;
@Column({ comment: 'ä»·æ ¼', type: 'decimal', precision: 5, scale: 2 })
price: number;
}
ç¼å api æ¥å£
src/modules/demo/controller/app/goods.ts
ï¼å¿«éç¼å 6 个 api æ¥å£
import { CoolController, BaseController } from '@cool-midway/core';
import { DemoAppGoodsEntity } from '../../entity/goods';
/**
* åå
*/
@CoolController({
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
entity: DemoAppGoodsEntity,
})
export class DemoAppGoodsController extends BaseController {
/**
* å
¶ä»æ¥å£
*/
@Get('/other')
async other() {
return this.ok('hello, cool-admin!!!');
}
}
è¿æ ·æ们就å®æäº 6 个æ¥å£çç¼åï¼å¯¹åºçæ¥å£å¦ä¸ï¼
POST /app/demo/goods/add
æ°å¢POST /app/demo/goods/delete
å é¤POST /app/demo/goods/update
æ´æ°GET /app/demo/goods/info
å个信æ¯POST /app/demo/goods/list
å表信æ¯POST /app/demo/goods/page
å页æ¥è¯¢(å å«æ¨¡ç³æ¥è¯¢ãåæ®µå ¨å¹é ç)
é¨ç½²
å ç½®æ令
- 使ç¨
npm run lint
æ¥å代ç é£æ ¼æ£æ¥ã
ä½ä»·æå¡å¨
é¿éäºãè ¾è®¯äºãå为äºä½ä»·äºæå¡å¨ï¼ä¸éæ°è
Top Related Projects
🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
The API and real-time application framework
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