easysql/README.md
2025-12-31 12:19:05 +08:00

176 lines
6.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🗄️ EasySQL
<div align="center">
![EasySQL](https://img.shields.io/badge/EasySQL-v2.0-06b6d4?style=for-the-badge)
![Electron](https://img.shields.io/badge/Electron-33-47848f?style=for-the-badge&logo=electron)
![React](https://img.shields.io/badge/React-18-61dafb?style=for-the-badge&logo=react)
![TypeScript](https://img.shields.io/badge/TypeScript-5-3178c6?style=for-the-badge&logo=typescript)
![Node.js](https://img.shields.io/badge/Node.js-18+-339933?style=for-the-badge&logo=node.js)
**现代化多数据库管理工具**
*轻量、高性能、跨平台*
</div>
---
## ✨ 特性
- 🚀 **跨平台** - 基于 Electron支持 Windows、macOS、Linux
-**高性能** - 原生数据库驱动,毫秒级响应
- 🎨 **精美 UI** - Windows Metro 风格,深色主题,无边框窗口
- 🔌 **多数据库** - 支持 MySQL、PostgreSQL、SQLite、SQL Server、MongoDB、Redis、MariaDB
- 📝 **智能编辑器** - Monaco EditorSQL 语法高亮、智能补全
- 📊 **数据编辑** - 支持直接编辑表格数据,虚拟滚动大数据量
- 🛠️ **表设计器** - Navicat 风格,可视化编辑字段、索引、外键、表选项
- 🗃️ **完整管理** - 创建/删除/重命名/复制数据库和表
- 📤 **导入导出** - 支持 JSON、Navicat NCX 格式连接配置导入导出
- 🔄 **批量操作** - 支持多选连接批量删除管理
## 🗃️ 支持的数据库
| 数据库 | 状态 | 驱动 |
|--------|------|------|
| 🐬 MySQL | ✅ | mysql2 |
| 🐘 PostgreSQL | ✅ | pg |
| 💾 SQLite | ✅ | sql.js |
| 📊 SQL Server | ✅ | mssql |
| 🦭 MariaDB | ✅ | mysql2 |
| 🍃 MongoDB | ✅ | mongodb |
| ⚡ Redis | ✅ | ioredis |
## 🚀 快速开始
### 环境要求
- Node.js 18+
- npm 或 yarn
### 安装
```bash
# 克隆项目
git clone https://github.com/your-repo/easysql.git
cd easysql
# 安装依赖
npm install
# 开发模式运行
npm run electron:dev
# 构建应用
npm run electron:build
```
## 📸 界面预览
```
┌─────────────────────────────────────────────────────────────────┐
│ 🗄️ EasySQL ─ □ ✕ │
├────────────────┬────────────────────────────────────────────────┤
│ │ 🏠 主页 │ 📝 查询1 │ 📋 users │ + │
│ + 新建连接 │ ┌──────────────────────────────────────────┐ │
│ │ │ SELECT * FROM users │ │
│ ─ 连接 ─────── │ │ WHERE status = 'active' │ │
│ │ │ ORDER BY created_at DESC │ │
│ 🐬 MySQL本地 │ │ LIMIT 100; │ │
│ 🐘 PostgreSQL │ ├──────────────────────────────────────────┤ │
│ 📊 SQL Server │ │ ┌────┬────────┬─────────┬────────────┐ │ │
│ │ │ │ id │ name │ email │ created_at │ │ │
│ ─ mydb ─────── │ │ ├────┼────────┼─────────┼────────────┤ │ │
│ 📋 users │ │ │ 1 │ Alice │ a@... │ 2024-01-01 │ │ │
│ 📋 orders │ │ │ 2 │ Bob │ b@... │ 2024-01-02 │ │ │
│ 📋 products │ │ └────┴────────┴─────────┴────────────┘ │ │
├────────────────┴────────────────────────────────────────────────┤
│ ● 就绪 · 2 行 (0.05s) EasySQL v2.0 │
└─────────────────────────────────────────────────────────────────┘
```
## 🛠️ 技术栈
- **运行时**: Electron 33
- **前端**: React 18 + TypeScript 5
- **样式**: Tailwind CSS 3
- **构建**: Vite 5
- **编辑器**: Monaco Editor
- **数据库驱动**: mysql2, pg, sql.js, mssql, mongodb, ioredis
## 📁 项目结构
```
easysql/
├── electron/ # Electron 主进程
│ ├── main.js # 主程序入口
│ └── preload.js # 预加载脚本
├── src/ # React 前端
│ ├── components/ # UI 组件
│ │ ├── TitleBar.tsx # 标题栏
│ │ ├── Sidebar.tsx # 侧边栏(连接/数据库/表树)
│ │ ├── MainContent.tsx # 主内容区
│ │ ├── SqlEditor.tsx # SQL 编辑器Monaco
│ │ ├── VirtualDataTable.tsx # 虚拟滚动数据表格
│ │ ├── TableDesigner.tsx # 表设计器Navicat 风格)
│ │ ├── ConnectionModal.tsx # 连接配置弹窗
│ │ ├── CreateDatabaseModal.tsx # 新建数据库弹窗
│ │ ├── CreateTableModal.tsx # 快速新建表弹窗
│ │ └── InputDialog.tsx # 通用输入对话框
│ ├── lib/
│ │ ├── electron-api.ts # Electron API 封装
│ │ └── hooks.ts # 自定义 Hooks
│ ├── App.tsx
│ ├── types.ts
│ └── index.css
├── index.html
├── package.json
├── tailwind.config.js
├── tsconfig.json
└── vite.config.ts
```
## ⌨️ 快捷键
| 快捷键 | 功能 |
|--------|------|
| `Ctrl+Enter` | 执行 SQL |
| `Ctrl+S` | 保存文件/保存修改 |
| `Ctrl+O` | 打开 SQL 文件 |
| `Ctrl+Shift+F` | 格式化 SQL |
| `Ctrl+Q` | 新建查询 |
| `Ctrl+W` | 关闭当前标签 |
| `Ctrl+F` | 搜索(侧边栏/表格) |
| `双击连接` | 快速连接数据库 |
| `右键菜单` | 连接/数据库/表操作 |
## 🔧 配置说明
连接配置保存在用户配置目录:
- Windows: `%APPDATA%\easysql\connections.json`
- macOS: `~/Library/Application Support/easysql/connections.json`
- Linux: `~/.config/easysql/connections.json`
## 📦 npm 脚本
| 命令 | 说明 |
|------|------|
| `npm run dev` | 启动 Vite 开发服务器 |
| `npm run build` | 构建前端资源 |
| `npm run electron:dev` | 开发模式运行 Electron |
| `npm run electron:build` | 打包 Electron 应用 |
## 🤝 贡献
欢迎提交 Issue 和 Pull Request
## 📄 License
MIT
---
<div align="center">
Made with ❤️ using Electron + React + Node.js
</div>