{"id":30141902,"url":"https://github.com/ethanz-code/cool-admin-midway","last_synced_at":"2025-09-03T07:40:10.859Z","repository":{"id":305312686,"uuid":"1022491148","full_name":"ethanz-code/cool-admin-midway","owner":"ethanz-code","description":"微调版本Cool Admin(Node版) 一个很酷的后台管理系统开发框架","archived":false,"fork":false,"pushed_at":"2025-07-19T09:45:07.000Z","size":3027,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T09:55:28.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethanz-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-19T07:23:42.000Z","updated_at":"2025-07-19T09:45:11.000Z","dependencies_parsed_at":"2025-07-19T15:16:38.391Z","dependency_job_id":"77e0f29b-92f4-49a0-87ae-0bb75d613ccd","html_url":"https://github.com/ethanz-code/cool-admin-midway","commit_stats":null,"previous_names":["ethanz-code/cool-admin-midway"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/ethanz-code/cool-admin-midway","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fcool-admin-midway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fcool-admin-midway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fcool-admin-midway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fcool-admin-midway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethanz-code","download_url":"https://codeload.github.com/ethanz-code/cool-admin-midway/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanz-code%2Fcool-admin-midway/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273410256,"owners_count":25100450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-11T05:20:29.780Z","updated_at":"2025-09-03T07:40:10.823Z","avatar_url":"https://github.com/ethanz-code.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://midwayjs.org/\" target=\"blank\"\u003e\u003cimg src=\"https://cool-show.oss-cn-shanghai.aliyuncs.com/admin/logo.png\" width=\"200\" alt=\"Midway Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003ecool-admin(nodejs版)一个很酷的后台权限管理系统，开源免费，Ai编码、流程编排、模块化、插件化、极速开发CRUD，方便快速构建迭代后台管理系统，支持原生、docker、普通服务器等多种方式部署\n到 \u003ca href=\"https://cool-js.com\" target=\"_blank\"\u003e官网\u003c/a\u003e 进一步了解。\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/cool-team-official/cool-admin-midway/blob/master/LICENSE\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-green?style=flat-square\" alt=\"GitHub license\" /\u003e\n    \u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/github/package-json/v/cool-team-official/cool-admin-midway?style=flat-square\" alt=\"GitHub tag\"\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/cool-team-official/cool-admin-midway?style=flat-square\" alt=\"GitHub tag\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 特性\n\nAi 时代，很多老旧的框架已经无法满足现代化的开发需求，Cool-Admin 开发了一系列的功能，让开发变得更简单、更快速、更高效。\n\n- **Ai 编码**：通过微调大模型学习框架特有写法，实现简单功能从 Api 接口到前端页面的一键生成[详情](https://node.cool-admin.com/src/guide/ai.html)\n- **流程编排**：通过拖拽编排方式，即可实现类似像智能客服这样的功能[详情](https://node.cool-admin.com/src/guide/flow.html)\n- **多租户**：支持多租户，采用全局动态注入查询条件[详情](https://node.cool-admin.com/src/guide/core/tenant.html)\n- **多语言**：基于大模型自动翻译，无需更改原有代码[详情](https://node.cool-admin.com/src/guide/core/i18n.html)\n- **原生打包**：打包成 exe 等安装包，打包完可以直接运行在 windows、mac、linux 等操作系统上[详情](https://node.cool-admin.com/src/guide/core/pkg.html)\n- **模块化**：代码是模块化的，清晰明了，方便维护\n- **插件化**：插件化的设计，可以通过安装插件的方式扩展如：支付、短信、邮件等功能\n- ......\n\n![](https://cool-show.oss-cn-shanghai.aliyuncs.com/admin/flow.png)\n\n## 演示\n\n[AI 极速编码](https://node.cool-admin.com/src/guide/ai.html)\n\n[https://show.cool-admin.com](https://show.cool-admin.com)\n\n- 账户：admin\n- 密码：123456\n\n\u003cimg src=\"https://cool-show.oss-cn-shanghai.aliyuncs.com/admin/home-mini.png\" alt=\"Admin Home\"\u003e\u003c/a\u003e\n\n#### 项目前端\n\n[https://github.com/cool-team-official/cool-admin-vue](https://github.com/cool-team-official/cool-admin-vue)\n\n## 运行\n\n#### 修改数据库配置，配置文件位于`src/config/config.local.ts`\n\n以 Mysql 为例，其他数据库请参考[数据库配置文档](https://cool-js.com/admin/node/quick.html#%E6%95%B0%E6%8D%AE%E5%BA%93%E9%85%8D%E7%BD%AE)\n\nMysql(`\u003e=5.7版本`)，建议 8.0，node 版本(`\u003e=18.x`)，首次启动会自动初始化并导入数据\n\n```ts\n// mysql，驱动已经内置，无需安装\ntypeorm: {\n    dataSource: {\n      default: {\n        type: 'mysql',\n        host: '127.0.0.1',\n        port: 3306,\n        username: 'root',\n        password: '123456',\n        database: 'cool',\n        // 自动建表 注意：线上部署的时候不要使用，有可能导致数据丢失\n        synchronize: true,\n        // 打印日志\n        logging: false,\n        // 字符集\n        charset: 'utf8mb4',\n        // 是否开启缓存\n        cache: true,\n        // 实体路径\n        entities: ['**/modules/*/entity'],\n      },\n    },\n  },\n```\n\n#### 安装依赖并运行\n\n```bash\n$ pnpm i\n$ pnpm run dev\n```\n\n启动完成访问：[http://localhost:8001/](http://localhost:8001)\n\n## CURD(快速增删改查)\n\n大部分的后台管理系统，或者 API 服务都是对数据进行管理，所以可以看到大量的 CRUD 场景(增删改查)，cool-admin 对此进行了大量地封装，让这块的编码量变得极其地少。\n\n#### 新建一个数据表\n\n`src/modules/demo/entity/goods.ts`，项目启动数据库会自动创建该表，无需手动创建\n\n```ts\nimport { BaseEntity } from '../../base/entity/base';\nimport { Column, Entity, Index } from 'typeorm';\n\n/**\n * 商品\n */\n@Entity('demo_app_goods')\nexport class DemoAppGoodsEntity extends BaseEntity {\n  @Column({ comment: '标题' })\n  title: string;\n\n  @Column({ comment: '图片' })\n  pic: string;\n\n  @Column({ comment: '价格', type: 'decimal', precision: 5, scale: 2 })\n  price: number;\n}\n```\n\n#### 编写 api 接口\n\n`src/modules/demo/controller/app/goods.ts`，快速编写 7 个 api 接口\n\n```ts\nimport { CoolController, BaseController } from '@cool-midway/core';\nimport { DemoAppGoodsEntity } from '../../entity/goods';\n\n/**\n * 商品\n */\n@CoolController({\n  api: ['add', 'delete', 'update', 'info', 'list', 'page'],\n  entity: DemoAppGoodsEntity,\n})\nexport class DemoAppGoodsController extends BaseController {\n  /**\n   * 其他接口\n   */\n  @Get('/other')\n  async other() {\n    return this.ok('hello, cool-admin!!!');\n  }\n}\n```\n\n这样我们就完成了 7 个接口的编写，对应的接口如下：\n\n- `POST /app/demo/goods/add` 新增\n- `POST /app/demo/goods/delete` 删除\n- `POST /app/demo/goods/update` 更新\n- `GET /app/demo/goods/info` 单个信息\n- `POST /app/demo/goods/list` 列表信息\n- `POST /app/demo/goods/page` 分页查询(包含模糊查询、字段全匹配等)\n- `GET /app/demo/goods/other` 其他接口，成功输出 hello, cool-admin!!!\n\n### 部署\n\n[部署教程](https://node.cool-admin.com/src/guide/deploy.html)\n\n### 内置指令\n\n- 使用 `pnpm run lint` 来做代码风格检查。\n\n[midway]: https://midwayjs.org\n\n---\n\n## 本地仓库与官方仓库的区别\n\n### 1. 版本信息\n\n- **本地仓库**：当前使用的是 cool-admin 8.0.0 版本\n- **官方仓库**：目前也是在 8.x 分支下开发维护\n\n### 2. 环境变量管理\n\n- **本地仓库**：使用 dotenvx 进行环境变量管理，支持非对称加密保护敏感配置\n- **官方仓库**：使用 cross-env 管理环境变量\n- 注意：环境变量中的 `NODE_ENV` 必须存在，并正确对应 `local` 或 `prod`\n- 本地仓库提供了环境变量加解密脚本：`encrypt:local`, `encrypt:prod`, `decrypt:local`, `decrypt:prod`\n\n### 3. 功能增强\n\n- 本地仓库提供了更贴合实际应用的用户地址和用户信息相关代码，包含 entity, controller 和 service\n- 修改了 JWT 密钥配置，提高安全性\n\n## 推荐插件\n\n### 短信发送插件\n\n为了方便应用中集成短信发送功能，推荐安装以下官方短信插件：\n\n#### 1. 阿里云短信插件\n\n支持调用阿里云短信服务发送短信，配置简单，使用方便。\n\n- **插件标识**: `sms-ali`\n- **详细信息**: [阿里云短信插件](https://cool-js.com/plugin/32)\n- **安装方式**: 在插件市场下载并添加到项目\n\n```ts\n// 调用示例\n@Inject()\npluginService: PluginService;\n\n// 发送短信\nawait this.pluginService.invoke(\n  'sms-ali',\n  'send',\n  ['13800138000'], // 手机号数组\n  { code: '1234' }  // 参数\n);\n```\n\n#### 2. 腾讯云短信插件\n\n支持调用腾讯云短信服务发送短信，功能完善。\n\n- **插件标识**: `sms-tx`\n- **详细信息**: [腾讯云短信插件](https://cool-js.com/plugin/31)\n- **安装方式**: 在插件市场下载并添加到项目\n\n```ts\n// 调用示例\n@Inject()\npluginService: PluginService;\n\n// 发送短信\nawait this.pluginService.invoke(\n  'sms-tx',\n  'send',\n  ['13800138000'], // 手机号数组\n  ['1234']         // 参数数组\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanz-code%2Fcool-admin-midway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethanz-code%2Fcool-admin-midway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanz-code%2Fcool-admin-midway/lists"}