feat: 添加二维码生成功能并简化架构

- 新增二维码生成服务层,支持自定义内容和配置
  - 移除 Platform 抽象层,简化为三层架构
  - 更新开发文档和架构说明
  - 添加前端二维码生成页面和状态管理
This commit is contained in:
2026-02-10 19:06:36 +08:00
parent 927eaa1e03
commit b2754bdad5
24 changed files with 1642 additions and 278 deletions

View File

@@ -0,0 +1,63 @@
//! 二维码生成相关数据模型
use serde::{Deserialize, Serialize};
/// 二维码配置
///
/// 定义生成二维码所需的参数
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QrConfig {
/// 二维码内容
pub content: String,
/// 输出尺寸(像素)
pub size: u32,
/// 边距(模块数)
pub margin: u32,
/// 容错级别: "L", "M", "Q", "H"
pub error_correction: String,
}
/// 二维码样式(阶段 2 使用)
///
/// 定义二维码的视觉样式
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QrStyle {
/// 点形状: "square", "circle", "rounded"
pub dot_shape: String,
/// 码眼形状: "square", "circle", "rounded"
pub eye_shape: String,
/// 前景色Hex 颜色代码)
pub foreground_color: String,
/// 背景色Hex 颜色代码)
pub background_color: String,
/// 是否使用渐变
pub is_gradient: bool,
/// 渐变颜色列表(如果 is_gradient 为 true
pub gradient_colors: Option<Vec<String>>,
}
/// Logo 配置(阶段 2 使用)
///
/// 定义 Logo 的位置和样式
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LogoConfig {
/// Logo 文件路径
pub path: String,
/// 缩放比例 (0.1 - 0.3)
pub scale: f32,
/// 是否添加边框
pub has_border: bool,
/// 边框宽度(像素)
pub border_width: u32,
}
/// 二维码生成结果
///
/// 包含生成的二维码图片数据
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QrResult {
/// Base64 编码的图片数据
pub data: String,
/// 图片格式(如 "png"
pub format: String,
}