#!/bin/bash # Phase 4 - OCR 集成验证脚本 echo "======================================" echo "Phase 4 - OCR 集成验证" echo "======================================" echo "" # 颜色定义 GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # 检查函数 check_file() { if [ -f "$1" ]; then echo -e "${GREEN}✓${NC} $1" return 0 else echo -e "${RED}✗${NC} $1 (不存在)" return 1 fi } check_dir() { if [ -d "$1" ]; then echo -e "${GREEN}✓${NC} $1 (目录)" return 0 else echo -e "${RED}✗${NC} $1 (目录不存在)" return 1 fi } # 项目根目录 PROJECT_ROOT="/home/congsh/CodeSpace/ClaudeSpace/cutThink_lite" cd "$PROJECT_ROOT" || exit 1 echo "1. 检查后端模块结构..." echo "-----------------------------------" check_dir "src-tauri/src/ocr" check_file "src-tauri/src/ocr/mod.rs" check_file "src-tauri/src/ocr/cloud.rs" check_file "src-tauri/src/ocr/local.rs" check_file "src-tauri/src/ocr/result.rs" check_dir "src-tauri/src/plugin" check_file "src-tauri/src/plugin/mod.rs" check_file "src-tauri/src/secure_storage.rs" echo "" echo "2. 检查 Go 插件项目..." echo "-----------------------------------" check_dir "src-ocr-plugin" check_file "src-ocr-plugin/go.mod" check_file "src-ocr-plugin/main.go" check_file "src-ocr-plugin/Makefile" check_file "src-ocr-plugin/README.md" echo "" echo "3. 检查前端组件..." echo "-----------------------------------" check_file "src/components/views/OCRManager.vue" check_file "src/components/views/PluginManager.vue" echo "" echo "4. 检查插件仓库..." echo "-----------------------------------" check_file "/home/congsh/CodeSpace/ClaudeSpace/CutThenThink/plugins/plugins.json" echo "" echo "5. 检查 Cargo.toml 依赖..." echo "-----------------------------------" if grep -q "sha2" src-tauri/Cargo.toml; then echo -e "${GREEN}✓${NC} SHA2 依赖已添加" else echo -e "${RED}✗${NC} SHA2 依赖缺失" fi if grep -q "aes-gcm" src-tauri/Cargo.toml; then echo -e "${GREEN}✓${NC} AES-GCM 依赖已添加" else echo -e "${RED}✗${NC} AES-GCM 依赖缺失" fi if grep -q "futures-util" src-tauri/Cargo.toml; then echo -e "${GREEN}✓${NC} futures-util 依赖已添加" else echo -e "${RED}✗${NC} futures-util 依赖缺失" fi echo "" echo "6. 功能模块统计..." echo "-----------------------------------" OCR_FILES=$(find src-tauri/src/ocr -name "*.rs" 2>/dev/null | wc -l) echo "OCR 模块文件数: $OCR_FILES" PLUGIN_FILES=$(find src-tauri/src/plugin -name "*.rs" 2>/dev/null | wc -l) echo "插件管理文件数: $PLUGIN_FILES" VUE_COMPONENTS=$(find src/components/views -name "*OCR*.vue" -o -name "*Plugin*.vue" 2>/dev/null | wc -l) echo "新增 Vue 组件: $VUE_COMPONENTS" echo "" echo "7. 代码行数统计..." echo "-----------------------------------" if command -v cloc &> /dev/null; then echo "Rust 代码行数:" cloc src-tauri/src/ocr src-tauri/src/plugin src-tauri/src/secure_storage.rs 2>/dev/null | grep "Rust" | awk '{print " " $5 " 行代码"}' else echo "cloc 未安装,跳过代码行数统计" fi echo "" echo "8. TODO 验证清单..." echo "-----------------------------------" echo -e "${YELLOW}□${NC} 至少 2 种云端 OCR 测试通过 (需要 API 密钥)" echo -e "${YELLOW}□${NC} API 密钥安全存储 (已实现 AES-256-GCM 加密)" echo -e "${YELLOW}□${NC} 可获取远程插件列表 (已实现)" echo -e "${YELLOW}□${NC} 插件下载带进度显示 (已实现)" echo -e "${YELLOW}□${NC} SHA256 校验正确执行 (已实现)" echo -e "${YELLOW}□${NC} OCR 结果实时显示 (已实现前端组件)" echo "" echo "======================================" echo "验证完成!" echo "======================================" echo "" echo "后续步骤:" echo "1. 安装 Rust 工具链并编译: cd src-tauri && cargo build" echo "2. 安装 Go 工具链并编译插件: cd src-ocr-plugin && make" echo "3. 配置百度/腾讯云 OCR API 密钥" echo "4. 测试 OCR 功能" echo ""