feat: 重构为前后端分离架构并完善设备端演示

- 新增 Web 用户端(登录体系 + 统一 REST API 调用)
- 后端增加用户认证、统一 ApiResponse、CORS 支持
- Android 设备端迁移至 MVVM + DataBinding + Retrofit 网络层
- 完善 README 架构说明与密码学原理文档
- 新增 .gitignore 与持久化数据表说明
This commit is contained in:
TongTongStudio
2026-08-21 04:34:58 +08:00
parent eda03d241d
commit 93499fa189
63 changed files with 4398 additions and 455 deletions

View File

@@ -1,27 +1,254 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SecureDevice Demo"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginBottom="12dp" />
<ScrollView
<data>
<variable
name="click"
type="com.secure.demo.activity.main.MainActivity.ViewClick" />
</data>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#F5F6FA">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- 标题 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="安全设备演示 · 模拟真实操作"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#1A1A2E" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="按真实使用流程逐步手动操作(注册 → 绑定 → 上传 → 下载 → 恢复出厂 → 重新注册 → 短信 → 恢复)"
android:textSize="12sp"
android:textColor="#888888" />
<!-- 设备状态摘要 -->
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="#FFFFFF"
android:padding="12dp"
android:text="设备未初始化..."
android:textSize="13sp"
android:typeface="monospace"
android:textColor="#333333"
android:elevation="1dp" />
<!-- 用户 ID -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="用户 ID绑定/恢复身份)"
android:textSize="12sp"
android:textColor="#555555" />
<EditText
android:id="@+id/user_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="例如 user-001"
android:text="user-001"
android:inputType="text"
android:background="@android:drawable/editbox_background" />
<!-- 手机号 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="手机号(绑定与短信必须一致)"
android:textSize="12sp"
android:textColor="#555555" />
<EditText
android:id="@+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="例如 13800138000"
android:text="13800138000"
android:inputType="phone"
android:background="@android:drawable/editbox_background" />
<!-- ① 注册设备 | ② 绑定用户 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_register"
android:layout_width="0dp"
android:onClick="@{click::registerDevice}"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="① 注册设备"
android:textSize="13sp" />
<Button
android:id="@+id/btn_bind"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:onClick="@{click::bindUser}"
android:text="② 绑定用户"
android:textSize="13sp" />
</LinearLayout>
<!-- ③ 上传图片 | ④ 下载解密 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_upload_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::uploadImage}"
android:text="③ 选择并上传图片"
android:textSize="13sp" />
<Button
android:id="@+id/btn_download"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:onClick="@{click::downloadPhoto}"
android:text="④ 下载解密照片"
android:textSize="13sp" />
</LinearLayout>
<!-- ⑤ 恢复出厂 | ⑥ 重新注册 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_reset"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::resetDevice}"
android:text="⑤ 恢复出厂"
android:textSize="13sp" />
<Button
android:id="@+id/btn_reregister"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:onClick="@{click::reRegisterDevice}"
android:text="⑥ 重新注册"
android:textSize="13sp" />
</LinearLayout>
<!-- ⑦ 发送短信 -->
<Button
android:id="@+id/btn_sms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:onClick="@{click::sendSms}"
android:text="⑦ 发送短信验证码"
android:textSize="13sp" />
<!-- 短信验证码 -->
<EditText
android:id="@+id/sms_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:hint="短信验证码demo 固定 000000"
android:text="000000"
android:inputType="number"
android:background="@android:drawable/editbox_background" />
<!-- ⑧ 恢复授权 | ⑨ 恢复照片 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<Button
android:id="@+id/btn_recover"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="@{click::recoverDevice}"
android:text="⑧ 恢复授权"
android:textSize="13sp" />
<Button
android:id="@+id/btn_recover_photos"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:onClick="@{click::recoverPhotos}"
android:text="⑨ 恢复照片"
android:textSize="13sp" />
</LinearLayout>
<!-- 图片预览 -->
<ImageView
android:id="@+id/img_preview"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginTop="12dp"
android:scaleType="centerInside"
android:background="#EEEEEE"
android:contentDescription="选中图片预览" />
<!-- 日志区 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="运行日志"
android:textSize="12sp"
android:textColor="#555555" />
<TextView
android:id="@+id/log"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="220dp"
android:layout_marginTop="12dp"
android:background="#1E1E2E"
android:padding="10dp"
android:textColor="#D0E8D0"
android:textSize="12sp"
android:typeface="monospace" />
</ScrollView>
</LinearLayout>
android:typeface="monospace"
android:scrollbars="vertical"
android:fadeScrollbars="false"
android:focusable="true"
android:clickable="true" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</layout>