一个专业的早报内容管理平台,基于React 18构建,提供智能编辑、短链接管理、数据分析和内容发布功能。支持响应式设计,适配桌面端和移动端。
git clone <repository-url>
cd bjq
npm install
# 或使用 yarn
yarn install
npm start
# 或使用 yarn
yarn start
# 构建生产版本
npm run build
# 预览生产构建
npx serve -s build
server { listen 80; server_name your-domain.com; root /path/to/bjq/build; index index.html; # 启用 gzip 压缩 gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # 处理 React Router 路由 location / { try_files $uri $uri/ /index.html; } # 短链接重定向处理 location /s/ { try_files $uri $uri/ /index.html; } # 静态资源缓存 location /static/ { expires 1y; add_header Cache-Control "public, immutable"; } # API 代理(如果需要) location /api/ { proxy_pass http://your-backend-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
RewriteEngine On # 处理 React Router 路由 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] # 启用压缩 <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript </IfModule> # 静态资源缓存 <IfModule mod_expires.c> ExpiresActive on ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" </IfModule>
# Dockerfile FROM node:18-alpine as build WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . RUN npm run build FROM nginx:alpine COPY --from=build /app/build /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
# 构建和运行 Docker 容器
docker build -t bjq-app .
docker run -p 80:80 bjq-app
bjq/ ├── public/ # 静态资源目录 │ ├── index.html # HTML 模板 │ ├── favicon.svg # 网站图标 │ └── logo.svg # Logo 文件 ├── src/ # 源代码目录 │ ├── components/ # React 组件 │ │ ├── App.js # 主应用组件 │ │ ├── Home.js # 首页组件(动画背景) │ │ ├── Editor.js # 核心编辑器组件 │ │ ├── Preview.js # 内容预览组件 │ │ ├── ArticleList.js # 技术文章管理 │ │ ├── communityactivity.js # 社区活动管理 │ │ ├── encyclopedia.js # 冲浪百科管理 │ │ ├── ClickTracker.js # 数据分析组件 │ │ ├── ShortLinkManager.js # 短链接管理 │ │ ├── ShortLinkRedirect.js # 短链接重定向 │ │ ├── ResponsiveNav.js # 响应式导航 │ │ ├── ProtectedRoute.js # 路由保护组件 │ │ └── PasswordModal.js # 密码验证模态框 │ ├── contexts/ # React Context │ │ └── AuthContext.js # 认证上下文 │ ├── services/ # API 服务层 │ │ └── api.js # API 接口和短链接服务 │ ├── utils/ # 工具函数 │ │ ├── helpers.js # 通用辅助函数 │ │ └── dailyLogger.js # 日志记录工具 │ ├── index.js # 应用入口文件 │ └── index.css # 全局样式 ├── .eslintrc.js # ESLint 配置 ├── .prettierrc # Prettier 配置 ├── package.json # 项目依赖配置 └── README.md # 项目文档
功能特性:
主要方法:
handleSave() - 保存编辑内容handlePreview() - 切换预览模式updateContent() - 更新内容模块功能特性:
核心功能:
fetchArticleMetadata() - 抓取文章元数据generateShortLink() - 生成短链接updateArticle() - 更新文章信息功能特性:
数据指标:
功能特性:
API 接口:
createShortLink() - 创建短链接getShortLink() - 获取短链接信息deleteShortLink() - 删除短链接updateClickCount() - 更新点击统计功能特性:
// 早报内容数据
'morning_report_data': {
greeting: string,
date: string,
articles: Array<{
id: number,
title: string,
author: string,
url: string,
shortLink: object,
clicks: number
}>,
activities: Array<{
id: number,
title: string,
description: string,
url: string,
shortLink: object
}>,
encyclopedia: {
term: string,
description: string
}
}
// 短链接存储
'shortLinksStorage': {
links: Map<string, {
shortId: string,
originalUrl: string,
createdAt: string,
metadata: object
}>,
clicks: Map<string, number>
}
// 点击统计数据
'daily_click_logs': Array<{
date: string,
clicks: number
}>
https://your-domain.com/s/{shortId}支持多种格式的数据导出:
腾讯云TCI早报 - 2024年1月15日 星期一 早上好!今天是美好的一天... 【技术精选】 1. 文章标题 - 作者名称 链接:https://example.com 点击量:123次 【社区活动】 1. 活动标题 描述:活动详细描述... 链接:https://example.com 【冲浪百科】 关键词:技术术语 解释:详细解释内容...
# 腾讯云TCI早报 - 2024年1月15日 星期一
早上好!今天是美好的一天...
## 技术精选
1. [文章标题](https://example.com) - 作者名称
点击量:123次
## 社区活动
1. **活动标题**
描述:活动详细描述...
链接:[查看详情](https://example.com)
## 冲浪百科
**关键词**:技术术语
**解释**:详细解释内容...
{
"date": "2024-01-15",
"greeting": "早上好!今天是美好的一天...",
"articles": [
{
"title": "文章标题",
"author": "作者名称",
"url": "https://example.com",
"clicks": 123
}
],
"activities": [
{
"title": "活动标题",
"description": "活动详细描述...",
"url": "https://example.com"
}
],
"encyclopedia": {
"term": "技术术语",
"description": "详细解释内容..."
}
}
Q: 短链接无法访问?
A: 检查服务器伪静态配置,确保正确处理 /s/ 路径的重定向。
Q: 数据丢失问题? A: 检查浏览器 LocalStorage 是否被清理,建议定期导出数据备份。
Q: 移动端显示异常? A: 确保使用现代浏览器,清除缓存后重新访问。
Q: 编辑器保存失败? A: 检查浏览器存储权限,确保有足够的存储空间。
// 开启调试模式
localStorage.setItem('debug', 'true');
// 查看存储数据
console.log('早报数据:', localStorage.getItem('morning_report_data'));
console.log('短链接数据:', localStorage.getItem('shortLinksStorage'));
console.log('点击日志:', localStorage.getItem('daily_click_logs'));
git checkout -b feature/new-featuregit commit -am 'Add new feature'git push origin feature/new-feature腾讯云TCI早报编辑器 - 让内容创作更简单,让数据分析更直观!