add: 为前后端添加exam数据库管理
This commit is contained in:
parent
0cc35ce541
commit
4df583e74b
|
@ -194,6 +194,19 @@ try
|
|||
// Setup Program
|
||||
MsgBus.Init();
|
||||
|
||||
// 扫描并更新实验数据库
|
||||
try
|
||||
{
|
||||
using var db = new Database.AppDataConnection();
|
||||
var examFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "exam");
|
||||
var updateCount = db.ScanAndUpdateExams(examFolderPath);
|
||||
logger.Info($"实验数据库扫描完成,更新了 {updateCount} 个实验");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"扫描实验文件夹时出错: {ex.Message}");
|
||||
}
|
||||
|
||||
// Generate API Client
|
||||
app.MapGet("GetAPIClientCode", async (HttpContext context) =>
|
||||
{
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# 实验001:基础逻辑门电路
|
||||
|
||||
## 实验目的
|
||||
|
||||
本实验旨在帮助学生理解基础逻辑门的工作原理,包括与门、或门、非门等基本逻辑运算。
|
||||
|
||||
## 实验内容
|
||||
|
||||
### 1. 与门(AND Gate)
|
||||
与门是一个基本的逻辑门,当所有输入都为高电平(1)时,输出才为高电平(1)。
|
||||
|
||||
### 2. 或门(OR Gate)
|
||||
或门是另一个基本的逻辑门,当任意一个输入为高电平(1)时,输出就为高电平(1)。
|
||||
|
||||
### 3. 非门(NOT Gate)
|
||||
非门是一个反相器,输入为高电平时输出为低电平,反之亦然。
|
||||
|
||||
## 实验步骤
|
||||
|
||||
1. 打开 FPGA 开发环境
|
||||
2. 创建新的项目文件
|
||||
3. 编写 Verilog 代码实现各种逻辑门
|
||||
4. 进行仿真验证
|
||||
5. 下载到 FPGA 板进行硬件验证
|
||||
|
||||
## 预期结果
|
||||
|
||||
通过本实验,学生应该能够:
|
||||
- 理解基本逻辑门的真值表
|
||||
- 掌握 Verilog 代码的基本语法
|
||||
- 学会使用 FPGA 开发工具进行仿真
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 确保输入信号的电平正确
|
||||
- 注意时序的约束
|
||||
- 验证结果时要仔细对比真值表
|
|
@ -0,0 +1,35 @@
|
|||
# 实验002:组合逻辑电路设计
|
||||
|
||||
## 实验目的
|
||||
|
||||
本实验旨在让学生学习如何设计和实现复杂的组合逻辑电路,掌握多个逻辑门的组合使用。
|
||||
|
||||
## 实验内容
|
||||
|
||||
### 1. 半加器设计
|
||||
设计一个半加器电路,实现两个一位二进制数的加法运算。
|
||||
|
||||
### 2. 全加器设计
|
||||
在半加器的基础上,设计全加器电路,考虑进位输入。
|
||||
|
||||
### 3. 编码器和译码器
|
||||
实现简单的编码器和译码器电路。
|
||||
|
||||
## 实验要求
|
||||
|
||||
1. 使用 Verilog HDL 编写代码
|
||||
2. 绘制逻辑电路图
|
||||
3. 编写测试用例验证功能
|
||||
4. 分析电路的延时特性
|
||||
|
||||
## 评估标准
|
||||
|
||||
- 电路功能正确性 (40%)
|
||||
- 代码质量和规范性 (30%)
|
||||
- 测试覆盖率 (20%)
|
||||
- 实验报告 (10%)
|
||||
|
||||
## 参考资料
|
||||
|
||||
- 数字逻辑设计教材第3-4章
|
||||
- Verilog HDL 语法参考手册
|
|
@ -0,0 +1,231 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using DotNext;
|
||||
|
||||
namespace server.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 实验控制器
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ExamController : ControllerBase
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// 实验信息类
|
||||
/// </summary>
|
||||
public class ExamInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 实验的唯一标识符
|
||||
/// </summary>
|
||||
public required string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验文档内容(Markdown格式)
|
||||
/// </summary>
|
||||
public required string DocContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验最后更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实验简要信息类(用于列表显示)
|
||||
/// </summary>
|
||||
public class ExamSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// 实验的唯一标识符
|
||||
/// </summary>
|
||||
public required string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验最后更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验标题(从文档内容中提取)
|
||||
/// </summary>
|
||||
public string Title { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描结果类
|
||||
/// </summary>
|
||||
public class ScanResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 结果消息
|
||||
/// </summary>
|
||||
public required string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新的实验数量
|
||||
/// </summary>
|
||||
public int UpdateCount { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有实验列表
|
||||
/// </summary>
|
||||
/// <returns>实验列表</returns>
|
||||
[Authorize]
|
||||
[HttpGet("list")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(ExamSummary[]), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult GetExamList()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var db = new Database.AppDataConnection();
|
||||
var exams = db.GetAllExams();
|
||||
|
||||
var examSummaries = exams.Select(exam => new ExamSummary
|
||||
{
|
||||
ID = exam.ID,
|
||||
CreatedTime = exam.CreatedTime,
|
||||
UpdatedTime = exam.UpdatedTime,
|
||||
Title = ExtractTitleFromMarkdown(exam.DocContent)
|
||||
}).ToArray();
|
||||
|
||||
logger.Info($"成功获取实验列表,共 {examSummaries.Length} 个实验");
|
||||
return Ok(examSummaries);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"获取实验列表时出错: {ex.Message}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, $"获取实验列表失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据实验ID获取实验详细信息
|
||||
/// </summary>
|
||||
/// <param name="examId">实验ID</param>
|
||||
/// <returns>实验详细信息</returns>
|
||||
[Authorize]
|
||||
[HttpGet("{examId}")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(ExamInfo), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult GetExam(string examId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(examId))
|
||||
return BadRequest("实验ID不能为空");
|
||||
|
||||
try
|
||||
{
|
||||
using var db = new Database.AppDataConnection();
|
||||
var result = db.GetExamByID(examId);
|
||||
|
||||
if (!result.IsSuccessful)
|
||||
{
|
||||
logger.Error($"获取实验时出错: {result.Error.Message}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, $"获取实验失败: {result.Error.Message}");
|
||||
}
|
||||
|
||||
if (!result.Value.HasValue)
|
||||
{
|
||||
logger.Warn($"实验不存在: {examId}");
|
||||
return NotFound($"实验 {examId} 不存在");
|
||||
}
|
||||
|
||||
var exam = result.Value.Value;
|
||||
var examInfo = new ExamInfo
|
||||
{
|
||||
ID = exam.ID,
|
||||
DocContent = exam.DocContent,
|
||||
CreatedTime = exam.CreatedTime,
|
||||
UpdatedTime = exam.UpdatedTime
|
||||
};
|
||||
|
||||
logger.Info($"成功获取实验信息: {examId}");
|
||||
return Ok(examInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"获取实验 {examId} 时出错: {ex.Message}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, $"获取实验失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新扫描实验文件夹并更新数据库
|
||||
/// </summary>
|
||||
/// <returns>更新结果</returns>
|
||||
[Authorize("Admin")]
|
||||
[HttpPost("scan")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(ScanResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult ScanExams()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var db = new Database.AppDataConnection();
|
||||
var examFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "exam");
|
||||
var updateCount = db.ScanAndUpdateExams(examFolderPath);
|
||||
|
||||
var result = new ScanResult
|
||||
{
|
||||
Message = $"扫描完成,更新了 {updateCount} 个实验",
|
||||
UpdateCount = updateCount
|
||||
};
|
||||
|
||||
logger.Info($"手动扫描实验完成,更新了 {updateCount} 个实验");
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"扫描实验时出错: {ex.Message}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, $"扫描实验失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从 Markdown 内容中提取标题
|
||||
/// </summary>
|
||||
/// <param name="markdownContent">Markdown 内容</param>
|
||||
/// <returns>提取的标题</returns>
|
||||
private static string ExtractTitleFromMarkdown(string markdownContent)
|
||||
{
|
||||
if (string.IsNullOrEmpty(markdownContent))
|
||||
return "";
|
||||
|
||||
var lines = markdownContent.Split('\n');
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var trimmedLine = line.Trim();
|
||||
if (trimmedLine.StartsWith("# "))
|
||||
{
|
||||
return trimmedLine.Substring(2).Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -150,6 +150,36 @@ public class Board
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实验类,表示实验信息
|
||||
/// </summary>
|
||||
public class Exam
|
||||
{
|
||||
/// <summary>
|
||||
/// 实验的唯一标识符
|
||||
/// </summary>
|
||||
[PrimaryKey]
|
||||
public required string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验文档内容(Markdown格式)
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public required string DocContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实验创建时间
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public DateTime CreatedTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 实验最后更新时间
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public DateTime UpdatedTime { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序数据连接类,用于与数据库交互
|
||||
/// </summary>
|
||||
|
@ -197,6 +227,7 @@ public class AppDataConnection : DataConnection
|
|||
logger.Info("正在创建数据库表...");
|
||||
this.CreateTable<User>();
|
||||
this.CreateTable<Board>();
|
||||
this.CreateTable<Exam>();
|
||||
logger.Info("数据库表创建完成");
|
||||
}
|
||||
|
||||
|
@ -208,6 +239,7 @@ public class AppDataConnection : DataConnection
|
|||
logger.Warn("正在删除所有数据库表...");
|
||||
this.DropTable<User>();
|
||||
this.DropTable<Board>();
|
||||
this.DropTable<Exam>();
|
||||
logger.Warn("所有数据库表已删除");
|
||||
}
|
||||
|
||||
|
@ -635,4 +667,117 @@ public class AppDataConnection : DataConnection
|
|||
/// FPGA 板子表
|
||||
/// </summary>
|
||||
public ITable<Board> BoardTable => this.GetTable<Board>();
|
||||
|
||||
/// <summary>
|
||||
/// 实验表
|
||||
/// </summary>
|
||||
public ITable<Exam> ExamTable => this.GetTable<Exam>();
|
||||
|
||||
/// <summary>
|
||||
/// 扫描 exam 文件夹并更新实验数据库
|
||||
/// </summary>
|
||||
/// <param name="examFolderPath">exam 文件夹的路径</param>
|
||||
/// <returns>更新的实验数量</returns>
|
||||
public int ScanAndUpdateExams(string examFolderPath)
|
||||
{
|
||||
if (!Directory.Exists(examFolderPath))
|
||||
{
|
||||
logger.Warn($"实验文件夹不存在: {examFolderPath}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int updateCount = 0;
|
||||
var subdirectories = Directory.GetDirectories(examFolderPath);
|
||||
|
||||
foreach (var examDir in subdirectories)
|
||||
{
|
||||
var examId = Path.GetFileName(examDir);
|
||||
var docPath = Path.Combine(examDir, "doc.md");
|
||||
|
||||
if (!File.Exists(docPath))
|
||||
{
|
||||
logger.Warn($"实验 {examId} 缺少 doc.md 文件");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var docContent = File.ReadAllText(docPath);
|
||||
var existingExam = this.ExamTable.Where(e => e.ID == examId).FirstOrDefault();
|
||||
|
||||
if (existingExam == null)
|
||||
{
|
||||
// 创建新实验
|
||||
var newExam = new Exam
|
||||
{
|
||||
ID = examId,
|
||||
DocContent = docContent,
|
||||
CreatedTime = DateTime.Now,
|
||||
UpdatedTime = DateTime.Now
|
||||
};
|
||||
this.Insert(newExam);
|
||||
logger.Info($"新实验已添加: {examId}");
|
||||
updateCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 更新现有实验
|
||||
var fileLastWrite = File.GetLastWriteTime(docPath);
|
||||
if (fileLastWrite > existingExam.UpdatedTime)
|
||||
{
|
||||
this.ExamTable
|
||||
.Where(e => e.ID == examId)
|
||||
.Set(e => e.DocContent, docContent)
|
||||
.Set(e => e.UpdatedTime, DateTime.Now)
|
||||
.Update();
|
||||
logger.Info($"实验已更新: {examId}");
|
||||
updateCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"处理实验 {examId} 时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info($"实验扫描完成,共更新 {updateCount} 个实验");
|
||||
return updateCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有实验信息
|
||||
/// </summary>
|
||||
/// <returns>所有实验的数组</returns>
|
||||
public Exam[] GetAllExams()
|
||||
{
|
||||
var exams = this.ExamTable.OrderBy(e => e.ID).ToArray();
|
||||
logger.Debug($"获取所有实验,共 {exams.Length} 个");
|
||||
return exams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据实验ID获取实验信息
|
||||
/// </summary>
|
||||
/// <param name="examId">实验ID</param>
|
||||
/// <returns>包含实验信息的结果,如果未找到则返回空</returns>
|
||||
public Result<Optional<Exam>> GetExamByID(string examId)
|
||||
{
|
||||
var exams = this.ExamTable.Where(exam => exam.ID == examId).ToArray();
|
||||
|
||||
if (exams.Length > 1)
|
||||
{
|
||||
logger.Error($"数据库中存在多个相同ID的实验: {examId}");
|
||||
return new(new Exception($"数据库中存在多个相同ID的实验: {examId}"));
|
||||
}
|
||||
|
||||
if (exams.Length == 0)
|
||||
{
|
||||
logger.Info($"未找到ID对应的实验: {examId}");
|
||||
return new(Optional<Exam>.None);
|
||||
}
|
||||
|
||||
logger.Debug($"成功获取实验信息: {examId}");
|
||||
return new(exams[0]);
|
||||
}
|
||||
}
|
||||
|
|
467
src/APIClient.ts
467
src/APIClient.ts
|
@ -2354,76 +2354,6 @@ export class DebuggerClient {
|
|||
return Promise.resolve<boolean>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新开始触发(刷新后再启动触发器)
|
||||
*/
|
||||
restartTrigger( cancelToken?: CancelToken): Promise<boolean> {
|
||||
let url_ = this.baseUrl + "/api/Debugger/RestartTrigger";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "POST",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processRestartTrigger(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processRestartTrigger(response: AxiosResponse): Promise<boolean> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
||||
|
||||
return Promise.resolve<boolean>(result200);
|
||||
|
||||
} else if (status === 400) {
|
||||
const _responseText = response.data;
|
||||
let result400: any = null;
|
||||
let resultData400 = _responseText;
|
||||
result400 = ProblemDetails.fromJS(resultData400);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers);
|
||||
|
||||
} else if (status === 401) {
|
||||
const _responseText = response.data;
|
||||
let result401: any = null;
|
||||
let resultData401 = _responseText;
|
||||
result401 = ProblemDetails.fromJS(resultData401);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result401);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<boolean>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取触发器状态标志
|
||||
*/
|
||||
|
@ -2716,6 +2646,241 @@ export class DebuggerClient {
|
|||
}
|
||||
}
|
||||
|
||||
export class ExamClient {
|
||||
protected instance: AxiosInstance;
|
||||
protected baseUrl: string;
|
||||
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
||||
|
||||
constructor(baseUrl?: string, instance?: AxiosInstance) {
|
||||
|
||||
this.instance = instance || axios.create();
|
||||
|
||||
this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有实验列表
|
||||
* @return 实验列表
|
||||
*/
|
||||
getExamList( cancelToken?: CancelToken): Promise<ExamSummary[]> {
|
||||
let url_ = this.baseUrl + "/api/Exam/list";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "GET",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processGetExamList(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetExamList(response: AxiosResponse): Promise<ExamSummary[]> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
if (Array.isArray(resultData200)) {
|
||||
result200 = [] as any;
|
||||
for (let item of resultData200)
|
||||
result200!.push(ExamSummary.fromJS(item));
|
||||
}
|
||||
else {
|
||||
result200 = <any>null;
|
||||
}
|
||||
return Promise.resolve<ExamSummary[]>(result200);
|
||||
|
||||
} else if (status === 401) {
|
||||
const _responseText = response.data;
|
||||
let result401: any = null;
|
||||
let resultData401 = _responseText;
|
||||
result401 = ProblemDetails.fromJS(resultData401);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result401);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<ExamSummary[]>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实验ID获取实验详细信息
|
||||
* @param examId 实验ID
|
||||
* @return 实验详细信息
|
||||
*/
|
||||
getExam(examId: string, cancelToken?: CancelToken): Promise<ExamInfo> {
|
||||
let url_ = this.baseUrl + "/api/Exam/{examId}";
|
||||
if (examId === undefined || examId === null)
|
||||
throw new Error("The parameter 'examId' must be defined.");
|
||||
url_ = url_.replace("{examId}", encodeURIComponent("" + examId));
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "GET",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processGetExam(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetExam(response: AxiosResponse): Promise<ExamInfo> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = ExamInfo.fromJS(resultData200);
|
||||
return Promise.resolve<ExamInfo>(result200);
|
||||
|
||||
} else if (status === 400) {
|
||||
const _responseText = response.data;
|
||||
let result400: any = null;
|
||||
let resultData400 = _responseText;
|
||||
result400 = ProblemDetails.fromJS(resultData400);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
|
||||
|
||||
} else if (status === 401) {
|
||||
const _responseText = response.data;
|
||||
let result401: any = null;
|
||||
let resultData401 = _responseText;
|
||||
result401 = ProblemDetails.fromJS(resultData401);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result401);
|
||||
|
||||
} else if (status === 404) {
|
||||
const _responseText = response.data;
|
||||
let result404: any = null;
|
||||
let resultData404 = _responseText;
|
||||
result404 = ProblemDetails.fromJS(resultData404);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result404);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<ExamInfo>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新扫描实验文件夹并更新数据库
|
||||
* @return 更新结果
|
||||
*/
|
||||
scanExams( cancelToken?: CancelToken): Promise<ScanResult> {
|
||||
let url_ = this.baseUrl + "/api/Exam/scan";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "POST",
|
||||
url: url_,
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processScanExams(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processScanExams(response: AxiosResponse): Promise<ScanResult> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText;
|
||||
result200 = ScanResult.fromJS(resultData200);
|
||||
return Promise.resolve<ScanResult>(result200);
|
||||
|
||||
} else if (status === 401) {
|
||||
const _responseText = response.data;
|
||||
let result401: any = null;
|
||||
let resultData401 = _responseText;
|
||||
result401 = ProblemDetails.fromJS(resultData401);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result401);
|
||||
|
||||
} else if (status === 403) {
|
||||
const _responseText = response.data;
|
||||
let result403: any = null;
|
||||
let resultData403 = _responseText;
|
||||
result403 = ProblemDetails.fromJS(resultData403);
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers, result403);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<ScanResult>(null as any);
|
||||
}
|
||||
}
|
||||
|
||||
export class JtagClient {
|
||||
protected instance: AxiosInstance;
|
||||
protected baseUrl: string;
|
||||
|
@ -7289,6 +7454,168 @@ export interface IChannelCaptureData {
|
|||
data: string;
|
||||
}
|
||||
|
||||
/** 实验简要信息类(用于列表显示) */
|
||||
export class ExamSummary implements IExamSummary {
|
||||
/** 实验的唯一标识符 */
|
||||
id!: string;
|
||||
/** 实验创建时间 */
|
||||
createdTime!: Date;
|
||||
/** 实验最后更新时间 */
|
||||
updatedTime!: Date;
|
||||
/** 实验标题(从文档内容中提取) */
|
||||
title!: string;
|
||||
|
||||
constructor(data?: IExamSummary) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.id = _data["id"];
|
||||
this.createdTime = _data["createdTime"] ? new Date(_data["createdTime"].toString()) : <any>undefined;
|
||||
this.updatedTime = _data["updatedTime"] ? new Date(_data["updatedTime"].toString()) : <any>undefined;
|
||||
this.title = _data["title"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): ExamSummary {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new ExamSummary();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["id"] = this.id;
|
||||
data["createdTime"] = this.createdTime ? this.createdTime.toISOString() : <any>undefined;
|
||||
data["updatedTime"] = this.updatedTime ? this.updatedTime.toISOString() : <any>undefined;
|
||||
data["title"] = this.title;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 实验简要信息类(用于列表显示) */
|
||||
export interface IExamSummary {
|
||||
/** 实验的唯一标识符 */
|
||||
id: string;
|
||||
/** 实验创建时间 */
|
||||
createdTime: Date;
|
||||
/** 实验最后更新时间 */
|
||||
updatedTime: Date;
|
||||
/** 实验标题(从文档内容中提取) */
|
||||
title: string;
|
||||
}
|
||||
|
||||
/** 实验信息类 */
|
||||
export class ExamInfo implements IExamInfo {
|
||||
/** 实验的唯一标识符 */
|
||||
id!: string;
|
||||
/** 实验文档内容(Markdown格式) */
|
||||
docContent!: string;
|
||||
/** 实验创建时间 */
|
||||
createdTime!: Date;
|
||||
/** 实验最后更新时间 */
|
||||
updatedTime!: Date;
|
||||
|
||||
constructor(data?: IExamInfo) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.id = _data["id"];
|
||||
this.docContent = _data["docContent"];
|
||||
this.createdTime = _data["createdTime"] ? new Date(_data["createdTime"].toString()) : <any>undefined;
|
||||
this.updatedTime = _data["updatedTime"] ? new Date(_data["updatedTime"].toString()) : <any>undefined;
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): ExamInfo {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new ExamInfo();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["id"] = this.id;
|
||||
data["docContent"] = this.docContent;
|
||||
data["createdTime"] = this.createdTime ? this.createdTime.toISOString() : <any>undefined;
|
||||
data["updatedTime"] = this.updatedTime ? this.updatedTime.toISOString() : <any>undefined;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 实验信息类 */
|
||||
export interface IExamInfo {
|
||||
/** 实验的唯一标识符 */
|
||||
id: string;
|
||||
/** 实验文档内容(Markdown格式) */
|
||||
docContent: string;
|
||||
/** 实验创建时间 */
|
||||
createdTime: Date;
|
||||
/** 实验最后更新时间 */
|
||||
updatedTime: Date;
|
||||
}
|
||||
|
||||
/** 扫描结果类 */
|
||||
export class ScanResult implements IScanResult {
|
||||
/** 结果消息 */
|
||||
declare message: string;
|
||||
/** 更新的实验数量 */
|
||||
updateCount!: number;
|
||||
|
||||
constructor(data?: IScanResult) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.message = _data["message"];
|
||||
this.updateCount = _data["updateCount"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): ScanResult {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new ScanResult();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["message"] = this.message;
|
||||
data["updateCount"] = this.updateCount;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 扫描结果类 */
|
||||
export interface IScanResult {
|
||||
/** 结果消息 */
|
||||
message: string;
|
||||
/** 更新的实验数量 */
|
||||
updateCount: number;
|
||||
}
|
||||
|
||||
/** 逻辑分析仪运行状态枚举 */
|
||||
export enum CaptureStatus {
|
||||
None = 0,
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
工程界面
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="my-1 hover:translate-x-1 transition-all duration-300">
|
||||
<router-link to="/exam" class="text-base font-medium">
|
||||
<FileText class="icon" />
|
||||
实验列表
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="my-1 hover:translate-x-1 transition-all duration-300">
|
||||
<router-link to="/test" class="text-base font-medium">
|
||||
<FlaskConical class="icon" />
|
||||
|
|
|
@ -4,6 +4,7 @@ import AuthView from "../views/AuthView.vue";
|
|||
import ProjectView from "../views/Project/Index.vue";
|
||||
import TestView from "../views/TestView.vue";
|
||||
import UserView from "@/views/User/Index.vue";
|
||||
import ExamView from "@/views/ExamView.vue";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
@ -13,6 +14,7 @@ const router = createRouter({
|
|||
{ path: "/project", name: "project", component: ProjectView },
|
||||
{ path: "/test", name: "test", component: TestView },
|
||||
{ path: "/user", name: "user", component: UserView },
|
||||
{ path: "/exam", name: "exam", component: ExamView },
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
NetConfigClient,
|
||||
OscilloscopeApiClient,
|
||||
DebuggerClient,
|
||||
ExamClient,
|
||||
} from "@/APIClient";
|
||||
import axios, { type AxiosInstance } from "axios";
|
||||
|
||||
|
@ -31,7 +32,8 @@ type SupportedClient =
|
|||
| UDPClient
|
||||
| NetConfigClient
|
||||
| OscilloscopeApiClient
|
||||
| DebuggerClient;
|
||||
| DebuggerClient
|
||||
| ExamClient;
|
||||
|
||||
export class AuthManager {
|
||||
// 存储token到localStorage
|
||||
|
@ -190,6 +192,10 @@ export class AuthManager {
|
|||
return AuthManager.createAuthenticatedClient(DebuggerClient);
|
||||
}
|
||||
|
||||
public static createAuthenticatedExamClient(): ExamClient {
|
||||
return AuthManager.createAuthenticatedClient(ExamClient);
|
||||
}
|
||||
|
||||
// 登录函数
|
||||
public static async login(
|
||||
username: string,
|
||||
|
|
|
@ -0,0 +1,516 @@
|
|||
<template>
|
||||
<div class="exam-page">
|
||||
<div class="page-header">
|
||||
<h1>实验列表</h1>
|
||||
<div class="header-actions">
|
||||
<button @click="refreshExams" class="btn btn-primary" :disabled="loading">
|
||||
<i class="icon-refresh" :class="{ spinning: loading }"></i>
|
||||
刷新
|
||||
</button>
|
||||
<button v-if="isAdmin" @click="scanExams" class="btn btn-secondary" :disabled="scanning">
|
||||
<i class="icon-scan" :class="{ spinning: scanning }"></i>
|
||||
扫描实验
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-container">
|
||||
<div class="loading-spinner"></div>
|
||||
<p>正在加载实验列表...</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error" class="error-container">
|
||||
<div class="error-message">
|
||||
<i class="icon-error"></i>
|
||||
<h3>加载失败</h3>
|
||||
<p>{{ error }}</p>
|
||||
<button @click="refreshExams" class="btn btn-primary">重试</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="exam-list">
|
||||
<div v-if="exams.length === 0" class="empty-state">
|
||||
<i class="icon-empty"></i>
|
||||
<h3>暂无实验</h3>
|
||||
<p>当前没有可用的实验,请联系管理员添加实验内容。</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="exam-grid">
|
||||
<div
|
||||
v-for="exam in exams"
|
||||
:key="exam.id"
|
||||
class="exam-card"
|
||||
@click="viewExam(exam.id)"
|
||||
>
|
||||
<div class="exam-card-header">
|
||||
<h3 class="exam-title">{{ exam.title || exam.id }}</h3>
|
||||
<span class="exam-id">{{ exam.id }}</span>
|
||||
</div>
|
||||
<div class="exam-card-content">
|
||||
<div class="exam-meta">
|
||||
<div class="meta-item">
|
||||
<i class="icon-calendar"></i>
|
||||
<span>创建时间:{{ formatDate(exam.createdTime) }}</span>
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<i class="icon-clock"></i>
|
||||
<span>更新时间:{{ formatDate(exam.updatedTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="exam-card-footer">
|
||||
<button class="btn btn-outline">查看详情</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 实验详情模态框 -->
|
||||
<div v-if="selectedExam" class="modal-overlay" @click="closeExamDetail">
|
||||
<div class="modal-content exam-detail" @click.stop>
|
||||
<div class="modal-header">
|
||||
<h2>{{ selectedExam.id }}</h2>
|
||||
<button @click="closeExamDetail" class="btn-close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="exam-info">
|
||||
<div class="info-row">
|
||||
<span class="label">实验ID:</span>
|
||||
<span class="value">{{ selectedExam.id }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">创建时间:</span>
|
||||
<span class="value">{{ formatDate(selectedExam.createdTime) }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span class="label">更新时间:</span>
|
||||
<span class="value">{{ formatDate(selectedExam.updatedTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="exam-content">
|
||||
<MarkdownRenderer :content="selectedExam.docContent" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 扫描结果提示 -->
|
||||
<div v-if="scanResult" class="toast" :class="{ show: showToast }">
|
||||
<i class="icon-success"></i>
|
||||
<span>{{ scanResult.message }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { AuthManager } from '@/utils/AuthManager'
|
||||
import { ExamClient, DataClient, type ExamSummary, type ExamInfo, type ScanResult } from '@/APIClient'
|
||||
import MarkdownRenderer from '@/components/MarkdownRenderer.vue'
|
||||
|
||||
// 响应式数据
|
||||
const exams = ref<ExamSummary[]>([])
|
||||
const selectedExam = ref<ExamInfo | null>(null)
|
||||
const loading = ref(false)
|
||||
const scanning = ref(false)
|
||||
const error = ref<string>('')
|
||||
const scanResult = ref<ScanResult | null>(null)
|
||||
const showToast = ref(false)
|
||||
const isAdmin = ref(false)
|
||||
|
||||
// 方法
|
||||
const checkAdminStatus = async () => {
|
||||
try {
|
||||
isAdmin.value = await AuthManager.verifyAdminAuth()
|
||||
} catch (err) {
|
||||
console.warn('无法验证管理员权限:', err)
|
||||
isAdmin.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const refreshExams = async () => {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
const client = AuthManager.createAuthenticatedExamClient()
|
||||
exams.value = await client.getExamList()
|
||||
} catch (err: any) {
|
||||
error.value = err.message || '获取实验列表失败'
|
||||
console.error('获取实验列表失败:', err)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const viewExam = async (examId: string) => {
|
||||
try {
|
||||
const client = AuthManager.createAuthenticatedExamClient()
|
||||
selectedExam.value = await client.getExam(examId)
|
||||
} catch (err: any) {
|
||||
error.value = err.message || '获取实验详情失败'
|
||||
console.error('获取实验详情失败:', err)
|
||||
}
|
||||
}
|
||||
|
||||
const closeExamDetail = () => {
|
||||
selectedExam.value = null
|
||||
}
|
||||
|
||||
const scanExams = async () => {
|
||||
scanning.value = true
|
||||
|
||||
try {
|
||||
const client = AuthManager.createAuthenticatedExamClient()
|
||||
scanResult.value = await client.scanExams()
|
||||
showToast.value = true
|
||||
setTimeout(() => {
|
||||
showToast.value = false
|
||||
}, 3000)
|
||||
|
||||
// 刷新实验列表
|
||||
await refreshExams()
|
||||
} catch (err: any) {
|
||||
error.value = err.message || '扫描实验失败'
|
||||
console.error('扫描实验失败:', err)
|
||||
} finally {
|
||||
scanning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (date: Date | string) => {
|
||||
const dateObj = typeof date === 'string' ? new Date(date) : date
|
||||
return dateObj.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
// 生命周期
|
||||
onMounted(async () => {
|
||||
await checkAdminStatus()
|
||||
await refreshExams()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.exam-page {
|
||||
padding: 20px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #e1e1e1;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
background-color: #545b62;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background-color: transparent;
|
||||
color: #007bff;
|
||||
border: 1px solid #007bff;
|
||||
}
|
||||
|
||||
.btn-outline:hover {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.loading-container, .error-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 300px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid #007bff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.error-message h3 {
|
||||
color: #dc3545;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.exam-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.exam-card {
|
||||
background: white;
|
||||
border: 1px solid #e1e1e1;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.exam-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.exam-card-header {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.exam-title {
|
||||
margin: 0 0 5px 0;
|
||||
color: #333;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.exam-id {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
background: #f8f9fa;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.exam-meta {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin-bottom: 5px;
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
max-width: 90vw;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.exam-detail {
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid #e1e1e1;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
padding: 0;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-close:hover {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.exam-info {
|
||||
background: #f8f9fa;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.exam-content {
|
||||
border: 1px solid #e1e1e1;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
margin-bottom: 10px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
background: #28a745;
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
transform: translateX(100%);
|
||||
transition: transform 0.3s;
|
||||
z-index: 1001;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.toast.show {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.spinning {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* 深色主题适配 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.exam-page {
|
||||
background: #1a1a1a;
|
||||
color: #e1e1e1;
|
||||
}
|
||||
|
||||
.exam-card {
|
||||
background: #2d2d2d;
|
||||
border-color: #404040;
|
||||
color: #e1e1e1;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: #2d2d2d;
|
||||
color: #e1e1e1;
|
||||
}
|
||||
|
||||
.exam-info {
|
||||
background: #404040;
|
||||
}
|
||||
|
||||
.exam-content {
|
||||
background: #2d2d2d;
|
||||
border-color: #404040;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue