feat(electron): 添加Electron桌面应用支持

- 新增Electron主进程、预加载脚本和构建配置
- 修改前端配置以支持Electron打包
- 更新项目文档和依赖
- 重构API调用使用统一axios实例
This commit is contained in:
dmy
2026-01-15 00:35:19 +08:00
parent f736f30248
commit eca3f4f9fd
22 changed files with 421 additions and 109 deletions

133
README.md
View File

@@ -15,23 +15,33 @@
### 前端
- **框架**: Vue.js 3
- **构建工具**: Vite
- **UI**: Tailwind CSS
- **状态管理**: Pinia
- **UI**: Element Plus
- **图标**: @element-plus/icons-vue
- **HTTP 客户端**: Axios
- **Tailwind CSS**: 用于样式辅助
## 项目结构
```
src/
├── ai/ # AI 模块
│ ├── ai.controller.ts
├── ai.service.ts
│ ├── entities/
│ └── ai-recommendation.entity.ts
│ ├── Prompt.ts
── entities/
── ai.controller.ts
│ ├── ai.module.ts
│ └── ai.service.ts
├── bids/ # 投标业务模块
│ ├── controllers/
│ │ └── bid.controller.ts
│ ├── entities/
│ └── services/
│ └── bid-item.entity.ts
│ ├── services/
│ │ └── bid.service.ts
│ └── bids.module.ts
├── crawler/ # 爬虫模块
│ ├── entities/
│ │ └── crawl-info-add.entity.ts
│ ├── services/
│ │ ├── bid-crawler.service.ts
│ │ ├── cdt_target.ts
@@ -46,32 +56,63 @@ src/
│ │ ├── powerbeijing_target.ts
│ │ ├── sdicc_target.ts
│ │ └── szecp_target.ts
── entities/
── crawler.controller.ts
│ └── crawler.module.ts
├── database/ # 数据库模块
│ └── database.module.ts
├── keywords/ # 关键词管理模块
│ ├── keyword.entity.ts
│ ├── keywords.controller.ts
│ ├── keywords.module.ts
│ └── keywords.service.ts
├── schedule/ # 定时任务
── tasks/
└── bid-crawl.task.ts
── tasks/
└── bid-crawl.task.ts
│ └── schedule.module.ts
├── scripts/ # 脚本工具
│ ├── ai-recommendations.ts
│ ├── crawl.ts
│ ├── deploy.ps1
│ ├── remove-duplicates.ts
│ ├── sync.ts
│ └── update-source.ts
── common/ # 公共模块
└── logger/
── common/ # 公共模块
└── logger/
│ ├── logger.module.ts
│ ├── logger.service.ts
│ └── winston.config.ts
├── app.controller.ts
├── app.module.ts
├── app.service.ts
└── main.ts
frontend/
── src/
├── components/
── Dashboard.vue
│ ├── Dashboard-AI.vue
│ ├── PinnedProject.vue
│ ├── Bids.vue
│ ├── Keywords.vue
── CrawlInfo.vue
├── App.vue
└── main.ts
── src/
├── assets/
── vue.svg
│ ├── components/
│ ├── Dashboard.vue
│ ├── Dashboard-AI.vue
│ ├── PinnedProject.vue
── Bids.vue
│ │ ├── Keywords.vue
│ │ └── CrawlInfo.vue
│ ├── utils/
│ │ └── api.ts
│ ├── App.vue
│ ├── main.ts
│ └── style.css
├── .env
├── .env.example
├── .gitignore
├── README.md
├── index.html
├── package.json
├── postcss.config.js
├── tsconfig.app.json
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts
```
## 快速开始
@@ -141,26 +182,28 @@ npm run start:prod
### 智能爬虫模块
- **多源爬取**: 支持 12 个主流招标网站
- 中国大唐集团电子商务平台 (CDT)
- 中国华能集团有限公司电子商务平台 (CHNG)
- 中国南方电网电子商务平台 (CSG)
- 中国海洋石油集团有限公司 (CNOOC)
- 中国华电集团有限公司电子商务平台 (CHDTP)
- 中国华能集团有限公司电子商务平台 (CHNG)
- 深圳交易集团有限公司 (SZECP)
- 中国大唐集团电子商务平台 (CDT)
- 中国电力招标网 (EPS)
- 国家能源投资集团有限责任公司 (CNNCECP)
- 中国核工业集团有限公司 (CNNC)
- 中国电力建设集团有限公司 (POWERCHINA)
- 中国石油天然气集团有限公司 (CGNPC)
- 中国能源建设集团有限公司 (CEIC)
- 中国石油天然气集团有限公司 (CNPC)
- 国家电网有限公司 (SGCC)
- 中国电力建设集团有限公司 (ESPIC)
- 北京电力交易中心 (POWERBEIJING)
- 山东能源集团有限公司 (SDICC)
- 中国海洋石油集团有限公司 (CNOOC)
- **智能防封策略**:
- 随机请求间隔 (3-8 秒)
- 轮换 User-Agent
- 随机请求间隔 (1-3 秒)
- 固定 User-Agent
- 异常检测与自动重试机制
- 代理支持
- **定时任务**: 每 30 分钟自动执行爬取
- **定时任务**:
- 爬虫任务:已暂停(默认每天午夜执行)
- 数据清理:每天午夜自动执行
### 数据处理与存储
@@ -168,10 +211,10 @@ npm run start:prod
- 投标项目标题
- 详细页面 URL
- 发布时间
- 招标单位
- 截止日期
- 关键词匹配
- 优先级评分
- 来源网站
- 置顶标记
- 创建时间
- 更新时间
- **增量存储**:
- 通过 URL 哈希值判断是否为新数据
@@ -215,8 +258,12 @@ npm run start:prod
### 投标信息
- `GET /api/bids` - 获取投标列表(支持分页、筛选)
- `GET /api/bids/high-priority` - 获取高优先级投标
- `GET /api/bids/today` - 获取今日投标
- `GET /api/bids/recent` - 获取最近投标
- `GET /api/bids/pinned` - 获取置顶投标
- `GET /api/bids/sources` - 获取来源列表
- `GET /api/bids/by-date-range` - 按日期范围获取投标
- `GET /api/bids/crawl-info-stats` - 获取爬取信息统计
- `PATCH /api/bids/:title/pin` - 更新置顶状态
### 关键词管理
- `GET /api/keywords` - 获取所有关键词
@@ -224,12 +271,14 @@ npm run start:prod
- `DELETE /api/keywords/:id` - 删除关键词
### AI 服务
- `GET /api/ai/recommendations` - 获取 AI 推荐投标
- `POST /api/ai/analyze` - 分析投标信息
- `POST /api/ai/recommendations` - 获取 AI 推荐
- `POST /api/ai/save-recommendations` - 保存 AI 推荐
- `GET /api/ai/latest-recommendations` - 获取最新 AI 推荐
### 爬虫管理
- `GET /api/crawler/info` - 获取爬取信息
- `POST /api/crawler/trigger` - 手动触发爬取
- `GET /api/crawler/status` - 获取爬虫状态
- `POST /api/crawler/run` - 运行爬虫
- `POST /api/crawler/crawl/:sourceName` - 爬取单个来源
## 前端路由