refactor: split workspace and delivery layout

This commit is contained in:
2026-03-19 13:00:40 +08:00
parent f12b3d5ecd
commit 74e50a2b30
83 changed files with 592 additions and 896 deletions

View File

@@ -1,140 +0,0 @@
# Web UI
## Start
From repository root:
```bash
docker compose up --build -d
```
Optional environment setup:
```bash
cp .env.example .env
```
Stop:
```bash
docker compose down
```
Reset both MySQL and managed raw/index data:
```bash
docker compose down -v
```
Open:
- http://127.0.0.1:8123/web/device_query.html (设备查询)
- http://127.0.0.1:8123/web/brand_management.html (数据管理)
整个功能栈统一运行在 Docker Compose 中,不再依赖本地 Python 或本地 MySQL 直接启动。
容器启动时会自动完成:
- 构建 `dist/device_index.json`
- 导出 MySQL seed 文件
- 加载 MySQL schema 与 seed 数据
- 启动 Web 页面与 API 服务
容器内还会同时启动 MySQL
- `127.0.0.1:3306`
- database: `mobilemodels`
- reader user: `mobilemodels_reader`
页面顶部有导航条Gitea 风格):
- `设备查询`
- `数据管理`
设备查询页顶部额外提供三个页内 tab
- `索引查询`
- `SQL 查询`
- `相关文档`
## 设备查询
### 客户端上报模式
字段按你给的上报方式输入:
- Android
- `platform=android`
- `model_raw=Build.MODEL`(例如 `SM-G9980`
- iOS
- `platform=ios`
- `model_raw=utsname.machine`(例如 `iPhone14,2`
- HarmonyOS
- `platform=harmony`
- `model_raw`(例如 `NOH-AL00`
说明:
- Android / iOS / HarmonyOS 都直接使用客户端原始上报的 `model_raw`
- 页面会输出完整候选列表,并附带 `report_payload` 方便核对上报值。
### SQL 查询模式
- 直接调用 Compose 内的 API 查询 MySQL 主表 `mobilemodels.mm_device_catalog`
- 服务端会先把输入归一化成 `alias_norm`
- 页面会显示实际执行的 SQL、结果列表和返回 JSON
### 相关文档
- 页面内统一展示主推 SQL、兼容 SQL、归一化规则和文档入口
- 可直接跳转查看 `misc/mysql-query-design.md``web/README.md``README.md`
## Output
设备查询页会返回:
- best candidate
- complete ranked candidates
- normalized brand + parent manufacturer
- source rank/weight (from source order config)
- matched inputs
- matched normalized keys
- source markdown file and section
- full JSON output for direct integration or debugging
## Data management
数据管理页支持:
- Independent maintenance:
- Brand list is maintained independently in the UI and initialized from index data on first load.
- Changes are stored in browser `localStorage`.
- Alias normalization (brand only):
- `华为 / huawei / HUAWEI` are normalized to brand `HUAWEI`.
- Brand-manufacturer relations:
- One brand has exactly one parent manufacturer.
- One manufacturer can contain multiple brands.
- Examples:
- `Xiaomi` manufacturer includes brands `Xiaomi`, `Redmi`, `POCO`.
- `vivo` manufacturer includes brands `vivo`, `iQOO`.
- `OPPO` manufacturer includes brands `OPPO`, `OnePlus`, `realme`.
- Click `品牌数 / 厂商数` to open full list popup.
- `编辑品牌列表`: popup edit.
- `编辑品牌-厂商关系`: popup edit.
- `编辑品牌同义词`: popup edit.
- 数据来源管理(新增):
- Supports drag-and-drop source ordering.
- Ranking weight is higher for sources at the top.
- Initial order puts `*_cn.md` before non-`cn` sources.
- 原始数据同步(新增):
- Available in the third left tab.
- Calls the Compose service API to sync upstream `KHwang9883/MobileModels` raw markdown, rebuild `dist/device_index.json`, export MySQL seed, and reload MySQL.
- Requires `docker compose up --build -d`.
- 索引数据(新增):
- Available in the fourth left tab.
- Includes index reload and index load status.
## Notes
- Managed raw data, rebuilt index, and MySQL seed files are persisted in Docker volumes, not written back to the local workspace during runtime.
- For production, override `MYSQL_ROOT_PASSWORD` and `MYSQL_READER_PASSWORD` with your own values.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,181 +0,0 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MobileModels 文档查看</title>
<style>
:root {
--bg: #f5f7fb;
--card: #ffffff;
--text: #1c2430;
--sub: #566173;
--line: #d9e0ea;
--brand: #0f6fff;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
background: radial-gradient(circle at 0 0, #eef4ff 0, var(--bg) 40%), var(--bg);
color: var(--text);
}
.top-nav {
background: linear-gradient(180deg, #1f2a3a, #1a2431);
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.top-nav-inner {
max-width: 1200px;
margin: 0 auto;
padding: 0 16px;
height: 52px;
display: flex;
align-items: center;
gap: 8px;
}
.top-nav .brand,
.top-nav .item {
color: #d6e3f7;
text-decoration: none;
font-size: 14px;
padding: 6px 10px;
border-radius: 6px;
}
.top-nav .brand {
font-weight: 700;
margin-right: 8px;
color: #f4f8ff;
}
.top-nav .item.active {
background: rgba(255, 255, 255, 0.16);
color: #ffffff;
font-weight: 600;
}
.wrap {
max-width: 1200px;
margin: 24px auto;
padding: 0 16px 32px;
display: grid;
gap: 16px;
}
.card {
background: var(--card);
border: 1px solid var(--line);
border-radius: 14px;
padding: 14px;
box-shadow: 0 6px 18px rgba(36, 56, 89, 0.06);
}
.title {
margin: 0 0 8px;
font-size: 18px;
font-weight: 700;
}
.sub {
margin: 0 0 14px;
color: var(--sub);
font-size: 13px;
line-height: 1.5;
}
.btns {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-top: 12px;
}
.btn {
display: inline-flex;
align-items: center;
padding: 9px 14px;
border-radius: 10px;
border: 1px solid #c8d6ee;
background: #f7faff;
color: #244775;
text-decoration: none;
font-size: 13px;
font-weight: 700;
}
.btn:hover {
background: #eef5ff;
}
pre {
margin: 0;
white-space: pre-wrap;
word-break: break-word;
font-size: 13px;
line-height: 1.65;
background: #f6f8fb;
border: 1px solid var(--line);
border-radius: 10px;
padding: 14px;
overflow: auto;
}
</style>
</head>
<body>
<nav class="top-nav">
<div class="top-nav-inner">
<a href="/web/device_query.html" class="brand">MobileModels</a>
<a href="/web/device_query.html" class="item">设备查询</a>
<a href="/web/brand_management.html" class="item">数据管理</a>
<a href="/web/device_query.html?view=docs" class="item active">相关文档</a>
</div>
</nav>
<div class="wrap">
<section class="card">
<h1 class="title" id="docTitle">文档查看</h1>
<p class="sub" id="docPath">正在加载文档...</p>
<div class="btns">
<a class="btn" href="/web/doc_viewer.html?path=/misc/mysql-query-design.md&title=MySQL%20%E8%AE%BE%E8%AE%A1%E8%AF%B4%E6%98%8E">MySQL 设计说明</a>
<a class="btn" href="/web/doc_viewer.html?path=/web/README.md&title=Web%20%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E">Web 使用说明</a>
<a class="btn" href="/web/doc_viewer.html?path=/README.md&title=%E9%A1%B9%E7%9B%AE%20README">项目 README</a>
</div>
</section>
<section class="card">
<pre id="docContent">加载中...</pre>
</section>
</div>
<script>
const ALLOWED_DOCS = new Map([
["/misc/mysql-query-design.md", "MySQL 设计说明"],
["/web/README.md", "Web 使用说明"],
["/README.md", "项目 README"],
]);
async function main() {
const params = new URLSearchParams(window.location.search);
const path = params.get("path") || "/misc/mysql-query-design.md";
const title = params.get("title") || ALLOWED_DOCS.get(path) || "文档查看";
const docTitleEl = document.getElementById("docTitle");
const docPathEl = document.getElementById("docPath");
const docContentEl = document.getElementById("docContent");
if (!ALLOWED_DOCS.has(path)) {
docTitleEl.textContent = "文档不存在";
docPathEl.textContent = path;
docContentEl.textContent = "当前只允许查看预设文档。";
return;
}
document.title = `${title} - MobileModels`;
docTitleEl.textContent = title;
docPathEl.textContent = path;
try {
const resp = await fetch(path, { cache: "no-store" });
if (!resp.ok) {
throw new Error(`HTTP ${resp.status}`);
}
const text = await resp.text();
docContentEl.textContent = text;
} catch (err) {
docContentEl.textContent = `加载失败\n${err.message || err}`;
}
}
main();
</script>
</body>
</html>