Redesign frontend

This commit is contained in:
Xin Wang
2026-07-16 13:58:44 +08:00
parent 69896460cb
commit af70358686
98 changed files with 880 additions and 11435 deletions

View File

@@ -1,75 +1,49 @@
# React + TypeScript + Vite
# ASR 事件监控前端
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
这是与仓库 Spring Boot 后端配套的新版 React + Vite 前端。
Currently, two official plugins are available:
## 本地联调
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
## React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
先在仓库根目录启动后端(默认端口 `8080`),再启动前端:
```bash
cd frontend
npm install
npm run dev
```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
访问 `http://localhost:3000`。Vite 会把 `/api` 请求代理到
`http://localhost:8080`,无需额外配置 CORS。
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
## 生产打包
```bash
cd frontend
npm run build
```
构建结果位于 `frontend/dist`。如需与 Spring Boot 打成同一个 JAR
在执行 Maven 打包前,将 `dist` 内的文件复制到:
```text
src/main/resources/static/
```
之后访问 Spring Boot 的 `http://localhost:8080/` 即可使用前端。
## 后端接口
- `GET /api/v1/admin/rules`:读取当前生效规则
- `PUT /api/v1/admin/rules`:保存并发布完整规则文档
- `POST /api/v1/asr-events`:提交 ASR Final 并获取会话告警
- `POST /api/v1/calls/{callId}/close`:关闭并释放通话会话
规则数据和生效版本以后端为准;浏览器不再通过 localStorage 模拟发布。
## Excel 导入导出
- “模板下载”生成 `.xlsx` 规则模板。
- 每行填写一条规则,多个关键词在同一个单元格内换行填写。
- “导入”会校验事件 ID、启用状态、关键词以及重复数据并替换页面工作副本。
- “导出”按照相同模板格式导出当前页面中的规则。
- 导入不会自动发布,确认数据后仍需点击“保存并发布”。