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

85
web-client/index.html Normal file
View File

@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Secure Device 用户端控制台</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="topbar">
<h1>Secure Device 用户端控制台</h1>
<div id="userInfo" class="user-info hidden">
<span id="userLabel"></span>
<button id="btnLogout" class="btn btn-sm">退出登录</button>
</div>
</header>
<main>
<!-- ============ 登录 / 注册 ============ -->
<section id="authSection" class="panel">
<h2>用户登录 / 注册</h2>
<p class="hint">模拟真实场景用户端Web先登录获取 Token再操作设备设备端Android无登录体系。</p>
<div class="form-row">
<input id="authUserId" placeholder="用户名,如 alice" autocomplete="username">
<input id="authPassword" type="password" placeholder="密码,注册时可自定义(默认 123456" autocomplete="current-password">
<input id="authPhone" placeholder="手机号(仅注册用),如 13800138000">
<button id="btnLogin" class="btn btn-primary">登录</button>
<button id="btnRegister" class="btn">注册</button>
</div>
<div id="authResult" class="result"></div>
</section>
<!-- ============ 设备管理 ============ -->
<section id="deviceSection" class="panel hidden">
<h2>绑定设备</h2>
<div class="form-row">
<input id="bindSn" placeholder="设备 SN如 SN-DEMO-001">
<button id="btnBind" class="btn btn-primary">绑定设备</button>
</div>
<div id="bindResult" class="result"></div>
<h2>我的设备</h2>
<button id="btnListDevices" class="btn">刷新设备列表</button>
<div id="devicesResult" class="result"></div>
</section>
<!-- ============ 短信 / 恢复授权 ============ -->
<section id="recoverSection" class="panel hidden">
<h2>恢复授权(出厂重置后重新取回照片)</h2>
<p class="hint">流程:设备端恢复出厂后生成 <b>新设备公钥</b> → 在此填入 SN + 新公钥 → 发送短信验证码 → 恢复授权。</p>
<div class="form-row">
<input id="recoverSn" placeholder="设备 SN如 SN-DEMO-001">
<input id="recoverPhone" placeholder="绑定手机号,如 13800138000">
<button id="btnSendSms" class="btn">发送验证码</button>
</div>
<div class="form-row">
<input id="recoverNewPubKey" placeholder="新设备公钥 Base64从设备端复制">
<input id="recoverSmsCode" placeholder="短信验证码demo 固定 000000">
<button id="btnRecover" class="btn btn-primary">恢复授权</button>
</div>
<div id="recoverResult" class="result"></div>
</section>
<!-- ============ 照片 ============ -->
<section id="photoSection" class="panel hidden">
<h2>我的照片(密文存储,需登录后下载解密)</h2>
<button id="btnListPhotos" class="btn">刷新照片列表</button>
<div id="photosResult" class="result"></div>
<div class="form-row">
<input id="decryptPhotoId" placeholder="photoId如 photo-001">
<button id="btnDecrypt" class="btn btn-primary">下载并解密</button>
</div>
<div id="decryptResult" class="result"></div>
</section>
<!-- ============ 原始响应展示 ============ -->
<section id="rawSection" class="panel">
<h2>最近一次 API 响应(统一格式 code/message/data</h2>
<pre id="rawOutput" class="raw">尚未发起请求</pre>
</section>
</main>
<script src="app.js"></script>
</body>
</html>