Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ accounts.json
password.json
sessions.json
antigravity-accounts-*.json

docs/MODULE_NAMING.md
# ====================
# 用户数据 & 数据库
# ====================
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ api-monitor/
│ ├── services/ # 业务服务
│ └── utils/ # 工具函数
├── modules/ # 可插拔业务模块
│ ├── server-management/ # 服务器/SSH/Docker
│ ├── cloudflare-dns/ # Cloudflare DNS
│ ├── server-api/ # 服务器/SSH/Docker
│ ├── cloudflare-api/ # Cloudflare DNS
│ ├── antigravity-api/ # Antigravity Agent
│ ├── music-api/ # 网易云音乐代理
│ └── ... # 更多模块
Expand Down
14 changes: 7 additions & 7 deletions agent-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

## 特性

- 🚀 **高性能**: Go 语言编写,单二进制部署,资源占用低
- 📊 **实时监控**: CPU、内存、磁盘、网络流量实时采集
- 🔗 **Socket.IO**: 与 Dashboard 实时通信
- 🔄 **自动重连**: 断线自动重连,稳定可靠
- 🐧 **跨平台**: 支持 Linux、Windows、macOS
- **高性能**: Go 语言编写,单二进制部署,资源占用低
- **实时监控**: CPU、内存、磁盘、网络流量实时采集
- **Socket.IO**: 与 Dashboard 实时通信
- **自动重连**: 断线自动重连,稳定可靠
- **跨平台**: 支持 Linux、Windows、macOS

## 构建

Expand Down Expand Up @@ -46,7 +46,7 @@ GOOS=windows GOARCH=amd64 go build -o agent-windows-amd64.exe

| 参数 | 说明 | 默认值 |
|------|------|--------|
| `-s, --server` | Dashboard 地址 | http://localhost:3000 |
| `-s, --server` | Dashboard 地址 | <http://localhost:3000> |
| `--id` | 主机 ID (必需) | - |
| `-k` | Agent 密钥 (必需) | - |
| `-i` | 上报间隔 (毫秒) | 1500 |
Expand Down Expand Up @@ -99,6 +99,6 @@ GOOS=windows GOARCH=amd64 go build -o agent-windows-amd64.exe
- [gorilla/websocket](https://github.com/gorilla/websocket) - WebSocket 客户端
- [shirou/gopsutil](https://github.com/shirou/gopsutil) - 系统信息采集

## License
## 许可证

MIT
1 change: 1 addition & 0 deletions agent-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ func (a *AgentClient) heartbeat() {
// Socket.IO 中只有服务端发送 ping (2),客户端只需响应 pong (3)
// 我们在 handleMessage 中已经处理了 ping 响应
// 这个 goroutine 只是为了监听 stopChan
// 这下应该不会错了(应该
<-a.stopChan
}

Expand Down
43 changes: 0 additions & 43 deletions diagnose_db.js

This file was deleted.

Binary file removed diagnose_result.txt
Binary file not shown.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
api-monitor:
image: iwvw/api-monitor:latest
# image: iwvw/api-monitor:dev # 开发版本可选
container_name: api-monitor
restart: unless-stopped
ports:
Expand Down
6 changes: 3 additions & 3 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ api-monitor/
│ ├── services/ # 业务服务
│ └── utils/ # 工具函数
├── modules/ # 可插拔业务模块 (13个)
│ ├── server-management/ # 服务器/SSH/Docker
│ ├── cloudflare-dns/ # Cloudflare DNS
│ ├── server-api/ # 服务器/SSH/Docker
│ ├── cloudflare-api/ # Cloudflare DNS
│ ├── antigravity-api/ # Antigravity Agent
│ ├── gemini-cli-api/ # Gemini CLI
│ ├── zeabur-api/ # Zeabur PaaS
│ ├── koyeb-api/ # Koyeb PaaS
│ ├── fly-api/ # Fly.io
│ ├── flyio-api/ # Fly.io
│ ├── music-api/ # 网易云音乐代理
│ ├── totp-api/ # 2FA 管理
│ └── ...
Expand Down
4 changes: 3 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ npm run format
```

**类型 (type)**:

- `feat`: 新功能
- `fix`: 修复 bug
- `docs`: 文档更新
Expand All @@ -66,6 +67,7 @@ npm run format
- `chore`: 构建/工具变更

**示例**:

```
feat(music): 添加歌词同步功能

Expand Down Expand Up @@ -107,7 +109,7 @@ api-monitor/
│ └── utils/ # 工具函数
├── modules/ # 功能模块
│ ├── music-api/ # 音乐 API
│ ├── cloudflare-dns/# DNS 管理
│ ├── cloudflare-api/# DNS 管理
│ └── ...
├── agent-go/ # Go Agent 源码
└── test/ # 测试文件
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module.exports = [
'plugin/**', // 浏览器扩展使用特殊 API
'src/js/modules/template.js', // 模板文件
'src/*_snippet*.js', // 代码片段
'modules/cloudflare-dns/router_utf8.js', // 备份文件

],
},
];
218 changes: 166 additions & 52 deletions modules/_template/README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,166 @@
# 模块开发模板使用指南

本目录提供了一个标准化的模块开发模板,用于快速扩展项目功能。

## 快速开始

### 1. 后端部分 (Backend)

1. **复制模板**: 复制 `modules/_template` 文件夹并重命名为你的模块名 (例如 `my-service-api`)。
2. **配置数据库**:
* 修改 `schema.sql`,定义你的表结构。
* 在 `src/db/database.js` 中添加新表的初始化逻辑(或者手动在 SQLite 中运行 SQL)。
3. **定义模型**:
* 修改 `models.js`,将 `{{module_name}}` 替换为实际表名。
* 在 `src/db/models/index.js` 中导出你的新模型。
4. **实现存储层**: 修改 `storage.js` 中的逻辑。
5. **实现 API 服务**: 在 `service.js` 中实现与外部第三方 API 的交互。
6. **注册路由**:
* 修改 `router.js` 中的路由定义。
* 在 `src/routes/index.js` 的 `moduleRouteMap` 中添加你的模块路由映射。

### 2. 前端部分 (Frontend)

1. **样式**:
* 复制 `src/css/template.css` 为 `src/css/your-module.css`。
* 在 `src/index.html` 中引入该 CSS 文件。
2. **模板**:
* 复制 `src/templates/template.html` 为 `src/templates/your-module.html`。
* 在 `src/index.html` 的 templates 区域引入该文件(或通过 `template-loader.js` 加载)。
3. **逻辑**:
* 复制 `src/js/modules/template.js` 为 `src/js/modules/your-module.js`。
* 在 `src/js/main.js` 中导入并混入 (mixin) 你的模块方法。
4. **导航**:
* 在 `src/index.html` 的侧边栏导航中添加指向你模块的链接。

## 关键变量替换

在模板文件中,请全局替换以下占位符:

* `{{module_name}}`: 模块名称 (小写,下划线分隔),如 `my_service`。
* `{{ModuleName}}`: 模块名称 (大驼峰),如 `MyService`。
* `{{module_prefix}}`: 数据库 ID 前缀,如 `ms`。
* `{{MODULE_ENV_VAR}}`: 环境变量名称,如 `MY_SERVICE_TOKEN`。
* `{{module_title}}`: UI 显示的中文标题。

## 集成检查清单

- [ ] `schema.sql` 已执行 (数据库表已创建)
- [ ] `src/db/models/index.js` 已导出新模型
- [ ] `src/routes/index.js` 已注册路由映射
- [ ] `src/js/main.js` 已混入前端方法
- [ ] `src/index.html` 已添加导航项、CSS 和 HTML 模板
# Antigravity 模块开发与集成规范指南

本文档规定了新模块接入系统的标准化流程与代码规范,确保全站 UI/UX 一致性及系统架构的整洁。

---

## 🚀 1. 挂载与注册 (Mounting & Registration)

### 1.1 后端路由挂载

在 `src/routes/index.js` 中,将模块路由添加到 `moduleRouteMap`:

```javascript
const moduleRouteMap = {
'notification-api': '/api/notification', // 键名为前端模块ID, 值为后端路径前缀
// ...
};
```

### 1.2 前端基础配置

在 `src/js/stores/app.js` 中配置图标与基本信息:

```javascript
export const MODULE_CONFIG = {
notification: {
name: '通知管理',
icon: 'fas fa-bell',
desc: '统一告警与通知中心'
},
// ...
};
```

### 1.3 模块可见性 (白名单)

**核心步骤!** 在 `src/js/modules/settings.js` 的 `validModules` 数组中手动添加模块 ID,否则模块在“用户设置”中会被过滤,导致前端不显示。

```javascript
const validModules = [
'dashboard', 'uptime', 'notification', // 必须包含模块名
// ...
];
```

---

## 💻 2. 前端显示与方法 (Frontend Methods)

### 2.1 Vue 方法集成 (Vue Mixin)

在 `src/js/main.js` 中导入并混入数据和方法:

```javascript
import { notificationData, notificationMethods } from './modules/notification.js';

const app = Vue.createApp({
data() {
return {
...notificationData, // 混入数据
// ...
};
},
methods: {
...notificationMethods, // 混入方法
// ...
}
});
```

### 2.2 HTML 模板加载

1. **容器定义**: 在 `src/index.html` 的主内容区域添加:

```html
<div id="template-notification" v-show="mainActiveTab === 'notification'"></div>
```

2. **路由映射**: 在 `src/js/template-loader.js` 的 `templateMap` 中指定文件:

```javascript
const templateMap = {
'notification.html': '#template-notification',
};
```

---

## 🎨 3. UI 标准化定义 (Standard UI)

### 3.1 主题配色 (Theming)

在 `src/css/styles.css` 中定义主题变量,所有子组件将自动继承配色:

```css
.theme-notification {
--current-primary: #f59e0b; /* 主色调 */
--current-dark: #d97706; /* 悬停/深色态 */
--current-rgb: 245, 158, 11; /* 阴影/半透明色 */
}
/* 定义子标签页激活态渐变 (必须) */
.theme-notification .tab-btn.active {
background: linear-gradient(135deg, var(--current-primary), var(--current-dark)) !important;
box-shadow: 0 2px 8px rgba(var(--current-rgb), 0.3);
}
```

### 3.2 子标签栏 (SecTabs)

统一使用 `sec-tabs` 类名。

```html
<div class="sec-tabs">
<button class="tab-btn" :class="{ active: currentSubTab === 'tab1' }" @click="...">
<i class="fas fa-xxx"></i> 标题
</button>
</div>
```

### 3.3 模态框标准化 (Modals)

1. **外部放置**: 模态框 HTML 必须放在 `.tab-content` 主容器之外。
2. **主题声明**: 在 `modal-overlay` 上添加模块主题类名。
3. **结构规范**:

```html
<!-- 模态框必须在 overlay 层声明 theme 类 -->
<div v-if="showModal" class="modal-overlay theme-notification" @click.self="showModal = false">
<div class="modal"> <!-- 大尺寸可用 .modal-lg -->
<div class="modal-header">
<h3><i class="fas fa-xxx"></i> 标题</h3>
<button class="modal-close" @click="..."><i class="fas fa-times"></i></button>
</div>
<div class="modal-body">...内容...</div>
<div class="modal-footer">
<button class="btn btn-secondary" @click="...">取消</button>
<button class="btn btn-primary" @click="...">确定</button>
</div>
</div>
</div>
```

### 3.4 开关切换器 (AG-Switch)

不再使用原生复选框,统一使用以下结构:

```html
<label class="ag-switch">
<input type="checkbox" v-model="...">
<div class="ag-switch-track">
<div class="ag-switch-knob"></div>
</div>
<span class="ag-switch-label">说明文字</span>
</label>
```

---

## ✅ 集成检查清单 (Checklist)

- [ ] 后端 `router.js` 定义完毕并注册到 `src/routes/index.js`。
- [ ] 前端 `validModules` 已加入白名单。
- [ ] `main.js` 已导入并混入 `{module}Data` 和 `{module}Methods`。
- [ ] `index.html` 占位符 ID 与 `template-loader.js` 映射一致。
- [ ] 所有的模态框均在容器外层且绑定了 `theme-xxx` 类。
- [ ] `styles.css` 中已定义模块专属渐变激活态样式。
Loading
Loading