feat: 本次提交更新内容如下
定版本转移2025年7月17日
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# API接口测试脚本
|
||||
echo "🚀 开始测试存客宝API接口..."
|
||||
|
||||
# 设置API基础地址
|
||||
API_BASE_URL="https://ckbapi.quwanzhi.com"
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 打印消息函数
|
||||
print_message() {
|
||||
echo -e "${1}${2}${NC}"
|
||||
}
|
||||
|
||||
# 测试API接口函数
|
||||
test_api() {
|
||||
local endpoint=$1
|
||||
local description=$2
|
||||
|
||||
print_message $BLUE "测试: $description"
|
||||
print_message $YELLOW "接口: $API_BASE_URL$endpoint"
|
||||
|
||||
# 发送请求并获取状态码
|
||||
status_code=$(curl -s -o /dev/null -w "%{http_code}" "$API_BASE_URL$endpoint")
|
||||
|
||||
if [ "$status_code" -eq 200 ]; then
|
||||
print_message $GREEN "✅ 成功 (状态码: $status_code)"
|
||||
elif [ "$status_code" -eq 404 ]; then
|
||||
print_message $YELLOW "⚠️ 接口不存在 (状态码: $status_code)"
|
||||
elif [ "$status_code" -eq 401 ]; then
|
||||
print_message $YELLOW "⚠️ 需要认证 (状态码: $status_code)"
|
||||
else
|
||||
print_message $RED "❌ 失败 (状态码: $status_code)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# 检查网络连接
|
||||
print_message $BLUE "🌐 检查网络连接..."
|
||||
if ping -c 1 quwanzhi.com &> /dev/null; then
|
||||
print_message $GREEN "✅ 网络连接正常"
|
||||
else
|
||||
print_message $RED "❌ 网络连接失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 测试主要API接口
|
||||
print_message $BLUE "📡 开始测试API接口..."
|
||||
echo ""
|
||||
|
||||
# 设备管理接口
|
||||
test_api "/api/devices" "设备列表"
|
||||
test_api "/api/devices/stats" "设备统计"
|
||||
|
||||
# 微信管理接口
|
||||
test_api "/api/wechat/accounts" "微信账号列表"
|
||||
test_api "/api/wechat/accounts/status" "微信账号状态"
|
||||
|
||||
# 流量池接口
|
||||
test_api "/api/traffic/pools" "流量池列表"
|
||||
test_api "/api/traffic/tags" "流量标签"
|
||||
|
||||
# 场景获客接口
|
||||
test_api "/api/scenarios" "场景列表"
|
||||
test_api "/api/scenarios/stats" "场景统计"
|
||||
|
||||
# 内容库接口
|
||||
test_api "/api/content/library" "内容库"
|
||||
test_api "/api/content/categories" "内容分类"
|
||||
|
||||
# 工作台接口
|
||||
test_api "/api/workspace/overview" "工作台概览"
|
||||
test_api "/api/workspace/tasks" "工作台任务"
|
||||
|
||||
# 用户接口
|
||||
test_api "/api/user/profile" "用户资料"
|
||||
test_api "/api/auth/verify" "认证验证"
|
||||
|
||||
print_message $BLUE "🔍 测试完成!"
|
||||
print_message $YELLOW "注意事项:"
|
||||
echo "1. 状态码200表示接口正常"
|
||||
echo "2. 状态码401表示需要认证,这是正常的"
|
||||
echo "3. 状态码404表示接口不存在,需要确认接口地址"
|
||||
echo "4. 其他状态码可能表示服务器问题"
|
||||
|
||||
echo ""
|
||||
print_message $GREEN "🎉 API测试脚本执行完成!"
|
||||
@@ -1,279 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 存客宝项目迁移设置脚本
|
||||
# 用于从GitHub项目快速设置开发环境
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 开始存客宝项目迁移设置..."
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 项目配置
|
||||
GITHUB_REPO="https://github.com/fnvtk/cunkebao_v3.git"
|
||||
GITHUB_DIR="cunkebao_v3_source"
|
||||
BACKUP_DIR="backup_$(date +%Y%m%d_%H%M%S)"
|
||||
|
||||
# 函数:打印带颜色的消息
|
||||
print_message() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${message}${NC}"
|
||||
}
|
||||
|
||||
# 函数:检查命令是否存在
|
||||
check_command() {
|
||||
if ! command -v $1 &> /dev/null; then
|
||||
print_message $RED "错误: $1 未安装,请先安装 $1"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 函数:检查Node.js版本
|
||||
check_node_version() {
|
||||
local node_version=$(node -v | cut -d'v' -f2)
|
||||
local required_version="18.0.0"
|
||||
|
||||
if [ "$(printf '%s\n' "$required_version" "$node_version" | sort -V | head -n1)" != "$required_version" ]; then
|
||||
print_message $RED "错误: Node.js版本需要 >= $required_version,当前版本: $node_version"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 步骤1:环境检查
|
||||
print_message $BLUE "📋 步骤1: 检查开发环境..."
|
||||
check_command "git"
|
||||
check_command "node"
|
||||
check_command "npm"
|
||||
check_node_version
|
||||
print_message $GREEN "✅ 环境检查通过"
|
||||
|
||||
# 步骤2:备份当前项目
|
||||
print_message $BLUE "💾 步骤2: 备份当前项目..."
|
||||
if [ -d "$BACKUP_DIR" ]; then
|
||||
rm -rf "$BACKUP_DIR"
|
||||
fi
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# 备份关键文件和目录
|
||||
cp -r app/ "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp -r lib/ "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp -r components/ "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp -r public/ "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp package.json "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp next.config.mjs "$BACKUP_DIR/" 2>/dev/null || true
|
||||
cp tailwind.config.ts "$BACKUP_DIR/" 2>/dev/null || true
|
||||
|
||||
print_message $GREEN "✅ 项目备份完成: $BACKUP_DIR"
|
||||
|
||||
# 步骤3:克隆GitHub仓库
|
||||
print_message $BLUE "📥 步骤3: 克隆GitHub仓库..."
|
||||
if [ -d "$GITHUB_DIR" ]; then
|
||||
print_message $YELLOW "⚠️ 目录 $GITHUB_DIR 已存在,正在删除..."
|
||||
rm -rf "$GITHUB_DIR"
|
||||
fi
|
||||
|
||||
git clone "$GITHUB_REPO" "$GITHUB_DIR"
|
||||
print_message $GREEN "✅ GitHub仓库克隆完成"
|
||||
|
||||
# 步骤4:分析项目结构
|
||||
print_message $BLUE "🔍 步骤4: 分析项目结构..."
|
||||
cd "$GITHUB_DIR"
|
||||
|
||||
print_message $YELLOW "GitHub项目结构:"
|
||||
find . -maxdepth 3 -type d | head -20
|
||||
|
||||
# 检查关键目录
|
||||
if [ -d "Cunkebao" ]; then
|
||||
print_message $GREEN "✅ 找到前端目录: Cunkebao"
|
||||
cd Cunkebao
|
||||
|
||||
if [ -f "package.json" ]; then
|
||||
print_message $GREEN "✅ 找到package.json"
|
||||
print_message $YELLOW "依赖分析:"
|
||||
cat package.json | grep -A 20 '"dependencies"' | head -15
|
||||
fi
|
||||
|
||||
cd ..
|
||||
fi
|
||||
|
||||
if [ -d "Server" ]; then
|
||||
print_message $GREEN "✅ 找到后端目录: Server"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
# 步骤5:创建迁移配置
|
||||
print_message $BLUE "⚙️ 步骤5: 创建迁移配置..."
|
||||
|
||||
cat > migration-config.json << EOF
|
||||
{
|
||||
"migration": {
|
||||
"sourceDir": "$GITHUB_DIR",
|
||||
"backupDir": "$BACKUP_DIR",
|
||||
"targetDir": ".",
|
||||
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
||||
"phases": {
|
||||
"preparation": {
|
||||
"completed": true,
|
||||
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
},
|
||||
"api_integration": {
|
||||
"completed": false,
|
||||
"timestamp": null
|
||||
},
|
||||
"business_logic": {
|
||||
"completed": false,
|
||||
"timestamp": null
|
||||
},
|
||||
"ui_migration": {
|
||||
"completed": false,
|
||||
"timestamp": null
|
||||
},
|
||||
"testing": {
|
||||
"completed": false,
|
||||
"timestamp": null
|
||||
}
|
||||
},
|
||||
"mappings": {
|
||||
"api_endpoints": {},
|
||||
"components": {},
|
||||
"pages": {},
|
||||
"utils": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
print_message $GREEN "✅ 迁移配置文件创建完成: migration-config.json"
|
||||
|
||||
# 步骤6:安装依赖
|
||||
print_message $BLUE "📦 步骤6: 安装项目依赖..."
|
||||
npm install
|
||||
|
||||
# 检查GitHub项目依赖
|
||||
if [ -d "$GITHUB_DIR/Cunkebao" ] && [ -f "$GITHUB_DIR/Cunkebao/package.json" ]; then
|
||||
print_message $YELLOW "分析GitHub项目依赖..."
|
||||
cd "$GITHUB_DIR/Cunkebao"
|
||||
|
||||
# 提取有用的依赖包
|
||||
print_message $YELLOW "建议添加的依赖包:"
|
||||
cat package.json | jq -r '.dependencies | to_entries[] | select(.key | test("axios|lodash|moment|dayjs|chart|echarts")) | "\(.key): \(.value)"' 2>/dev/null || true
|
||||
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
print_message $GREEN "✅ 依赖安装完成"
|
||||
|
||||
# 步骤7:创建迁移脚本
|
||||
print_message $BLUE "📝 步骤7: 创建迁移脚本..."
|
||||
|
||||
cat > scripts/migrate-api.js << 'EOF'
|
||||
#!/usr/bin/env node
|
||||
|
||||
// API迁移脚本
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
console.log('🔄 开始API迁移...');
|
||||
|
||||
// 读取GitHub项目的API文件
|
||||
const sourceApiDir = path.join(__dirname, '../cunkebao_v3_source/Cunkebao/src/api');
|
||||
const targetApiDir = path.join(__dirname, '../lib/api');
|
||||
|
||||
if (fs.existsSync(sourceApiDir)) {
|
||||
console.log('✅ 找到源API目录');
|
||||
|
||||
// 这里可以添加具体的迁移逻辑
|
||||
// 例如:转换Vue的API调用到React的API调用
|
||||
|
||||
} else {
|
||||
console.log('⚠️ 未找到源API目录');
|
||||
}
|
||||
|
||||
console.log('✅ API迁移完成');
|
||||
EOF
|
||||
|
||||
chmod +x scripts/migrate-api.js
|
||||
|
||||
cat > scripts/migrate-components.js << 'EOF'
|
||||
#!/usr/bin/env node
|
||||
|
||||
// 组件迁移脚本
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
console.log('🔄 开始组件迁移...');
|
||||
|
||||
// 读取GitHub项目的组件文件
|
||||
const sourceComponentDir = path.join(__dirname, '../cunkebao_v3_source/Cunkebao/src/components');
|
||||
const targetComponentDir = path.join(__dirname, '../app/components');
|
||||
|
||||
if (fs.existsSync(sourceComponentDir)) {
|
||||
console.log('✅ 找到源组件目录');
|
||||
|
||||
// 这里可以添加具体的迁移逻辑
|
||||
// 例如:转换Vue组件到React组件
|
||||
|
||||
} else {
|
||||
console.log('⚠️ 未找到源组件目录');
|
||||
}
|
||||
|
||||
console.log('✅ 组件迁移完成');
|
||||
EOF
|
||||
|
||||
chmod +x scripts/migrate-components.js
|
||||
|
||||
print_message $GREEN "✅ 迁移脚本创建完成"
|
||||
|
||||
# 步骤8:创建开发指南
|
||||
print_message $BLUE "📚 步骤8: 创建开发指南..."
|
||||
|
||||
cat > MIGRATION_GUIDE.md << 'EOF'
|
||||
# 存客宝项目迁移指南
|
||||
|
||||
## 项目概述
|
||||
本指南帮助您将GitHub上的cunkebao_v3项目与当前Next.js项目进行对接。
|
||||
|
||||
## 迁移阶段
|
||||
|
||||
### 阶段1: 环境准备 ✅
|
||||
- [x] 克隆GitHub仓库
|
||||
- [x] 分析项目结构
|
||||
- [x] 备份当前项目
|
||||
- [x] 安装依赖
|
||||
|
||||
### 阶段2: API对接 🔄
|
||||
- [ ] 映射API端点
|
||||
- [ ] 适配API客户端
|
||||
- [ ] 实现数据适配器
|
||||
- [ ] 测试API集成
|
||||
|
||||
### 阶段3: 业务逻辑迁移 ⏳
|
||||
- [ ] 迁移场景获客逻辑
|
||||
- [ ] 迁移设备管理逻辑
|
||||
- [ ] 迁移微信管理逻辑
|
||||
- [ ] 迁移流量池逻辑
|
||||
|
||||
### 阶段4: UI组件迁移 ⏳
|
||||
- [ ] Vue组件转React组件
|
||||
- [ ] 适配样式系统
|
||||
- [ ] 实现响应式设计
|
||||
- [ ] 优化用户体验
|
||||
|
||||
### 阶段5: 测试和优化 ⏳
|
||||
- [ ] 单元测试
|
||||
- [ ] 集成测试
|
||||
- [ ] 性能优化
|
||||
- [ ] Bug修复
|
||||
|
||||
## 快速开始
|
||||
|
||||
1. 运行开发服务器:
|
||||
```bash
|
||||
npm run dev
|
||||
87
Cunkebao/scripts/update-page-headers.js
Normal file
87
Cunkebao/scripts/update-page-headers.js
Normal file
@@ -0,0 +1,87 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 需要更新的页面文件列表
|
||||
const pagesToUpdate = [
|
||||
'src/pages/scenarios/ScenarioDetail.tsx',
|
||||
'src/pages/scenarios/NewPlan.tsx',
|
||||
'src/pages/plans/Plans.tsx',
|
||||
'src/pages/plans/PlanDetail.tsx',
|
||||
'src/pages/orders/Orders.tsx',
|
||||
'src/pages/profile/Profile.tsx',
|
||||
'src/pages/content/Content.tsx',
|
||||
'src/pages/contact-import/ContactImport.tsx',
|
||||
'src/pages/traffic-pool/TrafficPool.tsx',
|
||||
'src/pages/workspace/Workspace.tsx'
|
||||
];
|
||||
|
||||
// 更新规则
|
||||
const updateRules = [
|
||||
{
|
||||
// 替换旧的header结构
|
||||
pattern: /<header className="[^"]*fixed[^"]*">\s*<div className="[^"]*">\s*<div className="[^"]*">\s*<button[^>]*onClick=\{\(\) => navigate\(-1\)\}[^>]*>\s*<ChevronLeft[^>]*\/>\s*<\/button>\s*<h1[^>]*>([^<]*)<\/h1>\s*<\/div>\s*(?:<div[^>]*>([\s\S]*?)<\/div>)?\s*<\/div>\s*<\/header>/g,
|
||||
replacement: (match, title, rightContent) => {
|
||||
const rightContentStr = rightContent ? `\n rightContent={\n ${rightContent.trim()}\n }` : '';
|
||||
return `<PageHeader\n title="${title.trim()}"\n defaultBackPath="/"${rightContentStr}\n />`;
|
||||
}
|
||||
},
|
||||
{
|
||||
// 替换简单的header结构
|
||||
pattern: /<header className="[^"]*">\s*<div className="[^"]*">\s*<h1[^>]*>([^<]*)<\/h1>\s*<\/div>\s*<\/header>/g,
|
||||
replacement: (match, title) => {
|
||||
return `<PageHeader\n title="${title.trim()}"\n showBack={false}\n />`;
|
||||
}
|
||||
},
|
||||
{
|
||||
// 添加PageHeader导入
|
||||
pattern: /import React[^;]+;/,
|
||||
replacement: (match) => {
|
||||
return `${match}\nimport PageHeader from '@/components/PageHeader';`;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function updateFile(filePath) {
|
||||
try {
|
||||
const fullPath = path.join(process.cwd(), filePath);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
console.log(`文件不存在: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let content = fs.readFileSync(fullPath, 'utf8');
|
||||
let updated = false;
|
||||
|
||||
// 应用更新规则
|
||||
updateRules.forEach(rule => {
|
||||
const newContent = content.replace(rule.pattern, rule.replacement);
|
||||
if (newContent !== content) {
|
||||
content = newContent;
|
||||
updated = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (updated) {
|
||||
fs.writeFileSync(fullPath, content, 'utf8');
|
||||
console.log(`✅ 已更新: ${filePath}`);
|
||||
} else {
|
||||
console.log(`⏭️ 无需更新: ${filePath}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ 更新失败: ${filePath}`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 执行批量更新
|
||||
console.log('🚀 开始批量更新页面Header...\n');
|
||||
|
||||
pagesToUpdate.forEach(filePath => {
|
||||
updateFile(filePath);
|
||||
});
|
||||
|
||||
console.log('\n✨ 批量更新完成!');
|
||||
console.log('\n📝 注意事项:');
|
||||
console.log('1. 请检查更新后的文件是否正确');
|
||||
console.log('2. 可能需要手动调整一些特殊的header结构');
|
||||
console.log('3. 确保所有页面都正确导入了PageHeader组件');
|
||||
console.log('4. 运行 npm run build 检查是否有编译错误');
|
||||
Reference in New Issue
Block a user