feat(admin): 实现只读词库管理后台
- 新增 Spring Boot 3 后端:JWT 认证、六个业务模块查询接口、Caffeine 聚合缓存与只读事务约束 - 新增 Vue 3 管理前端:登录、概览、词书、词条、词根词族、近反义词与数据质量 - 补充前后端 README、环境变量示例与本地构建部署说明 - 同步 OpenSpec 变更文档与任务进度(64/65,只读数据库账号待确认) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
No files matched your search
@@ -22,11 +22,13 @@ htmlcov/
|
||||
node_modules/
|
||||
dist/
|
||||
build/
|
||||
target/
|
||||
.next/
|
||||
coverage/
|
||||
*.tsbuildinfo
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# ---- importer:本地数据、产物与大文件(不进 Git) ----
|
||||
/importer/output/
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
| 目录 | 项目 | 状态 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `importer/` | 单词导入 | 已有 | 从 Lexis 导出词书与词条,建库并导入 SQLite/PostgreSQL/MySQL |
|
||||
| `frontend/` | 单词管理前端 | 占位 | 待定技术栈 |
|
||||
| `backend/` | 单词管理后端 | 占位 | 待定技术栈 |
|
||||
| `backend/` | 管理后台后端 | 已有 | Spring Boot 3 + MyBatis-Plus,只读查询 MySQL `word_market` |
|
||||
| `frontend/` | 管理后台前端 | 已有 | Vue 3 + Vite + TypeScript + Element Plus + ECharts |
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 导入数据
|
||||
|
||||
单词导入流程见 [`importer/README.md`](importer/README.md)。命令需在 `importer/` 目录下执行:
|
||||
|
||||
```powershell
|
||||
@@ -17,6 +19,38 @@ cd importer
|
||||
python run.py
|
||||
```
|
||||
|
||||
### 2. 启动后端
|
||||
|
||||
准备数据库连接、管理员账号和 JWT 密钥(见 [`backend/README.md`](backend/README.md)):
|
||||
|
||||
```powershell
|
||||
cd backend
|
||||
$env:DB_USERNAME = 'your_user'
|
||||
$env:DB_PASSWORD = 'your_password'
|
||||
$env:ADMIN_USERNAME = 'admin'
|
||||
$env:ADMIN_PASSWORD_HASH = '$2a$10$...'
|
||||
$env:JWT_SECRET = 'at-least-32-bytes-random-secret'
|
||||
mvn spring-boot:run
|
||||
```
|
||||
|
||||
默认监听 `http://127.0.0.1:8080`。
|
||||
|
||||
### 3. 启动前端
|
||||
|
||||
```powershell
|
||||
cd frontend
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
默认地址 `http://127.0.0.1:5173`,开发服务器代理 `/api` 到后端。
|
||||
|
||||
## 管理后台
|
||||
|
||||
只读管理后台覆盖六个模块:概览、词书、词条、词根词族、近反义词、数据质量。所有接口仅执行 `SELECT`,应用层启用只读事务,建议数据库侧使用只读账号。
|
||||
|
||||
生产部署方式为后端可执行 jar + 前端 `dist` 静态资源,由 Nginx 托管并反向代理 `/api`。
|
||||
|
||||
## 数据与产物
|
||||
|
||||
`importer/` 下的数据与研究产物不纳入 Git(见 `.gitignore`),仅保留在本机:
|
||||
@@ -30,6 +64,8 @@ Git 只跟踪源码、文档与配置。
|
||||
|
||||
## 文档
|
||||
|
||||
- 管理后端:[`backend/README.md`](backend/README.md)
|
||||
- 管理前端:[`frontend/README.md`](frontend/README.md)
|
||||
- 导入流程与算法:[`importer/README.md`](importer/README.md)
|
||||
- 数据实体关系模型:[`importer/docs/DATA-MODEL.md`](importer/docs/DATA-MODEL.md)
|
||||
- ZPK 解密内容分析:[`importer/docs/zpk-decrypted-content-analysis.md`](importer/docs/zpk-decrypted-content-analysis.md)
|
||||
@@ -0,0 +1,18 @@
|
||||
# 复制为 .env 或直接在运行环境中设置;不要提交真实值。
|
||||
DB_URL=jdbc:mysql://s1.void01.com:3306/word_market?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&connectTimeout=10000&socketTimeout=30000
|
||||
DB_USERNAME=your_read_only_user
|
||||
DB_PASSWORD=your_password
|
||||
DB_POOL_SIZE=15
|
||||
|
||||
ADMIN_USERNAME=admin
|
||||
# BCrypt 哈希,可用 htpasswd 生成:htpasswd -bnBC 10 "" 'your-password' | tr -d ':\n'
|
||||
ADMIN_PASSWORD_HASH=$2a$10$replace_with_a_real_bcrypt_hash
|
||||
JWT_SECRET=replace_with_a_random_secret_at_least_32_characters
|
||||
ADMIN_TOKEN_TTL_HOURS=8
|
||||
|
||||
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
|
||||
COVER_BASE_URL=https://static.beingfine.cn
|
||||
CACHE_TTL_MINUTES=10
|
||||
CACHE_MAXIMUM_SIZE=200
|
||||
KNOWN_MISSING_ZPK_KEYS=0_53785_101_1775241011
|
||||
SERVER_PORT=8080
|
||||
@@ -1,7 +1,116 @@
|
||||
# backend — 单词管理后端
|
||||
# backend — 词库只读管理后端
|
||||
|
||||
占位目录,技术栈待定。
|
||||
Spring Boot 3.3 + Java 17 + MyBatis-Plus,只读连接 MySQL `word_market`,为 `frontend/` 提供查询接口。
|
||||
|
||||
用途:为 `frontend` 提供词书、词条及关联数据的查询与编辑接口,数据来源为 `importer` 生成的数据库。
|
||||
## 只读约束
|
||||
|
||||
后续确定技术栈与目录结构后在此实现。
|
||||
- 所有业务接口只执行 `SELECT`,代码中不存在任何写 Mapper。
|
||||
- 所有 Service 标注 `@Transactional(readOnly = true)`。
|
||||
- HikariCP 设置 `read-only: true`。
|
||||
- 数据库侧建议使用仅具备 `SELECT` 权限的账号;创建只读账号属于运维动作,需要单独确认后执行。
|
||||
|
||||
## 环境要求
|
||||
|
||||
- JDK 17
|
||||
- Maven 3.9+
|
||||
- 可访问的 MySQL `word_market` 数据库
|
||||
|
||||
## 配置
|
||||
|
||||
复制 `.env.example` 或参考 `src/main/resources/application.example.yml`。所有敏感值通过环境变量注入,仓库不保存真实凭据。
|
||||
|
||||
| 变量 | 必填 | 说明 |
|
||||
|---|---|---|
|
||||
| `DB_URL` | 否 | JDBC 地址,默认 `jdbc:mysql://s1.void01.com:3306/word_market?...` |
|
||||
| `DB_USERNAME` | 是 | 数据库用户名 |
|
||||
| `DB_PASSWORD` | 是 | 数据库密码 |
|
||||
| `DB_POOL_SIZE` | 否 | Hikari 最大连接数,默认 15 |
|
||||
| `ADMIN_USERNAME` | 是 | 管理员用户名 |
|
||||
| `ADMIN_PASSWORD_HASH` | 是 | 管理员密码的 BCrypt 哈希 |
|
||||
| `JWT_SECRET` | 是 | HS256 签名密钥,至少 32 字节 |
|
||||
| `ADMIN_TOKEN_TTL_HOURS` | 否 | token 有效期,默认 8 小时 |
|
||||
| `CORS_ALLOWED_ORIGINS` | 否 | 逗号分隔的前端来源,默认 `http://localhost:5173,http://127.0.0.1:5173` |
|
||||
| `COVER_BASE_URL` | 否 | 封面 CDN 前缀,默认 `https://static.beingfine.cn` |
|
||||
| `CACHE_TTL_MINUTES` | 否 | 聚合缓存时长,默认 10 分钟 |
|
||||
| `CACHE_MAXIMUM_SIZE` | 否 | 聚合缓存条目上限,默认 200 |
|
||||
| `KNOWN_MISSING_ZPK_KEYS` | 否 | 已知缺失的 zpk 文件键,逗号分隔 |
|
||||
| `SERVER_PORT` | 否 | 服务端口,默认 8080 |
|
||||
|
||||
缺少 `ADMIN_USERNAME`、`ADMIN_PASSWORD_HASH` 或 `JWT_SECRET` 时应用会拒绝启动并输出缺失项;`JWT_SECRET` 少于 32 字节同样拒绝启动。
|
||||
|
||||
生成 BCrypt 哈希:
|
||||
|
||||
```bash
|
||||
htpasswd -bnBC 10 "" 'your-password' | tr -d ':\n'
|
||||
# 或
|
||||
python -c "import bcrypt; print(bcrypt.hashpw(b'your-password', bcrypt.gensalt()).decode())"
|
||||
```
|
||||
|
||||
## 启动
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
mvn spring-boot:run
|
||||
```
|
||||
|
||||
或构建后运行:
|
||||
|
||||
```bash
|
||||
mvn -DskipTests package
|
||||
java -jar target/word-market-admin-0.1.0.jar
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
统一前缀 `/api`,响应结构 `{ code, message, data }`;分页为 `{ items, total, page, size }`;数值 ID 以字符串返回。
|
||||
|
||||
| 模块 | 接口 |
|
||||
|---|---|
|
||||
| 认证 | `POST /api/auth/login` |
|
||||
| 概览 | `GET /api/dashboard/summary`、`/exam-distribution`、`/book-size-top`、`/pos-distribution` |
|
||||
| 词书 | `GET /api/books`、`/api/books/{id}`、`/api/books/{id}/entries`、`/api/exams` |
|
||||
| 词条 | `GET /api/entries`、`/api/entries/{id}`、`/{id}/senses`、`/phrases`、`/examples`、`/confusables`、`/variants`、`/books` |
|
||||
| 词根词族 | `GET /api/morphemes`、`/api/morphemes/{id}`、`/api/cards`、`/api/cards/{id}`、`/api/families`、`/api/families/{id}`、`/api/families/{id}/tree` |
|
||||
| 近反义词 | `GET /api/synonyms`、`/api/synonyms/{wordId}`、`/api/synonyms/group-size-distribution` |
|
||||
| 数据质量 | `GET /api/quality/summary`、`/declared-vs-actual`、`/missing-references`、`/cross-domain-coverage` |
|
||||
|
||||
概览与质量聚合接口支持 `?refresh=true` 跳过缓存并重新计算。分页默认每页 20 条,最大 100 条。
|
||||
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
mvn test
|
||||
```
|
||||
|
||||
覆盖分页边界、认证成功/失败、404、空状态与缓存刷新行为。
|
||||
|
||||
## 部署
|
||||
|
||||
后端产出可执行 jar,前端由 Nginx 托管并反向代理 `/api`。示例:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name example.com;
|
||||
root /srv/word-market/frontend/dist;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
生产环境必须使用 HTTPS,并按需收紧 `CORS_ALLOWED_ORIGINS`。
|
||||
|
||||
## 已知数据异常
|
||||
|
||||
`KNOWN_MISSING_ZPK_KEYS` 默认登记 `0_53785_101_1775241011`,对应 importer 导出时缺失的一个 zpk 文件。数据质量模块会列出仍引用该文件键的词书关联;如后续补齐文件或更换数据快照,调整该配置即可。
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.3.5</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.wordmarket</groupId>
|
||||
<artifactId>word-market-admin</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<name>word-market-admin</name>
|
||||
<description>只读词库管理后台</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
||||
<jjwt.version>0.12.6</jjwt.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.wordmarket.admin;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
|
||||
@SpringBootApplication(exclude = UserDetailsServiceAutoConfiguration.class)
|
||||
@ConfigurationPropertiesScan
|
||||
@EnableCaching
|
||||
public class AdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
public record ApiResponse<T>(int code, String message, T data) {
|
||||
|
||||
public static <T> ApiResponse<T> ok(T data) {
|
||||
return new ApiResponse<>(0, "ok", data);
|
||||
}
|
||||
|
||||
public static ApiResponse<Void> error(int code, String message) {
|
||||
return new ApiResponse<>(code, message, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
public class BizException extends RuntimeException {
|
||||
|
||||
private final HttpStatus status;
|
||||
|
||||
public BizException(HttpStatus status, String message) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public HttpStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public static BizException badRequest(String message) {
|
||||
return new BizException(HttpStatus.BAD_REQUEST, message);
|
||||
}
|
||||
|
||||
public static BizException unauthorized(String message) {
|
||||
return new BizException(HttpStatus.UNAUTHORIZED, message);
|
||||
}
|
||||
|
||||
public static BizException notFound(String message) {
|
||||
return new BizException(HttpStatus.NOT_FOUND, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
@ExceptionHandler(BizException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleBiz(BizException ex) {
|
||||
return ResponseEntity.status(ex.getStatus())
|
||||
.body(ApiResponse.error(ex.getStatus().value(), ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleValidation(MethodArgumentNotValidException ex) {
|
||||
FieldError fieldError = ex.getBindingResult().getFieldError();
|
||||
String message = fieldError == null
|
||||
? "请求参数不合法"
|
||||
: "缺少或非法字段: " + fieldError.getField();
|
||||
return ResponseEntity.badRequest().body(ApiResponse.error(400, message));
|
||||
}
|
||||
|
||||
@ExceptionHandler({ConstraintViolationException.class, MethodArgumentTypeMismatchException.class,
|
||||
HttpMessageNotReadableException.class})
|
||||
public ResponseEntity<ApiResponse<Void>> handleBadRequest(Exception ex) {
|
||||
return ResponseEntity.badRequest().body(ApiResponse.error(400, "请求参数不合法"));
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleUnexpected(Exception ex) {
|
||||
log.error("Unhandled exception", ex);
|
||||
return ResponseEntity.internalServerError().body(ApiResponse.error(500, "服务暂时不可用"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record Items<T>(List<T> items) {
|
||||
|
||||
public static <T> Items<T> of(List<T> items) {
|
||||
return new Items<>(items);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record PageResult<T>(List<T> items, long total, int page, int size) {
|
||||
|
||||
public static <T> PageResult<T> of(List<T> items, long total, int page, int size) {
|
||||
return new PageResult<>(items, total, page, size);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
public final class Pages {
|
||||
|
||||
private static final int DEFAULT_SIZE = 20;
|
||||
private static final int MAX_SIZE = 100;
|
||||
|
||||
private Pages() {
|
||||
}
|
||||
|
||||
public static int page(Integer page) {
|
||||
return page == null || page < 1 ? 1 : page;
|
||||
}
|
||||
|
||||
public static int size(Integer size) {
|
||||
if (size == null || size < 1) {
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
return Math.min(size, MAX_SIZE);
|
||||
}
|
||||
|
||||
public static int offset(int page, int size) {
|
||||
long offset = (long) (page - 1) * size;
|
||||
return (int) Math.min(offset, Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class RequestLogFilter extends OncePerRequestFilter {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RequestLogFilter.class);
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
long started = System.currentTimeMillis();
|
||||
try {
|
||||
filterChain.doFilter(request, response);
|
||||
} finally {
|
||||
long elapsed = System.currentTimeMillis() - started;
|
||||
log.info("{} {} -> {} ({} ms)", request.getMethod(), request.getRequestURI(),
|
||||
response.getStatus(), elapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.wordmarket.admin.config;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ConfigurationProperties(prefix = "admin")
|
||||
public class AdminProperties implements InitializingBean {
|
||||
|
||||
private String username;
|
||||
private String passwordHash;
|
||||
private String jwtSecret;
|
||||
private int tokenTtlHours = 8;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
List<String> missing = new ArrayList<>();
|
||||
if (isBlank(username)) {
|
||||
missing.add("ADMIN_USERNAME / admin.username");
|
||||
}
|
||||
if (isBlank(passwordHash)) {
|
||||
missing.add("ADMIN_PASSWORD_HASH / admin.password-hash");
|
||||
}
|
||||
if (isBlank(jwtSecret)) {
|
||||
missing.add("JWT_SECRET / admin.jwt-secret");
|
||||
}
|
||||
if (!missing.isEmpty()) {
|
||||
throw new IllegalStateException("缺少管理员配置: " + String.join(", ", missing));
|
||||
}
|
||||
if (jwtSecret.getBytes(java.nio.charset.StandardCharsets.UTF_8).length < 32) {
|
||||
throw new IllegalStateException("JWT_SECRET 至少需要 32 字节(当前 "
|
||||
+ jwtSecret.getBytes(java.nio.charset.StandardCharsets.UTF_8).length + " 字节)");
|
||||
}
|
||||
if (tokenTtlHours <= 0) {
|
||||
throw new IllegalStateException("ADMIN_TOKEN_TTL_HOURS 必须大于 0");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBlank(String value) {
|
||||
return value == null || value.isBlank();
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPasswordHash() {
|
||||
return passwordHash;
|
||||
}
|
||||
|
||||
public void setPasswordHash(String passwordHash) {
|
||||
this.passwordHash = passwordHash;
|
||||
}
|
||||
|
||||
public String getJwtSecret() {
|
||||
return jwtSecret;
|
||||
}
|
||||
|
||||
public void setJwtSecret(String jwtSecret) {
|
||||
this.jwtSecret = jwtSecret;
|
||||
}
|
||||
|
||||
public int getTokenTtlHours() {
|
||||
return tokenTtlHours;
|
||||
}
|
||||
|
||||
public void setTokenTtlHours(int tokenTtlHours) {
|
||||
this.tokenTtlHours = tokenTtlHours;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.wordmarket.admin.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "app")
|
||||
public class AppProperties {
|
||||
|
||||
private final Cors cors = new Cors();
|
||||
private final Cache cache = new Cache();
|
||||
private final Quality quality = new Quality();
|
||||
private String coverBaseUrl = "https://static.beingfine.cn";
|
||||
|
||||
public static class Cors {
|
||||
private String allowedOrigins = "http://localhost:5173";
|
||||
|
||||
public String getAllowedOrigins() {
|
||||
return allowedOrigins;
|
||||
}
|
||||
|
||||
public void setAllowedOrigins(String allowedOrigins) {
|
||||
this.allowedOrigins = allowedOrigins;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cache {
|
||||
private long ttlMinutes = 10;
|
||||
private long maximumSize = 200;
|
||||
|
||||
public long getTtlMinutes() {
|
||||
return ttlMinutes;
|
||||
}
|
||||
|
||||
public void setTtlMinutes(long ttlMinutes) {
|
||||
this.ttlMinutes = ttlMinutes;
|
||||
}
|
||||
|
||||
public long getMaximumSize() {
|
||||
return maximumSize;
|
||||
}
|
||||
|
||||
public void setMaximumSize(long maximumSize) {
|
||||
this.maximumSize = maximumSize;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Quality {
|
||||
private String knownMissingZpkKeys = "";
|
||||
|
||||
public String getKnownMissingZpkKeys() {
|
||||
return knownMissingZpkKeys;
|
||||
}
|
||||
|
||||
public void setKnownMissingZpkKeys(String knownMissingZpkKeys) {
|
||||
this.knownMissingZpkKeys = knownMissingZpkKeys;
|
||||
}
|
||||
}
|
||||
|
||||
public Cors getCors() {
|
||||
return cors;
|
||||
}
|
||||
|
||||
public Cache getCache() {
|
||||
return cache;
|
||||
}
|
||||
|
||||
public Quality getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
public String getCoverBaseUrl() {
|
||||
return coverBaseUrl;
|
||||
}
|
||||
|
||||
public void setCoverBaseUrl(String coverBaseUrl) {
|
||||
this.coverBaseUrl = coverBaseUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.wordmarket.admin.config;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@Configuration
|
||||
public class CacheConfig {
|
||||
|
||||
@Bean
|
||||
public Cache<String, Object> caffeineAggregateCache(AppProperties properties) {
|
||||
return Caffeine.newBuilder()
|
||||
.expireAfterWrite(Duration.ofMinutes(properties.getCache().getTtlMinutes()))
|
||||
.maximumSize(properties.getCache().getMaximumSize())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.wordmarket.admin.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
PaginationInnerInterceptor pagination = new PaginationInnerInterceptor(DbType.MYSQL);
|
||||
pagination.setMaxLimit(100L);
|
||||
interceptor.addInnerInterceptor(pagination);
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.wordmarket.admin.config;
|
||||
|
||||
import com.wordmarket.admin.security.JwtAuthFilter;
|
||||
import com.wordmarket.admin.security.RestAuthEntryPoint;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig {
|
||||
|
||||
private final JwtAuthFilter jwtAuthFilter;
|
||||
private final RestAuthEntryPoint restAuthEntryPoint;
|
||||
private final AppProperties appProperties;
|
||||
|
||||
public SecurityConfig(JwtAuthFilter jwtAuthFilter, RestAuthEntryPoint restAuthEntryPoint,
|
||||
AppProperties appProperties) {
|
||||
this.jwtAuthFilter = jwtAuthFilter;
|
||||
this.restAuthEntryPoint = restAuthEntryPoint;
|
||||
this.appProperties = appProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
.cors(Customizer.withDefaults())
|
||||
.sessionManagement(session ->
|
||||
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(authorize -> authorize
|
||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
.requestMatchers("/api/auth/login", "/error").permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.exceptionHandling(handling ->
|
||||
handling.authenticationEntryPoint(restAuthEntryPoint))
|
||||
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.httpBasic(AbstractHttpConfigurer::disable)
|
||||
.formLogin(AbstractHttpConfigurer::disable)
|
||||
.logout(AbstractHttpConfigurer::disable)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
List<String> origins = Arrays.stream(appProperties.getCors().getAllowedOrigins().split(","))
|
||||
.map(String::trim)
|
||||
.filter(value -> !value.isEmpty())
|
||||
.toList();
|
||||
configuration.setAllowedOrigins(origins);
|
||||
configuration.setAllowedMethods(List.of("GET", "POST", "OPTIONS"));
|
||||
configuration.setAllowedHeaders(List.of("Authorization", "Content-Type"));
|
||||
configuration.setMaxAge(3600L);
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/api/**", configuration);
|
||||
return source;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.dto.AuthDtos.LoginRequest;
|
||||
import com.wordmarket.admin.dto.AuthDtos.LoginResponse;
|
||||
import com.wordmarket.admin.service.AuthService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
public class AuthController {
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
public AuthController(AuthService authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public ApiResponse<LoginResponse> login(@Valid @RequestBody LoginRequest request) {
|
||||
return ApiResponse.ok(authService.login(request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.common.Items;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookDetail;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookEntryItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookListItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.ExamOption;
|
||||
import com.wordmarket.admin.service.BookService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class BookController {
|
||||
|
||||
private final BookService bookService;
|
||||
|
||||
public BookController(BookService bookService) {
|
||||
this.bookService = bookService;
|
||||
}
|
||||
|
||||
@GetMapping("/books")
|
||||
public ApiResponse<PageResult<BookListItem>> list(
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size,
|
||||
@RequestParam(required = false) Long examId,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Boolean hasFile) {
|
||||
return ApiResponse.ok(bookService.list(page, size, examId, keyword, hasFile));
|
||||
}
|
||||
|
||||
@GetMapping("/books/{id}")
|
||||
public ApiResponse<BookDetail> detail(@PathVariable long id) {
|
||||
return ApiResponse.ok(bookService.detail(id));
|
||||
}
|
||||
|
||||
@GetMapping("/books/{id}/entries")
|
||||
public ApiResponse<PageResult<BookEntryItem>> entries(
|
||||
@PathVariable long id,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size,
|
||||
@RequestParam(required = false) String keyword) {
|
||||
return ApiResponse.ok(bookService.entries(id, page, size, keyword));
|
||||
}
|
||||
|
||||
@GetMapping("/exams")
|
||||
public ApiResponse<Items<ExamOption>> exams() {
|
||||
List<ExamOption> options = bookService.exams();
|
||||
return ApiResponse.ok(Items.of(options));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.common.Items;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.ExamStat;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.PosStat;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.Summary;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.TopBook;
|
||||
import com.wordmarket.admin.service.DashboardService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/dashboard")
|
||||
public class DashboardController {
|
||||
|
||||
private final DashboardService dashboardService;
|
||||
|
||||
public DashboardController(DashboardService dashboardService) {
|
||||
this.dashboardService = dashboardService;
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
public ApiResponse<Summary> summary(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
return ApiResponse.ok(dashboardService.summary(refresh));
|
||||
}
|
||||
|
||||
@GetMapping("/exam-distribution")
|
||||
public ApiResponse<Items<ExamStat>> examDistribution(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
return ApiResponse.ok(Items.of(dashboardService.examDistribution(refresh)));
|
||||
}
|
||||
|
||||
@GetMapping("/book-size-top")
|
||||
public ApiResponse<Items<TopBook>> bookSizeTop(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
return ApiResponse.ok(Items.of(dashboardService.topBooks(refresh)));
|
||||
}
|
||||
|
||||
@GetMapping("/pos-distribution")
|
||||
public ApiResponse<Items<PosStat>> posDistribution(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
return ApiResponse.ok(Items.of(dashboardService.posDistribution(refresh)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.common.Items;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ConfusableItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryBookItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryDetail;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryListItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleGroupItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SpellingVariantItem;
|
||||
import com.wordmarket.admin.service.EntryService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/entries")
|
||||
public class EntryController {
|
||||
|
||||
private final EntryService entryService;
|
||||
|
||||
public EntryController(EntryService entryService) {
|
||||
this.entryService = entryService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ApiResponse<PageResult<EntryListItem>> list(
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size,
|
||||
@RequestParam(required = false) String keyword) {
|
||||
return ApiResponse.ok(entryService.list(page, size, keyword));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ApiResponse<EntryDetail> detail(@PathVariable long id) {
|
||||
return ApiResponse.ok(entryService.detail(id));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/senses")
|
||||
public ApiResponse<Items<SenseItem>> senses(@PathVariable long id) {
|
||||
List<SenseItem> items = entryService.senses(id);
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/phrases")
|
||||
public ApiResponse<PageResult<PhraseItem>> phrases(
|
||||
@PathVariable long id,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(entryService.phrases(id, page, size));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/examples")
|
||||
public ApiResponse<PageResult<ExampleGroupItem>> examples(
|
||||
@PathVariable long id,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(entryService.examples(id, page, size));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/confusables")
|
||||
public ApiResponse<Items<ConfusableItem>> confusables(@PathVariable long id) {
|
||||
List<ConfusableItem> items = entryService.confusables(id);
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/variants")
|
||||
public ApiResponse<Items<SpellingVariantItem>> variants(@PathVariable long id) {
|
||||
List<SpellingVariantItem> items = entryService.spellingVariants(id);
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/books")
|
||||
public ApiResponse<PageResult<EntryBookItem>> books(
|
||||
@PathVariable long id,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(entryService.books(id, page, size));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardDetail;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyDetail;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeDetail;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.TreePage;
|
||||
import com.wordmarket.admin.service.MorphologyService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class MorphologyController {
|
||||
|
||||
private final MorphologyService morphologyService;
|
||||
|
||||
public MorphologyController(MorphologyService morphologyService) {
|
||||
this.morphologyService = morphologyService;
|
||||
}
|
||||
|
||||
@GetMapping("/morphemes")
|
||||
public ApiResponse<PageResult<MorphemeItem>> morphemes(
|
||||
@RequestParam(required = false) String type,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(morphologyService.morphemes(type, keyword, page, size));
|
||||
}
|
||||
|
||||
@GetMapping("/morphemes/{id}")
|
||||
public ApiResponse<MorphemeDetail> morpheme(@PathVariable long id) {
|
||||
return ApiResponse.ok(morphologyService.morpheme(id));
|
||||
}
|
||||
|
||||
@GetMapping("/cards")
|
||||
public ApiResponse<PageResult<CardItem>> cards(
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(morphologyService.cards(keyword, page, size));
|
||||
}
|
||||
|
||||
@GetMapping("/cards/{id}")
|
||||
public ApiResponse<CardDetail> card(@PathVariable long id) {
|
||||
return ApiResponse.ok(morphologyService.card(id));
|
||||
}
|
||||
|
||||
@GetMapping("/families")
|
||||
public ApiResponse<PageResult<FamilyItem>> families(
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(morphologyService.families(keyword, page, size));
|
||||
}
|
||||
|
||||
@GetMapping("/families/{id}")
|
||||
public ApiResponse<FamilyDetail> family(@PathVariable long id) {
|
||||
return ApiResponse.ok(morphologyService.family(id));
|
||||
}
|
||||
|
||||
@GetMapping("/families/{id}/tree")
|
||||
public ApiResponse<TreePage> tree(
|
||||
@PathVariable long id,
|
||||
@RequestParam(required = false) String nodeType,
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return ApiResponse.ok(morphologyService.tree(id, nodeType, page, size));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.common.Items;
|
||||
import com.wordmarket.admin.dto.QualityDtos.Coverage;
|
||||
import com.wordmarket.admin.dto.QualityDtos.DeclaredDiff;
|
||||
import com.wordmarket.admin.dto.QualityDtos.MissingReference;
|
||||
import com.wordmarket.admin.dto.QualityDtos.QualitySummary;
|
||||
import com.wordmarket.admin.service.QualityService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/quality")
|
||||
public class QualityController {
|
||||
|
||||
private final QualityService qualityService;
|
||||
|
||||
public QualityController(QualityService qualityService) {
|
||||
this.qualityService = qualityService;
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
public ApiResponse<QualitySummary> summary(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
return ApiResponse.ok(qualityService.summary(refresh));
|
||||
}
|
||||
|
||||
@GetMapping("/declared-vs-actual")
|
||||
public ApiResponse<Items<DeclaredDiff>> declaredVsActual(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
List<DeclaredDiff> items = qualityService.declaredVsActual(refresh);
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
|
||||
@GetMapping("/missing-references")
|
||||
public ApiResponse<Items<MissingReference>> missingReferences(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
List<MissingReference> items = qualityService.missingReferences(refresh);
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
|
||||
@GetMapping("/cross-domain-coverage")
|
||||
public ApiResponse<Items<Coverage>> crossDomainCoverage(
|
||||
@RequestParam(defaultValue = "false") boolean refresh) {
|
||||
List<Coverage> items = qualityService.crossDomainCoverage(refresh);
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.wordmarket.admin.controller;
|
||||
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import com.wordmarket.admin.common.Items;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.SizeBucket;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordDetail;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordItem;
|
||||
import com.wordmarket.admin.service.SynonymService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/synonyms")
|
||||
public class SynonymController {
|
||||
|
||||
private final SynonymService synonymService;
|
||||
|
||||
public SynonymController(SynonymService synonymService) {
|
||||
this.synonymService = synonymService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ApiResponse<PageResult<WordItem>> list(
|
||||
@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size,
|
||||
@RequestParam(required = false) String keyword) {
|
||||
return ApiResponse.ok(synonymService.list(page, size, keyword));
|
||||
}
|
||||
|
||||
@GetMapping("/group-size-distribution")
|
||||
public ApiResponse<Items<SizeBucket>> distribution() {
|
||||
List<SizeBucket> items = synonymService.groupSizeDistribution();
|
||||
return ApiResponse.ok(Items.of(items));
|
||||
}
|
||||
|
||||
@GetMapping("/{wordId}")
|
||||
public ApiResponse<WordDetail> detail(@PathVariable long wordId) {
|
||||
return ApiResponse.ok(synonymService.detail(wordId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public final class AuthDtos {
|
||||
|
||||
private AuthDtos() {
|
||||
}
|
||||
|
||||
public record LoginRequest(@NotBlank(message = "用户名不能为空") String username,
|
||||
@NotBlank(message = "密码不能为空") String password) {
|
||||
}
|
||||
|
||||
public record LoginResponse(String token, String expiresAt, String username) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
public final class BookDtos {
|
||||
|
||||
private BookDtos() {
|
||||
}
|
||||
|
||||
public record ExamOption(String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record BookListItem(String id, String code, String name, String examId, String examName,
|
||||
Long declared, long actual, boolean hasFile, String coverPath) {
|
||||
}
|
||||
|
||||
public record BookDetail(String id, String code, String name, String description, String examId,
|
||||
String examName, Long declared, long actual, Integer contentVersion,
|
||||
Integer schemaVersion, String coverPath, String packageUrl, boolean hasFile,
|
||||
Long sortAt, String labels, boolean mismatch) {
|
||||
}
|
||||
|
||||
public record BookDetailRow(String id, String code, String name, String description, String examId,
|
||||
String examName, Long declared, long actual, Integer contentVersion,
|
||||
Integer schemaVersion, String coverPath, String packageUrl,
|
||||
boolean hasFile, Long sortAt, String labels) {
|
||||
}
|
||||
|
||||
public record BookEntryItem(String entryId, String displayWord, String headwordText,
|
||||
Integer seqBook, Integer seqAz, Integer seqFreq, String headword,
|
||||
String indexWord) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class DashboardDtos {
|
||||
|
||||
private DashboardDtos() {
|
||||
}
|
||||
|
||||
public record Kpi(String key, String label, long value, String note, String tone) {
|
||||
}
|
||||
|
||||
public record QualityItem(String key, String label, long value, String unit, String level,
|
||||
String target) {
|
||||
}
|
||||
|
||||
public record CoverageItem(String name, long hit, long total, double pct) {
|
||||
}
|
||||
|
||||
public record Summary(List<Kpi> kpis, List<QualityItem> quality, List<CoverageItem> coverage) {
|
||||
}
|
||||
|
||||
public record ExamStat(String name, String code, long books, long entries) {
|
||||
}
|
||||
|
||||
public record TopBook(String id, String name, String code, String exam, Long declared,
|
||||
long actual, String coverPath) {
|
||||
}
|
||||
|
||||
public record PosStat(String name, long value) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class EntryDtos {
|
||||
|
||||
private EntryDtos() {
|
||||
}
|
||||
|
||||
public record ExamRef(String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record EntryListItem(String id, String headword, String indexWord, String pronunciation,
|
||||
String definition, long senseCount, long bookCount) {
|
||||
}
|
||||
|
||||
public record EntryDetail(String id, String headword, String indexWord, String usPronunciation,
|
||||
String ukPronunciation, String definitionText, String dataVersion,
|
||||
String bookExamId, String bookExamName, Integer occurrenceCount,
|
||||
boolean hasListeningExamples, String sourceZpkKey) {
|
||||
}
|
||||
|
||||
public record SenseRelation(String type, Integer position, String targetMeaningId,
|
||||
String targetEntryId) {
|
||||
}
|
||||
|
||||
public record SenseItem(String senseId, Integer senseNo, String partOfSpeech, String glossZh,
|
||||
List<ExamRef> exams, List<SenseRelation> relations) {
|
||||
}
|
||||
|
||||
public record PhraseOrder(String examId, String examName, Integer groupType, Integer position) {
|
||||
}
|
||||
|
||||
public record PhraseItem(String id, String textEn, String textZh, Integer groupType,
|
||||
String meaningId, List<ExamRef> exams, List<PhraseOrder> orders) {
|
||||
}
|
||||
|
||||
public record ExampleSentenceItem(String id, String textEn, String textZh, String sourceTitle,
|
||||
String audioUrl, boolean listening) {
|
||||
}
|
||||
|
||||
public record ExampleUsageItem(String id, String patternId, String patternText, Integer position,
|
||||
List<ExampleSentenceItem> sentences) {
|
||||
}
|
||||
|
||||
public record ExampleGroupItem(String id, Integer groupKind, String partOfSpeech,
|
||||
String entryKindCode, String headForm, String definitionEn,
|
||||
String definitionZh, List<ExamRef> exams,
|
||||
List<ExampleUsageItem> usages,
|
||||
List<ExampleSentenceItem> directSentences, long sentenceCount) {
|
||||
}
|
||||
|
||||
public record ConfusableItem(String id, String wordText, String glossZh, Integer posCode,
|
||||
String spellingFlag, Integer position) {
|
||||
}
|
||||
|
||||
public record SpellingVariantItem(Integer position, String variant) {
|
||||
}
|
||||
|
||||
public record EntryBookItem(String bookId, String bookName, String bookCode, String displayWord,
|
||||
Integer seqBook) {
|
||||
}
|
||||
|
||||
public record SenseExamRow(String senseId, String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record SenseRelationRow(String senseId, String type, Integer position, String targetMeaningId,
|
||||
String targetEntryId) {
|
||||
}
|
||||
|
||||
public record GroupExamRow(String groupId, String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record UsageRow(String id, String groupId, String patternId, String patternText,
|
||||
Integer position) {
|
||||
}
|
||||
|
||||
public record SentenceRow(String id, String groupId, String usageId, String textEn, String textZh,
|
||||
String sourceTitle, String audioUrl, boolean listening) {
|
||||
}
|
||||
|
||||
public record PhraseExamRow(String phraseId, String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record PhraseOrderRow(String examId, String examName, Integer groupType, Integer position,
|
||||
String phraseId) {
|
||||
}
|
||||
|
||||
public record SenseRow(String senseId, Integer senseNo, String partOfSpeech, String glossZh) {
|
||||
}
|
||||
|
||||
public record PhraseRow(String id, String textEn, String textZh, Integer groupType,
|
||||
String meaningId) {
|
||||
}
|
||||
|
||||
public record ExampleGroupRow(String id, Integer groupKind, String partOfSpeech,
|
||||
String entryKindCode, String headForm, String definitionEn,
|
||||
String definitionZh) {
|
||||
}
|
||||
|
||||
public record ConfusableRow(String id, String wordText, String glossZh, Integer posCode,
|
||||
String spellingFlag, Integer position) {
|
||||
}
|
||||
|
||||
public record VariantRow(Integer position, String variant) {
|
||||
}
|
||||
|
||||
public record EntryBookRow(String bookId, String bookName, String bookCode, String displayWord,
|
||||
Integer seqBook) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class MorphologyDtos {
|
||||
|
||||
private MorphologyDtos() {
|
||||
}
|
||||
|
||||
public record ExamRef(String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record MorphemeItem(String id, String type, String form, String displayText, String meaningEn,
|
||||
String meaningZh, String note) {
|
||||
}
|
||||
|
||||
public record CardBrief(String id, String word, String memoryNote, String exampleText) {
|
||||
}
|
||||
|
||||
public record CardRow(String id, String word, String highlightedWord, String memoryNote,
|
||||
String exampleText, boolean hidden, String prefixMorphemeId,
|
||||
String rootMorphemeId, String suffixMorphemeId, String defaultFamilyRef) {
|
||||
}
|
||||
|
||||
public record CardItemRow(String id, String word, String memoryNote, String highlightedWord) {
|
||||
}
|
||||
|
||||
public record FamilyRow(String id, String word, String topFamilyId, String topWord,
|
||||
String interpretation, Integer groupLevel1, Integer groupLevel2,
|
||||
Integer groupLevel3) {
|
||||
}
|
||||
|
||||
public record FamilyLinkRow(String id, Integer groupNo, String familyRef, boolean hidden) {
|
||||
}
|
||||
|
||||
public record MorphemeDetail(String id, String type, String form, String displayText,
|
||||
String meaningEn, String meaningZh, String note,
|
||||
List<CardBrief> cards, long cardCount) {
|
||||
}
|
||||
|
||||
public record CardItem(String id, String word, String memoryNote, String highlightedWord,
|
||||
List<ExamRef> exams) {
|
||||
}
|
||||
|
||||
public record CardFamilyLink(String linkId, Integer groupNo, String familyRef, boolean hidden) {
|
||||
}
|
||||
|
||||
public record CardDetail(String id, String word, String highlightedWord, String memoryNote,
|
||||
String exampleText, boolean hidden, String prefixMorphemeId, String prefixForm,
|
||||
String rootMorphemeId, String rootForm, String suffixMorphemeId,
|
||||
String suffixForm, String defaultFamilyRef, List<ExamRef> exams,
|
||||
List<CardFamilyLink> familyLinks) {
|
||||
}
|
||||
|
||||
public record FamilyItem(String id, String word, String topFamilyId, String topWord,
|
||||
String interpretation, Integer groupLevel1, Integer groupLevel2,
|
||||
Integer groupLevel3, List<ExamRef> exams) {
|
||||
}
|
||||
|
||||
public record FamilyVariantItem(String id, String variantWord, String interpretation,
|
||||
long memberCount) {
|
||||
}
|
||||
|
||||
public record FamilyMemberItem(String familyEntryId, String word, Integer position) {
|
||||
}
|
||||
|
||||
public record MiniGroupItem(String id, Integer size, List<FamilyMemberItem> members) {
|
||||
}
|
||||
|
||||
public record FamilyDetail(String id, String word, String topFamilyId, String topWord,
|
||||
String interpretation, Integer groupLevel1, Integer groupLevel2,
|
||||
Integer groupLevel3, List<ExamRef> exams,
|
||||
List<FamilyVariantItem> variants, List<MiniGroupItem> miniGroups) {
|
||||
}
|
||||
|
||||
public record TreeNode(String nodeType, String id, String label, String subtitle, long memberCount,
|
||||
boolean leaf) {
|
||||
}
|
||||
|
||||
public record TreePage(List<TreeNode> nodes, long total, int page, int size) {
|
||||
}
|
||||
|
||||
public record LinkExamRow(String cardId, String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record FamilyExamRow(String familyEntryId, String id, String code, String name) {
|
||||
}
|
||||
|
||||
public record MorphemeRefRow(String id, String form, String type, String meaningZh) {
|
||||
}
|
||||
|
||||
public record FamilyWordRow(String id, String word, String interpretation) {
|
||||
}
|
||||
|
||||
public record VariantRow(String id, String variantWord, String interpretation, long memberCount) {
|
||||
}
|
||||
|
||||
public record MiniGroupRow(String id, Integer size) {
|
||||
}
|
||||
|
||||
public record MemberRow(String familyEntryId, String word, Integer position) {
|
||||
}
|
||||
|
||||
public record CountRow(long count) {
|
||||
}
|
||||
|
||||
public record TreeCounts(long variantCount, long groupCount) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class QualityDtos {
|
||||
|
||||
private QualityDtos() {
|
||||
}
|
||||
|
||||
public record SummaryItem(String key, String label, long value, String unit, String level,
|
||||
String description) {
|
||||
}
|
||||
|
||||
public record QualitySummary(List<SummaryItem> items) {
|
||||
}
|
||||
|
||||
public record DeclaredDiff(String bookId, String bookName, String bookCode, String examName,
|
||||
long declared, long actual, long diff) {
|
||||
}
|
||||
|
||||
public record MissingReference(String type, String identifier, String source, String detail,
|
||||
String bookId) {
|
||||
}
|
||||
|
||||
public record Coverage(String key, String name, long hit, long total, double pct) {
|
||||
}
|
||||
|
||||
public record MissingBook(String bookId, String bookCode, String bookName) {
|
||||
}
|
||||
|
||||
public record MissingZpk(String sourceKey, long rowCount, String bookIds) {
|
||||
}
|
||||
|
||||
public record CountPair(long total, long hit) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.wordmarket.admin.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class SynonymDtos {
|
||||
|
||||
private SynonymDtos() {
|
||||
}
|
||||
|
||||
public record WordItem(String wordId, String word, long senseCount, boolean hasRelation) {
|
||||
}
|
||||
|
||||
public record WordRow(String wordId, String word) {
|
||||
}
|
||||
|
||||
public record SenseRow(String senseId, String partOfSpeech, String glossZh) {
|
||||
}
|
||||
|
||||
public record MemberItem(String wordId, String word, Integer position) {
|
||||
}
|
||||
|
||||
public record GroupItem(String examId, String examName, String canonicalWordId, String canonicalWord,
|
||||
Integer memberCount, List<MemberItem> members, boolean truncated) {
|
||||
}
|
||||
|
||||
public record AntonymItem(String examId, String examName, List<MemberItem> words) {
|
||||
}
|
||||
|
||||
public record SenseItem(String senseId, String partOfSpeech, String glossZh, List<GroupItem> groups,
|
||||
List<AntonymItem> antonyms) {
|
||||
}
|
||||
|
||||
public record WordDetail(String wordId, String word, List<SenseItem> senses) {
|
||||
}
|
||||
|
||||
public record SizeBucket(String label, long count, double pct) {
|
||||
}
|
||||
|
||||
public record GroupRow(String senseId, String examId, String examName, String canonicalWordId,
|
||||
String canonicalWord, Integer memberCount) {
|
||||
}
|
||||
|
||||
public record MemberRow(String senseId, String examId, String wordId, String word, Integer position) {
|
||||
}
|
||||
|
||||
public record AntonymRow(String senseId, String examId, String examName, String wordId, String word,
|
||||
Integer position) {
|
||||
}
|
||||
|
||||
public record ExamRow(String examId, String examName) {
|
||||
}
|
||||
|
||||
public record BucketRow(String label, long count) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.wordmarket.admin.mapper;
|
||||
|
||||
import com.wordmarket.admin.dto.BookDtos.BookDetailRow;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookEntryItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookListItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.ExamOption;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BookMapper {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*)
|
||||
FROM book b
|
||||
<where>
|
||||
<if test="examId != null">AND b.exam_id = #{examId}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (LOWER(b.book_name) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
OR LOWER(b.book_code) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
|
||||
</if>
|
||||
<if test="hasFile != null">AND b.has_wordbook_file = #{hasFile}</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
long countBooks(@Param("examId") Long examId, @Param("keyword") String keyword,
|
||||
@Param("hasFile") Boolean hasFile);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT b.book_id AS id,
|
||||
b.book_code AS code,
|
||||
b.book_name AS name,
|
||||
b.exam_id AS exam_id,
|
||||
e.exam_name_zh AS exam_name,
|
||||
b.declared_entry_count AS declared,
|
||||
(SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id) AS actual,
|
||||
b.has_wordbook_file AS has_file,
|
||||
b.cover_url AS cover_path
|
||||
FROM book b
|
||||
LEFT JOIN exam e ON e.exam_id = b.exam_id
|
||||
<where>
|
||||
<if test="examId != null">AND b.exam_id = #{examId}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (LOWER(b.book_name) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
OR LOWER(b.book_code) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
|
||||
</if>
|
||||
<if test="hasFile != null">AND b.has_wordbook_file = #{hasFile}</if>
|
||||
</where>
|
||||
ORDER BY b.book_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<BookListItem> listBooks(@Param("examId") Long examId, @Param("keyword") String keyword,
|
||||
@Param("hasFile") Boolean hasFile, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
SELECT b.book_id AS id,
|
||||
b.book_code AS code,
|
||||
b.book_name AS name,
|
||||
b.description,
|
||||
b.exam_id AS exam_id,
|
||||
e.exam_name_zh AS exam_name,
|
||||
b.declared_entry_count AS declared,
|
||||
(SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id) AS actual,
|
||||
b.content_version,
|
||||
b.schema_version,
|
||||
b.cover_url AS cover_path,
|
||||
b.package_url,
|
||||
b.has_wordbook_file AS has_file,
|
||||
b.sort_at,
|
||||
b.labels
|
||||
FROM book b
|
||||
LEFT JOIN exam e ON e.exam_id = b.exam_id
|
||||
WHERE b.book_id = #{id}
|
||||
""")
|
||||
BookDetailRow findBook(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*)
|
||||
FROM book_entry be
|
||||
WHERE be.book_id = #{bookId}
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (LOWER(be.display_word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
OR LOWER(be.headword_text) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
|
||||
</if>
|
||||
</script>
|
||||
""")
|
||||
long countBookEntries(@Param("bookId") long bookId, @Param("keyword") String keyword);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT be.entry_id AS entry_id,
|
||||
be.display_word AS display_word,
|
||||
be.headword_text AS headword_text,
|
||||
be.seq_book,
|
||||
be.seq_az,
|
||||
be.seq_freq,
|
||||
e.headword,
|
||||
e.index_word
|
||||
FROM book_entry be
|
||||
LEFT JOIN word_entry e ON e.entry_id = be.entry_id
|
||||
WHERE be.book_id = #{bookId}
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (LOWER(be.display_word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
OR LOWER(be.headword_text) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
|
||||
</if>
|
||||
ORDER BY be.seq_book, be.book_entry_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<BookEntryItem> listBookEntries(@Param("bookId") long bookId,
|
||||
@Param("keyword") String keyword,
|
||||
@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
SELECT exam_id AS id, exam_code AS code, exam_name_zh AS name
|
||||
FROM exam
|
||||
WHERE is_pseudo = 0
|
||||
ORDER BY exam_id
|
||||
""")
|
||||
List<ExamOption> listExams();
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.wordmarket.admin.mapper;
|
||||
|
||||
import com.wordmarket.admin.dto.DashboardDtos.ExamStat;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.PosStat;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.TopBook;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DashboardMapper {
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book")
|
||||
long countBooks();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book WHERE has_wordbook_file = 0")
|
||||
long countBooksWithoutFile();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM word_entry")
|
||||
long countEntries();
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT index_word) FROM word_entry")
|
||||
long countIndexWords();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book_entry")
|
||||
long countBookEntries();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM example_sentence")
|
||||
long countExampleSentences();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM example_usage")
|
||||
long countExampleUsages();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM word_family")
|
||||
long countFamilies();
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT top_family_id) FROM word_family")
|
||||
long countTopFamilies();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM synonym_word")
|
||||
long countSynonymWords();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM synonym_sense")
|
||||
long countSynonymSenses();
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COALESCE(e.exam_name_zh, '未归类') AS name,
|
||||
e.exam_code AS code,
|
||||
COUNT(*) AS books,
|
||||
COALESCE(SUM(x.c), 0) AS entries
|
||||
FROM book b
|
||||
LEFT JOIN exam e ON e.exam_id = b.exam_id
|
||||
LEFT JOIN (SELECT book_id, COUNT(*) AS c FROM book_entry GROUP BY book_id) x
|
||||
ON x.book_id = b.book_id
|
||||
GROUP BY b.exam_id, e.exam_name_zh, e.exam_code
|
||||
ORDER BY entries DESC, books DESC
|
||||
</script>
|
||||
""")
|
||||
List<ExamStat> examDistribution();
|
||||
|
||||
@Select("""
|
||||
SELECT b.book_id AS id,
|
||||
b.book_name AS name,
|
||||
b.book_code AS code,
|
||||
e.exam_name_zh AS exam,
|
||||
b.declared_entry_count AS declared,
|
||||
(SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id) AS actual,
|
||||
b.cover_url AS cover_path
|
||||
FROM book b
|
||||
LEFT JOIN exam e ON e.exam_id = b.exam_id
|
||||
ORDER BY actual DESC, b.book_id
|
||||
LIMIT 10
|
||||
""")
|
||||
List<TopBook> topBooks();
|
||||
|
||||
@Select("""
|
||||
SELECT COALESCE(NULLIF(part_of_speech, ''), '未标注') AS name,
|
||||
COUNT(*) AS value
|
||||
FROM word_sense
|
||||
GROUP BY part_of_speech
|
||||
ORDER BY value DESC, name
|
||||
LIMIT 10
|
||||
""")
|
||||
List<PosStat> posDistribution();
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package com.wordmarket.admin.mapper;
|
||||
|
||||
import com.wordmarket.admin.dto.EntryDtos.ConfusableRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryBookRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryDetail;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryListItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleGroupRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.GroupExamRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseExamRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseOrderRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseExamRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseRelationRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SentenceRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.UsageRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.VariantRow;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface EntryMapper {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*)
|
||||
FROM word_entry e
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (LOWER(e.headword) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
OR LOWER(e.index_word) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
|
||||
</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
long countEntries(@Param("keyword") String keyword);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT e.entry_id AS id,
|
||||
e.headword,
|
||||
e.index_word,
|
||||
COALESCE(NULLIF(e.us_pronunciation, ''), e.uk_pronunciation) AS pronunciation,
|
||||
e.definition_text AS definition,
|
||||
(SELECT COUNT(*) FROM word_sense s WHERE s.entry_id = e.entry_id) AS sense_count,
|
||||
(SELECT COUNT(*) FROM book_entry be WHERE be.entry_id = e.entry_id) AS book_count
|
||||
FROM word_entry e
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (LOWER(e.headword) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
OR LOWER(e.index_word) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY e.entry_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<EntryListItem> listEntries(@Param("keyword") String keyword, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
SELECT e.entry_id AS id,
|
||||
e.headword,
|
||||
e.index_word,
|
||||
e.us_pronunciation,
|
||||
e.uk_pronunciation,
|
||||
e.definition_text,
|
||||
e.data_version,
|
||||
e.book_exam_id AS book_exam_id,
|
||||
ex.exam_name_zh AS book_exam_name,
|
||||
e.occurrence_count,
|
||||
e.has_listening_examples,
|
||||
e.source_zpk_key
|
||||
FROM word_entry e
|
||||
LEFT JOIN exam ex ON ex.exam_id = e.book_exam_id
|
||||
WHERE e.entry_id = #{id}
|
||||
""")
|
||||
EntryDetail findEntry(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
SELECT sense_id, sense_no, part_of_speech, gloss_zh
|
||||
FROM word_sense
|
||||
WHERE entry_id = #{entryId}
|
||||
ORDER BY sense_no, sense_id
|
||||
""")
|
||||
List<SenseRow> listSenses(@Param("entryId") long entryId);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT se.sense_id, ex.exam_id AS id, ex.exam_code AS code, ex.exam_name_zh AS name
|
||||
FROM sense_exam se
|
||||
JOIN exam ex ON ex.exam_id = se.exam_id
|
||||
WHERE se.sense_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY se.sense_id, ex.exam_id
|
||||
</script>
|
||||
""")
|
||||
List<SenseExamRow> listSenseExams(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT sr.sense_id,
|
||||
sr.relation_type AS type,
|
||||
sr.position,
|
||||
sr.target_meaning_id,
|
||||
so.entry_id AS target_entry_id
|
||||
FROM sense_relation sr
|
||||
JOIN sense_object so ON so.meaning_id = sr.target_meaning_id
|
||||
WHERE sr.sense_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY sr.sense_id, sr.relation_type, sr.position
|
||||
</script>
|
||||
""")
|
||||
List<SenseRelationRow> listSenseRelations(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM phrase WHERE entry_id = #{entryId}")
|
||||
long countPhrases(@Param("entryId") long entryId);
|
||||
|
||||
@Select("""
|
||||
SELECT phrase_id AS id, text_en, text_zh, group_type, meaning_id
|
||||
FROM phrase
|
||||
WHERE entry_id = #{entryId}
|
||||
ORDER BY phrase_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<PhraseRow> listPhrases(@Param("entryId") long entryId, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT pe.phrase_id, ex.exam_id AS id, ex.exam_code AS code, ex.exam_name_zh AS name
|
||||
FROM phrase_exam pe
|
||||
JOIN exam ex ON ex.exam_id = pe.exam_id
|
||||
WHERE pe.phrase_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY pe.phrase_id, ex.exam_id
|
||||
</script>
|
||||
""")
|
||||
List<PhraseExamRow> listPhraseExams(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
SELECT p.exam_id, ex.exam_name_zh AS exam_name, p.group_type, p.position, p.phrase_id
|
||||
FROM phrase_exam_order p
|
||||
JOIN exam ex ON ex.exam_id = p.exam_id
|
||||
WHERE p.entry_id = #{entryId}
|
||||
ORDER BY p.exam_id, p.group_type, p.position
|
||||
""")
|
||||
List<PhraseOrderRow> listPhraseOrders(@Param("entryId") long entryId);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM example_group WHERE entry_id = #{entryId}")
|
||||
long countExampleGroups(@Param("entryId") long entryId);
|
||||
|
||||
@Select("""
|
||||
SELECT example_group_id AS id, group_kind, part_of_speech, entry_kind_code, head_form,
|
||||
definition_en, definition_zh
|
||||
FROM example_group
|
||||
WHERE entry_id = #{entryId}
|
||||
ORDER BY group_kind, example_group_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<ExampleGroupRow> listExampleGroups(@Param("entryId") long entryId,
|
||||
@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT ge.example_group_id AS group_id, ex.exam_id AS id, ex.exam_code AS code,
|
||||
ex.exam_name_zh AS name
|
||||
FROM example_group_exam ge
|
||||
JOIN exam ex ON ex.exam_id = ge.exam_id
|
||||
WHERE ge.example_group_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY ge.example_group_id, ex.exam_id
|
||||
</script>
|
||||
""")
|
||||
List<GroupExamRow> listExampleGroupExams(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT usage_id AS id, example_group_id AS group_id, pattern_id, pattern_text, position
|
||||
FROM example_usage
|
||||
WHERE example_group_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY example_group_id, position, usage_id
|
||||
</script>
|
||||
""")
|
||||
List<UsageRow> listExampleUsages(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT sentence_id AS id, example_group_id AS group_id, usage_id, text_en, text_zh,
|
||||
source_title, audio_url, is_listening_corpus AS listening
|
||||
FROM example_sentence
|
||||
WHERE example_group_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY example_group_id, position, sentence_id
|
||||
</script>
|
||||
""")
|
||||
List<SentenceRow> listExampleSentences(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
SELECT confusable_id AS id, word_text, gloss_zh, pos_code, spelling_flag, position
|
||||
FROM confusable_word
|
||||
WHERE entry_id = #{entryId}
|
||||
ORDER BY position, confusable_id
|
||||
""")
|
||||
List<ConfusableRow> listConfusables(@Param("entryId") long entryId);
|
||||
|
||||
@Select("""
|
||||
SELECT position, variant
|
||||
FROM word_spelling_variant
|
||||
WHERE entry_id = #{entryId}
|
||||
ORDER BY position
|
||||
""")
|
||||
List<VariantRow> listSpellingVariants(@Param("entryId") long entryId);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book_entry WHERE entry_id = #{entryId}")
|
||||
long countEntryBooks(@Param("entryId") long entryId);
|
||||
|
||||
@Select("""
|
||||
SELECT be.book_id AS book_id, b.book_name, b.book_code, be.display_word, be.seq_book
|
||||
FROM book_entry be
|
||||
JOIN book b ON b.book_id = be.book_id
|
||||
WHERE be.entry_id = #{entryId}
|
||||
ORDER BY b.book_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<EntryBookRow> listEntryBooks(@Param("entryId") long entryId, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
package com.wordmarket.admin.mapper;
|
||||
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardBrief;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyExamRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyLinkRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyWordRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.LinkExamRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MemberRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MiniGroupRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeRefRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.TreeNode;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.TreeCounts;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.VariantRow;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MorphologyMapper {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*) FROM morpheme
|
||||
<where>
|
||||
<if test="type != null and type != ''">AND morpheme_type = #{type}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(form) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
long countMorphemes(@Param("type") String type, @Param("keyword") String keyword);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT morpheme_id AS id, morpheme_type AS type, form, display_text, meaning_en, meaning_zh,
|
||||
note
|
||||
FROM morpheme
|
||||
<where>
|
||||
<if test="type != null and type != ''">AND morpheme_type = #{type}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(form) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY morpheme_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<MorphemeItem> listMorphemes(@Param("type") String type, @Param("keyword") String keyword,
|
||||
@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
SELECT morpheme_id AS id, morpheme_type AS type, form, display_text, meaning_en, meaning_zh,
|
||||
note
|
||||
FROM morpheme
|
||||
WHERE morpheme_id = #{id}
|
||||
""")
|
||||
MorphemeItem findMorpheme(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(*) FROM card
|
||||
WHERE prefix_morpheme_id = #{id} OR root_morpheme_id = #{id} OR suffix_morpheme_id = #{id}
|
||||
""")
|
||||
long countCardsByMorpheme(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
SELECT card_id AS id, word, memory_note, example_text
|
||||
FROM card
|
||||
WHERE prefix_morpheme_id = #{id} OR root_morpheme_id = #{id} OR suffix_morpheme_id = #{id}
|
||||
ORDER BY card_id
|
||||
LIMIT 100
|
||||
""")
|
||||
List<CardBrief> listCardsByMorpheme(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*) FROM card
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
long countCards(@Param("keyword") String keyword);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT card_id AS id, word, memory_note, highlighted_word
|
||||
FROM card
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY card_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<com.wordmarket.admin.dto.MorphologyDtos.CardItemRow> listCards(@Param("keyword") String keyword,
|
||||
@Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
SELECT card_id AS id, word, highlighted_word, memory_note, example_text, is_hidden AS hidden,
|
||||
prefix_morpheme_id, root_morpheme_id, suffix_morpheme_id, default_family_ref
|
||||
FROM card
|
||||
WHERE card_id = #{id}
|
||||
""")
|
||||
CardRow findCard(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT ce.card_id, ex.exam_id AS id, ex.exam_code AS code, ex.exam_name_zh AS name
|
||||
FROM card_exam ce
|
||||
JOIN exam ex ON ex.exam_id = ce.exam_id
|
||||
WHERE ce.card_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY ce.card_id, ex.exam_id
|
||||
</script>
|
||||
""")
|
||||
List<LinkExamRow> listCardExams(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT morpheme_id AS id, form, morpheme_type AS type, meaning_zh
|
||||
FROM morpheme
|
||||
WHERE morpheme_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</script>
|
||||
""")
|
||||
List<MorphemeRefRow> listMorphemeRefs(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
SELECT link_id AS id, group_no, family_ref, is_hidden AS hidden
|
||||
FROM card_family_link
|
||||
WHERE card_id = #{cardId}
|
||||
ORDER BY group_no, link_id
|
||||
""")
|
||||
List<FamilyLinkRow> listCardFamilyLinks(@Param("cardId") long cardId);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*) FROM word_family f
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(f.word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
long countFamilies(@Param("keyword") String keyword);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT f.family_entry_id AS id, f.word, f.top_family_id AS top_family_id,
|
||||
t.word AS top_word, f.interpretation,
|
||||
f.group_level_1, f.group_level_2, f.group_level_3
|
||||
FROM word_family f
|
||||
LEFT JOIN word_family t ON t.family_entry_id = f.top_family_id
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(f.word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY f.family_entry_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<FamilyRow> listFamilies(@Param("keyword") String keyword, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
SELECT f.family_entry_id AS id, f.word, f.top_family_id AS top_family_id,
|
||||
t.word AS top_word, f.interpretation,
|
||||
f.group_level_1, f.group_level_2, f.group_level_3
|
||||
FROM word_family f
|
||||
LEFT JOIN word_family t ON t.family_entry_id = f.top_family_id
|
||||
WHERE f.family_entry_id = #{id}
|
||||
""")
|
||||
FamilyRow findFamily(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT fe.family_entry_id, ex.exam_id AS id, ex.exam_code AS code, ex.exam_name_zh AS name
|
||||
FROM word_family_exam fe
|
||||
JOIN exam ex ON ex.exam_id = fe.exam_id
|
||||
WHERE fe.family_entry_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY fe.family_entry_id, ex.exam_id
|
||||
</script>
|
||||
""")
|
||||
List<FamilyExamRow> listFamilyExams(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
SELECT v.variant_id AS id, v.variant_word, v.interpretation,
|
||||
(SELECT COUNT(*) FROM word_family_variant_member m
|
||||
WHERE m.variant_id = v.variant_id) AS member_count
|
||||
FROM word_family_variant v
|
||||
WHERE v.top_family_id = #{topId}
|
||||
ORDER BY v.variant_id
|
||||
""")
|
||||
List<VariantRow> listVariants(@Param("topId") long topId);
|
||||
|
||||
@Select("""
|
||||
SELECT mg.mini_group_id AS id, mg.size
|
||||
FROM word_family_mini_group mg
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM word_family_mini_group_member m
|
||||
JOIN word_family f ON f.family_entry_id = m.family_entry_id
|
||||
WHERE m.mini_group_id = mg.mini_group_id AND f.top_family_id = #{topId}
|
||||
)
|
||||
ORDER BY mg.mini_group_id
|
||||
LIMIT 200
|
||||
""")
|
||||
List<MiniGroupRow> listMiniGroups(@Param("topId") long topId);
|
||||
|
||||
@Select("""
|
||||
SELECT m.family_entry_id, f.word, m.position
|
||||
FROM word_family_mini_group_member m
|
||||
JOIN word_family f ON f.family_entry_id = m.family_entry_id
|
||||
WHERE m.mini_group_id = #{miniGroupId}
|
||||
ORDER BY m.position
|
||||
LIMIT 50
|
||||
""")
|
||||
List<MemberRow> listMiniGroupMembers(@Param("miniGroupId") long miniGroupId);
|
||||
|
||||
@Select("""
|
||||
SELECT (SELECT COUNT(*) FROM word_family_variant v WHERE v.top_family_id = #{topId})
|
||||
AS variant_count,
|
||||
(SELECT COUNT(*) FROM word_family_mini_group mg WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM word_family_mini_group_member m
|
||||
JOIN word_family f ON f.family_entry_id = m.family_entry_id
|
||||
WHERE m.mini_group_id = mg.mini_group_id AND f.top_family_id = #{topId}))
|
||||
AS group_count
|
||||
""")
|
||||
TreeCounts countTopChildren(@Param("topId") long topId);
|
||||
|
||||
@Select("""
|
||||
SELECT * FROM (
|
||||
SELECT 'variant' AS node_type,
|
||||
CAST(v.variant_id AS CHAR) AS id,
|
||||
v.variant_word AS label,
|
||||
v.interpretation AS subtitle,
|
||||
(SELECT COUNT(*) FROM word_family_variant_member m
|
||||
WHERE m.variant_id = v.variant_id) AS member_count,
|
||||
0 AS leaf
|
||||
FROM word_family_variant v
|
||||
WHERE v.top_family_id = #{topId}
|
||||
UNION ALL
|
||||
SELECT 'miniGroup' AS node_type,
|
||||
CAST(mg.mini_group_id AS CHAR) AS id,
|
||||
CONCAT('小组 #', mg.mini_group_id) AS label,
|
||||
CONCAT('成员 ', mg.size) AS subtitle,
|
||||
mg.size AS member_count,
|
||||
0 AS leaf
|
||||
FROM word_family_mini_group mg
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM word_family_mini_group_member m
|
||||
JOIN word_family f ON f.family_entry_id = m.family_entry_id
|
||||
WHERE m.mini_group_id = mg.mini_group_id AND f.top_family_id = #{topId}
|
||||
)
|
||||
) t
|
||||
ORDER BY node_type, id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<TreeNode> listTopChildren(@Param("topId") long topId, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM word_family_variant_member WHERE variant_id = #{variantId}")
|
||||
long countVariantMembers(@Param("variantId") long variantId);
|
||||
|
||||
@Select("""
|
||||
SELECT 'member' AS node_type,
|
||||
CONCAT('word:', vm.member_word, ':', vm.exam_id, ':', vm.position) AS id,
|
||||
vm.member_word AS label,
|
||||
CONCAT(COALESCE(ex.exam_name_zh, CONCAT('考试 ', vm.exam_id)), ' · 第 ',
|
||||
vm.position, ' 位') AS subtitle,
|
||||
0 AS member_count,
|
||||
1 AS leaf
|
||||
FROM word_family_variant_member vm
|
||||
LEFT JOIN exam ex ON ex.exam_id = vm.exam_id
|
||||
WHERE vm.variant_id = #{variantId}
|
||||
ORDER BY vm.exam_id, vm.position
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<TreeNode> listVariantMemberNodes(@Param("variantId") long variantId,
|
||||
@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM word_family_mini_group_member WHERE mini_group_id = #{miniGroupId}")
|
||||
long countMiniGroupMembers(@Param("miniGroupId") long miniGroupId);
|
||||
|
||||
@Select("""
|
||||
SELECT 'member' AS node_type,
|
||||
CONCAT('family:', m.family_entry_id) AS id,
|
||||
f.word AS label,
|
||||
CONCAT('词族内位置 ', m.position) AS subtitle,
|
||||
0 AS member_count,
|
||||
1 AS leaf
|
||||
FROM word_family_mini_group_member m
|
||||
JOIN word_family f ON f.family_entry_id = m.family_entry_id
|
||||
WHERE m.mini_group_id = #{miniGroupId}
|
||||
ORDER BY m.position
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<TreeNode> listMiniGroupMemberNodes(@Param("miniGroupId") long miniGroupId,
|
||||
@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT family_entry_id AS id, word, interpretation
|
||||
FROM word_family
|
||||
WHERE family_entry_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</script>
|
||||
""")
|
||||
List<FamilyWordRow> listFamilyWords(@Param("ids") List<Long> ids);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.wordmarket.admin.mapper;
|
||||
|
||||
import com.wordmarket.admin.dto.QualityDtos.DeclaredDiff;
|
||||
import com.wordmarket.admin.dto.QualityDtos.MissingBook;
|
||||
import com.wordmarket.admin.dto.QualityDtos.MissingZpk;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface QualityMapper {
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(*)
|
||||
FROM book b
|
||||
WHERE b.declared_entry_count IS NOT NULL
|
||||
AND b.declared_entry_count <> (SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id)
|
||||
""")
|
||||
long countDeclaredMismatch();
|
||||
|
||||
@Select("""
|
||||
SELECT b.book_id AS book_id,
|
||||
b.book_name,
|
||||
b.book_code,
|
||||
e.exam_name_zh AS exam_name,
|
||||
b.declared_entry_count AS declared,
|
||||
(SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id) AS actual,
|
||||
(SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id)
|
||||
- b.declared_entry_count AS diff
|
||||
FROM book b
|
||||
LEFT JOIN exam e ON e.exam_id = b.exam_id
|
||||
WHERE b.declared_entry_count IS NOT NULL
|
||||
AND b.declared_entry_count <> (SELECT COUNT(*) FROM book_entry be WHERE be.book_id = b.book_id)
|
||||
ORDER BY ABS(diff) DESC, b.book_id
|
||||
""")
|
||||
List<DeclaredDiff> listDeclaredMismatch();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book WHERE has_wordbook_file = 0")
|
||||
long countMissingFiles();
|
||||
|
||||
@Select("SELECT book_id AS book_id, book_code, book_name FROM book WHERE has_wordbook_file = 0")
|
||||
List<MissingBook> listMissingFileBooks();
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT be.source_zpk_key AS source_key,
|
||||
COUNT(*) AS row_count,
|
||||
GROUP_CONCAT(DISTINCT be.book_id ORDER BY be.book_id) AS book_ids
|
||||
FROM book_entry be
|
||||
WHERE be.source_zpk_key IN
|
||||
<foreach collection="keys" item="key" open="(" separator="," close=")">#{key}</foreach>
|
||||
GROUP BY be.source_zpk_key
|
||||
ORDER BY be.source_zpk_key
|
||||
</script>
|
||||
""")
|
||||
List<MissingZpk> listKnownMissingZpk(@Param("keys") List<String> keys);
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(*)
|
||||
FROM word_entry e
|
||||
WHERE NOT EXISTS (SELECT 1 FROM word_sense s WHERE s.entry_id = e.entry_id)
|
||||
""")
|
||||
long countEntriesWithoutSense();
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(*)
|
||||
FROM synonym_word w
|
||||
WHERE NOT EXISTS (SELECT 1 FROM synonym_sense s WHERE s.word_id = w.word_id)
|
||||
""")
|
||||
long countSynonymWordsWithoutSense();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book WHERE exam_id IS NULL")
|
||||
long countBooksWithoutExam();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM book WHERE cover_url IS NULL OR cover_url = ''")
|
||||
long countBooksWithoutCover();
|
||||
|
||||
@Select("SELECT book_id AS book_id, book_code, book_name FROM book WHERE cover_url IS NULL OR cover_url = ''")
|
||||
List<MissingBook> listBooksWithoutCover();
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT LOWER(TRIM(word))) FROM card")
|
||||
long cardTotal();
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(DISTINCT LOWER(TRIM(c.word)))
|
||||
FROM card c
|
||||
WHERE EXISTS (SELECT 1 FROM word_entry e WHERE e.index_word = LOWER(TRIM(c.word)))
|
||||
""")
|
||||
long cardHit();
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT LOWER(TRIM(word))) FROM word_family")
|
||||
long familyTotal();
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(DISTINCT LOWER(TRIM(f.word)))
|
||||
FROM word_family f
|
||||
WHERE EXISTS (SELECT 1 FROM word_entry e WHERE e.index_word = LOWER(TRIM(f.word)))
|
||||
""")
|
||||
long familyHit();
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT LOWER(TRIM(word))) FROM synonym_word")
|
||||
long synonymTotal();
|
||||
|
||||
@Select("""
|
||||
SELECT COUNT(DISTINCT LOWER(TRIM(s.word)))
|
||||
FROM synonym_word s
|
||||
WHERE EXISTS (SELECT 1 FROM word_entry e WHERE e.index_word = LOWER(TRIM(s.word)))
|
||||
""")
|
||||
long synonymHit();
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.wordmarket.admin.mapper;
|
||||
|
||||
import com.wordmarket.admin.dto.SynonymDtos.AntonymRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.BucketRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.GroupRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.MemberRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordItem;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordRow;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SynonymMapper {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT COUNT(*) FROM synonym_word w
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(w.word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
long countWords(@Param("keyword") String keyword);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT w.word_id AS word_id,
|
||||
w.word,
|
||||
(SELECT COUNT(*) FROM synonym_sense s WHERE s.word_id = w.word_id) AS sense_count,
|
||||
EXISTS (SELECT 1
|
||||
FROM synonym_sense s
|
||||
JOIN synonym_group g ON g.sense_id = s.sense_id
|
||||
WHERE s.word_id = w.word_id) AS has_relation
|
||||
FROM synonym_word w
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND LOWER(w.word) LIKE CONCAT('%', LOWER(#{keyword}), '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY w.word_id
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</script>
|
||||
""")
|
||||
List<WordItem> listWords(@Param("keyword") String keyword, @Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
@Select("SELECT word_id AS word_id, word FROM synonym_word WHERE word_id = #{id}")
|
||||
WordRow findWord(@Param("id") long id);
|
||||
|
||||
@Select("""
|
||||
SELECT sense_id, part_of_speech, gloss_zh
|
||||
FROM synonym_sense
|
||||
WHERE word_id = #{wordId}
|
||||
ORDER BY sense_id
|
||||
""")
|
||||
List<com.wordmarket.admin.dto.SynonymDtos.SenseRow> listSenses(@Param("wordId") long wordId);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT g.sense_id, g.exam_id, ex.exam_name_zh AS exam_name, g.canonical_word_id,
|
||||
cw.word AS canonical_word, g.member_count
|
||||
FROM synonym_group g
|
||||
JOIN exam ex ON ex.exam_id = g.exam_id
|
||||
LEFT JOIN synonym_word cw ON cw.word_id = g.canonical_word_id
|
||||
WHERE g.sense_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY g.sense_id, g.exam_id
|
||||
</script>
|
||||
""")
|
||||
List<GroupRow> listGroups(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT m.sense_id, m.exam_id, m.member_word_id AS word_id, w.word, m.position
|
||||
FROM synonym_group_member m
|
||||
JOIN synonym_word w ON w.word_id = m.member_word_id
|
||||
WHERE m.sense_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY m.sense_id, m.exam_id, m.position
|
||||
</script>
|
||||
""")
|
||||
List<MemberRow> listMembers(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
SELECT a.sense_id, a.exam_id, ex.exam_name_zh AS exam_name,
|
||||
a.antonym_word_id AS word_id, w.word, a.position
|
||||
FROM synonym_antonym a
|
||||
JOIN synonym_word w ON w.word_id = a.antonym_word_id
|
||||
JOIN exam ex ON ex.exam_id = a.exam_id
|
||||
WHERE a.sense_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
ORDER BY a.sense_id, a.exam_id, a.position
|
||||
</script>
|
||||
""")
|
||||
List<AntonymRow> listAntonyms(@Param("ids") List<Long> ids);
|
||||
|
||||
@Select("""
|
||||
SELECT CASE
|
||||
WHEN member_count <= 1 THEN '1'
|
||||
WHEN member_count = 2 THEN '2'
|
||||
WHEN member_count = 3 THEN '3'
|
||||
WHEN member_count = 4 THEN '4'
|
||||
WHEN member_count <= 6 THEN '5-6'
|
||||
WHEN member_count <= 10 THEN '7-10'
|
||||
ELSE '11+'
|
||||
END AS label,
|
||||
COUNT(*) AS count
|
||||
FROM synonym_group
|
||||
GROUP BY label
|
||||
ORDER BY MIN(member_count)
|
||||
""")
|
||||
List<BucketRow> groupSizeDistribution();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.wordmarket.admin.security;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class JwtAuthFilter extends OncePerRequestFilter {
|
||||
|
||||
private final JwtService jwtService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public JwtAuthFilter(JwtService jwtService, ObjectMapper objectMapper) {
|
||||
this.jwtService = jwtService;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) {
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||
return true;
|
||||
}
|
||||
return "/api/auth/login".equals(request.getRequestURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
if (header == null || !header.startsWith("Bearer ")) {
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String username = jwtService.parseSubject(header.substring(7));
|
||||
var authentication = new UsernamePasswordAuthenticationToken(
|
||||
username, null, List.of(new SimpleGrantedAuthority("ROLE_ADMIN")));
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
filterChain.doFilter(request, response);
|
||||
} catch (RuntimeException ex) {
|
||||
SecurityContextHolder.clearContext();
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
objectMapper.writeValue(response.getWriter(),
|
||||
ApiResponse.error(401, "登录状态无效或已过期"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.wordmarket.admin.security;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.config.AdminProperties;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.JwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class JwtService {
|
||||
|
||||
private final SecretKey key;
|
||||
private final int ttlHours;
|
||||
|
||||
public JwtService(AdminProperties properties) {
|
||||
this.key = Keys.hmacShaKeyFor(properties.getJwtSecret().getBytes(StandardCharsets.UTF_8));
|
||||
this.ttlHours = properties.getTokenTtlHours();
|
||||
}
|
||||
|
||||
public IssuedToken issue(String username) {
|
||||
Instant now = Instant.now();
|
||||
Instant expiresAt = now.plus(ttlHours, ChronoUnit.HOURS);
|
||||
String token = Jwts.builder()
|
||||
.subject(username)
|
||||
.issuedAt(Date.from(now))
|
||||
.expiration(Date.from(expiresAt))
|
||||
.signWith(key)
|
||||
.compact();
|
||||
return new IssuedToken(token, expiresAt);
|
||||
}
|
||||
|
||||
public String parseSubject(String token) {
|
||||
try {
|
||||
Claims claims = Jwts.parser()
|
||||
.verifyWith(key)
|
||||
.build()
|
||||
.parseSignedClaims(token)
|
||||
.getPayload();
|
||||
return claims.getSubject();
|
||||
} catch (JwtException | IllegalArgumentException ex) {
|
||||
throw BizException.unauthorized("登录状态无效或已过期");
|
||||
}
|
||||
}
|
||||
|
||||
public record IssuedToken(String token, Instant expiresAt) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.wordmarket.admin.security;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wordmarket.admin.common.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Component
|
||||
public class RestAuthEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public RestAuthEntryPoint(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) throws IOException {
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
objectMapper.writeValue(response.getWriter(), ApiResponse.error(401, "未认证或登录已过期"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Component
|
||||
public class AggregateCache {
|
||||
|
||||
private final Cache<String, Object> cache;
|
||||
|
||||
public AggregateCache(Cache<String, Object> aggregateCache) {
|
||||
this.cache = aggregateCache;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(String key, boolean refresh, Supplier<T> loader) {
|
||||
if (!refresh) {
|
||||
Object cached = cache.getIfPresent(key);
|
||||
if (cached != null) {
|
||||
return (T) cached;
|
||||
}
|
||||
}
|
||||
T value = loader.get();
|
||||
cache.put(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
cache.invalidateAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.config.AdminProperties;
|
||||
import com.wordmarket.admin.dto.AuthDtos.LoginRequest;
|
||||
import com.wordmarket.admin.dto.AuthDtos.LoginResponse;
|
||||
import com.wordmarket.admin.security.JwtService;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AuthService {
|
||||
|
||||
private final AdminProperties adminProperties;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final JwtService jwtService;
|
||||
|
||||
public AuthService(AdminProperties adminProperties, PasswordEncoder passwordEncoder,
|
||||
JwtService jwtService) {
|
||||
this.adminProperties = adminProperties;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.jwtService = jwtService;
|
||||
}
|
||||
|
||||
public LoginResponse login(LoginRequest request) {
|
||||
boolean usernameMatches = adminProperties.getUsername().equals(request.username());
|
||||
boolean passwordMatches = passwordEncoder.matches(request.password(),
|
||||
adminProperties.getPasswordHash());
|
||||
if (!usernameMatches || !passwordMatches) {
|
||||
throw BizException.unauthorized("用户名或密码错误");
|
||||
}
|
||||
JwtService.IssuedToken issued = jwtService.issue(request.username());
|
||||
return new LoginResponse(issued.token(), issued.expiresAt().toString(), request.username());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.common.Pages;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookDetail;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookDetailRow;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookEntryItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookListItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.ExamOption;
|
||||
import com.wordmarket.admin.mapper.BookMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class BookService {
|
||||
|
||||
private final BookMapper bookMapper;
|
||||
|
||||
public BookService(BookMapper bookMapper) {
|
||||
this.bookMapper = bookMapper;
|
||||
}
|
||||
|
||||
public PageResult<BookListItem> list(Integer pageParam, Integer sizeParam, Long examId,
|
||||
String keyword, Boolean hasFile) {
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = bookMapper.countBooks(examId, keyword, hasFile);
|
||||
List<BookListItem> items = bookMapper.listBooks(examId, keyword, hasFile,
|
||||
Pages.offset(page, size), size);
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public BookDetail detail(long id) {
|
||||
BookDetailRow detail = bookMapper.findBook(id);
|
||||
if (detail == null) {
|
||||
throw BizException.notFound("词书不存在");
|
||||
}
|
||||
boolean mismatch = detail.declared() != null && detail.declared() != detail.actual();
|
||||
return new BookDetail(detail.id(), detail.code(), detail.name(), detail.description(),
|
||||
detail.examId(), detail.examName(), detail.declared(), detail.actual(),
|
||||
detail.contentVersion(), detail.schemaVersion(), detail.coverPath(),
|
||||
detail.packageUrl(), detail.hasFile(), detail.sortAt(), detail.labels(), mismatch);
|
||||
}
|
||||
|
||||
public PageResult<BookEntryItem> entries(long bookId, Integer pageParam, Integer sizeParam,
|
||||
String keyword) {
|
||||
detail(bookId);
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = bookMapper.countBookEntries(bookId, keyword);
|
||||
List<BookEntryItem> items = bookMapper.listBookEntries(bookId, keyword,
|
||||
Pages.offset(page, size), size);
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public List<ExamOption> exams() {
|
||||
return bookMapper.listExams();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.dto.DashboardDtos.CoverageItem;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.ExamStat;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.Kpi;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.PosStat;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.QualityItem;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.Summary;
|
||||
import com.wordmarket.admin.dto.DashboardDtos.TopBook;
|
||||
import com.wordmarket.admin.mapper.DashboardMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class DashboardService {
|
||||
|
||||
private final DashboardMapper dashboardMapper;
|
||||
private final QualityService qualityService;
|
||||
private final AggregateCache cache;
|
||||
|
||||
public DashboardService(DashboardMapper dashboardMapper, QualityService qualityService,
|
||||
AggregateCache cache) {
|
||||
this.dashboardMapper = dashboardMapper;
|
||||
this.qualityService = qualityService;
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public Summary summary(boolean refresh) {
|
||||
return cache.get("dashboard:summary", refresh, this::loadSummary);
|
||||
}
|
||||
|
||||
private Summary loadSummary() {
|
||||
long books = dashboardMapper.countBooks();
|
||||
long entries = dashboardMapper.countEntries();
|
||||
long links = dashboardMapper.countBookEntries();
|
||||
long sentences = dashboardMapper.countExampleSentences();
|
||||
long families = dashboardMapper.countFamilies();
|
||||
long synonymWords = dashboardMapper.countSynonymWords();
|
||||
|
||||
long averagePerBook = books == 0 ? 0 : Math.round(links * 1.0 / books);
|
||||
|
||||
List<Kpi> kpis = List.of(
|
||||
new Kpi("books", "词书", books,
|
||||
dashboardMapper.countBooksWithoutFile() + " 本无清单文件", "blue"),
|
||||
new Kpi("entries", "词条", entries,
|
||||
String.format("%,d 个索引词", dashboardMapper.countIndexWords()), "green"),
|
||||
new Kpi("links", "词书词条关联", links,
|
||||
String.format("平均每本 %,d 条", averagePerBook), "violet"),
|
||||
new Kpi("sentences", "例句", sentences,
|
||||
String.format("含使用模式 %,d", dashboardMapper.countExampleUsages()), "amber"),
|
||||
new Kpi("families", "词族", families,
|
||||
String.format("顶层族 %,d", dashboardMapper.countTopFamilies()), "cyan"),
|
||||
new Kpi("synonyms", "近义词头", synonymWords,
|
||||
String.format("义项 %,d", dashboardMapper.countSynonymSenses()), "rose"));
|
||||
|
||||
List<QualityItem> quality = qualityService.loadSummaryItems().stream()
|
||||
.map(item -> new QualityItem(item.key(), item.label(), item.value(), item.unit(),
|
||||
item.level(), QualityService.targetOf(item.key())))
|
||||
.toList();
|
||||
|
||||
List<CoverageItem> coverage = qualityService.loadCoverage().stream()
|
||||
.map(item -> new CoverageItem(item.name(), item.hit(), item.total(), item.pct()))
|
||||
.toList();
|
||||
|
||||
return new Summary(kpis, quality, coverage);
|
||||
}
|
||||
|
||||
public List<ExamStat> examDistribution(boolean refresh) {
|
||||
return cache.get("dashboard:exam", refresh, dashboardMapper::examDistribution);
|
||||
}
|
||||
|
||||
public List<TopBook> topBooks(boolean refresh) {
|
||||
return cache.get("dashboard:top", refresh, dashboardMapper::topBooks);
|
||||
}
|
||||
|
||||
public List<PosStat> posDistribution(boolean refresh) {
|
||||
return cache.get("dashboard:pos", refresh, dashboardMapper::posDistribution);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.common.Pages;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ConfusableItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryBookItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryBookRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryDetail;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryListItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExamRef;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleGroupItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleGroupRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleSentenceItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleUsageItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.GroupExamRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseExamRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseOrder;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseOrderRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.PhraseRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseExamRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseRelation;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseRelationRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SentenceRow;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SpellingVariantItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.UsageRow;
|
||||
import com.wordmarket.admin.mapper.EntryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class EntryService {
|
||||
|
||||
private static final int DEFINITION_PREVIEW = 120;
|
||||
|
||||
private final EntryMapper entryMapper;
|
||||
|
||||
public EntryService(EntryMapper entryMapper) {
|
||||
this.entryMapper = entryMapper;
|
||||
}
|
||||
|
||||
public PageResult<EntryListItem> list(Integer pageParam, Integer sizeParam, String keyword) {
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = entryMapper.countEntries(keyword);
|
||||
List<EntryListItem> items = entryMapper.listEntries(keyword, Pages.offset(page, size), size)
|
||||
.stream()
|
||||
.map(item -> new EntryListItem(item.id(), item.headword(), item.indexWord(),
|
||||
item.pronunciation(), preview(item.definition()), item.senseCount(),
|
||||
item.bookCount()))
|
||||
.toList();
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public EntryDetail detail(long id) {
|
||||
EntryDetail detail = entryMapper.findEntry(id);
|
||||
if (detail == null) {
|
||||
throw BizException.notFound("词条不存在");
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
public List<SenseItem> senses(long entryId) {
|
||||
detail(entryId);
|
||||
List<SenseRow> rows = entryMapper.listSenses(entryId);
|
||||
if (rows.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
List<Long> ids = rows.stream().map(row -> Long.parseLong(row.senseId())).toList();
|
||||
Map<Long, List<ExamRef>> exams = groupExams(entryMapper.listSenseExams(ids));
|
||||
Map<Long, List<SenseRelation>> relations = groupRelations(entryMapper.listSenseRelations(ids));
|
||||
List<SenseItem> items = new ArrayList<>(rows.size());
|
||||
for (SenseRow row : rows) {
|
||||
long senseId = Long.parseLong(row.senseId());
|
||||
items.add(new SenseItem(row.senseId(), row.senseNo(), row.partOfSpeech(), row.glossZh(),
|
||||
exams.getOrDefault(senseId, List.of()),
|
||||
relations.getOrDefault(senseId, List.of())));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public PageResult<PhraseItem> phrases(long entryId, Integer pageParam, Integer sizeParam) {
|
||||
detail(entryId);
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = entryMapper.countPhrases(entryId);
|
||||
List<PhraseRow> rows = entryMapper.listPhrases(entryId, Pages.offset(page, size), size);
|
||||
if (rows.isEmpty()) {
|
||||
return PageResult.of(List.of(), total, page, size);
|
||||
}
|
||||
List<Long> ids = rows.stream().map(row -> Long.parseLong(row.id())).toList();
|
||||
Map<Long, List<ExamRef>> exams = groupPhraseExams(entryMapper.listPhraseExams(ids));
|
||||
Map<Long, List<PhraseOrder>> orders = new HashMap<>();
|
||||
for (PhraseOrderRow order : entryMapper.listPhraseOrders(entryId)) {
|
||||
orders.computeIfAbsent(Long.parseLong(order.phraseId()), key -> new ArrayList<>())
|
||||
.add(new PhraseOrder(order.examId(), order.examName(), order.groupType(),
|
||||
order.position()));
|
||||
}
|
||||
List<PhraseItem> items = rows.stream()
|
||||
.map(row -> {
|
||||
long phraseId = Long.parseLong(row.id());
|
||||
return new PhraseItem(row.id(), row.textEn(), row.textZh(), row.groupType(),
|
||||
row.meaningId(), exams.getOrDefault(phraseId, List.of()),
|
||||
orders.getOrDefault(phraseId, List.of()));
|
||||
})
|
||||
.toList();
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public PageResult<ExampleGroupItem> examples(long entryId, Integer pageParam, Integer sizeParam) {
|
||||
detail(entryId);
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = entryMapper.countExampleGroups(entryId);
|
||||
List<ExampleGroupRow> rows = entryMapper.listExampleGroups(entryId,
|
||||
Pages.offset(page, size), size);
|
||||
if (rows.isEmpty()) {
|
||||
return PageResult.of(List.of(), total, page, size);
|
||||
}
|
||||
List<Long> ids = rows.stream().map(row -> Long.parseLong(row.id())).toList();
|
||||
Map<Long, List<ExamRef>> exams = groupExampleExams(entryMapper.listExampleGroupExams(ids));
|
||||
Map<Long, List<UsageRow>> usages = new HashMap<>();
|
||||
for (UsageRow usage : entryMapper.listExampleUsages(ids)) {
|
||||
usages.computeIfAbsent(Long.parseLong(usage.groupId()), key -> new ArrayList<>())
|
||||
.add(usage);
|
||||
}
|
||||
Map<Long, List<SentenceRow>> sentencesByGroup = new HashMap<>();
|
||||
Map<Long, List<SentenceRow>> sentencesByUsage = new HashMap<>();
|
||||
for (SentenceRow sentence : entryMapper.listExampleSentences(ids)) {
|
||||
sentencesByGroup.computeIfAbsent(Long.parseLong(sentence.groupId()),
|
||||
key -> new ArrayList<>()).add(sentence);
|
||||
if (sentence.usageId() != null) {
|
||||
sentencesByUsage.computeIfAbsent(Long.parseLong(sentence.usageId()),
|
||||
key -> new ArrayList<>()).add(sentence);
|
||||
}
|
||||
}
|
||||
List<ExampleGroupItem> items = new ArrayList<>(rows.size());
|
||||
for (ExampleGroupRow row : rows) {
|
||||
long groupId = Long.parseLong(row.id());
|
||||
List<ExampleUsageItem> usageItems = usages.getOrDefault(groupId, List.of()).stream()
|
||||
.map(usage -> new ExampleUsageItem(usage.id(), usage.patternId(),
|
||||
usage.patternText(), usage.position(), toSentenceItems(
|
||||
sentencesByUsage.getOrDefault(Long.parseLong(usage.id()), List.of()))))
|
||||
.toList();
|
||||
List<SentenceRow> groupSentences = sentencesByGroup.getOrDefault(groupId, List.of());
|
||||
List<ExampleSentenceItem> direct = groupSentences.stream()
|
||||
.filter(sentence -> sentence.usageId() == null)
|
||||
.map(EntryService::toSentenceItem)
|
||||
.toList();
|
||||
items.add(new ExampleGroupItem(row.id(), row.groupKind(), row.partOfSpeech(),
|
||||
row.entryKindCode(), row.headForm(), row.definitionEn(), row.definitionZh(),
|
||||
exams.getOrDefault(groupId, List.of()), usageItems, direct, groupSentences.size()));
|
||||
}
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public List<ConfusableItem> confusables(long entryId) {
|
||||
detail(entryId);
|
||||
return entryMapper.listConfusables(entryId).stream()
|
||||
.map(row -> new ConfusableItem(row.id(), row.wordText(), row.glossZh(), row.posCode(),
|
||||
row.spellingFlag(), row.position()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<SpellingVariantItem> spellingVariants(long entryId) {
|
||||
detail(entryId);
|
||||
return entryMapper.listSpellingVariants(entryId).stream()
|
||||
.map(row -> new SpellingVariantItem(row.position(), row.variant()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public PageResult<EntryBookItem> books(long entryId, Integer pageParam, Integer sizeParam) {
|
||||
detail(entryId);
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = entryMapper.countEntryBooks(entryId);
|
||||
List<EntryBookItem> items = entryMapper.listEntryBooks(entryId, Pages.offset(page, size), size)
|
||||
.stream()
|
||||
.map(row -> new EntryBookItem(row.bookId(), row.bookName(), row.bookCode(),
|
||||
row.displayWord(), row.seqBook()))
|
||||
.toList();
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
private static Map<Long, List<ExamRef>> groupExams(List<SenseExamRow> rows) {
|
||||
Map<Long, List<ExamRef>> map = new HashMap<>();
|
||||
for (SenseExamRow row : rows) {
|
||||
map.computeIfAbsent(Long.parseLong(row.senseId()), key -> new ArrayList<>())
|
||||
.add(new ExamRef(row.id(), row.code(), row.name()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<Long, List<SenseRelation>> groupRelations(List<SenseRelationRow> rows) {
|
||||
Map<Long, List<SenseRelation>> map = new HashMap<>();
|
||||
for (SenseRelationRow row : rows) {
|
||||
map.computeIfAbsent(Long.parseLong(row.senseId()), key -> new ArrayList<>())
|
||||
.add(new SenseRelation(row.type(), row.position(), row.targetMeaningId(),
|
||||
row.targetEntryId()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<Long, List<ExamRef>> groupPhraseExams(List<PhraseExamRow> rows) {
|
||||
Map<Long, List<ExamRef>> map = new LinkedHashMap<>();
|
||||
for (PhraseExamRow row : rows) {
|
||||
map.computeIfAbsent(Long.parseLong(row.phraseId()), key -> new ArrayList<>())
|
||||
.add(new ExamRef(row.id(), row.code(), row.name()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<Long, List<ExamRef>> groupExampleExams(List<GroupExamRow> rows) {
|
||||
Map<Long, List<ExamRef>> map = new HashMap<>();
|
||||
for (GroupExamRow row : rows) {
|
||||
map.computeIfAbsent(Long.parseLong(row.groupId()), key -> new ArrayList<>())
|
||||
.add(new ExamRef(row.id(), row.code(), row.name()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static List<ExampleSentenceItem> toSentenceItems(List<SentenceRow> rows) {
|
||||
return rows.stream().map(EntryService::toSentenceItem).toList();
|
||||
}
|
||||
|
||||
private static ExampleSentenceItem toSentenceItem(SentenceRow row) {
|
||||
return new ExampleSentenceItem(row.id(), row.textEn(), row.textZh(), row.sourceTitle(),
|
||||
row.audioUrl(), row.listening());
|
||||
}
|
||||
|
||||
private static String preview(String text) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
String trimmed = text.trim();
|
||||
if (trimmed.length() <= DEFINITION_PREVIEW) {
|
||||
return trimmed;
|
||||
}
|
||||
return trimmed.substring(0, DEFINITION_PREVIEW) + "…";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.common.Pages;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardBrief;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardDetail;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardFamilyLink;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardItemRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.CardRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.ExamRef;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyDetail;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyExamRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyLinkRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyMemberItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.FamilyVariantItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.LinkExamRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MemberRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MiniGroupItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MiniGroupRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeDetail;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeItem;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.MorphemeRefRow;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.TreeCounts;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.TreeNode;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.TreePage;
|
||||
import com.wordmarket.admin.dto.MorphologyDtos.VariantRow;
|
||||
import com.wordmarket.admin.mapper.MorphologyMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class MorphologyService {
|
||||
|
||||
private static final Set<String> MORPHEME_TYPES = Set.of("prefix", "root", "suffix");
|
||||
private static final int MEMBER_PREVIEW = 50;
|
||||
|
||||
private final MorphologyMapper morphologyMapper;
|
||||
|
||||
public MorphologyService(MorphologyMapper morphologyMapper) {
|
||||
this.morphologyMapper = morphologyMapper;
|
||||
}
|
||||
|
||||
public PageResult<MorphemeItem> morphemes(String type, String keyword, Integer pageParam,
|
||||
Integer sizeParam) {
|
||||
if (type != null && !type.isBlank() && !MORPHEME_TYPES.contains(type)) {
|
||||
throw BizException.badRequest("词素类型必须为 prefix、root 或 suffix");
|
||||
}
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = morphologyMapper.countMorphemes(type, keyword);
|
||||
List<MorphemeItem> items = morphologyMapper.listMorphemes(type, keyword,
|
||||
Pages.offset(page, size), size);
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public MorphemeDetail morpheme(long id) {
|
||||
MorphemeItem item = morphologyMapper.findMorpheme(id);
|
||||
if (item == null) {
|
||||
throw BizException.notFound("词素不存在");
|
||||
}
|
||||
List<CardBrief> cards = morphologyMapper.listCardsByMorpheme(id);
|
||||
return new MorphemeDetail(item.id(), item.type(), item.form(), item.displayText(),
|
||||
item.meaningEn(), item.meaningZh(), item.note(), cards,
|
||||
morphologyMapper.countCardsByMorpheme(id));
|
||||
}
|
||||
|
||||
public PageResult<CardItem> cards(String keyword, Integer pageParam, Integer sizeParam) {
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = morphologyMapper.countCards(keyword);
|
||||
List<CardItemRow> rows = morphologyMapper.listCards(keyword, Pages.offset(page, size), size);
|
||||
if (rows.isEmpty()) {
|
||||
return PageResult.of(List.of(), total, page, size);
|
||||
}
|
||||
List<Long> ids = rows.stream().map(row -> Long.parseLong(row.id())).toList();
|
||||
Map<Long, List<ExamRef>> exams = groupCardExams(morphologyMapper.listCardExams(ids));
|
||||
List<CardItem> items = rows.stream()
|
||||
.map(row -> new CardItem(row.id(), row.word(), row.memoryNote(), row.highlightedWord(),
|
||||
exams.getOrDefault(Long.parseLong(row.id()), List.of())))
|
||||
.toList();
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public CardDetail card(long id) {
|
||||
CardRow row = morphologyMapper.findCard(id);
|
||||
if (row == null) {
|
||||
throw BizException.notFound("单词卡片不存在");
|
||||
}
|
||||
Map<Long, List<ExamRef>> exams = groupCardExams(
|
||||
morphologyMapper.listCardExams(List.of(id)));
|
||||
List<Long> morphemeIds = new ArrayList<>();
|
||||
addPositive(morphemeIds, row.prefixMorphemeId());
|
||||
addPositive(morphemeIds, row.rootMorphemeId());
|
||||
addPositive(morphemeIds, row.suffixMorphemeId());
|
||||
Map<Long, MorphemeRefRow> refs = new HashMap<>();
|
||||
if (!morphemeIds.isEmpty()) {
|
||||
for (MorphemeRefRow ref : morphologyMapper.listMorphemeRefs(morphemeIds)) {
|
||||
refs.put(Long.parseLong(ref.id()), ref);
|
||||
}
|
||||
}
|
||||
List<CardFamilyLink> links = morphologyMapper.listCardFamilyLinks(id).stream()
|
||||
.map(link -> new CardFamilyLink(link.id(), link.groupNo(), link.familyRef(),
|
||||
link.hidden()))
|
||||
.toList();
|
||||
return new CardDetail(row.id(), row.word(), row.highlightedWord(), row.memoryNote(),
|
||||
row.exampleText(), row.hidden(),
|
||||
morphemeId(row.prefixMorphemeId()), formOf(refs, row.prefixMorphemeId()),
|
||||
morphemeId(row.rootMorphemeId()), formOf(refs, row.rootMorphemeId()),
|
||||
morphemeId(row.suffixMorphemeId()), formOf(refs, row.suffixMorphemeId()),
|
||||
row.defaultFamilyRef(), exams.getOrDefault(id, List.of()), links);
|
||||
}
|
||||
|
||||
public PageResult<FamilyItem> families(String keyword, Integer pageParam, Integer sizeParam) {
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = morphologyMapper.countFamilies(keyword);
|
||||
List<FamilyRow> rows = morphologyMapper.listFamilies(keyword, Pages.offset(page, size), size);
|
||||
if (rows.isEmpty()) {
|
||||
return PageResult.of(List.of(), total, page, size);
|
||||
}
|
||||
List<Long> ids = rows.stream().map(row -> Long.parseLong(row.id())).toList();
|
||||
Map<Long, List<ExamRef>> exams = groupFamilyExams(morphologyMapper.listFamilyExams(ids));
|
||||
List<FamilyItem> items = rows.stream()
|
||||
.map(row -> new FamilyItem(row.id(), row.word(), row.topFamilyId(), row.topWord(),
|
||||
row.interpretation(), row.groupLevel1(), row.groupLevel2(), row.groupLevel3(),
|
||||
exams.getOrDefault(Long.parseLong(row.id()), List.of())))
|
||||
.toList();
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public FamilyDetail family(long id) {
|
||||
FamilyRow row = morphologyMapper.findFamily(id);
|
||||
if (row == null) {
|
||||
throw BizException.notFound("词族不存在");
|
||||
}
|
||||
Map<Long, List<ExamRef>> exams = groupFamilyExams(
|
||||
morphologyMapper.listFamilyExams(List.of(id)));
|
||||
long topId = Long.parseLong(row.topFamilyId());
|
||||
List<FamilyVariantItem> variants = morphologyMapper.listVariants(topId).stream()
|
||||
.map(variant -> new FamilyVariantItem(variant.id(), variant.variantWord(),
|
||||
variant.interpretation(), variant.memberCount()))
|
||||
.toList();
|
||||
List<MiniGroupItem> miniGroups = new ArrayList<>();
|
||||
for (MiniGroupRow group : morphologyMapper.listMiniGroups(topId)) {
|
||||
List<FamilyMemberItem> members = morphologyMapper
|
||||
.listMiniGroupMembers(Long.parseLong(group.id())).stream()
|
||||
.map(member -> new FamilyMemberItem(member.familyEntryId(), member.word(),
|
||||
member.position()))
|
||||
.toList();
|
||||
miniGroups.add(new MiniGroupItem(group.id(), group.size(), members));
|
||||
}
|
||||
return new FamilyDetail(row.id(), row.word(), row.topFamilyId(), row.topWord(),
|
||||
row.interpretation(), row.groupLevel1(), row.groupLevel2(), row.groupLevel3(),
|
||||
exams.getOrDefault(id, List.of()), variants, miniGroups);
|
||||
}
|
||||
|
||||
public TreePage tree(long id, String nodeType, Integer pageParam, Integer sizeParam) {
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
String type = nodeType == null || nodeType.isBlank() ? "top" : nodeType;
|
||||
return switch (type) {
|
||||
case "top" -> {
|
||||
if (morphologyMapper.findFamily(id) == null) {
|
||||
throw BizException.notFound("词族不存在");
|
||||
}
|
||||
TreeCounts counts = morphologyMapper.countTopChildren(id);
|
||||
List<TreeNode> nodes = morphologyMapper.listTopChildren(id, Pages.offset(page, size),
|
||||
size);
|
||||
yield new TreePage(nodes, counts.variantCount() + counts.groupCount(), page, size);
|
||||
}
|
||||
case "variant" -> new TreePage(
|
||||
morphologyMapper.listVariantMemberNodes(id, Pages.offset(page, size), size),
|
||||
morphologyMapper.countVariantMembers(id), page, size);
|
||||
case "miniGroup" -> new TreePage(
|
||||
morphologyMapper.listMiniGroupMemberNodes(id, Pages.offset(page, size), size),
|
||||
morphologyMapper.countMiniGroupMembers(id), page, size);
|
||||
default -> throw BizException.badRequest("不支持的树节点类型");
|
||||
};
|
||||
}
|
||||
|
||||
private static Map<Long, List<ExamRef>> groupCardExams(List<LinkExamRow> rows) {
|
||||
Map<Long, List<ExamRef>> map = new HashMap<>();
|
||||
for (LinkExamRow row : rows) {
|
||||
map.computeIfAbsent(Long.parseLong(row.cardId()), key -> new ArrayList<>())
|
||||
.add(new ExamRef(row.id(), row.code(), row.name()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<Long, List<ExamRef>> groupFamilyExams(List<FamilyExamRow> rows) {
|
||||
Map<Long, List<ExamRef>> map = new HashMap<>();
|
||||
for (FamilyExamRow row : rows) {
|
||||
map.computeIfAbsent(Long.parseLong(row.familyEntryId()), key -> new ArrayList<>())
|
||||
.add(new ExamRef(row.id(), row.code(), row.name()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void addPositive(List<Long> ids, String value) {
|
||||
if (value != null && !value.isBlank() && !"0".equals(value)) {
|
||||
ids.add(Long.parseLong(value));
|
||||
}
|
||||
}
|
||||
|
||||
private static String morphemeId(String value) {
|
||||
return value == null || "0".equals(value) ? null : value;
|
||||
}
|
||||
|
||||
private static String formOf(Map<Long, MorphemeRefRow> refs, String id) {
|
||||
if (id == null || "0".equals(id)) {
|
||||
return null;
|
||||
}
|
||||
MorphemeRefRow ref = refs.get(Long.parseLong(id));
|
||||
return ref == null ? null : ref.form();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.config.AppProperties;
|
||||
import com.wordmarket.admin.dto.QualityDtos.Coverage;
|
||||
import com.wordmarket.admin.dto.QualityDtos.DeclaredDiff;
|
||||
import com.wordmarket.admin.dto.QualityDtos.MissingBook;
|
||||
import com.wordmarket.admin.dto.QualityDtos.MissingReference;
|
||||
import com.wordmarket.admin.dto.QualityDtos.MissingZpk;
|
||||
import com.wordmarket.admin.dto.QualityDtos.QualitySummary;
|
||||
import com.wordmarket.admin.dto.QualityDtos.SummaryItem;
|
||||
import com.wordmarket.admin.mapper.QualityMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class QualityService {
|
||||
|
||||
private static final String KEY_MISMATCH = "mismatch";
|
||||
private static final String KEY_NO_FILE = "nofile";
|
||||
private static final String KEY_NO_ZPK = "nozpk";
|
||||
private static final String KEY_NO_SENSE = "nosense";
|
||||
private static final String KEY_NO_SYN_SENSE = "nosyn";
|
||||
private static final String KEY_NO_EXAM = "noexam";
|
||||
private static final String KEY_NO_COVER = "nocover";
|
||||
|
||||
private final QualityMapper qualityMapper;
|
||||
private final AggregateCache cache;
|
||||
private final AppProperties appProperties;
|
||||
|
||||
public QualityService(QualityMapper qualityMapper, AggregateCache cache, AppProperties appProperties) {
|
||||
this.qualityMapper = qualityMapper;
|
||||
this.cache = cache;
|
||||
this.appProperties = appProperties;
|
||||
}
|
||||
|
||||
public QualitySummary summary(boolean refresh) {
|
||||
return cache.get("quality:summary", refresh, () -> new QualitySummary(loadSummaryItems()));
|
||||
}
|
||||
|
||||
public List<SummaryItem> loadSummaryItems() {
|
||||
List<SummaryItem> items = new ArrayList<>();
|
||||
items.add(new SummaryItem(KEY_MISMATCH, "声明与实际词条数不一致",
|
||||
qualityMapper.countDeclaredMismatch(), "本", "warn",
|
||||
"口径:book.declared_entry_count 与 book_entry 实际行数不一致的词书。"));
|
||||
items.add(new SummaryItem(KEY_NO_FILE, "缺失词书清单文件",
|
||||
qualityMapper.countMissingFiles(), "本", "bad",
|
||||
"口径:目录中存在但磁盘缺少清单文件的词书(book.has_wordbook_file = 0)。"));
|
||||
items.add(new SummaryItem(KEY_NO_ZPK, "缺失 zpk 引用",
|
||||
missingZpkRows().size(), "个", "bad",
|
||||
"口径:配置中登记的缺失 zpk 文件键,仍被 book_entry.source_zpk_key 引用的去重数量。"));
|
||||
items.add(new SummaryItem(KEY_NO_SENSE, "无结构化义项的词条",
|
||||
qualityMapper.countEntriesWithoutSense(), "条", "warn",
|
||||
"口径:word_sense 中完全没有记录的词条。"));
|
||||
items.add(new SummaryItem(KEY_NO_SYN_SENSE, "无义项的近义词头",
|
||||
qualityMapper.countSynonymWordsWithoutSense(), "个", "warn",
|
||||
"口径:synonym_sense 中完全没有记录的近义词头。"));
|
||||
items.add(new SummaryItem(KEY_NO_EXAM, "未设置考试的词书",
|
||||
qualityMapper.countBooksWithoutExam(), "本", "info",
|
||||
"口径:book.exam_id 为空的词书,通常为非考试类或未归类。"));
|
||||
items.add(new SummaryItem(KEY_NO_COVER, "无封面词书",
|
||||
qualityMapper.countBooksWithoutCover(), "本", "info",
|
||||
"口径:book.cover_url 为空的词书,前端展示统一占位图。"));
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<DeclaredDiff> declaredVsActual(boolean refresh) {
|
||||
return cache.get("quality:declared", refresh, qualityMapper::listDeclaredMismatch);
|
||||
}
|
||||
|
||||
public List<MissingReference> missingReferences(boolean refresh) {
|
||||
return cache.get("quality:missing", refresh, this::loadMissingReferences);
|
||||
}
|
||||
|
||||
private List<MissingReference> loadMissingReferences() {
|
||||
List<MissingReference> items = new ArrayList<>();
|
||||
for (MissingBook book : qualityMapper.listMissingFileBooks()) {
|
||||
items.add(new MissingReference("book_file", book.bookCode(),
|
||||
"book.has_wordbook_file", book.bookName(), book.bookId()));
|
||||
}
|
||||
List<String> keys = configuredZpkKeys();
|
||||
if (!keys.isEmpty()) {
|
||||
for (MissingZpk zpk : qualityMapper.listKnownMissingZpk(keys)) {
|
||||
items.add(new MissingReference("zpk", zpk.sourceKey(), "book_entry.source_zpk_key",
|
||||
"影响 " + zpk.rowCount() + " 行词书关联;词书 ID: " + zpk.bookIds(), null));
|
||||
}
|
||||
}
|
||||
for (MissingBook book : qualityMapper.listBooksWithoutCover()) {
|
||||
items.add(new MissingReference("cover", book.bookCode(), "book.cover_url",
|
||||
book.bookName(), book.bookId()));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<Coverage> crossDomainCoverage(boolean refresh) {
|
||||
return cache.get("quality:coverage", refresh, this::loadCoverage);
|
||||
}
|
||||
|
||||
public List<Coverage> loadCoverage() {
|
||||
List<Coverage> items = new ArrayList<>();
|
||||
items.add(coverage("card", "单词卡片", qualityMapper.cardHit(), qualityMapper.cardTotal()));
|
||||
items.add(coverage("family", "词族", qualityMapper.familyHit(), qualityMapper.familyTotal()));
|
||||
items.add(coverage("synonym", "近义词头", qualityMapper.synonymHit(), qualityMapper.synonymTotal()));
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<MissingZpk> missingZpkRows() {
|
||||
List<String> keys = configuredZpkKeys();
|
||||
if (keys.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
return qualityMapper.listKnownMissingZpk(keys);
|
||||
}
|
||||
|
||||
private List<String> configuredZpkKeys() {
|
||||
String raw = appProperties.getQuality().getKnownMissingZpkKeys();
|
||||
if (raw == null || raw.isBlank()) {
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.stream(raw.split(","))
|
||||
.map(String::trim)
|
||||
.filter(value -> !value.isEmpty())
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static Coverage coverage(String key, String name, long hit, long total) {
|
||||
double pct = total == 0 ? 0 : Math.round(hit * 1000.0 / total) / 10.0;
|
||||
return new Coverage(key, name, hit, total, pct);
|
||||
}
|
||||
|
||||
public static String levelOf(String key) {
|
||||
return switch (key) {
|
||||
case KEY_NO_FILE, KEY_NO_ZPK -> "bad";
|
||||
case KEY_MISMATCH, KEY_NO_SENSE, KEY_NO_SYN_SENSE -> "warn";
|
||||
default -> "info";
|
||||
};
|
||||
}
|
||||
|
||||
public static String targetOf(String key) {
|
||||
return switch (key) {
|
||||
case KEY_NO_SENSE, KEY_NO_ZPK -> "词条";
|
||||
case KEY_NO_SYN_SENSE -> "近义词";
|
||||
default -> "词书";
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.common.Pages;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.AntonymItem;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.AntonymRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.GroupItem;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.GroupRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.MemberItem;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.MemberRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.SenseItem;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.SenseRow;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.SizeBucket;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordDetail;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordItem;
|
||||
import com.wordmarket.admin.dto.SynonymDtos.WordRow;
|
||||
import com.wordmarket.admin.mapper.SynonymMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class SynonymService {
|
||||
|
||||
private static final int MEMBER_LIMIT = 50;
|
||||
|
||||
private final SynonymMapper synonymMapper;
|
||||
|
||||
public SynonymService(SynonymMapper synonymMapper) {
|
||||
this.synonymMapper = synonymMapper;
|
||||
}
|
||||
|
||||
public PageResult<WordItem> list(Integer pageParam, Integer sizeParam, String keyword) {
|
||||
int page = Pages.page(pageParam);
|
||||
int size = Pages.size(sizeParam);
|
||||
long total = synonymMapper.countWords(keyword);
|
||||
List<WordItem> items = synonymMapper.listWords(keyword, Pages.offset(page, size), size);
|
||||
return PageResult.of(items, total, page, size);
|
||||
}
|
||||
|
||||
public WordDetail detail(long wordId) {
|
||||
WordRow word = synonymMapper.findWord(wordId);
|
||||
if (word == null) {
|
||||
throw BizException.notFound("近义词词头不存在");
|
||||
}
|
||||
List<SenseRow> senses = synonymMapper.listSenses(wordId);
|
||||
if (senses.isEmpty()) {
|
||||
return new WordDetail(word.wordId(), word.word(), List.of());
|
||||
}
|
||||
List<Long> ids = senses.stream().map(sense -> Long.parseLong(sense.senseId())).toList();
|
||||
Map<String, List<GroupRow>> groupsBySense = new HashMap<>();
|
||||
for (GroupRow group : synonymMapper.listGroups(ids)) {
|
||||
groupsBySense.computeIfAbsent(group.senseId(), key -> new ArrayList<>()).add(group);
|
||||
}
|
||||
Map<String, List<MemberRow>> membersByGroup = new HashMap<>();
|
||||
for (MemberRow member : synonymMapper.listMembers(ids)) {
|
||||
membersByGroup.computeIfAbsent(member.senseId() + ":" + member.examId(),
|
||||
key -> new ArrayList<>()).add(member);
|
||||
}
|
||||
Map<String, List<AntonymRow>> antonymsByGroup = new LinkedHashMap<>();
|
||||
for (AntonymRow antonym : synonymMapper.listAntonyms(ids)) {
|
||||
antonymsByGroup.computeIfAbsent(antonym.senseId() + ":" + antonym.examId(),
|
||||
key -> new ArrayList<>()).add(antonym);
|
||||
}
|
||||
|
||||
List<SenseItem> senseItems = new ArrayList<>(senses.size());
|
||||
for (SenseRow sense : senses) {
|
||||
List<GroupItem> groups = new ArrayList<>();
|
||||
List<AntonymItem> antonyms = new ArrayList<>();
|
||||
List<String> examOrder = new ArrayList<>();
|
||||
for (GroupRow group : groupsBySense.getOrDefault(sense.senseId(), List.of())) {
|
||||
String key = group.senseId() + ":" + group.examId();
|
||||
examOrder.add(key);
|
||||
List<MemberItem> members = membersByGroup.getOrDefault(key, List.of()).stream()
|
||||
.limit(MEMBER_LIMIT)
|
||||
.map(member -> new MemberItem(member.wordId(), member.word(), member.position()))
|
||||
.toList();
|
||||
boolean truncated = membersByGroup.getOrDefault(key, List.of()).size() > MEMBER_LIMIT;
|
||||
groups.add(new GroupItem(group.examId(), group.examName(), group.canonicalWordId(),
|
||||
group.canonicalWord(), group.memberCount(), members, truncated));
|
||||
}
|
||||
for (String key : examOrder) {
|
||||
List<AntonymRow> rows = antonymsByGroup.getOrDefault(key, List.of());
|
||||
if (rows.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
AntonymRow first = rows.get(0);
|
||||
List<MemberItem> words = rows.stream()
|
||||
.map(row -> new MemberItem(row.wordId(), row.word(), row.position()))
|
||||
.toList();
|
||||
antonyms.add(new AntonymItem(first.examId(), first.examName(), words));
|
||||
}
|
||||
if (groups.isEmpty() && antonyms.isEmpty()) {
|
||||
senseItems.add(new SenseItem(sense.senseId(), sense.partOfSpeech(), sense.glossZh(),
|
||||
List.of(), List.of()));
|
||||
} else {
|
||||
senseItems.add(new SenseItem(sense.senseId(), sense.partOfSpeech(), sense.glossZh(),
|
||||
groups, antonyms));
|
||||
}
|
||||
}
|
||||
return new WordDetail(word.wordId(), word.word(), senseItems);
|
||||
}
|
||||
|
||||
public List<SizeBucket> groupSizeDistribution() {
|
||||
var rows = synonymMapper.groupSizeDistribution();
|
||||
long total = rows.stream().mapToLong(row -> row.count()).sum();
|
||||
List<SizeBucket> buckets = new ArrayList<>(rows.size());
|
||||
for (var row : rows) {
|
||||
double pct = total == 0 ? 0 : Math.round(row.count() * 1000.0 / total) / 10.0;
|
||||
buckets.add(new SizeBucket(row.label(), row.count(), pct));
|
||||
}
|
||||
return buckets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
logging:
|
||||
level:
|
||||
com.wordmarket.admin: DEBUG
|
||||
org.springframework.web: INFO
|
||||
org.mybatis: INFO
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
@@ -0,0 +1,28 @@
|
||||
# 复制为 application-local.yml,或直接通过环境变量注入。
|
||||
# 仓库中不得出现真实凭据。
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://s1.void01.com:3306/word_market?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&connectTimeout=10000&socketTimeout=30000
|
||||
username: your_read_only_user
|
||||
password: your_password
|
||||
|
||||
admin:
|
||||
username: admin
|
||||
# 使用 BCrypt 哈希,例如:
|
||||
# htpasswd -bnBC 10 "" 'your-password' | tr -d ':\n'
|
||||
password-hash: $2a$10$replace_with_a_real_bcrypt_hash
|
||||
jwt-secret: replace_with_a_random_secret_at_least_32_characters
|
||||
token-ttl-hours: 8
|
||||
|
||||
app:
|
||||
cors:
|
||||
allowed-origins: http://localhost:5173,http://127.0.0.1:5173
|
||||
cover-base-url: https://static.beingfine.cn
|
||||
cache:
|
||||
ttl-minutes: 10
|
||||
maximum-size: 200
|
||||
quality:
|
||||
known-missing-zpk-keys: 0_53785_101_1775241011
|
||||
@@ -0,0 +1,53 @@
|
||||
server:
|
||||
port: ${SERVER_PORT:8080}
|
||||
shutdown: graceful
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: word-market-admin
|
||||
profiles:
|
||||
default: dev
|
||||
datasource:
|
||||
url: ${DB_URL:jdbc:mysql://s1.void01.com:3306/word_market?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&connectTimeout=10000&socketTimeout=30000}
|
||||
username: ${DB_USERNAME:}
|
||||
password: ${DB_PASSWORD:}
|
||||
hikari:
|
||||
read-only: true
|
||||
maximum-pool-size: ${DB_POOL_SIZE:15}
|
||||
minimum-idle: 2
|
||||
connection-timeout: 10000
|
||||
validation-timeout: 5000
|
||||
connection-init-sql: SET NAMES utf8mb4
|
||||
jackson:
|
||||
time-zone: Asia/Shanghai
|
||||
mvc:
|
||||
problemdetails:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
default-fetch-size: 100
|
||||
global-config:
|
||||
banner: false
|
||||
|
||||
admin:
|
||||
username: ${ADMIN_USERNAME:}
|
||||
password-hash: ${ADMIN_PASSWORD_HASH:}
|
||||
jwt-secret: ${JWT_SECRET:}
|
||||
token-ttl-hours: ${ADMIN_TOKEN_TTL_HOURS:8}
|
||||
|
||||
app:
|
||||
cors:
|
||||
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:5173,http://127.0.0.1:5173}
|
||||
cover-base-url: ${COVER_BASE_URL:https://static.beingfine.cn}
|
||||
cache:
|
||||
ttl-minutes: ${CACHE_TTL_MINUTES:10}
|
||||
maximum-size: ${CACHE_MAXIMUM_SIZE:200}
|
||||
quality:
|
||||
known-missing-zpk-keys: ${KNOWN_MISSING_ZPK_KEYS:0_53785_101_1775241011}
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
com.wordmarket.admin: INFO
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.wordmarket.admin.common;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class PagesTest {
|
||||
|
||||
@Test
|
||||
void normalizesPageAndSize() {
|
||||
assertThat(Pages.page(null)).isEqualTo(1);
|
||||
assertThat(Pages.page(0)).isEqualTo(1);
|
||||
assertThat(Pages.page(-3)).isEqualTo(1);
|
||||
assertThat(Pages.page(4)).isEqualTo(4);
|
||||
|
||||
assertThat(Pages.size(null)).isEqualTo(20);
|
||||
assertThat(Pages.size(0)).isEqualTo(20);
|
||||
assertThat(Pages.size(500)).isEqualTo(100);
|
||||
assertThat(Pages.size(50)).isEqualTo(50);
|
||||
}
|
||||
|
||||
@Test
|
||||
void computesOffset() {
|
||||
assertThat(Pages.offset(1, 20)).isZero();
|
||||
assertThat(Pages.offset(3, 20)).isEqualTo(40);
|
||||
assertThat(Pages.offset(Integer.MAX_VALUE, 100)).isEqualTo(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AggregateCacheTest {
|
||||
|
||||
private final Cache<String, Object> cache = Caffeine.newBuilder().maximumSize(10).build();
|
||||
private final AggregateCache aggregateCache = new AggregateCache(cache);
|
||||
|
||||
@Test
|
||||
void cachesUntilRefresh() {
|
||||
AtomicInteger loads = new AtomicInteger();
|
||||
String first = aggregateCache.get("k", false, () -> "v" + loads.incrementAndGet());
|
||||
String second = aggregateCache.get("k", false, () -> "v" + loads.incrementAndGet());
|
||||
assertThat(first).isEqualTo("v1");
|
||||
assertThat(second).isEqualTo("v1");
|
||||
assertThat(loads.get()).isEqualTo(1);
|
||||
|
||||
String refreshed = aggregateCache.get("k", true, () -> "v" + loads.incrementAndGet());
|
||||
assertThat(refreshed).isEqualTo("v2");
|
||||
assertThat(loads.get()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.config.AdminProperties;
|
||||
import com.wordmarket.admin.dto.AuthDtos.LoginRequest;
|
||||
import com.wordmarket.admin.dto.AuthDtos.LoginResponse;
|
||||
import com.wordmarket.admin.security.JwtService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class AuthServiceTest {
|
||||
|
||||
private final AdminProperties properties = new AdminProperties();
|
||||
private final PasswordEncoder passwordEncoder = mock(PasswordEncoder.class);
|
||||
private final JwtService jwtService = mock(JwtService.class);
|
||||
private AuthService authService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
properties.setUsername("admin");
|
||||
properties.setPasswordHash("hash");
|
||||
properties.setJwtSecret("0123456789012345678901234567890123456789");
|
||||
authService = new AuthService(properties, passwordEncoder, jwtService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void issuesTokenForValidCredentials() {
|
||||
when(passwordEncoder.matches("secret", "hash")).thenReturn(true);
|
||||
when(jwtService.issue("admin")).thenReturn(
|
||||
new JwtService.IssuedToken("token", Instant.parse("2030-01-01T00:00:00Z")));
|
||||
|
||||
LoginResponse response = authService.login(new LoginRequest("admin", "secret"));
|
||||
|
||||
assertThat(response.token()).isEqualTo("token");
|
||||
assertThat(response.username()).isEqualTo("admin");
|
||||
assertThat(response.expiresAt()).isEqualTo("2030-01-01T00:00:00Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsWrongCredentials() {
|
||||
when(passwordEncoder.matches("bad", "hash")).thenReturn(false);
|
||||
|
||||
assertThatThrownBy(() -> authService.login(new LoginRequest("admin", "bad")))
|
||||
.isInstanceOf(BizException.class)
|
||||
.satisfies(error -> assertThat(((BizException) error).getStatus())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsWrongUsername() {
|
||||
when(passwordEncoder.matches("secret", "hash")).thenReturn(true);
|
||||
|
||||
assertThatThrownBy(() -> authService.login(new LoginRequest("other", "secret")))
|
||||
.isInstanceOf(BizException.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.BizException;
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookDetailRow;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookEntryItem;
|
||||
import com.wordmarket.admin.dto.BookDtos.BookListItem;
|
||||
import com.wordmarket.admin.mapper.BookMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class BookServiceTest {
|
||||
|
||||
private final BookMapper bookMapper = mock(BookMapper.class);
|
||||
private final BookService bookService = new BookService(bookMapper);
|
||||
|
||||
@Test
|
||||
void detailReturnsNotFoundWhenMissing() {
|
||||
when(bookMapper.findBook(99L)).thenReturn(null);
|
||||
|
||||
assertThatThrownBy(() -> bookService.detail(99L))
|
||||
.isInstanceOf(BizException.class)
|
||||
.satisfies(error -> assertThat(((BizException) error).getStatus())
|
||||
.isEqualTo(HttpStatus.NOT_FOUND));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listClampsPageAndSize() {
|
||||
when(bookMapper.countBooks(isNull(), isNull(), isNull())).thenReturn(0L);
|
||||
when(bookMapper.listBooks(isNull(), isNull(), isNull(), eq(0), eq(100)))
|
||||
.thenReturn(List.<BookListItem>of());
|
||||
|
||||
PageResult<BookListItem> result = bookService.list(0, 500, null, null, null);
|
||||
|
||||
assertThat(result.page()).isEqualTo(1);
|
||||
assertThat(result.size()).isEqualTo(100);
|
||||
assertThat(result.items()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void entriesClampPaginationAndVerifyBook() {
|
||||
when(bookMapper.findBook(3L)).thenReturn(new BookDetailRow("3", "CET6", "六级", null, "4",
|
||||
"六级", 100L, 90L, 1, 3, null, null, true, 0L, null));
|
||||
when(bookMapper.countBookEntries(3L, null)).thenReturn(0L);
|
||||
when(bookMapper.listBookEntries(eq(3L), isNull(), eq(0), eq(100)))
|
||||
.thenReturn(List.<BookEntryItem>of());
|
||||
|
||||
PageResult<BookEntryItem> result = bookService.entries(3L, 0, 500, null);
|
||||
|
||||
assertThat(result.page()).isEqualTo(1);
|
||||
assertThat(result.size()).isEqualTo(100);
|
||||
assertThat(result.total()).isZero();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.wordmarket.admin.service;
|
||||
|
||||
import com.wordmarket.admin.common.PageResult;
|
||||
import com.wordmarket.admin.dto.EntryDtos.EntryDetail;
|
||||
import com.wordmarket.admin.dto.EntryDtos.ExampleGroupItem;
|
||||
import com.wordmarket.admin.dto.EntryDtos.SenseItem;
|
||||
import com.wordmarket.admin.mapper.EntryMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class EntryServiceTest {
|
||||
|
||||
private final EntryMapper entryMapper = mock(EntryMapper.class);
|
||||
private final EntryService entryService = new EntryService(entryMapper);
|
||||
|
||||
private EntryDetail detail() {
|
||||
return new EntryDetail("1", "word", "word", null, null, null, "2.0", null, null,
|
||||
0, false, "key");
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsEmptySensesAndExamples() {
|
||||
when(entryMapper.findEntry(1L)).thenReturn(detail());
|
||||
when(entryMapper.listSenses(1L)).thenReturn(List.of());
|
||||
when(entryMapper.countExampleGroups(1L)).thenReturn(0L);
|
||||
when(entryMapper.listExampleGroups(1L, 0, 5)).thenReturn(List.of());
|
||||
|
||||
List<SenseItem> senses = entryService.senses(1L);
|
||||
PageResult<ExampleGroupItem> examples = entryService.examples(1L, 1, 5);
|
||||
|
||||
assertThat(senses).isEmpty();
|
||||
assertThat(examples.items()).isEmpty();
|
||||
assertThat(examples.total()).isZero();
|
||||
assertThat(examples.page()).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# 默认连接真实后端;后端未就绪时可临时设为 true 使用本地同形 mock
|
||||
VITE_USE_MOCK=false
|
||||
VITE_API_BASE_URL=/api
|
||||
VITE_COVER_BASE_URL=https://static.beingfine.cn
|
||||
@@ -1,7 +1,77 @@
|
||||
# frontend — 单词管理前端
|
||||
# frontend — 词库管理前端
|
||||
|
||||
占位目录,技术栈待定。
|
||||
Vue 3 + Vite + TypeScript + Element Plus + ECharts。
|
||||
|
||||
用途:浏览、检索、编辑与管理由 `importer` 导入的词书、词条及其关联数据。
|
||||
## 功能
|
||||
|
||||
后续确定技术栈与目录结构后在此实现。
|
||||
- 单管理员登录、token 持久化、路由守卫与 401 自动跳转。
|
||||
- 概览:六项 KPI、考试分布、词书规模排行、词性分布、质量红绿灯、跨域覆盖度,支持强制刷新聚合缓存。
|
||||
- 词书:列表筛选、详情、词条清单分页与搜索、封面占位。
|
||||
- 词条:搜索列表 + 右侧抽屉详情,义项/短语/例句/收录词书按 Tab 懒加载,支持空状态与分页。
|
||||
- 词根词族:词素、单词卡片、词族列表与详情,词族树形族谱按节点懒加载。
|
||||
- 近反义词:组规模分布图、词头列表、词头详情(分考试近义组与反义词)。
|
||||
- 数据质量:指标摘要与口径提示、声明与实际差异、缺失引用明细、跨域覆盖度、实体跳转。
|
||||
|
||||
## 开发
|
||||
|
||||
```powershell
|
||||
cd frontend
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
默认地址:http://127.0.0.1:5173。开发服务器将 `/api` 代理到 `http://127.0.0.1:8080`;如后端端口不同:
|
||||
|
||||
```powershell
|
||||
$env:VITE_PROXY_TARGET = 'http://127.0.0.1:18080'
|
||||
npm run dev
|
||||
```
|
||||
|
||||
后端未启动时可临时使用本地 mock:
|
||||
|
||||
```powershell
|
||||
$env:VITE_USE_MOCK = 'true'
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## 构建
|
||||
|
||||
```powershell
|
||||
npm run build
|
||||
```
|
||||
|
||||
产物在 `dist/`。构建前会执行 `vue-tsc --noEmit` 类型检查。
|
||||
|
||||
## 环境变量
|
||||
|
||||
复制 `.env.example` 为 `.env`:
|
||||
|
||||
```text
|
||||
VITE_USE_MOCK=false
|
||||
VITE_API_BASE_URL=/api
|
||||
VITE_COVER_BASE_URL=https://static.beingfine.cn
|
||||
```
|
||||
|
||||
- `VITE_USE_MOCK`:仅在明确设为 `true` 时使用本地 mock。
|
||||
- `VITE_API_BASE_URL`:接口前缀,默认 `/api`。
|
||||
- `VITE_COVER_BASE_URL`:词书封面 CDN 前缀。
|
||||
|
||||
## 目录
|
||||
|
||||
```text
|
||||
src/
|
||||
api/ Axios 封装、各模块接口与类型
|
||||
charts/ ECharts 配置
|
||||
components/ DataTable、CoverImage、StatCard、SectionPanel
|
||||
layouts/ AdminLayout 侧边栏布局
|
||||
mocks/ 离线开发用的概览数据快照
|
||||
router/ 路由与登录守卫
|
||||
stores/ 认证状态
|
||||
styles/ 全局基础样式
|
||||
utils/ 封面地址、存储键、HTML 文本清理
|
||||
views/ 登录、概览、词书、词条、词根词族、近反义词、数据质量
|
||||
```
|
||||
|
||||
## 生产部署
|
||||
|
||||
`npm run build` 后将 `dist/` 交给 Nginx,并把 `/api` 反向代理到后端。示例配置见 [`../backend/README.md`](../backend/README.md) 的部署章节。
|
||||
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link
|
||||
rel="icon"
|
||||
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%232563eb'/%3E%3Ctext x='16' y='22' font-size='18' font-family='Arial' font-weight='bold' fill='white' text-anchor='middle'%3EW%3C/text%3E%3C/svg%3E"
|
||||
/>
|
||||
<title>Word Market · 词库管理后台</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "word-market-frontend",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"axios": "^1.7.9",
|
||||
"echarts": "^5.5.1",
|
||||
"element-plus": "^2.8.8",
|
||||
"pinia": "^2.3.0",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"typescript": "~5.7.2",
|
||||
"vite": "^6.0.5",
|
||||
"vue-tsc": "^2.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
# UI 原型(throwaway)
|
||||
|
||||
> **方案 A(经典后台)已选定。** 原型现已覆盖概览与五个业务模块;正式实现见 `frontend/src/`。
|
||||
>
|
||||
> **这是可丢弃的 UI 原型,不是生产代码。**
|
||||
|
||||
## 运行
|
||||
|
||||
在仓库根目录执行:
|
||||
|
||||
```powershell
|
||||
python -m http.server 8090 --directory frontend/prototype
|
||||
```
|
||||
|
||||
打开 http://127.0.0.1:8090/index.html 即可。也可以直接双击 `index.html`(依赖 CDN,需要联网)。
|
||||
|
||||
## 页面
|
||||
|
||||
| 页面 | URL | 内容 |
|
||||
|---|---|---|
|
||||
| 概览 | `?page=overview&variant=A` | KPI、考试分布、词性分布、词书排行、质量红绿灯;支持 A/B/C 方案切换 |
|
||||
| 词书管理 | `?page=books` | 词书列表、考试/关键词/文件状态筛选、词书详情与词条清单 |
|
||||
| 词书详情 | `?page=books&id=15` | SAT10000 信息卡 + 12 条词条清单 |
|
||||
| 词条词典 | `?page=entries` | 词条搜索与列表 |
|
||||
| 词条详情 | `?page=entries&id=26132` | 右侧抽屉展示 `cinema` 基本信息 + 义项/短语/例句/易混词/收录词书五个 Tab |
|
||||
| 词根词族 | `?page=morphology` | 词素、单词卡片、词族、树形族谱四个 Tab |
|
||||
| 近反义词 | `?page=synonyms` | 词头列表 |
|
||||
| 近反义词详情 | `?page=synonyms&id=2411` | `gain` 义项、分考试近义组、组规模分布、反义词 |
|
||||
| 数据质量 | `?page=quality` | 7 项摘要、18 本声明差异、缺失引用、跨域覆盖度 |
|
||||
|
||||
侧边栏可切换模块;词书与近义词列表中的“查看”进入详情页;词条列表点击行或“查看”在右侧非模态抽屉中展开详情,抽屉打开时仍可继续点击其他词条或切换模块,关闭抽屉即回到列表;词条与词根词族支持 Tab 切换;概览页底部条和键盘 `←` / `→` 切换 A/B/C。
|
||||
|
||||
## 数据
|
||||
|
||||
全部来自 MySQL `word_market` 的真实快照(2026-11-08),不是编造内容:
|
||||
|
||||
- 词书 10 本、词书词条 12 条
|
||||
- 词条 10 条;`cinema` 含 2 个义项、3 个短语、6 条例句、5 个易混词、8 本收录词书
|
||||
- 词素 12 个、卡片 6 张、词族 8 个;`behave` 含 5 个变体与 4 个小组
|
||||
- 近义词头 8 个;`gain` 含 5 个义项、10 个近义组、2 组反义词
|
||||
- 质量差异 18 本词书、19 个无义项近义词头
|
||||
|
||||
## 文件
|
||||
|
||||
- `index.html`:入口、CDN 依赖、页面路由与方案切换
|
||||
- `data.js`:概览数据快照
|
||||
- `data-modules.js`:模块数据样本
|
||||
- `variant-a.js` / `variant-b.js` / `variant-c.js`:概览三方案
|
||||
- `module-shell.js`:模块页共用的 A 风格侧边栏布局
|
||||
- `view-books.js` / `view-entries.js` / `view-morphology.js` / `view-synonyms.js` / `view-quality.js`
|
||||
- `styles.css`:概览与通用样式
|
||||
- `modules.css`:模块页样式
|
||||
- `screenshots/`:各页面截图
|
||||
|
||||
## 仍待确认
|
||||
|
||||
- 词条抽屉宽度是否合适,是否需要支持拖拽调整宽度。
|
||||
- 词书详情是否需要展示内容版本、发布时间等目录字段。
|
||||
- 词条抽屉内例句是否按例句组折叠,而不是平铺。
|
||||
- 族谱是否需要支持逐层懒加载,而不是默认展开全部。
|
||||
- 质量页的差异行是否需要提供“定位到词书”的钻取。
|
||||
@@ -0,0 +1,214 @@
|
||||
// PROTOTYPE ONLY — real data samples from MySQL word_market (2026-11-08).
|
||||
window.MODULE_DATA = {
|
||||
books: [
|
||||
{ id: 15, code: 'SAT', name: 'SAT10000', exam: '未归类', declared: 10001, actual: 10001, coverPath: '/dicts/v3/img_032516463440_24_opt.png', hasFile: true },
|
||||
{ id: 1170, code: 'LLYC2027', name: '2027恋练有词考研英语词汇', exam: '考研', declared: 7969, actual: 7969, coverPath: '/dicts/v3/img_122613473672_1017_opt.png', hasFile: true },
|
||||
{ id: 557, code: 'LLYCKY2024', name: '2024恋练有词考研英语词汇', exam: '考研', declared: 7949, actual: 7949, coverPath: '/dicts/v3/img_032615238520_111_opt.png', hasFile: true },
|
||||
{ id: 740, code: 'LLYCKY2026', name: '2026恋练有词考研英语词汇', exam: '考研', declared: 7941, actual: 7941, coverPath: '/dicts/v3/img_122414371550_51_opt.png', hasFile: true },
|
||||
{ id: 630, code: 'LLYCKY2025', name: '2025恋练有词考研英语词汇', exam: '考研', declared: 7940, actual: 7940, coverPath: '/dicts/v3/img_032615097259_51_opt.png', hasFile: true },
|
||||
{ id: 508, code: 'LLYCK2023N', name: '2023恋练有词考研英语词汇', exam: '考研', declared: 7919, actual: 7919, coverPath: '/dicts/v3/img_042716404904_126_opt.png', hasFile: true },
|
||||
{ id: 331, code: 'LLYCKY2023', name: '2023恋练有词考研英语词汇', exam: '考研', declared: 7919, actual: 7919, coverPath: '/dicts/v3/img_032617141081_126_opt.png', hasFile: true },
|
||||
{ id: 841, code: 'HZBCET6N', name: '英语六级 你还在背单词吗(新版)', exam: '六级', declared: 7799, actual: 7799, coverPath: '/dicts/v3/img_081109464902_93_opt.png', hasFile: true },
|
||||
{ id: 519, code: 'PETS5', name: '全国英语等级考试第五级', exam: '未归类', declared: 7527, actual: 7527, coverPath: '/dicts/v3/img_032516041386_40_opt.png', hasFile: true },
|
||||
{ id: 819, code: 'KYLX2026', name: '考研词汇 词根联想记忆法 乱序版', exam: '考研', declared: 7349, actual: 7349, coverPath: '/dicts/v3/img_071615349355_34_opt.png', hasFile: true }
|
||||
],
|
||||
bookEntries: [
|
||||
{ displayWord: 'abandon', headword: 'abandon', pronunciation: 'əˈbændən', definition: 'vt. 放弃;抛弃;沉湎于 n. 放任,放纵', seq: 1 },
|
||||
{ displayWord: 'surge', headword: 'surge', pronunciation: 'sɜːrdʒ', definition: 'vi. 涌动;激增 n. 激增;(感情的) 突发', seq: 1 },
|
||||
{ displayWord: 'promotion', headword: 'promotion', pronunciation: 'prəˈmoʊʃn', definition: 'n. 晋升;促销;促进;晋级', seq: 2 },
|
||||
{ displayWord: 'prompt', headword: 'prompt', pronunciation: 'prɑːmpt', definition: 'vt. 促使;引起 adj. 迅速的;准时的', seq: 2 },
|
||||
{ displayWord: 'competitive', headword: 'competitive', pronunciation: 'kəmˈpetətɪv', definition: 'adj. 竞争的;有竞争力的;好胜的', seq: 3 },
|
||||
{ displayWord: 'efficient', headword: 'efficient', pronunciation: 'ɪˈfɪʃnt', definition: 'adj. 效率高的', seq: 4 },
|
||||
{ displayWord: 'uneasy', headword: 'uneasy', pronunciation: 'ʌnˈiːzi', definition: 'adj. 不安的,不自在的;不稳定的', seq: 4 },
|
||||
{ displayWord: 'inquiry', headword: 'inquiry', pronunciation: 'ˈɪnkwəri', definition: 'n. 询问,打听;调查,探究', seq: 5 },
|
||||
{ displayWord: 'stock', headword: 'stock', pronunciation: 'stɑːk', definition: 'n. 库存;储备物;股票;家畜', seq: 6 },
|
||||
{ displayWord: 'exploit', headword: 'exploit', pronunciation: 'ɪkˈsplɔɪt', definition: 'vt. 剥削;利用;开采 n. 英勇的行为', seq: 7 },
|
||||
{ displayWord: 'diagnose', headword: 'diagnose', pronunciation: 'ˌdaɪəɡˈnoʊs', definition: 'vt. vi. 诊断 (病症)', seq: 9 },
|
||||
{ displayWord: 'advertise', headword: 'advertise', pronunciation: 'ˈædvərtaɪz', definition: 'vi. vt. 为…做广告;征聘', seq: 10 }
|
||||
],
|
||||
entries: [
|
||||
{ id: 26132, headword: 'cinema', indexWord: 'cinema', pronunciation: 'ˈsɪnəmə', definition: 'n. 电影院;电影艺术,电影业', occurrence: 91, senses: 2 },
|
||||
{ id: 2763, headword: 'China', indexWord: 'China', pronunciation: 'ˈtʃaɪnə', definition: 'n. 中国', occurrence: 50, senses: 1 },
|
||||
{ id: 52254, headword: 'inhabitant', indexWord: 'inhabitant', pronunciation: 'ɪnˈhæbɪtənt', definition: 'n. 居民,栖居的动物', occurrence: 37, senses: 1 },
|
||||
{ id: 96868, headword: 'vast', indexWord: 'vast', pronunciation: 'væst', definition: 'adj. 巨大的,广阔的', occurrence: 36, senses: 1 },
|
||||
{ id: 54775, headword: 'kilo', indexWord: 'kilo', pronunciation: 'ˈkiːloʊ', definition: 'n. 千克,公斤', occurrence: 35, senses: 1 },
|
||||
{ id: 84763, headword: 'sometimes', indexWord: 'sometimes', pronunciation: 'ˈsʌmtaɪmz', definition: 'adv. 有时', occurrence: 35, senses: 1 },
|
||||
{ id: 74617, headword: 'put on', indexWord: 'put on', pronunciation: '', definition: 'phrv. 穿上,戴上;增加体重;举办,上演', occurrence: 34, senses: 3 },
|
||||
{ id: 81834, headword: 'seventeen', indexWord: 'seventeen', pronunciation: 'ˌsevnˈtiːn', definition: 'num. 十七', occurrence: 33, senses: 1 },
|
||||
{ id: 29516, headword: 'corresponding', indexWord: 'corresponding', pronunciation: 'ˌkɔːrəˈspɑːndɪŋ', definition: 'adj. 符合的,相应的', occurrence: 32, senses: 1 },
|
||||
{ id: 63898, headword: 'neutron', indexWord: 'neutron', pronunciation: 'ˈnuːtrɑːn', definition: 'n. 中子', occurrence: 30, senses: 1 }
|
||||
],
|
||||
entryDetail: {
|
||||
id: 26132,
|
||||
headword: 'cinema',
|
||||
indexWord: 'cinema',
|
||||
pronunciation: 'ˈsɪnəmə',
|
||||
definition: 'n. 电影院;电影艺术,电影业',
|
||||
occurrence: 91,
|
||||
senses: [
|
||||
{ no: 1, pos: 'n.', gloss: '电影院', exams: '中考 / 高考 / 六级 / 考研 / 雅思 / 专升本' },
|
||||
{ no: 2, pos: 'n.', gloss: '电影艺术,电影业', exams: '高考 / 雅思' }
|
||||
],
|
||||
phrases: [
|
||||
{ en: 'go to the cinema', zh: '去看电影', type: 2 },
|
||||
{ en: 'a local cinema', zh: '当地影院', type: 2 },
|
||||
{ en: 'American cinema', zh: '美国电影界', type: 2 }
|
||||
],
|
||||
examples: [
|
||||
{ en: "And besides, it's rude to talk in the cinema.", zh: '而且,在电影院大声喧哗是不礼貌的。' },
|
||||
{ en: "I'm free this afternoon. Why don't we go to the cinema?", zh: '我今天下午有空,要不我们去看电影吧?' },
|
||||
{ en: '"Loving Vincent" is set to hit cinema screens this fall.', zh: '《至爱梵高》将在今年秋季上映。' },
|
||||
{ en: 'This was shown at a local cinema and made $100.', zh: '这部电影在当地一家影院上映,取得了100美元的利润。' },
|
||||
{ en: 'Bruce Lee exploded onto American cinemas screen in August 1973.', zh: '1973年8月,李小龙凭借《龙争虎斗》闯入美国影坛。' },
|
||||
{ en: 'A Moscow cinema has stopped screening the banned film.', zh: '莫斯科某影院已停止放映被禁影片。' }
|
||||
],
|
||||
confusables: [
|
||||
{ word: 'ninety', gloss: 'num. 九十' },
|
||||
{ word: 'china', gloss: 'n. 瓷,瓷料;瓷器' },
|
||||
{ word: 'coma', gloss: 'n. 昏迷' },
|
||||
{ word: 'mine', gloss: 'pron. 我的' },
|
||||
{ word: 'lineup', gloss: 'n. 阵容,阵列' }
|
||||
],
|
||||
books: [
|
||||
{ name: '外研join in六年级上', display: 'cinema', seq: 1 },
|
||||
{ name: '人教PEP版六年级上', display: 'cinema', seq: 5 },
|
||||
{ name: '辽师大五年级上(新版)', display: 'cinema', seq: 12 },
|
||||
{ name: '鲁教版七年级上(五四学制)', display: 'cinema', seq: 14 },
|
||||
{ name: '人教大同版四年级上(新版)', display: 'cinema', seq: 15 },
|
||||
{ name: '外研社版四年级上(三年级起点)', display: 'cinema', seq: 15 },
|
||||
{ name: '沪教版二年级上(新版)', display: 'cinema', seq: 20 },
|
||||
{ name: '闽教版四年级上(新版)', display: 'cinema', seq: 21 }
|
||||
]
|
||||
},
|
||||
morphemes: [
|
||||
{ id: 1, type: 'prefix', form: 'caco-', meaningEn: 'bad', meaningZh: '坏的', note: '' },
|
||||
{ id: 2, type: 'prefix', form: 'genu-', meaningEn: 'knee', meaningZh: '膝盖', note: '' },
|
||||
{ id: 3, type: 'prefix', form: 'geronto-', meaningEn: 'old', meaningZh: '老的', note: '' },
|
||||
{ id: 4, type: 'prefix', form: 'mega-', meaningEn: 'great', meaningZh: '巨大的', note: '' },
|
||||
{ id: 215, type: 'root', form: 'duct', meaningEn: 'to lead', meaningZh: '引导', note: '' },
|
||||
{ id: 216, type: 'root', form: 'duc', meaningEn: 'to lead', meaningZh: '引导', note: '' },
|
||||
{ id: 217, type: 'root', form: 'du', meaningEn: 'to lead', meaningZh: '引导', note: '' },
|
||||
{ id: 218, type: 'root', form: 'hom', meaningEn: 'man', meaningZh: '人类', note: '' },
|
||||
{ id: 2080, type: 'suffix', form: '-aholic', meaningEn: '', meaningZh: '构成名词', note: '对…成瘾的人' },
|
||||
{ id: 2081, type: 'suffix', form: '-ar', meaningEn: '', meaningZh: '构成形容词', note: '' },
|
||||
{ id: 2082, type: 'suffix', form: '-ar', meaningEn: '', meaningZh: '构成名词', note: '做某事的人' },
|
||||
{ id: 2083, type: 'suffix', form: '-ard', meaningEn: '', meaningZh: '构成名词', note: '常处于某种状态的人' }
|
||||
],
|
||||
cards: [
|
||||
{ id: 3, word: 'adherence', memory: '粘在…上 → 紧紧跟随 ⇨ 坚持,遵守,遵循', example: 'strict adherence to the rules\n严格遵守规章制度' },
|
||||
{ id: 6, word: 'adherent', memory: '粘在…上 → 紧紧跟随 ⇨ 追随者,拥护者', example: 'adherents of the Greek Orthodox Church\n希腊东正教的信徒' },
|
||||
{ id: 1, word: 'Anglican', memory: '英国国教会的;圣公会的', example: '' },
|
||||
{ id: 2, word: 'Anglo-Saxon', memory: '盎格鲁-撒克逊人的;古英语的', example: '' },
|
||||
{ id: 4, word: 'Antarctic', memory: '北边的反面 ⇨ 南极地区', example: '' },
|
||||
{ id: 5, word: 'Antarctica', memory: '北边的反面 ⇨ 南极地区', example: '' }
|
||||
],
|
||||
families: [
|
||||
{ id: 585, word: 'act', interpretation: 'n. 行为;法案 v. 扮演', members: 112 },
|
||||
{ id: 10126, word: 'heart', interpretation: 'n. 心脏;内心;中央', members: 97 },
|
||||
{ id: 18270, word: 'sense', interpretation: 'n. 感官;意识;意思 v. 意识到', members: 74 },
|
||||
{ id: 12115, word: 'light', interpretation: 'n. 光;电灯 adj. 明亮的;轻的', members: 68 },
|
||||
{ id: 1501, word: 'arm', interpretation: 'n. 手臂 v. 武装,装备', members: 64 },
|
||||
{ id: 12616, word: 'man', interpretation: 'n. 男人;人类,人', members: 63 },
|
||||
{ id: 2146, word: 'behave', interpretation: 'v. 表现;举止得体', members: 24 },
|
||||
{ id: 3664, word: 'civil', interpretation: 'adj. 公民的;有礼貌的', members: 18 }
|
||||
],
|
||||
familyTree: {
|
||||
id: 2146,
|
||||
word: 'behave',
|
||||
interpretation: 'v. 表现;举止得体',
|
||||
variants: ['behaviour', 'behavioural', 'behaviourism', 'behaviourist', 'misbehaviour'],
|
||||
groups: [
|
||||
['behave', 'behavior', 'misbehave'],
|
||||
['behave', 'behavior', 'behavioral'],
|
||||
['behave', 'behavior', 'behaviorism'],
|
||||
['behave', 'behavior', 'behaviorist']
|
||||
]
|
||||
},
|
||||
synonyms: [
|
||||
{ id: 4990, word: 'show', senses: 10 },
|
||||
{ id: 3509, word: 'mark', senses: 8 },
|
||||
{ id: 2174, word: 'fall', senses: 6 },
|
||||
{ id: 2245, word: 'figure', senses: 6 },
|
||||
{ id: 2411, word: 'gain', senses: 6 },
|
||||
{ id: 4183, word: 'position', senses: 6 },
|
||||
{ id: 4191, word: 'post', senses: 6 },
|
||||
{ id: 4244, word: 'present', senses: 6 }
|
||||
],
|
||||
synonymDetail: {
|
||||
id: 2411,
|
||||
word: 'gain',
|
||||
senses: [
|
||||
{ id: 3267, pos: 'v.', gloss: '获得' },
|
||||
{ id: 3268, pos: 'v.', gloss: '增加' },
|
||||
{ id: 3269, pos: 'v.', gloss: '受益' },
|
||||
{ id: 3270, pos: 'n.', gloss: '增加' },
|
||||
{ id: 3271, pos: 'n.', gloss: '好处' }
|
||||
],
|
||||
groups: [
|
||||
{ senseId: 3267, exam: '中考', canonical: 'achieve', count: 2 },
|
||||
{ senseId: 3267, exam: '高考', canonical: 'obtain', count: 6 },
|
||||
{ senseId: 3267, exam: '四级', canonical: 'obtain', count: 6 },
|
||||
{ senseId: 3267, exam: '六级', canonical: 'obtain', count: 6 },
|
||||
{ senseId: 3267, exam: '考研', canonical: 'obtain', count: 6 },
|
||||
{ senseId: 3267, exam: '雅思', canonical: 'obtain', count: 6 },
|
||||
{ senseId: 3267, exam: '托福', canonical: 'achieve', count: 6 },
|
||||
{ senseId: 3268, exam: '中考', canonical: '', count: 8 },
|
||||
{ senseId: 3268, exam: '高考', canonical: '', count: 10 },
|
||||
{ senseId: 3268, exam: '四级', canonical: '', count: 10 }
|
||||
],
|
||||
members: [
|
||||
{ senseId: 3267, exam: '中考', words: ['gain', 'achieve'] },
|
||||
{ senseId: 3267, exam: '高考', words: ['gain', 'obtain', 'achieve', 'acquire', 'attain', 'secure'] },
|
||||
{ senseId: 3267, exam: '四级', words: ['gain', 'obtain', 'achieve', 'acquire', 'attain', 'secure'] },
|
||||
{ senseId: 3267, exam: '六级', words: ['gain', 'obtain', 'achieve', 'acquire', 'attain', 'secure'] },
|
||||
{ senseId: 3267, exam: '考研', words: ['gain', 'obtain', 'achieve', 'acquire', 'attain', 'secure'] },
|
||||
{ senseId: 3267, exam: '雅思', words: ['gain', 'obtain', 'achieve', 'acquire', 'attain', 'secure'] }
|
||||
],
|
||||
antonyms: [
|
||||
{ senseId: 3270, gloss: '增加', exams: ['高考', '四级', '六级', '雅思', '托福', '其他'], word: 'loss' },
|
||||
{ senseId: 3271, gloss: '好处', exams: ['中考', '高考', '四级', '六级', '考研', '雅思', '专升本', '其他'], word: 'loss' }
|
||||
]
|
||||
},
|
||||
quality: {
|
||||
summary: [
|
||||
{ label: '声明与实际词条数不一致', value: 18, unit: '本', level: 'warn' },
|
||||
{ label: '缺失词书清单文件', value: 1, unit: '本', level: 'bad' },
|
||||
{ label: '缺失 zpk 引用', value: 1, unit: '个', level: 'bad' },
|
||||
{ label: '无结构化义项的词条', value: 5250, unit: '条', level: 'warn' },
|
||||
{ label: '无义项的近义词头', value: 19, unit: '个', level: 'warn' },
|
||||
{ label: '未设置考试的词书', value: 509, unit: '本', level: 'info' },
|
||||
{ label: '无封面词书', value: 27, unit: '本', level: 'info' }
|
||||
],
|
||||
mismatch: [
|
||||
{ name: '外研社版八年级上(新版)', code: 'WYS8S', declared: 335, actual: 256 },
|
||||
{ name: '译林版牛津英语九上(新版)', code: 'YLB9S', declared: 305, actual: 368 },
|
||||
{ name: '人教版七年级上(新版)', code: 'RJB7S2024', declared: 288, actual: 269 },
|
||||
{ name: '沪教版三年级上(新版)', code: 'HJ3S', declared: 162, actual: 146 },
|
||||
{ name: '外研社版四年级上(新版)', code: 'WYS4NJS', declared: 165, actual: 153 },
|
||||
{ name: '鲁教版九年级全册(新版)', code: 'LJ9Q', declared: 482, actual: 492 },
|
||||
{ name: '外研社版七年级上(新版)', code: 'WYS7S2024', declared: 298, actual: 288 },
|
||||
{ name: '译林版牛津英语八上(新版)', code: 'YLB8S', declared: 440, actual: 450 },
|
||||
{ name: '人教PEP版四年级上(新版)', code: 'RJPEP4S', declared: 109, actual: 117 },
|
||||
{ name: '人教版八年级上(新版)', code: 'RJB8S', declared: 554, actual: 550 },
|
||||
{ name: '外研社版高中选择性必修一(新)', code: 'WYSGZXZBX1', declared: 266, actual: 263 },
|
||||
{ name: '科普版六年级上(新版)', code: 'KP6SN', declared: 108, actual: 109 },
|
||||
{ name: '六级考前保命200词', code: 'CET6BM200', declared: 219, actual: 220 },
|
||||
{ name: '闽教版五年级上(新版)', code: 'MJ5SN', declared: 135, actual: 134 },
|
||||
{ name: '杭州English for Kids 2B', code: 'HZ2B', declared: 42, actual: 41 },
|
||||
{ name: '人教版高中选择性必修一(新)', code: 'RJBGZXZBX1', declared: 345, actual: 344 },
|
||||
{ name: '2021何凯文考研英语必考词汇', code: 'HKWKY2021', declared: 4249, actual: 4248 },
|
||||
{ name: '考研考前保命200词', code: 'KYBM200', declared: 257, actual: 258 }
|
||||
],
|
||||
missingFile: [{ name: '全国医学博士外语统一考试大纲', code: 'KBYXKSDG' }],
|
||||
synNoSense: [
|
||||
'adulthood', 'at home', 'attached', 'away', 'caring', 'childhood', 'confirmed', 'debit', 'luck',
|
||||
'nap', 'on a daily basis', 'purely', 'set sail', 'take a nap', 'trade union', 'unattached',
|
||||
'unbroken', 'uncaring', 'unconfirmed'
|
||||
],
|
||||
coverage: [
|
||||
{ name: '单词卡片', hit: 11662, total: 11998, pct: 97.2 },
|
||||
{ name: '词族', hit: 17587, total: 22710, pct: 77.4 },
|
||||
{ name: '近义词头', hit: 6231, total: 6279, pct: 99.2 }
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
// PROTOTYPE ONLY — throwaway UI data. Real snapshot from MySQL word_market (2026-11-08).
|
||||
// Not production code; safe to delete.
|
||||
window.DASHBOARD_DATA = {
|
||||
kpis: [
|
||||
{ key: 'books', label: '词书', value: 1025, note: '1 本无清单文件', tone: 'blue' },
|
||||
{ key: 'entries', label: '词条', value: 38116, note: '38,000 个索引词', tone: 'green' },
|
||||
{ key: 'links', label: '词书词条关联', value: 1228421, note: '平均每本 1,200 条', tone: 'violet' },
|
||||
{ key: 'sentences', label: '例句', value: 235744, note: '含使用模式 71,964', tone: 'amber' },
|
||||
{ key: 'families', label: '词族', value: 22717, note: '顶层族 5,629', tone: 'cyan' },
|
||||
{ key: 'synonyms', label: '近义词头', value: 6279, note: '义项 8,383', tone: 'rose' }
|
||||
],
|
||||
exams: [
|
||||
{ name: '考研', code: 'KY', books: 108, entries: 480091 },
|
||||
{ name: '未归类', code: '—', books: 509, entries: 258233 },
|
||||
{ name: '高考', code: 'GK', books: 150, entries: 154292 },
|
||||
{ name: '中考', code: 'ZK', books: 156, entries: 74439 },
|
||||
{ name: '四级', code: 'CET4', books: 29, entries: 69362 },
|
||||
{ name: '六级', code: 'CET6', books: 22, entries: 52863 },
|
||||
{ name: '专升本', code: 'ZSB', books: 19, entries: 52681 },
|
||||
{ name: '专四', code: 'PRO4', books: 7, entries: 25627 },
|
||||
{ name: '雅思', code: 'IELTS', books: 11, entries: 25314 },
|
||||
{ name: '专八', code: 'PRO8', books: 6, entries: 19954 },
|
||||
{ name: '托福', code: 'TOEFL', books: 8, entries: 15565 }
|
||||
],
|
||||
topBooks: [
|
||||
{ id: 15, name: 'SAT10000', code: 'SAT', exam: 'SAT', declared: 10001, actual: 10001, cover: 'https://static.beingfine.cn/dicts/v3/img_032516463440_24_opt.png' },
|
||||
{ id: 1170, name: '2027恋练有词考研英语词汇', code: 'LLYC2027', exam: '考研', declared: 7969, actual: 7969, cover: 'https://static.beingfine.cn/dicts/v3/img_122613473672_1017_opt.png' },
|
||||
{ id: 557, name: '2024恋练有词考研英语词汇', code: 'LLYCKY2024', exam: '考研', declared: 7949, actual: 7949, cover: 'https://static.beingfine.cn/dicts/v3/img_032615238520_111_opt.png' },
|
||||
{ id: 740, name: '2026恋练有词考研英语词汇', code: 'LLYCKY2026', exam: '考研', declared: 7941, actual: 7941, cover: 'https://static.beingfine.cn/dicts/v3/img_122414371550_51_opt.png' },
|
||||
{ id: 630, name: '2025恋练有词考研英语词汇', code: 'LLYCKY2025', exam: '考研', declared: 7940, actual: 7940, cover: 'https://static.beingfine.cn/dicts/v3/img_032615097259_51_opt.png' },
|
||||
{ id: 331, name: '2023恋练有词考研英语词汇', code: 'LLYCKY2023', exam: '考研', declared: 7919, actual: 7919, cover: 'https://static.beingfine.cn/dicts/v3/img_032617141081_126_opt.png' },
|
||||
{ id: 508, name: '2023恋练有词考研英语词汇', code: 'LLYCK2023N', exam: '考研', declared: 7919, actual: 7919, cover: 'https://static.beingfine.cn/dicts/v3/img_042716404904_126_opt.png' },
|
||||
{ id: 841, name: '英语六级 你还在背单词吗(新版)', code: 'HZBCET6N', exam: '六级', declared: 7799, actual: 7799, cover: 'https://static.beingfine.cn/dicts/v3/img_081109464902_93_opt.png' },
|
||||
{ id: 519, name: '全国英语等级考试第五级', code: 'PETS5', exam: '未归类', declared: 7527, actual: 7527, cover: 'https://static.beingfine.cn/dicts/v3/img_032516041386_40_opt.png' },
|
||||
{ id: 819, name: '考研词汇 词根联想记忆法 乱序版', code: 'KYLX2026', exam: '考研', declared: 7349, actual: 7349, cover: 'https://static.beingfine.cn/dicts/v3/img_071615349355_34_opt.png' }
|
||||
],
|
||||
pos: [
|
||||
{ name: 'n.', value: 21313 },
|
||||
{ name: 'adj.', value: 9782 },
|
||||
{ name: 'phr.', value: 6922 },
|
||||
{ name: 'vt.', value: 5331 },
|
||||
{ name: 'adv.', value: 1996 },
|
||||
{ name: 'vi.', value: 1800 },
|
||||
{ name: 'phrv.', value: 1758 },
|
||||
{ name: 'idm.', value: 1595 },
|
||||
{ name: 'vi. vt.', value: 971 },
|
||||
{ name: 'vt. vi.', value: 896 }
|
||||
],
|
||||
quality: [
|
||||
{ key: 'mismatch', label: '声明与实际词条数不一致', value: 18, unit: '本', level: 'warn', target: '词书' },
|
||||
{ key: 'nofile', label: '缺失词书清单文件', value: 1, unit: '本', level: 'bad', target: '词书' },
|
||||
{ key: 'nozpk', label: '缺失 zpk 引用', value: 1, unit: '个', level: 'bad', target: '词条' },
|
||||
{ key: 'nosense', label: '无结构化义项的词条', value: 5250, unit: '条', level: 'warn', target: '词条' },
|
||||
{ key: 'nosyn', label: '无义项的近义词头', value: 19, unit: '个', level: 'warn', target: '近义词' },
|
||||
{ key: 'noexam', label: '未设置考试的词书', value: 509, unit: '本', level: 'info', target: '词书' },
|
||||
{ key: 'nocover', label: '无封面词书', value: 27, unit: '本', level: 'info', target: '词书' }
|
||||
],
|
||||
coverage: [
|
||||
{ name: '单词卡片', hit: 11662, total: 11998, pct: 97.2 },
|
||||
{ name: '词族', hit: 17587, total: 22710, pct: 77.4 },
|
||||
{ name: '近义词头', hit: 6231, total: 6279, pct: 99.2 }
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,167 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link
|
||||
rel="icon"
|
||||
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%232563eb'/%3E%3Ctext x='16' y='22' font-size='18' font-family='Arial' font-weight='bold' fill='white' text-anchor='middle'%3EW%3C/text%3E%3C/svg%3E"
|
||||
/>
|
||||
<title>词库后台 · UI 原型(throwaway)</title>
|
||||
<!-- PROTOTYPE ONLY — not production. Serve with: python -m http.server 8090 --directory frontend/prototype -->
|
||||
<link rel="stylesheet" href="https://registry.npmmirror.com/element-plus/2.8.8/files/dist/index.css" />
|
||||
<link rel="stylesheet" href="./styles.css" />
|
||||
<link rel="stylesheet" href="./modules.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<script src="https://registry.npmmirror.com/vue/3.5.13/files/dist/vue.global.prod.js"></script>
|
||||
<script src="https://registry.npmmirror.com/element-plus/2.8.8/files/dist/index.full.min.js"></script>
|
||||
<script src="https://registry.npmmirror.com/echarts/5.5.1/files/dist/echarts.min.js"></script>
|
||||
|
||||
<script src="./data.js"></script>
|
||||
<script src="./data-modules.js"></script>
|
||||
<script src="./variant-a.js"></script>
|
||||
<script src="./variant-b.js"></script>
|
||||
<script src="./variant-c.js"></script>
|
||||
<script src="./module-shell.js"></script>
|
||||
<script src="./view-books.js"></script>
|
||||
<script src="./view-entries.js"></script>
|
||||
<script src="./view-morphology.js"></script>
|
||||
<script src="./view-synonyms.js"></script>
|
||||
<script src="./view-quality.js"></script>
|
||||
|
||||
<script>
|
||||
const { createApp, ref, computed, onMounted, onBeforeUnmount } = Vue;
|
||||
const VARIANTS = [
|
||||
{ key: 'A', comp: window.VariantA },
|
||||
{ key: 'B', comp: window.VariantB },
|
||||
{ key: 'C', comp: window.VariantC }
|
||||
];
|
||||
const VARIANT_KEYS = VARIANTS.map((v) => v.key);
|
||||
const PAGES = ['overview', 'books', 'entries', 'morphology', 'synonyms', 'quality'];
|
||||
const VIEWS = {
|
||||
books: window.ViewBooks,
|
||||
entries: window.ViewEntries,
|
||||
morphology: window.ViewMorphology,
|
||||
synonyms: window.ViewSynonyms,
|
||||
quality: window.ViewQuality
|
||||
};
|
||||
const PAGE_TITLES = {
|
||||
overview: '概览',
|
||||
books: '词书管理',
|
||||
entries: '词条词典',
|
||||
morphology: '词根词族',
|
||||
synonyms: '近反义词',
|
||||
quality: '数据质量'
|
||||
};
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
function initialPage() {
|
||||
const p = params.get('page');
|
||||
return PAGES.includes(p) ? p : 'overview';
|
||||
}
|
||||
function initialVariant() {
|
||||
const v = params.get('variant');
|
||||
return VARIANT_KEYS.includes(v) ? v : 'A';
|
||||
}
|
||||
|
||||
const app = createApp({
|
||||
setup() {
|
||||
const page = ref(initialPage());
|
||||
const variant = ref(initialVariant());
|
||||
const id = ref(params.get('id') || '');
|
||||
const kw = ref(params.get('kw') || '');
|
||||
|
||||
const isOverview = computed(() => page.value === 'overview');
|
||||
const meta = computed(() => VARIANTS.find((v) => v.key === variant.value));
|
||||
const label = computed(() => {
|
||||
const name = meta.value.comp.name.replace(/^Variant[A-Z]\s*—\s*/, '');
|
||||
return `${variant.value} — ${name}`;
|
||||
});
|
||||
const viewComp = computed(() => VIEWS[page.value]);
|
||||
|
||||
function writeUrl() {
|
||||
try {
|
||||
const url = new URL(location.href);
|
||||
url.searchParams.set('page', page.value);
|
||||
if (page.value === 'overview') {
|
||||
url.searchParams.set('variant', variant.value);
|
||||
url.searchParams.delete('id');
|
||||
url.searchParams.delete('kw');
|
||||
} else {
|
||||
url.searchParams.delete('variant');
|
||||
if (id.value) url.searchParams.set('id', id.value);
|
||||
else url.searchParams.delete('id');
|
||||
if (kw.value) url.searchParams.set('kw', kw.value);
|
||||
else url.searchParams.delete('kw');
|
||||
}
|
||||
history.replaceState({}, '', url);
|
||||
} catch (_) { /* file:// may reject history updates */ }
|
||||
document.title = `词库后台 · ${PAGE_TITLES[page.value] || page.value} · UI 原型`;
|
||||
}
|
||||
|
||||
function navigate(nextPage, nextId, nextKw) {
|
||||
if (!PAGES.includes(nextPage)) return;
|
||||
page.value = nextPage;
|
||||
id.value = nextId === undefined || nextId === null || nextId === '' ? '' : String(nextId);
|
||||
kw.value = nextKw || '';
|
||||
if (nextPage !== 'overview') variant.value = 'A';
|
||||
writeUrl();
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
function setVariant(key) {
|
||||
variant.value = key;
|
||||
page.value = 'overview';
|
||||
writeUrl();
|
||||
}
|
||||
|
||||
function cycle(dir) {
|
||||
const i = VARIANT_KEYS.indexOf(variant.value);
|
||||
setVariant(VARIANT_KEYS[(i + dir + VARIANT_KEYS.length) % VARIANT_KEYS.length]);
|
||||
}
|
||||
|
||||
function onKey(e) {
|
||||
const t = e.target;
|
||||
if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return;
|
||||
if (!isOverview.value) return;
|
||||
if (e.key === 'ArrowLeft') { e.preventDefault(); cycle(-1); }
|
||||
if (e.key === 'ArrowRight') { e.preventDefault(); cycle(1); }
|
||||
}
|
||||
|
||||
window.protoNavigate = navigate;
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', onKey);
|
||||
writeUrl();
|
||||
});
|
||||
onBeforeUnmount(() => window.removeEventListener('keydown', onKey));
|
||||
|
||||
return { page, variant, id, kw, isOverview, label, viewComp, cycle, navigate, keys: VARIANT_KEYS };
|
||||
},
|
||||
template: `
|
||||
<component v-if="isOverview" :is="'Variant' + variant" :key="variant" />
|
||||
<component v-else :is="viewComp" :id="id" :kw="kw" :key="page" />
|
||||
|
||||
<div class="proto-badge">UI PROTOTYPE · 仅预览</div>
|
||||
|
||||
<div v-if="isOverview" class="proto-switcher">
|
||||
<button @click="cycle(-1)" aria-label="上一个方案">‹</button>
|
||||
<div class="label"><b>{{ label }}</b><span class="hint">← → 切换 · ?variant={{ variant }}</span></div>
|
||||
<button @click="cycle(1)" aria-label="下一个方案">›</button>
|
||||
</div>
|
||||
`
|
||||
});
|
||||
|
||||
VARIANTS.forEach((v) => app.component('Variant' + v.key, v.comp));
|
||||
app.use(ElementPlus);
|
||||
Object.entries(VIEWS).forEach(([name, comp]) => {
|
||||
app.component('View' + name.charAt(0).toUpperCase() + name.slice(1), comp);
|
||||
});
|
||||
app.component('ModuleShell', window.ModuleShell);
|
||||
app.mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,42 @@
|
||||
// PROTOTYPE ONLY — shared A-style shell for module pages.
|
||||
window.ModuleShell = {
|
||||
name: 'ModuleShell',
|
||||
props: { active: String, title: String },
|
||||
methods: {
|
||||
go(page) {
|
||||
window.protoNavigate(page);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="a-root">
|
||||
<div class="a-shell">
|
||||
<aside class="a-sidebar">
|
||||
<div class="a-brand" style="cursor:pointer" @click="go('overview')">
|
||||
<div class="a-brand-mark">W</div>
|
||||
<div><div class="a-brand-name">Word Market</div><div class="a-brand-sub">词库管理后台</div></div>
|
||||
</div>
|
||||
<nav class="a-nav">
|
||||
<div class="a-nav-item" :class="{ active: active === 'overview' }" @click="go('overview')"><span class="dot"></span>概览</div>
|
||||
<div class="a-nav-item" :class="{ active: active === 'books' }" @click="go('books')"><span class="dot"></span>词书管理</div>
|
||||
<div class="a-nav-item" :class="{ active: active === 'entries' }" @click="go('entries')"><span class="dot"></span>词条词典</div>
|
||||
<div class="a-nav-item" :class="{ active: active === 'morphology' }" @click="go('morphology')"><span class="dot"></span>词根词族</div>
|
||||
<div class="a-nav-item" :class="{ active: active === 'synonyms' }" @click="go('synonyms')"><span class="dot"></span>近反义词</div>
|
||||
<div class="a-nav-gap"></div>
|
||||
<div class="a-nav-item" :class="{ active: active === 'quality' }" @click="go('quality')"><span class="dot"></span>数据质量</div>
|
||||
</nav>
|
||||
<div class="a-side-foot">只读模式 · 数据快照 2026-11-08</div>
|
||||
</aside>
|
||||
|
||||
<main class="a-main">
|
||||
<div class="a-topbar">
|
||||
<div class="a-crumb">后台 / <b>{{ title }}</b></div>
|
||||
<div class="a-top-actions">
|
||||
<div class="a-search">搜索词书、词条…</div>
|
||||
<div class="a-avatar">AD</div>
|
||||
</div>
|
||||
</div>
|
||||
<slot />
|
||||
</main>
|
||||
</div>
|
||||
</div>`
|
||||
};
|
||||
@@ -0,0 +1,893 @@
|
||||
/* PROTOTYPE ONLY — module pages (books / entries / morphology / synonyms / quality). */
|
||||
|
||||
.m-page-head {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.m-page-head h1 {
|
||||
margin: 0 0 4px;
|
||||
font-size: 22px;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.m-page-head p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.m-page-meta {
|
||||
font-size: 11.5px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.m-toolbar {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 14px;
|
||||
flex-wrap: wrap;
|
||||
background: #fff;
|
||||
border: 1px solid #e8ebf0;
|
||||
border-radius: 10px;
|
||||
padding: 14px 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.m-toolbar-inline {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.m-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.m-field-grow {
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.m-field label {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.m-field input,
|
||||
.m-field select {
|
||||
height: 34px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 7px;
|
||||
background: #fff;
|
||||
padding: 0 10px;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
color: #374151;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.m-field input:focus,
|
||||
.m-field select:focus {
|
||||
border-color: #93c5fd;
|
||||
box-shadow: 0 0 0 3px #eff6ff;
|
||||
}
|
||||
|
||||
.m-toolbar-note {
|
||||
margin-left: auto;
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
padding-bottom: 9px;
|
||||
}
|
||||
|
||||
.m-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.m-table th {
|
||||
text-align: left;
|
||||
font-weight: 500;
|
||||
font-size: 11.5px;
|
||||
color: #9ca3af;
|
||||
padding: 7px 8px;
|
||||
border-bottom: 1px solid #eef0f3;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.m-table td {
|
||||
padding: 9px 8px;
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.m-table tbody tr:hover {
|
||||
background: #fafbfc;
|
||||
}
|
||||
|
||||
.m-table tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.m-num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.m-cell-title {
|
||||
font-weight: 500;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.m-cell-sub {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.m-book-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.m-cover {
|
||||
width: 30px;
|
||||
height: 40px;
|
||||
border-radius: 4px;
|
||||
object-fit: cover;
|
||||
background: #eef2f7;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.m-cover-lg {
|
||||
width: 96px;
|
||||
height: 132px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
background: #eef2f7;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.m-word {
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.m-phonetic {
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.m-def {
|
||||
font-size: 12.5px;
|
||||
color: #4b5563;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.m-tag {
|
||||
display: inline-block;
|
||||
padding: 1px 7px;
|
||||
border-radius: 999px;
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.m-tag-prefix {
|
||||
background: #eef2ff;
|
||||
color: #4338ca;
|
||||
}
|
||||
|
||||
.m-tag-root {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
}
|
||||
|
||||
.m-tag-suffix {
|
||||
background: #fffbeb;
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.m-dot {
|
||||
display: inline-block;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
margin-right: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.m-dot.ok {
|
||||
background: #16a34a;
|
||||
}
|
||||
|
||||
.m-dot.bad {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
.m-dot.warn {
|
||||
background: #f59e0b;
|
||||
}
|
||||
|
||||
.m-dot.info {
|
||||
background: #3b82f6;
|
||||
}
|
||||
|
||||
.m-link {
|
||||
color: #2563eb;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.m-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.m-ok {
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.m-warn-text {
|
||||
color: #d97706;
|
||||
}
|
||||
|
||||
.m-bad-text {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.m-empty {
|
||||
padding: 42px 16px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.m-back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.m-back:hover {
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.m-detail-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 22px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.m-detail-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.m-detail-kicker {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.12em;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.m-detail-title {
|
||||
margin: 4px 0 8px;
|
||||
font-size: 26px;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.m-detail-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.m-stat-row {
|
||||
display: flex;
|
||||
gap: 28px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.m-stat {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.m-stat b {
|
||||
display: block;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.m-stat span {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.m-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
margin: 18px 0 0;
|
||||
}
|
||||
|
||||
.m-tab {
|
||||
padding: 9px 14px;
|
||||
font-size: 13.5px;
|
||||
color: #6b7280;
|
||||
cursor: pointer;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.m-tab:hover {
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.m-tab.active {
|
||||
color: #4338ca;
|
||||
border-color: #4338ca;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.m-tab-panel {
|
||||
margin-top: 0;
|
||||
border-radius: 0 0 10px 10px;
|
||||
padding: 16px 18px;
|
||||
}
|
||||
|
||||
.m-note {
|
||||
font-size: 11.5px;
|
||||
color: #9ca3af;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.m-example-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.m-example {
|
||||
display: grid;
|
||||
grid-template-columns: 36px minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px dashed #eef0f3;
|
||||
}
|
||||
|
||||
.m-example:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.m-example-no {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.m-example-en {
|
||||
font-size: 13px;
|
||||
color: #1f2937;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.m-example-zh {
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
margin-top: 4px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.m-chip-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.m-chip {
|
||||
display: inline-block;
|
||||
padding: 3px 9px;
|
||||
border-radius: 999px;
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
font-size: 11.5px;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.m-chip-row .m-chip {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.m-chip.active {
|
||||
background: #eef2ff;
|
||||
color: #4338ca;
|
||||
border-color: #c7d2fe;
|
||||
}
|
||||
|
||||
.m-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.m-card-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.m-memo-card {
|
||||
background: #fff;
|
||||
border: 1px solid #e8ebf0;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.m-memo-word {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.m-memo-note {
|
||||
margin-top: 8px;
|
||||
font-size: 12.5px;
|
||||
color: #4b5563;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.m-memo-example {
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px dashed #eef0f3;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
white-space: pre-line;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.m-tree-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 250px minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.m-family-list {
|
||||
padding: 12px;
|
||||
max-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.m-family-item {
|
||||
padding: 9px 10px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.m-family-item:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.m-family-item.active {
|
||||
background: #eef2ff;
|
||||
}
|
||||
|
||||
.m-family-item.active .m-family-word {
|
||||
color: #4338ca;
|
||||
}
|
||||
|
||||
.m-family-word {
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.m-family-meta {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.m-tree-panel {
|
||||
padding: 16px 18px;
|
||||
}
|
||||
|
||||
.m-tree-panel .el-tree {
|
||||
background: transparent;
|
||||
--el-tree-node-hover-bg-color: #f8fafc;
|
||||
}
|
||||
|
||||
.m-tree-panel .el-tree-node__content {
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.m-tree-node {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.m-tree-type {
|
||||
font-size: 9.5px;
|
||||
color: #9ca3af;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.m-tree-root {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.m-tree-branch {
|
||||
font-weight: 600;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.m-tree-variant {
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
.m-tree-group {
|
||||
color: #0891b2;
|
||||
}
|
||||
|
||||
.m-two-col {
|
||||
display: grid;
|
||||
grid-template-columns: 1.35fr minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.m-side-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.m-sense {
|
||||
padding: 14px 0;
|
||||
border-bottom: 1px dashed #eef0f3;
|
||||
}
|
||||
|
||||
.m-sense:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.m-sense:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.m-sense-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.m-sense-no {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
min-width: 26px;
|
||||
}
|
||||
|
||||
.m-sense-gloss {
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.m-group-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.m-group {
|
||||
border: 1px solid #eef0f3;
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
background: #fcfcfd;
|
||||
}
|
||||
|
||||
.m-group-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.m-group-canon {
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.m-group-empty {
|
||||
font-size: 11.5px;
|
||||
color: #9ca3af;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.m-bar-row {
|
||||
display: grid;
|
||||
grid-template-columns: 82px minmax(0, 1fr) 54px;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.m-bar-label {
|
||||
font-size: 11.5px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.m-bar-track {
|
||||
display: block;
|
||||
height: 6px;
|
||||
background: #eef0f3;
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.m-bar-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #2563eb, #7c3aed);
|
||||
}
|
||||
|
||||
.m-bar-value {
|
||||
text-align: right;
|
||||
font-size: 11.5px;
|
||||
color: #6b7280;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.m-antonym {
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px dashed #eef0f3;
|
||||
}
|
||||
|
||||
.m-antonym:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.m-antonym-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.m-antonym-word {
|
||||
margin-left: auto;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.m-metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.m-metric {
|
||||
background: #fff;
|
||||
border: 1px solid #e8ebf0;
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.m-metric-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.m-metric-value {
|
||||
margin-top: 8px;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.m-metric-value span {
|
||||
margin-left: 3px;
|
||||
font-size: 10px;
|
||||
color: #9ca3af;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.m-issue {
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px dashed #eef0f3;
|
||||
}
|
||||
|
||||
.m-issue:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.m-issue-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.m-issue-body {
|
||||
font-size: 12.5px;
|
||||
color: #4b5563;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.m-cov {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.m-cov-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.m-cov-top b {
|
||||
color: #374151;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.m-cov-track {
|
||||
display: block;
|
||||
height: 5px;
|
||||
background: #eef0f3;
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.m-cov-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #2563eb, #7c3aed);
|
||||
}
|
||||
|
||||
.m-cov-note {
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
/* ---------- entry drawer ---------- */
|
||||
/* Element Plus 在 modal=false 时仍保留全屏定位层,放行点击到页面,仅抽屉本身可交互 */
|
||||
body > div:has(> .entry-drawer) {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.entry-drawer {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.entry-drawer .el-drawer__body {
|
||||
padding: 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.entry-drawer .el-drawer__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.drawer-body {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.drawer-head {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 22px;
|
||||
padding: 22px 54px 16px 24px;
|
||||
border-bottom: 1px solid #eef0f3;
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
margin: 4px 0 8px;
|
||||
font-size: 28px;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.drawer-close {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 18px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #e5e7eb;
|
||||
background: #fff;
|
||||
color: #6b7280;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.drawer-close:hover {
|
||||
background: #f3f4f6;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.drawer-note {
|
||||
margin: 12px 24px 0;
|
||||
}
|
||||
|
||||
.drawer-tabs {
|
||||
margin: 0;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
.drawer-tab-panel {
|
||||
padding: 16px 24px 28px;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.entry-drawer {
|
||||
width: 92% !important;
|
||||
}
|
||||
|
||||
.drawer-head {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.drawer-head .m-stat-row {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.m-two-col {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.m-tree-layout {
|
||||
grid-template-columns: 220px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.m-detail-head {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.m-stat-row {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 780px) {
|
||||
.m-tree-layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.m-metric-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 164 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 182 KiB |
|
After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 152 KiB |
@@ -0,0 +1,202 @@
|
||||
/* PROTOTYPE ONLY — throwaway styling for UI variants. */
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body { font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
|
||||
button { font: inherit; cursor: pointer; }
|
||||
img { display: block; }
|
||||
|
||||
.proto-badge {
|
||||
position: fixed; top: 14px; right: 14px; z-index: 1500;
|
||||
background: #111827; color: #f9fafb; border: 1px solid #374151;
|
||||
padding: 5px 10px; border-radius: 999px; font-size: 11px; letter-spacing: .08em;
|
||||
opacity: .82; pointer-events: none;
|
||||
}
|
||||
|
||||
/* ---------- shared switcher ---------- */
|
||||
.proto-switcher {
|
||||
position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
|
||||
z-index: 9999; display: flex; align-items: center; gap: 10px;
|
||||
background: #0f172a; color: #e2e8f0; border: 1px solid #334155;
|
||||
padding: 8px 10px; border-radius: 999px;
|
||||
box-shadow: 0 10px 30px rgba(2, 6, 23, .45);
|
||||
font-size: 13px; user-select: none;
|
||||
}
|
||||
.proto-switcher button {
|
||||
width: 30px; height: 30px; border-radius: 50%;
|
||||
border: 1px solid #475569; background: #1e293b; color: #e2e8f0;
|
||||
display: grid; place-items: center; font-size: 15px; line-height: 1;
|
||||
}
|
||||
.proto-switcher button:hover { background: #334155; }
|
||||
.proto-switcher .label { min-width: 210px; text-align: center; letter-spacing: .02em; }
|
||||
.proto-switcher .label b { color: #fff; }
|
||||
.proto-switcher .hint { color: #94a3b8; font-size: 11px; margin-left: 4px; }
|
||||
|
||||
/* =========================================================
|
||||
VARIANT A — 经典后台:白色侧栏 + KPI 卡 + 图表网格
|
||||
========================================================= */
|
||||
.a-root { min-height: 100vh; background: #f3f5f8; color: #1f2937; }
|
||||
.a-shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
|
||||
.a-sidebar { background: #fff; border-right: 1px solid #e5e7eb; padding: 22px 16px; display: flex; flex-direction: column; }
|
||||
.a-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
|
||||
.a-brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 700; }
|
||||
.a-brand-name { font-size: 15px; font-weight: 700; }
|
||||
.a-brand-sub { font-size: 11px; color: #9ca3af; }
|
||||
.a-nav { display: flex; flex-direction: column; gap: 2px; }
|
||||
.a-nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #4b5563; font-size: 13.5px; cursor: pointer; }
|
||||
.a-nav-item.active { background: #eef2ff; color: #4338ca; font-weight: 600; }
|
||||
.a-nav-item .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
|
||||
.a-nav-gap { height: 14px; }
|
||||
.a-side-foot { margin-top: auto; border-top: 1px solid #eef0f3; padding-top: 14px; font-size: 12px; color: #9ca3af; }
|
||||
.a-main { padding: 0 26px 90px; }
|
||||
.a-topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; margin-bottom: 22px; }
|
||||
.a-crumb { font-size: 13px; color: #6b7280; }
|
||||
.a-crumb b { color: #111827; }
|
||||
.a-top-actions { display: flex; align-items: center; gap: 10px; }
|
||||
.a-search { width: 240px; height: 34px; border: 1px solid #e5e7eb; background: #fff; border-radius: 8px; padding: 0 12px; font-size: 13px; color: #6b7280; display: flex; align-items: center; }
|
||||
.a-avatar { width: 32px; height: 32px; border-radius: 50%; background: #e0e7ff; color: #4338ca; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
|
||||
.a-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
|
||||
.a-heading h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
|
||||
.a-heading p { margin: 0; font-size: 13px; color: #6b7280; }
|
||||
.a-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
|
||||
.a-kpi { background: #fff; border: 1px solid #e8ebf0; border-radius: 10px; padding: 14px; position: relative; overflow: hidden; }
|
||||
.a-kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, #2563eb); }
|
||||
.a-kpi-label { font-size: 12px; color: #6b7280; }
|
||||
.a-kpi-value { font-size: 23px; font-weight: 700; margin: 7px 0 3px; font-variant-numeric: tabular-nums; }
|
||||
.a-kpi-note { font-size: 11px; color: #9ca3af; }
|
||||
.a-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
|
||||
.a-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
|
||||
.a-panel { background: #fff; border: 1px solid #e8ebf0; border-radius: 10px; padding: 16px 18px; }
|
||||
.a-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
|
||||
.a-panel-title { font-size: 14px; font-weight: 600; }
|
||||
.a-panel-sub { font-size: 11.5px; color: #9ca3af; }
|
||||
.a-chart { height: 300px; width: 100%; }
|
||||
.a-chart-sm { height: 240px; width: 100%; }
|
||||
.a-ranking { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
.a-ranking th { text-align: left; font-weight: 500; color: #9ca3af; font-size: 11.5px; padding: 6px 8px; border-bottom: 1px solid #eef0f3; }
|
||||
.a-ranking td { padding: 8px; border-bottom: 1px solid #f3f4f6; }
|
||||
.a-ranking tr:last-child td { border-bottom: 0; }
|
||||
.a-book { display: flex; align-items: center; gap: 10px; }
|
||||
.a-cover { width: 30px; height: 40px; border-radius: 4px; object-fit: cover; background: #eef2f7; }
|
||||
.a-cover-ph { width: 30px; height: 40px; border-radius: 4px; background: linear-gradient(135deg, #e5e7eb, #d1d5db); display: grid; place-items: center; font-size: 9px; color: #6b7280; }
|
||||
.a-mono { font-variant-numeric: tabular-nums; color: #374151; }
|
||||
.a-quality { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
|
||||
.a-q-item { border: 1px solid #eef0f3; border-radius: 8px; padding: 10px 12px; }
|
||||
.a-q-top { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #6b7280; }
|
||||
.a-led { width: 8px; height: 8px; border-radius: 50%; }
|
||||
.a-led.bad { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
|
||||
.a-led.warn { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
|
||||
.a-led.info { background: #3b82f6; box-shadow: 0 0 0 3px #dbeafe; }
|
||||
.a-q-value { font-size: 18px; font-weight: 700; margin-top: 6px; }
|
||||
.a-q-value span { font-size: 11px; color: #9ca3af; font-weight: 400; margin-left: 3px; }
|
||||
|
||||
/* =========================================================
|
||||
VARIANT B — 指挥中心:深色全宽 + 巨型数字 + 横向条形
|
||||
========================================================= */
|
||||
.b-root { min-height: 100vh; background: #080f1e; color: #dbe4f0; font-family: "DIN Alternate", "Bahnschrift", "Segoe UI", sans-serif; }
|
||||
.b-grid-bg { position: fixed; inset: 0; background-image: linear-gradient(rgba(56,189,248,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(56,189,248,.045) 1px, transparent 1px); background-size: 42px 42px; pointer-events: none; }
|
||||
.b-shell { position: relative; padding: 0 30px 90px; }
|
||||
.b-top { height: 66px; display: flex; align-items: center; gap: 26px; border-bottom: 1px solid rgba(148,163,184,.16); }
|
||||
.b-brand { font-size: 15px; letter-spacing: .16em; color: #7dd3fc; font-weight: 700; white-space: nowrap; }
|
||||
.b-nav { display: flex; gap: 20px; font-size: 12.5px; color: #64748b; letter-spacing: .04em; }
|
||||
.b-nav .active { color: #e0f2fe; border-bottom: 2px solid #38bdf8; padding-bottom: 4px; }
|
||||
.b-top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 11px; color: #64748b; letter-spacing: .08em; }
|
||||
.b-live { display: inline-flex; align-items: center; gap: 6px; color: #4ade80; }
|
||||
.b-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; }
|
||||
.b-title-row { display: flex; align-items: baseline; justify-content: space-between; padding: 26px 0 18px; }
|
||||
.b-title-row h1 { margin: 0; font-size: 24px; letter-spacing: .1em; font-weight: 600; color: #f0f9ff; }
|
||||
.b-title-row .sub { font-size: 11px; color: #64748b; letter-spacing: .12em; }
|
||||
.b-kpi-band { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid rgba(148,163,184,.16); border-bottom: 1px solid rgba(148,163,184,.16); }
|
||||
.b-kpi { padding: 18px 20px 16px; border-right: 1px solid rgba(148,163,184,.12); }
|
||||
.b-kpi:last-child { border-right: 0; }
|
||||
.b-kpi-label { font-size: 10.5px; color: #64748b; letter-spacing: .14em; }
|
||||
.b-kpi-value { font-size: 38px; font-weight: 700; color: #f8fafc; line-height: 1.12; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
|
||||
.b-kpi-note { font-size: 10.5px; color: #475569; letter-spacing: .04em; }
|
||||
.b-body { display: grid; grid-template-columns: 1.5fr 1fr; gap: 30px; margin-top: 26px; }
|
||||
.b-section-title { font-size: 11px; color: #7dd3fc; letter-spacing: .18em; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
|
||||
.b-section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(56,189,248,.35), transparent); }
|
||||
.b-bars { display: flex; flex-direction: column; gap: 11px; }
|
||||
.b-bar-row { display: grid; grid-template-columns: 74px 1fr 92px; align-items: center; gap: 12px; font-size: 12.5px; }
|
||||
.b-bar-name { color: #cbd5e1; }
|
||||
.b-bar-track { height: 9px; background: rgba(148,163,184,.1); border-radius: 2px; overflow: hidden; }
|
||||
.b-bar-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
|
||||
.b-bar-row.unclassified .b-bar-fill { background: linear-gradient(90deg, #475569, #64748b); }
|
||||
.b-bar-value { text-align: right; color: #94a3b8; font-variant-numeric: tabular-nums; font-size: 12px; }
|
||||
.b-bar-value b { color: #e2e8f0; }
|
||||
.b-chart { height: 230px; }
|
||||
.b-side { display: flex; flex-direction: column; gap: 26px; }
|
||||
.b-quality { display: flex; flex-direction: column; }
|
||||
.b-q-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed rgba(148,163,184,.14); font-size: 12.5px; }
|
||||
.b-q-row:last-child { border-bottom: 0; }
|
||||
.b-q-led { width: 7px; height: 7px; border-radius: 50%; }
|
||||
.b-q-led.bad { background: #f87171; box-shadow: 0 0 7px #f87171; }
|
||||
.b-q-led.warn { background: #fbbf24; box-shadow: 0 0 7px #fbbf24; }
|
||||
.b-q-led.info { background: #60a5fa; box-shadow: 0 0 7px #60a5fa; }
|
||||
.b-q-label { color: #94a3b8; }
|
||||
.b-q-value { color: #f1f5f9; font-variant-numeric: tabular-nums; font-size: 15px; }
|
||||
.b-coverage { display: flex; flex-direction: column; gap: 13px; }
|
||||
.b-cov-row { font-size: 12px; }
|
||||
.b-cov-top { display: flex; justify-content: space-between; color: #94a3b8; margin-bottom: 5px; }
|
||||
.b-cov-top b { color: #e2e8f0; font-variant-numeric: tabular-nums; }
|
||||
.b-cov-track { height: 4px; background: rgba(148,163,184,.12); }
|
||||
.b-cov-fill { height: 100%; background: linear-gradient(90deg, #22d3ee, #818cf8); }
|
||||
.b-rank { display: flex; flex-direction: column; }
|
||||
.b-rank-row { display: grid; grid-template-columns: 26px 1fr 88px 74px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(148,163,184,.08); font-size: 12px; }
|
||||
.b-rank-no { color: #38bdf8; font-variant-numeric: tabular-nums; }
|
||||
.b-rank-name { color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.b-rank-actual { text-align: right; color: #f8fafc; font-variant-numeric: tabular-nums; }
|
||||
.b-rank-diff { text-align: right; color: #64748b; font-size: 11px; }
|
||||
|
||||
/* =========================================================
|
||||
VARIANT C — 编辑部:纸面 + 编号目录 + 编辑式排版
|
||||
========================================================= */
|
||||
.c-root { min-height: 100vh; background: #f7f3ea; color: #26221c; font-family: "Songti SC", "Noto Serif SC", Georgia, serif; }
|
||||
.c-shell { display: grid; grid-template-columns: 74px minmax(0, 1fr); max-width: 1240px; margin: 0 auto; padding: 0 28px 100px; }
|
||||
.c-rail { padding-top: 46px; position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; gap: 18px; align-items: center; }
|
||||
.c-rail-num { width: 30px; height: 30px; border: 1px solid #d6cdbb; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #8a8172; font-family: "Segoe UI", sans-serif; }
|
||||
.c-rail-num.active { background: #26221c; color: #f7f3ea; border-color: #26221c; }
|
||||
.c-main { padding-top: 44px; min-width: 0; }
|
||||
.c-masthead { display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 2px solid #26221c; padding-bottom: 14px; }
|
||||
.c-masthead h1 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: .02em; }
|
||||
.c-masthead .kicker { font-family: "Segoe UI", sans-serif; font-size: 10.5px; letter-spacing: .22em; color: #8a8172; text-transform: uppercase; margin-bottom: 8px; }
|
||||
.c-masthead .date { font-family: "Segoe UI", sans-serif; font-size: 11.5px; color: #8a8172; text-align: right; line-height: 1.7; }
|
||||
.c-lede { max-width: 780px; font-size: 15px; line-height: 1.85; color: #4a443a; margin: 24px 0 34px; }
|
||||
.c-lede b { color: #26221c; }
|
||||
.c-section { padding: 22px 0; border-top: 1px solid #d9d1c1; }
|
||||
.c-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
|
||||
.c-section-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
|
||||
.c-section-head h2 span { font-family: "Segoe UI", sans-serif; font-size: 11px; color: #9a917f; letter-spacing: .1em; margin-right: 10px; }
|
||||
.c-section-head .aside { font-family: "Segoe UI", sans-serif; font-size: 11px; color: #9a917f; }
|
||||
.c-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; border-top: 1px solid #d9d1c1; }
|
||||
.c-stat { padding: 16px 14px 16px 0; border-right: 1px solid #e2dacb; }
|
||||
.c-stat:last-child { border-right: 0; }
|
||||
.c-stat .n { font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
|
||||
.c-stat .l { font-family: "Segoe UI", sans-serif; font-size: 11px; color: #8a8172; margin-top: 6px; letter-spacing: .04em; }
|
||||
.c-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 44px; }
|
||||
.c-chart { height: 270px; }
|
||||
.c-list { margin: 0; padding: 0; list-style: none; counter-reset: item; }
|
||||
.c-list li { counter-increment: item; display: grid; grid-template-columns: 26px 34px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px dotted #d9d1c1; font-family: "Segoe UI", sans-serif; font-size: 12.5px; }
|
||||
.c-list li::before { content: counter(item, decimal-leading-zero); color: #9a917f; font-size: 10.5px; }
|
||||
.c-list .thumb { width: 26px; height: 34px; border-radius: 2px; object-fit: cover; background: #e6dece; }
|
||||
.c-list .title { color: #33302a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.c-list .num { color: #6e6556; font-variant-numeric: tabular-nums; }
|
||||
.c-quality-cols { column-count: 2; column-gap: 40px; }
|
||||
.c-q { break-inside: avoid; display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px dotted #d9d1c1; font-family: "Segoe UI", sans-serif; font-size: 12.5px; }
|
||||
.c-q .k { color: #5d5547; }
|
||||
.c-q .v { font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
.c-q .v.bad { color: #a33a2b; }
|
||||
.c-q .v.warn { color: #9a6a12; }
|
||||
.c-q .v.info { color: #3d6b8a; }
|
||||
.c-cov { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
|
||||
.c-cov-row { font-family: "Segoe UI", sans-serif; font-size: 12px; display: grid; grid-template-columns: 82px 1fr 72px; gap: 12px; align-items: center; }
|
||||
.c-cov-track { display: block; height: 2px; background: #ded5c5; position: relative; }
|
||||
.c-cov-fill { position: absolute; inset: 0 auto 0 0; background: #26221c; }
|
||||
.c-cov-val { text-align: right; color: #5d5547; font-variant-numeric: tabular-nums; }
|
||||
.c-footnote { margin-top: 26px; padding-top: 14px; border-top: 1px solid #d9d1c1; font-family: "Segoe UI", sans-serif; font-size: 11px; color: #9a917f; line-height: 1.8; }
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
.a-kpis { grid-template-columns: repeat(3, 1fr); }
|
||||
.b-kpi-band { grid-template-columns: repeat(3, 1fr); }
|
||||
.b-kpi:nth-child(3n) { border-right: 0; }
|
||||
.c-stats { grid-template-columns: repeat(3, 1fr); }
|
||||
.c-stat:nth-child(3n) { border-right: 0; }
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
// PROTOTYPE ONLY — Variant A: classic admin (white sidebar, KPI cards, chart grid).
|
||||
(function () {
|
||||
const { ref, onMounted, onBeforeUnmount, nextTick } = Vue;
|
||||
const D = window.DASHBOARD_DATA;
|
||||
const PH = 'data:image/svg+xml;utf8,' + encodeURIComponent(
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="60" height="80"><rect width="60" height="80" fill="#e5e7eb"/><text x="30" y="44" font-size="10" fill="#9ca3af" text-anchor="middle">N/A</text></svg>'
|
||||
);
|
||||
const fmt = (n) => n.toLocaleString('en-US');
|
||||
const short = (n) => n >= 10000 ? (n / 1000).toFixed(1) + 'k' : String(n);
|
||||
const tone = { blue: '#2563eb', green: '#16a34a', violet: '#7c3aed', amber: '#d97706', cyan: '#0891b2', rose: '#e11d48' };
|
||||
|
||||
window.VariantA = {
|
||||
name: 'VariantA — 经典后台',
|
||||
setup() {
|
||||
const examEl = ref(null);
|
||||
const posEl = ref(null);
|
||||
let charts = [];
|
||||
const resize = () => charts.forEach((c) => c.resize());
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
const exam = echarts.init(examEl.value);
|
||||
const rows = D.exams;
|
||||
exam.setOption({
|
||||
grid: { left: 8, right: 54, top: 6, bottom: 6, containLabel: true },
|
||||
tooltip: {
|
||||
trigger: 'axis', axisPointer: { type: 'shadow' },
|
||||
formatter: (p) => {
|
||||
const r = rows[rows.length - 1 - p[0].dataIndex];
|
||||
return `<b>${r.name}</b><br/>关联词条 ${fmt(r.entries)}<br/>词书 ${r.books} 本`;
|
||||
}
|
||||
},
|
||||
xAxis: { type: 'value', splitLine: { lineStyle: { color: '#f1f3f6' } }, axisLabel: { color: '#9ca3af', fontSize: 10, formatter: short } },
|
||||
yAxis: { type: 'category', data: rows.map((r) => r.name).reverse(), axisTick: { show: false }, axisLine: { show: false }, axisLabel: { color: '#4b5563', fontSize: 11.5 } },
|
||||
series: [{
|
||||
type: 'bar', barWidth: 13,
|
||||
data: rows.map((r) => ({ value: r.entries, itemStyle: { color: r.code === '—' ? '#cbd5e1' : '#3b82f6', borderRadius: [0, 3, 3, 0] } })).reverse(),
|
||||
label: { show: true, position: 'right', color: '#6b7280', fontSize: 10.5, formatter: (p) => short(p.value) }
|
||||
}]
|
||||
});
|
||||
|
||||
const pos = echarts.init(posEl.value);
|
||||
pos.setOption({
|
||||
tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
||||
legend: { right: 0, top: 'center', orient: 'vertical', itemWidth: 8, itemHeight: 8, textStyle: { color: '#6b7280', fontSize: 11 } },
|
||||
series: [{
|
||||
type: 'pie', radius: ['46%', '70%'], center: ['34%', '50%'],
|
||||
itemStyle: { borderColor: '#fff', borderWidth: 2 },
|
||||
label: { show: false },
|
||||
data: D.pos.map((p, i) => ({ name: p.name, value: p.value, itemStyle: { color: ['#2563eb', '#3b82f6', '#60a5fa', '#93c5fd', '#a5b4fc', '#c7d2fe', '#818cf8', '#6366f1', '#4f46e5', '#cbd5e1'][i] } }))
|
||||
}]
|
||||
});
|
||||
|
||||
charts = [exam, pos];
|
||||
window.addEventListener('resize', resize);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', resize);
|
||||
charts.forEach((c) => c.dispose());
|
||||
charts = [];
|
||||
});
|
||||
|
||||
return { D, fmt, short, tone, PH, examEl, posEl, go };
|
||||
|
||||
function go(page) {
|
||||
window.protoNavigate(page);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="a-root">
|
||||
<div class="a-shell">
|
||||
<aside class="a-sidebar">
|
||||
<div class="a-brand">
|
||||
<div class="a-brand-mark">W</div>
|
||||
<div><div class="a-brand-name">Word Market</div><div class="a-brand-sub">词库管理后台</div></div>
|
||||
</div>
|
||||
<nav class="a-nav">
|
||||
<div class="a-nav-item active" @click="go('overview')"><span class="dot"></span>概览</div>
|
||||
<div class="a-nav-item" @click="go('books')"><span class="dot"></span>词书管理</div>
|
||||
<div class="a-nav-item" @click="go('entries')"><span class="dot"></span>词条词典</div>
|
||||
<div class="a-nav-item" @click="go('morphology')"><span class="dot"></span>词根词族</div>
|
||||
<div class="a-nav-item" @click="go('synonyms')"><span class="dot"></span>近反义词</div>
|
||||
<div class="a-nav-gap"></div>
|
||||
<div class="a-nav-item" @click="go('quality')"><span class="dot"></span>数据质量</div>
|
||||
</nav>
|
||||
<div class="a-side-foot">只读模式 · 数据快照 2026-11-08</div>
|
||||
</aside>
|
||||
|
||||
<main class="a-main">
|
||||
<div class="a-topbar">
|
||||
<div class="a-crumb">后台 / <b>概览</b></div>
|
||||
<div class="a-top-actions">
|
||||
<div class="a-search">搜索词书、词条…</div>
|
||||
<div class="a-avatar">AD</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-heading">
|
||||
<div>
|
||||
<h1>数据概览</h1>
|
||||
<p>四个业务域的整体规模、分布与健康度</p>
|
||||
</div>
|
||||
<div class="a-panel-sub">共 36 张表 · 约 364 万行</div>
|
||||
</div>
|
||||
|
||||
<div class="a-kpis">
|
||||
<div class="a-kpi" v-for="k in D.kpis" :key="k.key" :style="{ '--tone': tone[k.tone] }">
|
||||
<div class="a-kpi-label">{{ k.label }}</div>
|
||||
<div class="a-kpi-value">{{ fmt(k.value) }}</div>
|
||||
<div class="a-kpi-note">{{ k.note }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-grid">
|
||||
<section class="a-panel">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">考试维度 · 关联词条量</div>
|
||||
<div class="a-panel-sub">按 book.exam_id 汇总</div>
|
||||
</div>
|
||||
<div class="a-chart" ref="examEl"></div>
|
||||
</section>
|
||||
<section class="a-panel">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">词性分布</div>
|
||||
<div class="a-panel-sub">word_sense · Top 10</div>
|
||||
</div>
|
||||
<div class="a-chart" ref="posEl"></div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="a-grid-2" style="grid-template-columns: 1.45fr 1fr;">
|
||||
<section class="a-panel">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">词书规模排行</div>
|
||||
<div class="a-panel-sub">实际词条数 Top 10</div>
|
||||
</div>
|
||||
<table class="a-ranking">
|
||||
<thead><tr><th style="width:44%">词书</th><th>考试</th><th style="text-align:right">实际</th><th style="text-align:right">声明</th><th style="text-align:right">差异</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="b in D.topBooks" :key="b.id">
|
||||
<td>
|
||||
<div class="a-book">
|
||||
<img class="a-cover" :src="b.cover" @error="e => e.target.src = PH" alt="" />
|
||||
<div>
|
||||
<div style="font-weight:500;max-width:250px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{ b.name }}</div>
|
||||
<div style="font-size:11px;color:#9ca3af;">{{ b.code }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="color:#6b7280;font-size:12px;">{{ b.exam }}</td>
|
||||
<td class="a-mono" style="text-align:right;">{{ fmt(b.actual) }}</td>
|
||||
<td class="a-mono" style="text-align:right;color:#9ca3af;">{{ fmt(b.declared) }}</td>
|
||||
<td :style="{ textAlign: 'right', color: b.actual === b.declared ? '#16a34a' : '#d97706', fontSize: '12px' }">{{ b.actual === b.declared ? '一致' : (b.actual - b.declared) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<div style="display:flex;flex-direction:column;gap:16px;">
|
||||
<section class="a-panel">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">质量红绿灯</div>
|
||||
<div class="a-panel-sub">点击进入数据质量</div>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;">
|
||||
<div v-for="q in D.quality" :key="q.key" style="display:grid;grid-template-columns:10px 1fr auto;gap:10px;align-items:center;padding:7px 0;border-bottom:1px dashed #f1f3f6;">
|
||||
<span class="a-led" :class="q.level"></span>
|
||||
<span style="font-size:12.5px;color:#4b5563;">{{ q.label }}</span>
|
||||
<span style="font-size:13px;font-weight:600;color:#111827;">{{ fmt(q.value) }}<span style="font-size:10px;color:#9ca3af;font-weight:400;"> {{ q.unit }}</span></span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="a-panel">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">跨域文本覆盖度</div>
|
||||
<div class="a-panel-sub">与词条索引词交集</div>
|
||||
</div>
|
||||
<div v-for="c in D.coverage" :key="c.name" style="margin-bottom:11px;">
|
||||
<div style="display:flex;justify-content:space-between;font-size:12px;color:#6b7280;margin-bottom:4px;">
|
||||
<span>{{ c.name }}</span><b style="color:#374151;">{{ c.pct }}% · {{ fmt(c.hit) }}/{{ fmt(c.total) }}</b>
|
||||
</div>
|
||||
<div style="height:5px;background:#eef0f3;border-radius:3px;overflow:hidden;">
|
||||
<div :style="{ width: c.pct + '%', height: '100%', background: 'linear-gradient(90deg,#2563eb,#7c3aed)' }"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,121 @@
|
||||
// PROTOTYPE ONLY — Variant B: dark operations console (full-width bands, dense data, no cards).
|
||||
(function () {
|
||||
const D = window.DASHBOARD_DATA;
|
||||
const fmt = (n) => n.toLocaleString('en-US');
|
||||
const short = (n) => n >= 10000 ? (n / 1000).toFixed(1) + 'k' : String(n);
|
||||
const maxEntries = Math.max(...D.exams.map((e) => e.entries));
|
||||
const maxPos = Math.max(...D.pos.map((p) => p.value));
|
||||
|
||||
window.VariantB = {
|
||||
name: 'VariantB — 指挥中心',
|
||||
setup() {
|
||||
return { D, fmt, short, maxEntries, maxPos };
|
||||
},
|
||||
template: `
|
||||
<div class="b-root">
|
||||
<div class="b-grid-bg"></div>
|
||||
<div class="b-shell">
|
||||
<header class="b-top">
|
||||
<div class="b-brand">WORD · MARKET</div>
|
||||
<nav class="b-nav">
|
||||
<span class="active">OVERVIEW</span><span>BOOKS</span><span>ENTRIES</span><span>MORPHOLOGY</span><span>SYNONYMS</span><span>QUALITY</span>
|
||||
</nav>
|
||||
<div class="b-top-right">
|
||||
<span class="b-live">SYNCED</span>
|
||||
<span>SNAPSHOT 2026-11-08</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="b-title-row">
|
||||
<h1>词库运行概览</h1>
|
||||
<div class="sub">36 TABLES / 3.64M ROWS / READ-ONLY</div>
|
||||
</div>
|
||||
|
||||
<div class="b-kpi-band">
|
||||
<div class="b-kpi" v-for="k in D.kpis" :key="k.key">
|
||||
<div class="b-kpi-label">{{ k.label }}</div>
|
||||
<div class="b-kpi-value">{{ fmt(k.value) }}</div>
|
||||
<div class="b-kpi-note">{{ k.note }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-body">
|
||||
<div>
|
||||
<div class="b-section-title">考试维度 / 关联词条量</div>
|
||||
<div class="b-bars">
|
||||
<div class="b-bar-row" :class="{ unclassified: e.code === '—' }" v-for="e in D.exams" :key="e.name">
|
||||
<div class="b-bar-name">{{ e.name }}</div>
|
||||
<div class="b-bar-track"><div class="b-bar-fill" :style="{ width: (e.entries / maxEntries * 100) + '%' }"></div></div>
|
||||
<div class="b-bar-value"><b>{{ short(e.entries) }}</b> / {{ e.books }}本</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-section-title" style="margin-top:30px;">词书规模 / TOP 10</div>
|
||||
<div class="b-rank">
|
||||
<div class="b-rank-row" v-for="(b, i) in D.topBooks" :key="b.id">
|
||||
<div class="b-rank-no">{{ String(i + 1).padStart(2, '0') }}</div>
|
||||
<div class="b-rank-name">{{ b.name }}</div>
|
||||
<div class="b-rank-actual">{{ fmt(b.actual) }}</div>
|
||||
<div class="b-rank-diff">{{ b.actual === b.declared ? 'MATCH' : 'Δ ' + (b.actual - b.declared) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-section-title" style="margin-top:30px;">词性分布 / WORD SENSE</div>
|
||||
<div style="display:flex;align-items:flex-end;gap:14px;height:150px;padding:6px 4px 0;border-bottom:1px solid rgba(148,163,184,.2);">
|
||||
<div v-for="p in D.pos" :key="p.name" style="flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;gap:6px;">
|
||||
<div style="font-size:10px;color:#94a3b8;font-variant-numeric:tabular-nums;">{{ short(p.value) }}</div>
|
||||
<div :style="{ width: '100%', height: Math.max(3, p.value / maxPos * 105) + 'px', background: 'linear-gradient(180deg,#38bdf8,#0ea5e9)', opacity: .85 }"></div>
|
||||
<div style="font-size:10.5px;color:#64748b;white-space:nowrap;">{{ p.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-side">
|
||||
<section>
|
||||
<div class="b-section-title">质量状态 / DATA HEALTH</div>
|
||||
<div class="b-quality">
|
||||
<div class="b-q-row" v-for="q in D.quality" :key="q.key">
|
||||
<span class="b-q-led" :class="q.level"></span>
|
||||
<span class="b-q-label">{{ q.label }}</span>
|
||||
<span class="b-q-value">{{ fmt(q.value) }}<span style="font-size:10px;color:#64748b;font-weight:400;"> {{ q.unit }}</span></span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<div class="b-section-title">跨域覆盖 / WEAK LINK</div>
|
||||
<div class="b-coverage">
|
||||
<div class="b-cov-row" v-for="c in D.coverage" :key="c.name">
|
||||
<div class="b-cov-top"><span>{{ c.name }}</span><b>{{ c.pct }}% · {{ fmt(c.hit) }}/{{ fmt(c.total) }}</b></div>
|
||||
<div class="b-cov-track"><div class="b-cov-fill" :style="{ width: c.pct + '%' }"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<div class="b-section-title">数据快照 / SNAPSHOT</div>
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:14px;">
|
||||
<div style="border-left:2px solid #38bdf8;padding-left:12px;">
|
||||
<div style="font-size:10px;color:#64748b;letter-spacing:.12em;">EXAM VIEWS</div>
|
||||
<div style="font-size:24px;color:#f8fafc;margin-top:4px;">16</div>
|
||||
</div>
|
||||
<div style="border-left:2px solid #818cf8;padding-left:12px;">
|
||||
<div style="font-size:10px;color:#64748b;letter-spacing:.12em;">TOP FAMILIES</div>
|
||||
<div style="font-size:24px;color:#f8fafc;margin-top:4px;">5,629</div>
|
||||
</div>
|
||||
<div style="border-left:2px solid #22d3ee;padding-left:12px;">
|
||||
<div style="font-size:10px;color:#64748b;letter-spacing:.12em;">SENTENCES</div>
|
||||
<div style="font-size:24px;color:#f8fafc;margin-top:4px;">235,744</div>
|
||||
</div>
|
||||
<div style="border-left:2px solid #f472b6;padding-left:12px;">
|
||||
<div style="font-size:10px;color:#64748b;letter-spacing:.12em;">CONFUSABLES</div>
|
||||
<div style="font-size:24px;color:#f8fafc;margin-top:4px;">158,870</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,169 @@
|
||||
// PROTOTYPE ONLY — Variant C: editorial paper layout (numbered rail, prose, lists instead of cards).
|
||||
(function () {
|
||||
const { ref, onMounted, onBeforeUnmount, nextTick } = Vue;
|
||||
const D = window.DASHBOARD_DATA;
|
||||
const PH = 'data:image/svg+xml;utf8,' + encodeURIComponent(
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="60" height="80"><rect width="60" height="80" fill="#e6dece"/><text x="30" y="44" font-size="9" fill="#9a917f" text-anchor="middle">N/A</text></svg>'
|
||||
);
|
||||
const fmt = (n) => n.toLocaleString('en-US');
|
||||
const maxPos = Math.max(...D.pos.map((p) => p.value));
|
||||
const maxEntries = Math.max(...D.exams.map((e) => e.entries));
|
||||
|
||||
window.VariantC = {
|
||||
name: 'VariantC — 编辑部',
|
||||
setup() {
|
||||
const examEl = ref(null);
|
||||
let chart = null;
|
||||
const resize = () => chart && chart.resize();
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
chart = echarts.init(examEl.value);
|
||||
const rows = D.exams;
|
||||
chart.setOption({
|
||||
grid: { left: 6, right: 46, top: 8, bottom: 4, containLabel: true },
|
||||
tooltip: {
|
||||
trigger: 'axis', axisPointer: { type: 'shadow' },
|
||||
backgroundColor: '#26221c', borderWidth: 0,
|
||||
textStyle: { color: '#f7f3ea', fontSize: 12 },
|
||||
formatter: (p) => {
|
||||
const r = rows[rows.length - 1 - p[0].dataIndex];
|
||||
return `${r.name} 关联 ${fmt(r.entries)} 词书 ${r.books} 本`;
|
||||
}
|
||||
},
|
||||
xAxis: { type: 'value', splitLine: { show: false }, axisLabel: { show: false }, axisLine: { show: false }, axisTick: { show: false } },
|
||||
yAxis: { type: 'category', data: rows.map((r) => r.name).reverse(), axisLine: { show: false }, axisTick: { show: false }, axisLabel: { color: '#4a443a', fontSize: 11.5, fontFamily: 'Segoe UI' } },
|
||||
series: [{
|
||||
type: 'bar', barWidth: 9,
|
||||
data: rows.map((r) => ({ value: r.entries, itemStyle: { color: r.code === '—' ? '#b9ae9a' : '#26221c' } })).reverse(),
|
||||
label: { show: true, position: 'right', color: '#6e6556', fontSize: 10.5, fontFamily: 'Segoe UI', formatter: (p) => fmt(p.value) }
|
||||
}]
|
||||
});
|
||||
window.addEventListener('resize', resize);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', resize);
|
||||
if (chart) chart.dispose();
|
||||
chart = null;
|
||||
});
|
||||
|
||||
return { D, fmt, PH, examEl, maxPos, maxEntries };
|
||||
},
|
||||
template: `
|
||||
<div class="c-root">
|
||||
<div class="c-shell">
|
||||
<aside class="c-rail">
|
||||
<div class="c-rail-num active">01</div>
|
||||
<div class="c-rail-num">02</div>
|
||||
<div class="c-rail-num">03</div>
|
||||
<div class="c-rail-num">04</div>
|
||||
</aside>
|
||||
|
||||
<main class="c-main">
|
||||
<header class="c-masthead">
|
||||
<div>
|
||||
<div class="kicker">Word Market · Data Report</div>
|
||||
<h1>词库概览</h1>
|
||||
</div>
|
||||
<div class="date">2026 年 11 月 8 日<br/>只读快照 · 36 张表</div>
|
||||
</header>
|
||||
|
||||
<p class="c-lede">
|
||||
当前词库收录 <b>1,025 本词书</b>、<b>38,116 个词条</b>,词书与词条之间形成
|
||||
<b>1,228,421 条</b>关联;配套沉淀了 235,744 条例句、22,717 个词族与 6,279 个近义词头。
|
||||
四个业务域之间以单词文本弱关联,覆盖度存在差异,阅读时应把“未归类”与弱关联一并考虑。
|
||||
</p>
|
||||
|
||||
<section class="c-section" style="border-top:0;padding-top:0;">
|
||||
<div class="c-section-head">
|
||||
<h2><span>01</span>规模</h2>
|
||||
<div class="aside">SNAPSHOT · 2026-11-08</div>
|
||||
</div>
|
||||
<div class="c-stats">
|
||||
<div class="c-stat" v-for="k in D.kpis" :key="k.key">
|
||||
<div class="n">{{ fmt(k.value) }}</div>
|
||||
<div class="l">{{ k.label }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="c-section">
|
||||
<div class="c-section-head">
|
||||
<h2><span>02</span>分布</h2>
|
||||
<div class="aside">按考试关联词条量 / 词性义项数</div>
|
||||
</div>
|
||||
<div class="c-cols">
|
||||
<div>
|
||||
<div class="c-chart" ref="examEl"></div>
|
||||
</div>
|
||||
<div>
|
||||
<div v-for="p in D.pos" :key="p.name" style="display:grid;grid-template-columns:62px 1fr 58px;gap:10px;align-items:center;padding:5px 0;font-family:'Segoe UI',sans-serif;font-size:12px;">
|
||||
<span style="color:#5d5547;">{{ p.name }}</span>
|
||||
<span style="display:inline-block;height:3px;background:#e2dacb;position:relative;"><span :style="{ position: 'absolute', inset: '0 auto 0 0', width: (p.value / maxPos * 100) + '%', background: '#26221c' }"></span></span>
|
||||
<span style="text-align:right;color:#6e6556;font-variant-numeric:tabular-nums;">{{ fmt(p.value) }}</span>
|
||||
</div>
|
||||
<div style="font-family:'Segoe UI',sans-serif;font-size:11px;color:#9a917f;margin-top:12px;line-height:1.7;">
|
||||
名词义项占绝对多数;短语类(phr.)义项 6,922 条,提示词条中存在大量短语条目。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="c-section">
|
||||
<div class="c-section-head">
|
||||
<h2><span>03</span>词书排行</h2>
|
||||
<div class="aside">实际词条数 TOP 10</div>
|
||||
</div>
|
||||
<div class="c-cols" style="grid-template-columns:1fr 1fr;gap:48px;">
|
||||
<ol class="c-list">
|
||||
<li v-for="b in D.topBooks.slice(0, 5)" :key="b.id">
|
||||
<img class="thumb" :src="b.cover" @error="e => e.target.src = PH" alt="" />
|
||||
<span class="title">{{ b.name }}</span>
|
||||
<span class="num">{{ fmt(b.actual) }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
<ol class="c-list" style="counter-reset:item 5;">
|
||||
<li v-for="b in D.topBooks.slice(5)" :key="b.id">
|
||||
<img class="thumb" :src="b.cover" @error="e => e.target.src = PH" alt="" />
|
||||
<span class="title">{{ b.name }}</span>
|
||||
<span class="num">{{ fmt(b.actual) }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="c-section">
|
||||
<div class="c-section-head">
|
||||
<h2><span>04</span>质量注脚</h2>
|
||||
<div class="aside">异常项与弱关联覆盖度</div>
|
||||
</div>
|
||||
<div class="c-cols">
|
||||
<div class="c-quality-cols">
|
||||
<div class="c-q" v-for="q in D.quality" :key="q.key">
|
||||
<span class="k">{{ q.label }}</span>
|
||||
<span class="v" :class="q.level">{{ fmt(q.value) }} {{ q.unit }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-family:'Segoe UI',sans-serif;font-size:11px;letter-spacing:.12em;color:#9a917f;margin-bottom:12px;">CROSS-DOMAIN COVERAGE</div>
|
||||
<div class="c-cov">
|
||||
<div class="c-cov-row" v-for="c in D.coverage" :key="c.name">
|
||||
<span>{{ c.name }}</span>
|
||||
<span class="c-cov-track"><span class="c-cov-fill" :style="{ width: c.pct + '%' }"></span></span>
|
||||
<span class="c-cov-val">{{ c.pct }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="c-footnote">
|
||||
口径说明:考试维度按 book.exam_id 汇总,未设置考试的词书单列为“未归类”;跨域覆盖度以词条索引词(index_word)为基准,属于文本弱关联,不作为外键约束。<br/>
|
||||
数据来源:MySQL word_market · 只读快照。
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,153 @@
|
||||
// PROTOTYPE ONLY — 词书列表与详情。
|
||||
(function () {
|
||||
const D = window.MODULE_DATA;
|
||||
const PH = 'data:image/svg+xml;utf8,' + encodeURIComponent(
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="60" height="80"><rect width="60" height="80" fill="#e5e7eb"/><text x="30" y="44" font-size="10" fill="#9ca3af" text-anchor="middle">N/A</text></svg>'
|
||||
);
|
||||
const fmt = (n) => n.toLocaleString('en-US');
|
||||
|
||||
window.ViewBooks = {
|
||||
name: 'ViewBooks',
|
||||
props: { id: String, kw: String },
|
||||
setup(props) {
|
||||
const { ref, computed } = Vue;
|
||||
const keyword = ref(props.kw || '');
|
||||
const exam = ref('全部');
|
||||
const file = ref('全部');
|
||||
|
||||
const exams = computed(() => ['全部', ...new Set(D.books.map((b) => b.exam))]);
|
||||
const filtered = computed(() => D.books.filter((b) => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
const matchKw = !kw || b.name.toLowerCase().includes(kw) || b.code.toLowerCase().includes(kw);
|
||||
const matchExam = exam.value === '全部' || b.exam === exam.value;
|
||||
const matchFile = file.value === '全部'
|
||||
|| (file.value === '有文件' && b.hasFile)
|
||||
|| (file.value === '无文件' && !b.hasFile);
|
||||
return matchKw && matchExam && matchFile;
|
||||
}));
|
||||
const selected = computed(() => D.books.find((b) => String(b.id) === props.id) || null);
|
||||
|
||||
function openBook(id) { window.protoNavigate('books', id); }
|
||||
function openEntry() { window.protoNavigate('entries', 26132); }
|
||||
function back() { window.protoNavigate('books'); }
|
||||
function cover(path) { return path ? 'https://static.beingfine.cn' + path : PH; }
|
||||
|
||||
return { D, PH, fmt, keyword, exam, file, exams, filtered, selected, openBook, openEntry, back, cover };
|
||||
},
|
||||
template: `
|
||||
<module-shell active="books" :title="selected ? '词书详情' : '词书管理'">
|
||||
<template v-if="!selected">
|
||||
<div class="m-page-head">
|
||||
<div>
|
||||
<h1>词书管理</h1>
|
||||
<p>浏览词书目录、考试归属与词条规模,只读</p>
|
||||
</div>
|
||||
<div class="m-page-meta">1,025 本词书 · 1,228,421 条关联</div>
|
||||
</div>
|
||||
|
||||
<div class="m-toolbar">
|
||||
<div class="m-field m-field-grow">
|
||||
<label>关键词</label>
|
||||
<input v-model="keyword" placeholder="搜索词书名称或编码" />
|
||||
</div>
|
||||
<div class="m-field">
|
||||
<label>考试</label>
|
||||
<select v-model="exam">
|
||||
<option v-for="e in exams" :key="e">{{ e }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="m-field">
|
||||
<label>清单文件</label>
|
||||
<select v-model="file">
|
||||
<option>全部</option><option>有文件</option><option>无文件</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="m-toolbar-note">仅展示 10 本样本</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel">
|
||||
<table class="m-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:38%">词书</th>
|
||||
<th>考试</th>
|
||||
<th class="m-num">声明词条</th>
|
||||
<th class="m-num">实际词条</th>
|
||||
<th class="m-num">差异</th>
|
||||
<th>清单文件</th>
|
||||
<th class="m-num">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="b in filtered" :key="b.id">
|
||||
<td>
|
||||
<div class="m-book-cell">
|
||||
<img class="m-cover" :src="cover(b.coverPath)" @error="e => e.target.src = PH" alt="" />
|
||||
<div style="min-width:0">
|
||||
<div class="m-cell-title">{{ b.name }}</div>
|
||||
<div class="m-cell-sub">{{ b.code }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><span class="m-tag">{{ b.exam }}</span></td>
|
||||
<td class="m-num">{{ fmt(b.declared) }}</td>
|
||||
<td class="m-num">{{ fmt(b.actual) }}</td>
|
||||
<td class="m-num" :class="b.actual === b.declared ? 'm-ok' : 'm-warn-text'">
|
||||
{{ b.actual === b.declared ? '一致' : (b.actual - b.declared) }}
|
||||
</td>
|
||||
<td><span class="m-dot" :class="b.hasFile ? 'ok' : 'bad'"></span>{{ b.hasFile ? '有' : '无' }}</td>
|
||||
<td class="m-num"><a class="m-link" @click="openBook(b.id)">查看</a></td>
|
||||
</tr>
|
||||
<tr v-if="!filtered.length">
|
||||
<td colspan="7"><div class="m-empty">没有匹配的词书</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="m-back" @click="back">← 返回词书列表</div>
|
||||
|
||||
<div class="a-panel m-detail-head">
|
||||
<img class="m-cover-lg" :src="cover(selected.coverPath)" @error="e => e.target.src = PH" alt="" />
|
||||
<div class="m-detail-main">
|
||||
<div class="m-detail-kicker">{{ selected.code }}</div>
|
||||
<h1 class="m-detail-title">{{ selected.name }}</h1>
|
||||
<div class="m-detail-meta">
|
||||
<span class="m-tag">{{ selected.exam }}</span>
|
||||
<span class="m-tag">{{ selected.hasFile ? '清单文件存在' : '清单文件缺失' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-stat-row">
|
||||
<div class="m-stat"><b>{{ fmt(selected.actual) }}</b><span>实际词条</span></div>
|
||||
<div class="m-stat"><b>{{ fmt(selected.declared) }}</b><span>声明词条</span></div>
|
||||
<div class="m-stat"><b :class="selected.actual === selected.declared ? 'm-ok' : 'm-warn-text'">{{ selected.actual === selected.declared ? '一致' : (selected.actual - selected.declared) }}</b><span>差异</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel" style="margin-top:16px">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">词条清单</div>
|
||||
<div class="a-panel-sub">按 seq_book 排序 · 原型样本</div>
|
||||
</div>
|
||||
<table class="m-table">
|
||||
<thead>
|
||||
<tr><th style="width:64px">顺序</th><th>展示词</th><th>音标</th><th style="width:44%">释义</th><th class="m-num">操作</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="e in D.bookEntries" :key="e.seq + e.displayWord">
|
||||
<td class="m-num">{{ e.seq }}</td>
|
||||
<td><span class="m-word">{{ e.displayWord }}</span></td>
|
||||
<td class="m-phonetic">{{ e.pronunciation }}</td>
|
||||
<td class="m-def">{{ e.definition }}</td>
|
||||
<td class="m-num"><a class="m-link" @click="openEntry">查看词条</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-if="selected.id !== 15" class="m-note">该词书的词条清单在原型中统一使用 SAT10000 的样本数据。</div>
|
||||
</div>
|
||||
</template>
|
||||
</module-shell>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,195 @@
|
||||
// PROTOTYPE ONLY — 词条列表;详情以右侧抽屉展示。
|
||||
(function () {
|
||||
const D = window.MODULE_DATA;
|
||||
const fmt = (n) => n.toLocaleString('en-US');
|
||||
|
||||
window.ViewEntries = {
|
||||
name: 'ViewEntries',
|
||||
props: { id: String, kw: String },
|
||||
setup(props) {
|
||||
const { ref, computed, watch } = Vue;
|
||||
const keyword = ref('');
|
||||
const tab = ref('senses');
|
||||
const drawerOpen = ref(!!props.id);
|
||||
|
||||
const filtered = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (!kw) return D.entries;
|
||||
return D.entries.filter((e) => e.headword.toLowerCase().includes(kw) || e.definition.toLowerCase().includes(kw));
|
||||
});
|
||||
const selected = computed(() => D.entries.find((e) => String(e.id) === props.id) || null);
|
||||
const rich = computed(() => !!selected.value && String(selected.value.id) === String(D.entryDetail.id));
|
||||
|
||||
watch(() => props.id, () => {
|
||||
drawerOpen.value = !!selected.value;
|
||||
tab.value = 'senses';
|
||||
});
|
||||
|
||||
function openEntry(id) { window.protoNavigate('entries', id); }
|
||||
function closeDrawer() { drawerOpen.value = false; }
|
||||
function handleDrawerClose() {
|
||||
const page = new URLSearchParams(location.search).get('page');
|
||||
if (props.id && page === 'entries') window.protoNavigate('entries');
|
||||
}
|
||||
function setTab(name) { tab.value = name; }
|
||||
|
||||
return {
|
||||
D, fmt, keyword, tab, drawerOpen, filtered, selected, rich,
|
||||
openEntry, closeDrawer, handleDrawerClose, setTab
|
||||
};
|
||||
},
|
||||
template: `
|
||||
<module-shell active="entries" title="词条词典">
|
||||
<div class="m-page-head">
|
||||
<div>
|
||||
<h1>词条词典</h1>
|
||||
<p>搜索词条,点击行内“查看”在右侧抽屉中展开详情</p>
|
||||
</div>
|
||||
<div class="m-page-meta">38,116 个词条 · 5,250 条无结构化义项</div>
|
||||
</div>
|
||||
|
||||
<div class="m-toolbar">
|
||||
<div class="m-field m-field-grow">
|
||||
<label>搜索</label>
|
||||
<input v-model="keyword" placeholder="输入单词或释义关键词" />
|
||||
</div>
|
||||
<div class="m-toolbar-note">仅展示 10 条样本 · cinema 含完整详情</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel">
|
||||
<table class="m-table">
|
||||
<thead>
|
||||
<tr><th style="width:22%">词条</th><th>释义</th><th class="m-num">义项</th><th class="m-num">收录词书</th><th class="m-num">操作</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="e in filtered" :key="e.id" style="cursor:pointer" @click="openEntry(e.id)">
|
||||
<td>
|
||||
<div class="m-word">{{ e.headword }}</div>
|
||||
<div class="m-phonetic">{{ e.pronunciation || '—' }}</div>
|
||||
</td>
|
||||
<td class="m-def">{{ e.definition }}</td>
|
||||
<td class="m-num">{{ e.senses }}</td>
|
||||
<td class="m-num">{{ e.occurrence }}</td>
|
||||
<td class="m-num"><a class="m-link" @click.stop="openEntry(e.id)">查看</a></td>
|
||||
</tr>
|
||||
<tr v-if="!filtered.length"><td colspan="5"><div class="m-empty">没有匹配的词条</div></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<el-drawer
|
||||
v-model="drawerOpen"
|
||||
:with-header="false"
|
||||
:modal="false"
|
||||
:lock-scroll="false"
|
||||
append-to-body
|
||||
size="760px"
|
||||
direction="rtl"
|
||||
class="entry-drawer"
|
||||
@close="handleDrawerClose"
|
||||
>
|
||||
<div v-if="selected" class="drawer-body">
|
||||
<div class="drawer-head">
|
||||
<div class="m-detail-main">
|
||||
<div class="m-detail-kicker">{{ selected.indexWord }}</div>
|
||||
<h2 class="drawer-title">{{ selected.headword }}</h2>
|
||||
<div class="m-detail-meta">
|
||||
<span class="m-tag">{{ selected.pronunciation || '无音标' }}</span>
|
||||
<span class="m-def" style="font-size:13px">{{ selected.definition }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-stat-row">
|
||||
<div class="m-stat"><b>{{ fmt(selected.occurrence) }}</b><span>收录词书</span></div>
|
||||
<div class="m-stat"><b>{{ selected.senses }}</b><span>结构化义项</span></div>
|
||||
<div class="m-stat"><b>{{ rich ? 6 : 0 }}</b><span>例句(样本)</span></div>
|
||||
</div>
|
||||
<button class="drawer-close" aria-label="关闭" @click="closeDrawer">×</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!rich" class="m-note drawer-note">
|
||||
原型仅展开 cinema(entry_id=26132)的完整子资源;当前词条展示基本信息与空状态。
|
||||
</div>
|
||||
|
||||
<div class="m-tabs drawer-tabs">
|
||||
<div class="m-tab" :class="{ active: tab === 'senses' }" @click="setTab('senses')">义项</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'phrases' }" @click="setTab('phrases')">短语</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'examples' }" @click="setTab('examples')">例句</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'confusables' }" @click="setTab('confusables')">易混词</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'books' }" @click="setTab('books')">收录词书</div>
|
||||
</div>
|
||||
|
||||
<div class="drawer-tab-panel">
|
||||
<template v-if="tab === 'senses'">
|
||||
<table v-if="rich" class="m-table">
|
||||
<thead><tr><th style="width:56px">#</th><th style="width:80px">词性</th><th>释义</th><th>关联考试</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="s in D.entryDetail.senses" :key="s.no">
|
||||
<td class="m-num">{{ s.no }}</td>
|
||||
<td><span class="m-tag">{{ s.pos }}</span></td>
|
||||
<td class="m-def">{{ s.gloss }}</td>
|
||||
<td class="m-cell-sub">{{ s.exams }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-else class="m-empty">该词条在原型中未展开结构化义项</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="tab === 'phrases'">
|
||||
<table v-if="rich" class="m-table">
|
||||
<thead><tr><th style="width:38%">短语</th><th>中文</th><th class="m-num">分组</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="p in D.entryDetail.phrases" :key="p.en">
|
||||
<td class="m-word">{{ p.en }}</td>
|
||||
<td class="m-def">{{ p.zh }}</td>
|
||||
<td class="m-num">{{ p.type }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-else class="m-empty">该词条在原型中未展开短语</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="tab === 'examples'">
|
||||
<div v-if="rich" class="m-example-list">
|
||||
<div v-for="(ex, i) in D.entryDetail.examples" :key="i" class="m-example">
|
||||
<div class="m-example-no">{{ String(i + 1).padStart(2, '0') }}</div>
|
||||
<div>
|
||||
<div class="m-example-en">{{ ex.en }}</div>
|
||||
<div class="m-example-zh">{{ ex.zh }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="m-empty">该词条在原型中未展开例句</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="tab === 'confusables'">
|
||||
<table v-if="rich" class="m-table">
|
||||
<thead><tr><th style="width:30%">易混词</th><th>释义</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="c in D.entryDetail.confusables" :key="c.word">
|
||||
<td class="m-word">{{ c.word }}</td>
|
||||
<td class="m-def">{{ c.gloss }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-else class="m-empty">该词条在原型中未展开易混词</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<table v-if="rich" class="m-table">
|
||||
<thead><tr><th style="width:46%">词书</th><th>展示词</th><th class="m-num">词书内顺序</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="b in D.entryDetail.books" :key="b.name">
|
||||
<td class="m-cell-title">{{ b.name }}</td>
|
||||
<td class="m-def">{{ b.display }}</td>
|
||||
<td class="m-num">{{ b.seq }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-else class="m-empty">该词条在原型中未展开收录词书</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</module-shell>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,154 @@
|
||||
// PROTOTYPE ONLY — 词根词缀与词族,含树形族谱。
|
||||
(function () {
|
||||
const D = window.MODULE_DATA;
|
||||
|
||||
window.ViewMorphology = {
|
||||
name: 'ViewMorphology',
|
||||
props: { id: String, kw: String },
|
||||
setup() {
|
||||
const { ref, computed } = Vue;
|
||||
const tab = ref('morphemes');
|
||||
const morphemeType = ref('all');
|
||||
const selectedFamily = ref(D.families.find((f) => f.word === 'behave') || D.families[0]);
|
||||
|
||||
const typeLabel = (t) => ({ prefix: '前缀', root: '词根', suffix: '后缀' }[t] || t);
|
||||
const filteredMorphemes = computed(() => (
|
||||
morphemeType.value === 'all'
|
||||
? D.morphemes
|
||||
: D.morphemes.filter((m) => m.type === morphemeType.value)
|
||||
));
|
||||
|
||||
const treeData = computed(() => [{
|
||||
label: `${D.familyTree.word} · ${D.familyTree.interpretation}`,
|
||||
type: 'root',
|
||||
children: [
|
||||
{
|
||||
label: `变体 · ${D.familyTree.variants.length}`,
|
||||
type: 'branch',
|
||||
children: D.familyTree.variants.map((word) => ({ label: word, type: 'variant' }))
|
||||
},
|
||||
{
|
||||
label: `小组 · ${D.familyTree.groups.length}`,
|
||||
type: 'branch',
|
||||
children: D.familyTree.groups.map((group) => ({
|
||||
label: group.join(' / '),
|
||||
type: 'group',
|
||||
children: group.map((word) => ({ label: word, type: 'member' }))
|
||||
}))
|
||||
}
|
||||
]
|
||||
}]);
|
||||
const treeProps = { children: 'children', label: 'label' };
|
||||
|
||||
function setTab(name) { tab.value = name; }
|
||||
function setType(type) { morphemeType.value = type; }
|
||||
function selectFamily(family) { selectedFamily.value = family; }
|
||||
function openTree(family) {
|
||||
selectedFamily.value = family;
|
||||
tab.value = 'tree';
|
||||
}
|
||||
|
||||
return {
|
||||
D, tab, morphemeType, selectedFamily, typeLabel, filteredMorphemes,
|
||||
treeData, treeProps, setTab, setType, selectFamily, openTree
|
||||
};
|
||||
},
|
||||
template: `
|
||||
<module-shell active="morphology" title="词根词族">
|
||||
<div class="m-page-head">
|
||||
<div>
|
||||
<h1>词根词族</h1>
|
||||
<p>词素、单词卡片与词族层级关系,支持树形族谱</p>
|
||||
</div>
|
||||
<div class="m-page-meta">2,235 个词素 · 12,003 张卡片 · 22,717 个词族</div>
|
||||
</div>
|
||||
|
||||
<div class="m-tabs" style="margin-top:0">
|
||||
<div class="m-tab" :class="{ active: tab === 'morphemes' }" @click="setTab('morphemes')">词素</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'cards' }" @click="setTab('cards')">单词卡片</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'families' }" @click="setTab('families')">词族</div>
|
||||
<div class="m-tab" :class="{ active: tab === 'tree' }" @click="setTab('tree')">树形族谱</div>
|
||||
</div>
|
||||
|
||||
<div v-if="tab === 'morphemes'" class="a-panel">
|
||||
<div class="m-chip-row">
|
||||
<span class="m-chip" :class="{ active: morphemeType === 'all' }" @click="setType('all')">全部</span>
|
||||
<span class="m-chip" :class="{ active: morphemeType === 'prefix' }" @click="setType('prefix')">前缀</span>
|
||||
<span class="m-chip" :class="{ active: morphemeType === 'root' }" @click="setType('root')">词根</span>
|
||||
<span class="m-chip" :class="{ active: morphemeType === 'suffix' }" @click="setType('suffix')">后缀</span>
|
||||
</div>
|
||||
<table class="m-table">
|
||||
<thead><tr><th style="width:120px">类型</th><th style="width:22%">词形</th><th>英文释义</th><th>中文释义</th><th>备注</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="m in filteredMorphemes" :key="m.id">
|
||||
<td><span class="m-tag" :class="'m-tag-' + m.type">{{ typeLabel(m.type) }}</span></td>
|
||||
<td class="m-word">{{ m.form }}</td>
|
||||
<td class="m-def">{{ m.meaningEn || '—' }}</td>
|
||||
<td class="m-def">{{ m.meaningZh || '—' }}</td>
|
||||
<td class="m-cell-sub">{{ m.note || '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else-if="tab === 'cards'" class="m-card-grid">
|
||||
<div class="m-memo-card" v-for="c in D.cards" :key="c.id">
|
||||
<div class="m-memo-word">{{ c.word }}</div>
|
||||
<div class="m-memo-note">{{ c.memory }}</div>
|
||||
<div v-if="c.example" class="m-memo-example">{{ c.example }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="tab === 'families'" class="a-panel">
|
||||
<table class="m-table">
|
||||
<thead><tr><th style="width:22%">词族</th><th>释义</th><th class="m-num">成员数</th><th class="m-num">操作</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="f in D.families" :key="f.id">
|
||||
<td class="m-word">{{ f.word }}</td>
|
||||
<td class="m-def">{{ f.interpretation }}</td>
|
||||
<td class="m-num">{{ f.members }}</td>
|
||||
<td class="m-num"><a class="m-link" @click="openTree(f)">查看族谱</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else class="m-tree-layout">
|
||||
<div class="a-panel m-family-list">
|
||||
<div class="a-panel-head"><div class="a-panel-title">顶层词族</div><div class="a-panel-sub">5,629 个</div></div>
|
||||
<div
|
||||
v-for="f in D.families"
|
||||
:key="f.id"
|
||||
class="m-family-item"
|
||||
:class="{ active: selectedFamily.id === f.id }"
|
||||
@click="selectFamily(f)"
|
||||
>
|
||||
<div class="m-family-word">{{ f.word }}</div>
|
||||
<div class="m-family-meta">{{ f.members }} 个成员</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel m-tree-panel">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">{{ selectedFamily.word }} · 族谱</div>
|
||||
<div class="a-panel-sub">变体 + 小组 + 成员</div>
|
||||
</div>
|
||||
<template v-if="selectedFamily.word === 'behave'">
|
||||
<el-tree :data="treeData" :props="treeProps" node-key="label" default-expand-all :expand-on-click-node="false">
|
||||
<template #default="{ data }">
|
||||
<span class="m-tree-node" :class="'m-tree-' + data.type">
|
||||
<span>{{ data.label }}</span>
|
||||
<span v-if="data.type !== 'member'" class="m-tree-type">{{ data.type }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
<div class="m-note" style="margin-top:14px">
|
||||
注意:变体使用英式拼写 behaviour,小组内使用美式拼写 behavior,源数据存在拼写不一致。
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="m-empty">该词族的族谱在原型中未展开,仅 behave 提供完整示例。</div>
|
||||
</div>
|
||||
</div>
|
||||
</module-shell>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,124 @@
|
||||
// PROTOTYPE ONLY — 数据质量摘要、差异明细与覆盖度。
|
||||
(function () {
|
||||
const D = window.MODULE_DATA;
|
||||
const fmt = (n) => n.toLocaleString('en-US');
|
||||
|
||||
window.ViewQuality = {
|
||||
name: 'ViewQuality',
|
||||
props: { id: String, kw: String },
|
||||
setup() {
|
||||
const { ref, computed } = Vue;
|
||||
const keyword = ref('');
|
||||
const mismatch = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (!kw) return D.quality.mismatch;
|
||||
return D.quality.mismatch.filter((b) => b.name.toLowerCase().includes(kw) || b.code.toLowerCase().includes(kw));
|
||||
});
|
||||
return { D, fmt, keyword, mismatch };
|
||||
},
|
||||
template: `
|
||||
<module-shell active="quality" title="数据质量">
|
||||
<div class="m-page-head">
|
||||
<div>
|
||||
<h1>数据质量</h1>
|
||||
<p>汇总异常指标,定位声明不符、缺失引用与跨域弱关联</p>
|
||||
</div>
|
||||
<div class="m-page-meta">只读快照 · 2026-11-08</div>
|
||||
</div>
|
||||
|
||||
<div class="m-metric-grid">
|
||||
<div class="m-metric" v-for="q in D.quality.summary" :key="q.label">
|
||||
<div class="m-metric-top">
|
||||
<span class="m-dot" :class="q.level"></span>
|
||||
<span>{{ q.label }}</span>
|
||||
</div>
|
||||
<div class="m-metric-value">{{ fmt(q.value) }}<span>{{ q.unit }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel" style="margin-top:16px">
|
||||
<div class="a-panel-head">
|
||||
<div class="a-panel-title">声明与实际词条数差异</div>
|
||||
<div class="a-panel-sub">{{ D.quality.mismatch.length }} 本词书不一致</div>
|
||||
</div>
|
||||
<div class="m-toolbar m-toolbar-inline">
|
||||
<div class="m-field m-field-grow">
|
||||
<label>筛选</label>
|
||||
<input v-model="keyword" placeholder="搜索词书名称或编码" />
|
||||
</div>
|
||||
</div>
|
||||
<table class="m-table">
|
||||
<thead><tr><th style="width:44%">词书</th><th>编码</th><th class="m-num">声明</th><th class="m-num">实际</th><th class="m-num">差异</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="b in mismatch" :key="b.code">
|
||||
<td class="m-cell-title">{{ b.name }}</td>
|
||||
<td class="m-cell-sub">{{ b.code }}</td>
|
||||
<td class="m-num">{{ fmt(b.declared) }}</td>
|
||||
<td class="m-num">{{ fmt(b.actual) }}</td>
|
||||
<td class="m-num" :class="b.actual > b.declared ? 'm-warn-text' : 'm-bad-text'">
|
||||
{{ b.actual - b.declared > 0 ? '+' : '' }}{{ b.actual - b.declared }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!mismatch.length"><td colspan="5"><div class="m-empty">没有匹配的词书</div></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="m-two-col" style="margin-top:16px">
|
||||
<div class="a-panel">
|
||||
<div class="a-panel-head"><div class="a-panel-title">缺失引用与文件</div><div class="a-panel-sub">需人工核查</div></div>
|
||||
|
||||
<div class="m-issue">
|
||||
<div class="m-issue-head">
|
||||
<span class="m-dot bad"></span>
|
||||
<b>缺失词书清单文件</b>
|
||||
<span class="m-tag">{{ D.quality.missingFile.length }} 本</span>
|
||||
</div>
|
||||
<div class="m-issue-body">
|
||||
<span v-for="b in D.quality.missingFile" :key="b.code">{{ b.name }}({{ b.code }})</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m-issue">
|
||||
<div class="m-issue-head">
|
||||
<span class="m-dot bad"></span>
|
||||
<b>缺失 zpk 引用</b>
|
||||
<span class="m-tag">1 个</span>
|
||||
</div>
|
||||
<div class="m-issue-body">源文件引用的 zpk 在解密目录中缺失,无法定位到具体词条。</div>
|
||||
</div>
|
||||
|
||||
<div class="m-issue">
|
||||
<div class="m-issue-head">
|
||||
<span class="m-dot warn"></span>
|
||||
<b>无义项的近义词头</b>
|
||||
<span class="m-tag">{{ D.quality.synNoSense.length }} 个</span>
|
||||
</div>
|
||||
<div class="m-chips">
|
||||
<span class="m-chip" v-for="w in D.quality.synNoSense" :key="w">{{ w }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel">
|
||||
<div class="a-panel-head"><div class="a-panel-title">跨域文本覆盖度</div><div class="a-panel-sub">与词条索引词交集</div></div>
|
||||
<div class="m-cov" v-for="c in D.quality.coverage" :key="c.name">
|
||||
<div class="m-cov-top">
|
||||
<span>{{ c.name }}</span>
|
||||
<b>{{ c.pct }}% · {{ fmt(c.hit) }}/{{ fmt(c.total) }}</b>
|
||||
</div>
|
||||
<div class="m-cov-track"><div class="m-cov-fill" :style="{ width: c.pct + '%' }"></div></div>
|
||||
<div class="m-cov-note">未覆盖 {{ fmt(c.total - c.hit) }} 个</div>
|
||||
</div>
|
||||
<div class="m-note" style="margin-top:14px">
|
||||
跨域关联基于单词文本(归一化小写),不是数据库外键;词族覆盖度明显低于其他两域。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m-note" style="margin-top:16px">
|
||||
口径说明:声明与实际差异按 book.declared_entry_count 与 book_entry 实际行数比较;“未设置考试”单列为“未归类”,不计入异常;无结构化义项指 word_entry 在 word_sense 中没有任何记录。
|
||||
</div>
|
||||
</module-shell>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,153 @@
|
||||
// PROTOTYPE ONLY — 近义词头、义项、分考试近义组与反义词。
|
||||
(function () {
|
||||
const D = window.MODULE_DATA;
|
||||
|
||||
window.ViewSynonyms = {
|
||||
name: 'ViewSynonyms',
|
||||
props: { id: String, kw: String },
|
||||
setup(props) {
|
||||
const { ref, computed } = Vue;
|
||||
const keyword = ref('');
|
||||
const selected = computed(() => D.synonyms.find((s) => String(s.id) === props.id) || null);
|
||||
const rich = computed(() => !!selected.value && selected.value.id === D.synonymDetail.id);
|
||||
const filtered = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
return kw ? D.synonyms.filter((s) => s.word.toLowerCase().includes(kw)) : D.synonyms;
|
||||
});
|
||||
|
||||
const groupsFor = (senseId) => D.synonymDetail.groups.filter((g) => g.senseId === senseId);
|
||||
const membersFor = (group) => {
|
||||
const found = D.synonymDetail.members.find((m) => m.senseId === group.senseId && m.exam === group.exam);
|
||||
return found ? found.words : [];
|
||||
};
|
||||
const dist = computed(() => {
|
||||
const buckets = {};
|
||||
D.synonymDetail.groups.forEach((g) => { buckets[g.count] = (buckets[g.count] || 0) + 1; });
|
||||
const keys = Object.keys(buckets).map(Number).sort((a, b) => a - b);
|
||||
const max = Math.max(...Object.values(buckets), 1);
|
||||
return keys.map((k) => ({ label: `${k} 个成员`, count: buckets[k], pct: Math.round((buckets[k] / max) * 100) }));
|
||||
});
|
||||
|
||||
function openWord(id) { window.protoNavigate('synonyms', id); }
|
||||
function back() { window.protoNavigate('synonyms'); }
|
||||
|
||||
return { D, keyword, filtered, selected, rich, groupsFor, membersFor, dist, openWord, back };
|
||||
},
|
||||
template: `
|
||||
<module-shell active="synonyms" :title="selected ? '近反义词详情' : '近反义词'">
|
||||
<template v-if="!selected">
|
||||
<div class="m-page-head">
|
||||
<div>
|
||||
<h1>近反义词</h1>
|
||||
<p>按义项与考试浏览近义组、规范词和反义词</p>
|
||||
</div>
|
||||
<div class="m-page-meta">6,279 个词头 · 8,383 个义项 · 188,003 个组成员</div>
|
||||
</div>
|
||||
|
||||
<div class="m-toolbar">
|
||||
<div class="m-field m-field-grow">
|
||||
<label>搜索</label>
|
||||
<input v-model="keyword" placeholder="输入近义词头" />
|
||||
</div>
|
||||
<div class="m-toolbar-note">仅展示 8 个样本 · gain 含完整详情</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel">
|
||||
<table class="m-table">
|
||||
<thead><tr><th style="width:32%">词头</th><th class="m-num">义项数</th><th class="m-num">操作</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="s in filtered" :key="s.id">
|
||||
<td class="m-word">{{ s.word }}</td>
|
||||
<td class="m-num">{{ s.senses }}</td>
|
||||
<td class="m-num"><a class="m-link" @click="openWord(s.id)">查看</a></td>
|
||||
</tr>
|
||||
<tr v-if="!filtered.length"><td colspan="3"><div class="m-empty">没有匹配的词头</div></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="m-back" @click="back">← 返回词头列表</div>
|
||||
|
||||
<div class="a-panel m-detail-head">
|
||||
<div class="m-detail-main">
|
||||
<div class="m-detail-kicker">SYNONYM</div>
|
||||
<h1 class="m-detail-title">{{ selected.word }}</h1>
|
||||
<div class="m-detail-meta">
|
||||
<span class="m-tag">{{ selected.senses }} 个义项</span>
|
||||
<span v-if="rich" class="m-tag">267 个组成员</span>
|
||||
<span v-if="rich" class="m-tag">22 条反义关系</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="rich" class="m-stat-row">
|
||||
<div class="m-stat"><b>{{ selected.senses }}</b><span>义项</span></div>
|
||||
<div class="m-stat"><b>267</b><span>组成员</span></div>
|
||||
<div class="m-stat"><b>22</b><span>反义关系</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!rich" class="m-note" style="margin-top:12px">
|
||||
原型仅展开 gain(word_id=2411)的完整近反义数据;当前词头展示基本信息与空状态。
|
||||
</div>
|
||||
|
||||
<template v-if="rich">
|
||||
<div class="m-two-col" style="margin-top:16px">
|
||||
<div class="a-panel">
|
||||
<div class="a-panel-head"><div class="a-panel-title">义项与近义组</div><div class="a-panel-sub">按考试分组</div></div>
|
||||
<div class="m-sense" v-for="s in D.synonymDetail.senses" :key="s.id">
|
||||
<div class="m-sense-head">
|
||||
<span class="m-sense-no">{{ s.id }}</span>
|
||||
<span class="m-tag">{{ s.pos }}</span>
|
||||
<span class="m-sense-gloss">{{ s.gloss }}</span>
|
||||
</div>
|
||||
<div v-if="groupsFor(s.id).length" class="m-group-grid">
|
||||
<div class="m-group" v-for="g in groupsFor(s.id)" :key="g.exam">
|
||||
<div class="m-group-top">
|
||||
<span class="m-tag">{{ g.exam }}</span>
|
||||
<span class="m-cell-sub">{{ g.count }} 个成员</span>
|
||||
</div>
|
||||
<div class="m-group-canon" v-if="g.canonical">规范词:<b>{{ g.canonical }}</b></div>
|
||||
<div class="m-chips" v-if="membersFor(g).length">
|
||||
<span class="m-chip" v-for="w in membersFor(g)" :key="w">{{ w }}</span>
|
||||
</div>
|
||||
<div v-else class="m-group-empty">成员未在原型中展开</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="m-group-empty">该义项在原型中没有考试分组数据</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m-side-stack">
|
||||
<div class="a-panel">
|
||||
<div class="a-panel-head"><div class="a-panel-title">组规模分布</div><div class="a-panel-sub">按成员数量分桶</div></div>
|
||||
<div class="m-bar-row" v-for="d in dist" :key="d.label">
|
||||
<span class="m-bar-label">{{ d.label }}</span>
|
||||
<span class="m-bar-track"><span class="m-bar-fill" :style="{ width: d.pct + '%' }"></span></span>
|
||||
<span class="m-bar-value">{{ d.count }} 组</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="a-panel">
|
||||
<div class="a-panel-head"><div class="a-panel-title">反义词</div><div class="a-panel-sub">按义项与考试</div></div>
|
||||
<div class="m-antonym" v-for="a in D.synonymDetail.antonyms" :key="a.senseId">
|
||||
<div class="m-antonym-head">
|
||||
<span class="m-tag">义项</span>
|
||||
<span class="m-sense-gloss">{{ a.gloss }}</span>
|
||||
<b class="m-antonym-word">{{ a.word }}</b>
|
||||
</div>
|
||||
<div class="m-chips">
|
||||
<span class="m-chip" v-for="e in a.exams" :key="e">{{ e }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="a-panel m-tab-panel" style="margin-top:16px">
|
||||
<div class="m-empty">该词头的义项、近义组与反义词在原型中未展开</div>
|
||||
</div>
|
||||
</template>
|
||||
</module-shell>`
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
@@ -0,0 +1,7 @@
|
||||
import http from './http'
|
||||
import type { ApiResponse, LoginResponse } from './types'
|
||||
|
||||
export async function login(username: string, password: string): Promise<LoginResponse> {
|
||||
const { data } = await http.post<ApiResponse<LoginResponse>>('/auth/login', { username, password })
|
||||
return data.data
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import http from './http'
|
||||
import type {
|
||||
ApiResponse,
|
||||
BookDetail,
|
||||
BookEntryItem,
|
||||
BookListItem,
|
||||
ExamOption,
|
||||
Items,
|
||||
PageResult
|
||||
} from './types'
|
||||
|
||||
export interface BookQuery {
|
||||
page?: number
|
||||
size?: number
|
||||
examId?: string | null
|
||||
keyword?: string
|
||||
hasFile?: boolean | null
|
||||
}
|
||||
|
||||
export interface BookEntryQuery {
|
||||
page?: number
|
||||
size?: number
|
||||
keyword?: string
|
||||
}
|
||||
|
||||
export async function getBooks(params: BookQuery): Promise<PageResult<BookListItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<BookListItem>>>('/books', { params })
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getBook(id: string): Promise<BookDetail> {
|
||||
const { data } = await http.get<ApiResponse<BookDetail>>(`/books/${id}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getBookEntries(
|
||||
id: string,
|
||||
params: BookEntryQuery
|
||||
): Promise<PageResult<BookEntryItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<BookEntryItem>>>(`/books/${id}/entries`, {
|
||||
params
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getExams(): Promise<ExamOption[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<ExamOption>>>('/exams')
|
||||
return data.data.items
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import http from './http'
|
||||
import type {
|
||||
ApiResponse,
|
||||
DashboardSummary,
|
||||
ExamStat,
|
||||
Items,
|
||||
PosStat,
|
||||
TopBook
|
||||
} from './types'
|
||||
import {
|
||||
mockCoverage,
|
||||
mockExams,
|
||||
mockKpis,
|
||||
mockPos,
|
||||
mockQuality,
|
||||
mockTopBooks
|
||||
} from '@/mocks/dashboard'
|
||||
|
||||
const useMock = import.meta.env.VITE_USE_MOCK === 'true'
|
||||
|
||||
function delay<T>(data: T): Promise<T> {
|
||||
return new Promise((resolve) => setTimeout(() => resolve(data), 220))
|
||||
}
|
||||
|
||||
function refreshParams(refresh: boolean) {
|
||||
return refresh ? { refresh: true } : undefined
|
||||
}
|
||||
|
||||
export async function getDashboardSummary(refresh = false): Promise<DashboardSummary> {
|
||||
if (useMock) {
|
||||
return delay({ kpis: mockKpis, quality: mockQuality, coverage: mockCoverage })
|
||||
}
|
||||
const { data } = await http.get<ApiResponse<DashboardSummary>>('/dashboard/summary', {
|
||||
params: refreshParams(refresh)
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getExamDistribution(refresh = false): Promise<ExamStat[]> {
|
||||
if (useMock) return delay(mockExams)
|
||||
const { data } = await http.get<ApiResponse<Items<ExamStat>>>('/dashboard/exam-distribution', {
|
||||
params: refreshParams(refresh)
|
||||
})
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getTopBooks(refresh = false): Promise<TopBook[]> {
|
||||
if (useMock) return delay(mockTopBooks)
|
||||
const { data } = await http.get<ApiResponse<Items<TopBook>>>('/dashboard/book-size-top', {
|
||||
params: refreshParams(refresh)
|
||||
})
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getPosDistribution(refresh = false): Promise<PosStat[]> {
|
||||
if (useMock) return delay(mockPos)
|
||||
const { data } = await http.get<ApiResponse<Items<PosStat>>>('/dashboard/pos-distribution', {
|
||||
params: refreshParams(refresh)
|
||||
})
|
||||
return data.data.items
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import http from './http'
|
||||
import type {
|
||||
ApiResponse,
|
||||
ConfusableItem,
|
||||
EntryBookItem,
|
||||
EntryDetail,
|
||||
EntryListItem,
|
||||
ExampleGroupItem,
|
||||
Items,
|
||||
PageResult,
|
||||
PhraseItem,
|
||||
SenseItem,
|
||||
SpellingVariantItem
|
||||
} from './types'
|
||||
|
||||
export interface EntryQuery {
|
||||
page?: number
|
||||
size?: number
|
||||
keyword?: string
|
||||
}
|
||||
|
||||
export async function getEntries(params: EntryQuery): Promise<PageResult<EntryListItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<EntryListItem>>>('/entries', { params })
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getEntry(id: string): Promise<EntryDetail> {
|
||||
const { data } = await http.get<ApiResponse<EntryDetail>>(`/entries/${id}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getEntrySenses(id: string): Promise<SenseItem[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<SenseItem>>>(`/entries/${id}/senses`)
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getEntryPhrases(
|
||||
id: string,
|
||||
page: number,
|
||||
size: number
|
||||
): Promise<PageResult<PhraseItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<PhraseItem>>>(`/entries/${id}/phrases`, {
|
||||
params: { page, size }
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getEntryExamples(
|
||||
id: string,
|
||||
page: number,
|
||||
size: number
|
||||
): Promise<PageResult<ExampleGroupItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<ExampleGroupItem>>>(`/entries/${id}/examples`, {
|
||||
params: { page, size }
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getEntryConfusables(id: string): Promise<ConfusableItem[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<ConfusableItem>>>(`/entries/${id}/confusables`)
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getEntryVariants(id: string): Promise<SpellingVariantItem[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<SpellingVariantItem>>>(`/entries/${id}/variants`)
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getEntryBooks(
|
||||
id: string,
|
||||
page: number,
|
||||
size: number
|
||||
): Promise<PageResult<EntryBookItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<EntryBookItem>>>(`/entries/${id}/books`, {
|
||||
params: { page, size }
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import axios from 'axios'
|
||||
import { clearAuthStorage, TOKEN_KEY } from '@/utils/storage'
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL ?? '/api',
|
||||
timeout: 20000
|
||||
})
|
||||
|
||||
http.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem(TOKEN_KEY)
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
return config
|
||||
})
|
||||
|
||||
http.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
const status = error.response?.status
|
||||
const url: string = error.config?.url ?? ''
|
||||
const message: string =
|
||||
error.response?.data?.message ?? error.message ?? '请求失败'
|
||||
if (status === 401 && !url.includes('/auth/login')) {
|
||||
clearAuthStorage()
|
||||
if (window.location.pathname !== '/login') {
|
||||
const redirect = encodeURIComponent(window.location.pathname + window.location.search)
|
||||
window.location.assign(`/login?redirect=${redirect}`)
|
||||
}
|
||||
}
|
||||
return Promise.reject(new Error(message))
|
||||
}
|
||||
)
|
||||
|
||||
export default http
|
||||
@@ -0,0 +1,62 @@
|
||||
import http from './http'
|
||||
import type {
|
||||
ApiResponse,
|
||||
CardDetail,
|
||||
CardItem,
|
||||
FamilyDetail,
|
||||
FamilyItem,
|
||||
MorphemeDetail,
|
||||
MorphemeItem,
|
||||
PageResult,
|
||||
TreePage
|
||||
} from './types'
|
||||
|
||||
export interface PagedQuery {
|
||||
page?: number
|
||||
size?: number
|
||||
keyword?: string
|
||||
}
|
||||
|
||||
export async function getMorphemes(
|
||||
params: PagedQuery & { type?: string }
|
||||
): Promise<PageResult<MorphemeItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<MorphemeItem>>>('/morphemes', { params })
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getMorpheme(id: string): Promise<MorphemeDetail> {
|
||||
const { data } = await http.get<ApiResponse<MorphemeDetail>>(`/morphemes/${id}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getCards(params: PagedQuery): Promise<PageResult<CardItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<CardItem>>>('/cards', { params })
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getCard(id: string): Promise<CardDetail> {
|
||||
const { data } = await http.get<ApiResponse<CardDetail>>(`/cards/${id}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getFamilies(params: PagedQuery): Promise<PageResult<FamilyItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<FamilyItem>>>('/families', { params })
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getFamily(id: string): Promise<FamilyDetail> {
|
||||
const { data } = await http.get<ApiResponse<FamilyDetail>>(`/families/${id}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getFamilyTree(
|
||||
id: string,
|
||||
nodeType: string,
|
||||
page = 1,
|
||||
size = 50
|
||||
): Promise<TreePage> {
|
||||
const { data } = await http.get<ApiResponse<TreePage>>(`/families/${id}/tree`, {
|
||||
params: { nodeType, page, size }
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import http from './http'
|
||||
import type {
|
||||
ApiResponse,
|
||||
DeclaredDiff,
|
||||
Items,
|
||||
MissingReference,
|
||||
QualityCoverage,
|
||||
QualitySummary
|
||||
} from './types'
|
||||
|
||||
export async function getQualitySummary(refresh = false): Promise<QualitySummary> {
|
||||
const { data } = await http.get<ApiResponse<QualitySummary>>('/quality/summary', {
|
||||
params: refresh ? { refresh: true } : undefined
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getDeclaredDiff(refresh = false): Promise<DeclaredDiff[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<DeclaredDiff>>>('/quality/declared-vs-actual', {
|
||||
params: refresh ? { refresh: true } : undefined
|
||||
})
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getMissingReferences(refresh = false): Promise<MissingReference[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<MissingReference>>>(
|
||||
'/quality/missing-references',
|
||||
{ params: refresh ? { refresh: true } : undefined }
|
||||
)
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function getQualityCoverage(refresh = false): Promise<QualityCoverage[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<QualityCoverage>>>(
|
||||
'/quality/cross-domain-coverage',
|
||||
{ params: refresh ? { refresh: true } : undefined }
|
||||
)
|
||||
return data.data.items
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import http from './http'
|
||||
import type {
|
||||
ApiResponse,
|
||||
Items,
|
||||
PageResult,
|
||||
SizeBucket,
|
||||
SynonymDetail,
|
||||
SynonymWordItem
|
||||
} from './types'
|
||||
|
||||
export interface SynonymQuery {
|
||||
page?: number
|
||||
size?: number
|
||||
keyword?: string
|
||||
}
|
||||
|
||||
export async function getSynonyms(params: SynonymQuery): Promise<PageResult<SynonymWordItem>> {
|
||||
const { data } = await http.get<ApiResponse<PageResult<SynonymWordItem>>>('/synonyms', { params })
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getSynonym(wordId: string): Promise<SynonymDetail> {
|
||||
const { data } = await http.get<ApiResponse<SynonymDetail>>(`/synonyms/${wordId}`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function getSynonymDistribution(): Promise<SizeBucket[]> {
|
||||
const { data } = await http.get<ApiResponse<Items<SizeBucket>>>('/synonyms/group-size-distribution')
|
||||
return data.data.items
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
export type Tone = 'blue' | 'green' | 'violet' | 'amber' | 'cyan' | 'rose'
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
code: number
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
|
||||
export interface Items<T> {
|
||||
items: T[]
|
||||
}
|
||||
|
||||
export interface PageResult<T> {
|
||||
items: T[]
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
}
|
||||
|
||||
export interface ExamOption {
|
||||
id: string
|
||||
code: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface ExamRef {
|
||||
id: string
|
||||
code: string | null
|
||||
name: string
|
||||
}
|
||||
|
||||
/* ---------- 概览 ---------- */
|
||||
|
||||
export interface Kpi {
|
||||
key: string
|
||||
label: string
|
||||
value: number
|
||||
note: string
|
||||
tone: Tone
|
||||
}
|
||||
|
||||
export interface ExamStat {
|
||||
name: string
|
||||
code: string | null
|
||||
books: number
|
||||
entries: number
|
||||
}
|
||||
|
||||
export interface TopBook {
|
||||
id: string
|
||||
name: string
|
||||
code: string
|
||||
exam: string | null
|
||||
declared: number | null
|
||||
actual: number
|
||||
coverPath: string | null
|
||||
}
|
||||
|
||||
export interface PosStat {
|
||||
name: string
|
||||
value: number
|
||||
}
|
||||
|
||||
export type QualityLevel = 'bad' | 'warn' | 'info'
|
||||
|
||||
export interface QualityItem {
|
||||
key: string
|
||||
label: string
|
||||
value: number
|
||||
unit: string
|
||||
level: QualityLevel
|
||||
target: string
|
||||
}
|
||||
|
||||
export interface CoverageItem {
|
||||
name: string
|
||||
hit: number
|
||||
total: number
|
||||
pct: number
|
||||
}
|
||||
|
||||
export interface DashboardSummary {
|
||||
kpis: Kpi[]
|
||||
quality: QualityItem[]
|
||||
coverage: CoverageItem[]
|
||||
}
|
||||
|
||||
/* ---------- 词书 ---------- */
|
||||
|
||||
export interface BookListItem {
|
||||
id: string
|
||||
code: string
|
||||
name: string
|
||||
examId: string | null
|
||||
examName: string | null
|
||||
declared: number | null
|
||||
actual: number
|
||||
hasFile: boolean
|
||||
coverPath: string | null
|
||||
}
|
||||
|
||||
export interface BookDetail extends BookListItem {
|
||||
description: string | null
|
||||
contentVersion: number | null
|
||||
schemaVersion: number | null
|
||||
packageUrl: string | null
|
||||
sortAt: number | null
|
||||
labels: string | null
|
||||
mismatch: boolean
|
||||
}
|
||||
|
||||
export interface BookEntryItem {
|
||||
entryId: string
|
||||
displayWord: string
|
||||
headwordText: string | null
|
||||
seqBook: number | null
|
||||
seqAz: number | null
|
||||
seqFreq: number | null
|
||||
headword: string | null
|
||||
indexWord: string | null
|
||||
}
|
||||
|
||||
/* ---------- 词条 ---------- */
|
||||
|
||||
export interface EntryListItem {
|
||||
id: string
|
||||
headword: string
|
||||
indexWord: string
|
||||
pronunciation: string | null
|
||||
definition: string | null
|
||||
senseCount: number
|
||||
bookCount: number
|
||||
}
|
||||
|
||||
export interface EntryDetail {
|
||||
id: string
|
||||
headword: string
|
||||
indexWord: string
|
||||
usPronunciation: string | null
|
||||
ukPronunciation: string | null
|
||||
definitionText: string | null
|
||||
dataVersion: string | null
|
||||
bookExamId: string | null
|
||||
bookExamName: string | null
|
||||
occurrenceCount: number | null
|
||||
hasListeningExamples: boolean
|
||||
sourceZpkKey: string | null
|
||||
}
|
||||
|
||||
export interface SenseRelation {
|
||||
type: string
|
||||
position: number | null
|
||||
targetMeaningId: string | null
|
||||
targetEntryId: string | null
|
||||
}
|
||||
|
||||
export interface SenseItem {
|
||||
senseId: string
|
||||
senseNo: number | null
|
||||
partOfSpeech: string | null
|
||||
glossZh: string | null
|
||||
exams: ExamRef[]
|
||||
relations: SenseRelation[]
|
||||
}
|
||||
|
||||
export interface PhraseOrder {
|
||||
examId: string
|
||||
examName: string
|
||||
groupType: number | null
|
||||
position: number | null
|
||||
}
|
||||
|
||||
export interface PhraseItem {
|
||||
id: string
|
||||
textEn: string
|
||||
textZh: string | null
|
||||
groupType: number | null
|
||||
meaningId: string | null
|
||||
exams: ExamRef[]
|
||||
orders: PhraseOrder[]
|
||||
}
|
||||
|
||||
export interface ExampleSentenceItem {
|
||||
id: string
|
||||
textEn: string
|
||||
textZh: string | null
|
||||
sourceTitle: string | null
|
||||
audioUrl: string | null
|
||||
listening: boolean
|
||||
}
|
||||
|
||||
export interface ExampleUsageItem {
|
||||
id: string
|
||||
patternId: string | null
|
||||
patternText: string | null
|
||||
position: number | null
|
||||
sentences: ExampleSentenceItem[]
|
||||
}
|
||||
|
||||
export interface ExampleGroupItem {
|
||||
id: string
|
||||
groupKind: number
|
||||
partOfSpeech: string | null
|
||||
entryKindCode: string | null
|
||||
headForm: string | null
|
||||
definitionEn: string | null
|
||||
definitionZh: string | null
|
||||
exams: ExamRef[]
|
||||
usages: ExampleUsageItem[]
|
||||
directSentences: ExampleSentenceItem[]
|
||||
sentenceCount: number
|
||||
}
|
||||
|
||||
export interface ConfusableItem {
|
||||
id: string
|
||||
wordText: string
|
||||
glossZh: string | null
|
||||
posCode: number | null
|
||||
spellingFlag: string | null
|
||||
position: number | null
|
||||
}
|
||||
|
||||
export interface SpellingVariantItem {
|
||||
position: number | null
|
||||
variant: string
|
||||
}
|
||||
|
||||
export interface EntryBookItem {
|
||||
bookId: string
|
||||
bookName: string
|
||||
bookCode: string
|
||||
displayWord: string
|
||||
seqBook: number | null
|
||||
}
|
||||
|
||||
/* ---------- 词根词族 ---------- */
|
||||
|
||||
export interface MorphemeItem {
|
||||
id: string
|
||||
type: 'prefix' | 'root' | 'suffix'
|
||||
form: string | null
|
||||
displayText: string
|
||||
meaningEn: string | null
|
||||
meaningZh: string | null
|
||||
note: string | null
|
||||
}
|
||||
|
||||
export interface CardBrief {
|
||||
id: string
|
||||
word: string
|
||||
memoryNote: string | null
|
||||
exampleText: string | null
|
||||
}
|
||||
|
||||
export interface MorphemeDetail extends MorphemeItem {
|
||||
cards: CardBrief[]
|
||||
cardCount: number
|
||||
}
|
||||
|
||||
export interface CardItem {
|
||||
id: string
|
||||
word: string
|
||||
memoryNote: string | null
|
||||
highlightedWord: string | null
|
||||
exams: ExamRef[]
|
||||
}
|
||||
|
||||
export interface CardFamilyLink {
|
||||
linkId: string
|
||||
groupNo: number
|
||||
familyRef: string | null
|
||||
hidden: boolean
|
||||
}
|
||||
|
||||
export interface CardDetail {
|
||||
id: string
|
||||
word: string
|
||||
highlightedWord: string | null
|
||||
memoryNote: string | null
|
||||
exampleText: string | null
|
||||
hidden: boolean
|
||||
prefixMorphemeId: string | null
|
||||
prefixForm: string | null
|
||||
rootMorphemeId: string | null
|
||||
rootForm: string | null
|
||||
suffixMorphemeId: string | null
|
||||
suffixForm: string | null
|
||||
defaultFamilyRef: string | null
|
||||
exams: ExamRef[]
|
||||
familyLinks: CardFamilyLink[]
|
||||
}
|
||||
|
||||
export interface FamilyItem {
|
||||
id: string
|
||||
word: string
|
||||
topFamilyId: string
|
||||
topWord: string
|
||||
interpretation: string | null
|
||||
groupLevel1: number | null
|
||||
groupLevel2: number | null
|
||||
groupLevel3: number | null
|
||||
exams: ExamRef[]
|
||||
}
|
||||
|
||||
export interface FamilyVariantItem {
|
||||
id: string
|
||||
variantWord: string
|
||||
interpretation: string | null
|
||||
memberCount: number
|
||||
}
|
||||
|
||||
export interface FamilyMemberItem {
|
||||
familyEntryId: string
|
||||
word: string
|
||||
position: number | null
|
||||
}
|
||||
|
||||
export interface MiniGroupItem {
|
||||
id: string
|
||||
size: number
|
||||
members: FamilyMemberItem[]
|
||||
}
|
||||
|
||||
export interface FamilyDetail extends FamilyItem {
|
||||
variants: FamilyVariantItem[]
|
||||
miniGroups: MiniGroupItem[]
|
||||
}
|
||||
|
||||
export interface TreeNode {
|
||||
nodeType: 'top' | 'variant' | 'miniGroup' | 'member' | 'info'
|
||||
id: string
|
||||
label: string
|
||||
subtitle: string
|
||||
memberCount: number
|
||||
leaf: boolean
|
||||
}
|
||||
|
||||
export interface TreePage {
|
||||
nodes: TreeNode[]
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
}
|
||||
|
||||
/* ---------- 近反义词 ---------- */
|
||||
|
||||
export interface SynonymWordItem {
|
||||
wordId: string
|
||||
word: string
|
||||
senseCount: number
|
||||
hasRelation: boolean
|
||||
}
|
||||
|
||||
export interface SynonymMember {
|
||||
wordId: string
|
||||
word: string
|
||||
position: number | null
|
||||
}
|
||||
|
||||
export interface SynonymGroup {
|
||||
examId: string
|
||||
examName: string
|
||||
canonicalWordId: string | null
|
||||
canonicalWord: string | null
|
||||
memberCount: number
|
||||
members: SynonymMember[]
|
||||
truncated: boolean
|
||||
}
|
||||
|
||||
export interface AntonymGroup {
|
||||
examId: string
|
||||
examName: string
|
||||
words: SynonymMember[]
|
||||
}
|
||||
|
||||
export interface SynonymSense {
|
||||
senseId: string
|
||||
partOfSpeech: string | null
|
||||
glossZh: string | null
|
||||
groups: SynonymGroup[]
|
||||
antonyms: AntonymGroup[]
|
||||
}
|
||||
|
||||
export interface SynonymDetail {
|
||||
wordId: string
|
||||
word: string
|
||||
senses: SynonymSense[]
|
||||
}
|
||||
|
||||
export interface SizeBucket {
|
||||
label: string
|
||||
count: number
|
||||
pct: number
|
||||
}
|
||||
|
||||
/* ---------- 数据质量 ---------- */
|
||||
|
||||
export interface QualitySummaryItem {
|
||||
key: string
|
||||
label: string
|
||||
value: number
|
||||
unit: string
|
||||
level: QualityLevel
|
||||
description: string
|
||||
}
|
||||
|
||||
export interface QualitySummary {
|
||||
items: QualitySummaryItem[]
|
||||
}
|
||||
|
||||
export interface DeclaredDiff {
|
||||
bookId: string
|
||||
bookName: string
|
||||
bookCode: string
|
||||
examName: string | null
|
||||
declared: number
|
||||
actual: number
|
||||
diff: number
|
||||
}
|
||||
|
||||
export interface MissingReference {
|
||||
type: string
|
||||
identifier: string
|
||||
source: string
|
||||
detail: string
|
||||
bookId: string | null
|
||||
}
|
||||
|
||||
export interface QualityCoverage {
|
||||
key: string
|
||||
name: string
|
||||
hit: number
|
||||
total: number
|
||||
pct: number
|
||||
}
|
||||
|
||||
/* ---------- 认证 ---------- */
|
||||
|
||||
export interface LoginResponse {
|
||||
token: string
|
||||
expiresAt: string
|
||||
username: string
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import type { EChartsOption } from 'echarts'
|
||||
import type { ExamStat, PosStat } from '@/api/types'
|
||||
|
||||
const POS_COLORS = [
|
||||
'#2563eb',
|
||||
'#3b82f6',
|
||||
'#60a5fa',
|
||||
'#93c5fd',
|
||||
'#a5b4fc',
|
||||
'#c7d2fe',
|
||||
'#818cf8',
|
||||
'#6366f1',
|
||||
'#4f46e5',
|
||||
'#cbd5e1'
|
||||
]
|
||||
|
||||
function short(n: number): string {
|
||||
return n >= 10000 ? `${(n / 1000).toFixed(1)}k` : String(n)
|
||||
}
|
||||
|
||||
export function examChartOption(rows: ExamStat[]): EChartsOption {
|
||||
const reversed = [...rows].reverse()
|
||||
return {
|
||||
grid: { left: 8, right: 56, top: 6, bottom: 6, containLabel: true },
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
formatter: '{b}<br/>关联词条 {c}'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
splitLine: { lineStyle: { color: '#f1f3f6' } },
|
||||
axisLabel: {
|
||||
color: '#9ca3af',
|
||||
fontSize: 10,
|
||||
formatter: (value: string | number) => short(Number(value))
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: reversed.map((row) => row.name),
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: '#4b5563', fontSize: 11.5 }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
barWidth: 13,
|
||||
data: reversed.map((row) => ({
|
||||
value: row.entries,
|
||||
itemStyle: { color: row.code === null ? '#cbd5e1' : '#3b82f6', borderRadius: [0, 3, 3, 0] }
|
||||
})),
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
color: '#6b7280',
|
||||
fontSize: 10.5,
|
||||
formatter: '{c}'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export function posChartOption(rows: PosStat[]): EChartsOption {
|
||||
return {
|
||||
tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
||||
legend: {
|
||||
right: 0,
|
||||
top: 'center',
|
||||
orient: 'vertical',
|
||||
itemWidth: 8,
|
||||
itemHeight: 8,
|
||||
textStyle: { color: '#6b7280', fontSize: 11 }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: ['46%', '70%'],
|
||||
center: ['34%', '50%'],
|
||||
itemStyle: { borderColor: '#fff', borderWidth: 2 },
|
||||
label: { show: false },
|
||||
data: rows.map((row, index) => ({
|
||||
name: row.name,
|
||||
value: row.value,
|
||||
itemStyle: { color: POS_COLORS[index % POS_COLORS.length] }
|
||||
}))
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { EChartsOption } from 'echarts'
|
||||
import type { QualityCoverage } from '@/api/types'
|
||||
|
||||
export function coverageOption(rows: QualityCoverage[]): EChartsOption {
|
||||
return {
|
||||
grid: { left: 8, right: 48, top: 8, bottom: 8, containLabel: true },
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
formatter: (params: unknown) => {
|
||||
const item = (params as { name: string; value: number }[])[0]
|
||||
return `${item.name}<br/>覆盖率 ${item.value}%`
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
max: 100,
|
||||
splitLine: { lineStyle: { color: '#f1f3f6' } },
|
||||
axisLabel: { color: '#9ca3af', fontSize: 10, formatter: '{value}%' }
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: rows.map((row) => row.name),
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: '#4b5563', fontSize: 11.5 }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
barWidth: 16,
|
||||
itemStyle: { color: '#0891b2', borderRadius: [0, 4, 4, 0] },
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
color: '#6b7280',
|
||||
fontSize: 10.5,
|
||||
formatter: '{c}%'
|
||||
},
|
||||
data: rows.map((row) => row.pct)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { EChartsOption } from 'echarts'
|
||||
import type { SizeBucket } from '@/api/types'
|
||||
|
||||
export function synonymDistributionOption(rows: SizeBucket[]): EChartsOption {
|
||||
return {
|
||||
grid: { left: 8, right: 24, top: 16, bottom: 8, containLabel: true },
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
formatter: (params: unknown) => {
|
||||
const item = (params as { name: string; value: number }[])[0]
|
||||
return `${item.name} 个成员<br/>组数 ${item.value.toLocaleString('en-US')}`
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: rows.map((row) => row.label),
|
||||
axisTick: { show: false },
|
||||
axisLine: { lineStyle: { color: '#e5e7eb' } },
|
||||
axisLabel: { color: '#6b7280', fontSize: 11 }
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
splitLine: { lineStyle: { color: '#f1f3f6' } },
|
||||
axisLabel: { color: '#9ca3af', fontSize: 10 }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
barWidth: 22,
|
||||
itemStyle: { color: '#6366f1', borderRadius: [4, 4, 0, 0] },
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color: '#6b7280',
|
||||
fontSize: 10,
|
||||
formatter: '{c}'
|
||||
},
|
||||
data: rows.map((row) => row.count)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { coverUrl, onCoverError } from '@/utils/cover'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
path: string | null
|
||||
width?: number
|
||||
height?: number
|
||||
radius?: number
|
||||
}>(),
|
||||
{ width: 30, height: 40, radius: 4 }
|
||||
)
|
||||
|
||||
const style = computed(() => ({
|
||||
width: `${props.width}px`,
|
||||
height: `${props.height}px`,
|
||||
borderRadius: `${props.radius}px`
|
||||
}))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<img class="cover-image" :src="coverUrl(props.path)" :style="style" alt="" @error="onCoverError" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cover-image {
|
||||
object-fit: cover;
|
||||
background: #eef2f7;
|
||||
flex: none;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||