Compare commits
2 Commits
6e5d3e64cd
...
ae94ced2d5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae94ced2d5 | ||
|
|
e1f4a4b91f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -46,6 +46,7 @@ backend/src/Health.WebApi/data-protection-keys/
|
||||
*.txt
|
||||
*.jpg
|
||||
*.png
|
||||
!backend/src/Health.WebApi/wwwroot/app-icon.png
|
||||
!health_app/assets/branding/*.png
|
||||
!health_app/android/app/src/main/res/drawable/launch_brand.png
|
||||
!health_app/android/app/src/main/res/drawable-v21/launch_brand.png
|
||||
|
||||
1
audit/2026-07-18-ui/00-current.xml
Normal file
1
audit/2026-07-18-ui/00-current.xml
Normal file
File diff suppressed because one or more lines are too long
@@ -16,25 +16,32 @@ public sealed class AdminService(AppDbContext db) : IAdminService
|
||||
|
||||
public async Task<AdminResult> AddDoctorAsync(AddDoctorCommand command, CancellationToken ct)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command.Phone)) return Error(40001, "手机号不能为空");
|
||||
if (string.IsNullOrWhiteSpace(command.Name)) return Error(40002, "姓名不能为空");
|
||||
var phone = command.Phone.Trim();
|
||||
var name = command.Name.Trim();
|
||||
if (string.IsNullOrWhiteSpace(phone)) return Error(40001, "手机号不能为空");
|
||||
if (string.IsNullOrWhiteSpace(name)) return Error(40002, "姓名不能为空");
|
||||
if (await _db.Users.AnyAsync(x => x.Phone == phone, ct) ||
|
||||
await _db.Doctors.AnyAsync(x => x.Phone == phone, ct))
|
||||
return Error(40003, "该手机号已被其他账号使用");
|
||||
|
||||
var doctor = new Doctor
|
||||
{
|
||||
Id = Guid.NewGuid(), Name = command.Name, Title = command.Title, Department = command.Department,
|
||||
Phone = command.Phone, ProfessionalDirection = command.ProfessionalDirection, IsActive = true, CreatedAt = DateTime.UtcNow,
|
||||
Id = Guid.NewGuid(), Name = name, Title = command.Title?.Trim(), Department = command.Department?.Trim(),
|
||||
Phone = phone, ProfessionalDirection = command.ProfessionalDirection?.Trim(), IsActive = true, CreatedAt = DateTime.UtcNow,
|
||||
};
|
||||
var user = new User
|
||||
{
|
||||
Id = Guid.NewGuid(), Phone = phone, Role = "Doctor", Name = name,
|
||||
CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
_db.Doctors.Add(doctor);
|
||||
if (!await _db.Users.AnyAsync(x => x.Phone == command.Phone, ct))
|
||||
{
|
||||
var user = new User { Id = Guid.NewGuid(), Phone = command.Phone, Role = "Doctor", Name = command.Name, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow };
|
||||
_db.Users.Add(user);
|
||||
_db.DoctorProfiles.Add(new DoctorProfile
|
||||
{
|
||||
Id = Guid.NewGuid(), UserId = user.Id, DoctorId = doctor.Id, Name = command.Name,
|
||||
Title = command.Title, Department = command.Department, IsActive = true,
|
||||
Id = Guid.NewGuid(), UserId = user.Id, DoctorId = doctor.Id, Name = name,
|
||||
Title = doctor.Title, Department = doctor.Department, IsActive = true,
|
||||
CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow,
|
||||
});
|
||||
}
|
||||
await _db.SaveChangesAsync(ct);
|
||||
return Ok(new { doctor.Id, doctor.Name });
|
||||
}
|
||||
@@ -43,11 +50,43 @@ public sealed class AdminService(AppDbContext db) : IAdminService
|
||||
{
|
||||
var doctor = await _db.Doctors.FindAsync([id], ct);
|
||||
if (doctor == null) return Error(404, "医生不存在");
|
||||
if (command.Name != null) doctor.Name = command.Name;
|
||||
if (command.Title != null) doctor.Title = command.Title;
|
||||
if (command.Department != null) doctor.Department = command.Department;
|
||||
if (command.Phone != null) doctor.Phone = command.Phone;
|
||||
if (command.ProfessionalDirection != null) doctor.ProfessionalDirection = command.ProfessionalDirection;
|
||||
var profile = await _db.DoctorProfiles.Include(x => x.User)
|
||||
.FirstOrDefaultAsync(x => x.DoctorId == id, ct);
|
||||
if (profile == null) return Error(40901, "医生登录资料不完整,请联系技术人员修复");
|
||||
|
||||
var user = profile.User;
|
||||
if (command.Phone != null)
|
||||
{
|
||||
var phone = command.Phone.Trim();
|
||||
if (phone.Length == 0) return Error(40001, "手机号不能为空");
|
||||
if (await _db.Users.AnyAsync(x => x.Id != user.Id && x.Phone == phone, ct) ||
|
||||
await _db.Doctors.AnyAsync(x => x.Id != id && x.Phone == phone, ct))
|
||||
return Error(40003, "该手机号已被其他账号使用");
|
||||
doctor.Phone = phone;
|
||||
user.Phone = phone;
|
||||
}
|
||||
if (command.Name != null)
|
||||
{
|
||||
var name = command.Name.Trim();
|
||||
if (name.Length == 0) return Error(40002, "姓名不能为空");
|
||||
doctor.Name = name;
|
||||
user.Name = name;
|
||||
profile.Name = name;
|
||||
}
|
||||
if (command.Title != null)
|
||||
{
|
||||
doctor.Title = command.Title.Trim();
|
||||
profile.Title = doctor.Title;
|
||||
}
|
||||
if (command.Department != null)
|
||||
{
|
||||
doctor.Department = command.Department.Trim();
|
||||
profile.Department = doctor.Department;
|
||||
}
|
||||
if (command.ProfessionalDirection != null)
|
||||
doctor.ProfessionalDirection = command.ProfessionalDirection.Trim();
|
||||
user.UpdatedAt = DateTime.UtcNow;
|
||||
profile.UpdatedAt = DateTime.UtcNow;
|
||||
await _db.SaveChangesAsync(ct);
|
||||
return Ok(new { doctor.Id });
|
||||
}
|
||||
@@ -56,7 +95,11 @@ public sealed class AdminService(AppDbContext db) : IAdminService
|
||||
{
|
||||
var doctor = await _db.Doctors.FindAsync([id], ct);
|
||||
if (doctor == null) return Error(404, "医生不存在");
|
||||
var profile = await _db.DoctorProfiles.FirstOrDefaultAsync(x => x.DoctorId == id, ct);
|
||||
if (profile == null) return Error(40901, "医生登录资料不完整,请联系技术人员修复");
|
||||
doctor.IsActive = !doctor.IsActive;
|
||||
profile.IsActive = doctor.IsActive;
|
||||
profile.UpdatedAt = DateTime.UtcNow;
|
||||
await _db.SaveChangesAsync(ct);
|
||||
return Ok(new { doctor.Id, doctor.IsActive });
|
||||
}
|
||||
@@ -65,7 +108,22 @@ public sealed class AdminService(AppDbContext db) : IAdminService
|
||||
{
|
||||
var doctor = await _db.Doctors.FindAsync([id], ct);
|
||||
if (doctor == null) return Error(404, "医生不存在");
|
||||
await _db.Users.Where(x => x.DoctorId == id).ExecuteUpdateAsync(s => s.SetProperty(x => x.DoctorId, (Guid?)null), ct);
|
||||
|
||||
if (await _db.Users.AnyAsync(x => x.Role == "User" && x.DoctorId == id, ct))
|
||||
return Error(40004, "该医生仍有绑定患者,请先停用,不能直接删除");
|
||||
if (await _db.Consultations.AnyAsync(x => x.DoctorId == id, ct))
|
||||
return Error(40005, "该医生已有问诊记录,只能停用,不能删除");
|
||||
|
||||
var profile = await _db.DoctorProfiles.Include(x => x.User)
|
||||
.FirstOrDefaultAsync(x => x.DoctorId == id, ct);
|
||||
if (profile != null)
|
||||
{
|
||||
var user = profile.User;
|
||||
var refreshTokens = await _db.RefreshTokens.Where(x => x.UserId == user.Id).ToListAsync(ct);
|
||||
_db.RefreshTokens.RemoveRange(refreshTokens);
|
||||
_db.DoctorProfiles.Remove(profile);
|
||||
_db.Users.Remove(user);
|
||||
}
|
||||
_db.Doctors.Remove(doctor);
|
||||
await _db.SaveChangesAsync(ct);
|
||||
return Ok(new { success = true });
|
||||
|
||||
@@ -105,6 +105,7 @@ public static class DoctorEndpoints
|
||||
doctorHospital = profile.Hospital,
|
||||
doctorAvatar = profile.AvatarUrl,
|
||||
doctorOnline = profile.IsOnline,
|
||||
doctorActive = profile.IsActive,
|
||||
stats = new { totalPatients, activeConsultations, pendingReports, todayFollowUps },
|
||||
pendingConsultations,
|
||||
pendingReports = pendingReportList,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
backend/src/Health.WebApi/wwwroot/app-icon.png
Normal file
BIN
backend/src/Health.WebApi/wwwroot/app-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
191
backend/tests/Health.Tests/admin_service_tests.cs
Normal file
191
backend/tests/Health.Tests/admin_service_tests.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
using Health.Application.Admin;
|
||||
using Health.Domain.Entities;
|
||||
using Health.Infrastructure.Admin;
|
||||
using Health.Infrastructure.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Health.Tests;
|
||||
|
||||
public sealed class AdminServiceTests
|
||||
{
|
||||
private static AppDbContext CreateDbContext()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseInMemoryDatabase(Guid.NewGuid().ToString())
|
||||
.Options;
|
||||
return new AppDbContext(options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddDoctor_CreatesDoctorLoginAndProfileTogether()
|
||||
{
|
||||
await using var db = CreateDbContext();
|
||||
var service = new AdminService(db);
|
||||
|
||||
var result = await service.AddDoctorAsync(
|
||||
new AddDoctorCommand("13800138001", "王医生", "主任医师", "心内科", "高血压"),
|
||||
CancellationToken.None);
|
||||
|
||||
Assert.Equal(0, result.Code);
|
||||
var doctor = await db.Doctors.SingleAsync();
|
||||
var user = await db.Users.SingleAsync();
|
||||
var profile = await db.DoctorProfiles.SingleAsync();
|
||||
Assert.Equal("Doctor", user.Role);
|
||||
Assert.Equal(doctor.Id, profile.DoctorId);
|
||||
Assert.Equal(user.Id, profile.UserId);
|
||||
Assert.Equal(doctor.Name, user.Name);
|
||||
Assert.Equal(doctor.Name, profile.Name);
|
||||
Assert.Equal(doctor.Title, profile.Title);
|
||||
Assert.Equal(doctor.Department, profile.Department);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddDoctor_RejectsAPhoneAlreadyUsedByAnyAccount()
|
||||
{
|
||||
await using var db = CreateDbContext();
|
||||
db.Users.Add(new User
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Phone = "13800138002",
|
||||
Role = "User",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
var service = new AdminService(db);
|
||||
|
||||
var result = await service.AddDoctorAsync(
|
||||
new AddDoctorCommand("13800138002", "李医生", null, null, null),
|
||||
CancellationToken.None);
|
||||
|
||||
Assert.NotEqual(0, result.Code);
|
||||
Assert.Empty(db.Doctors);
|
||||
Assert.Empty(db.DoctorProfiles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateDoctor_SynchronizesDoctorLoginAndProfile()
|
||||
{
|
||||
await using var db = CreateDbContext();
|
||||
var (doctor, user, profile) = await SeedDoctorAsync(db);
|
||||
var service = new AdminService(db);
|
||||
|
||||
var result = await service.UpdateDoctorAsync(
|
||||
doctor.Id,
|
||||
new UpdateDoctorCommand("13800138999", "新姓名", "副主任医师", "神经内科", "脑血管"),
|
||||
CancellationToken.None);
|
||||
|
||||
Assert.Equal(0, result.Code);
|
||||
Assert.Equal("13800138999", doctor.Phone);
|
||||
Assert.Equal("13800138999", user.Phone);
|
||||
Assert.Equal("新姓名", doctor.Name);
|
||||
Assert.Equal("新姓名", user.Name);
|
||||
Assert.Equal("新姓名", profile.Name);
|
||||
Assert.Equal("副主任医师", profile.Title);
|
||||
Assert.Equal("神经内科", profile.Department);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ToggleDoctor_SynchronizesAvailabilityButKeepsLoginEnabled()
|
||||
{
|
||||
await using var db = CreateDbContext();
|
||||
var (doctor, user, profile) = await SeedDoctorAsync(db);
|
||||
var service = new AdminService(db);
|
||||
|
||||
var result = await service.ToggleDoctorAsync(doctor.Id, CancellationToken.None);
|
||||
|
||||
Assert.Equal(0, result.Code);
|
||||
Assert.False(doctor.IsActive);
|
||||
Assert.False(profile.IsActive);
|
||||
Assert.Equal("Doctor", user.Role);
|
||||
Assert.NotNull(await db.Users.FindAsync(user.Id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteDoctor_IsRejectedWhilePatientsAreBound()
|
||||
{
|
||||
await using var db = CreateDbContext();
|
||||
var (doctor, user, profile) = await SeedDoctorAsync(db);
|
||||
db.Users.Add(new User
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Phone = "13800138088",
|
||||
Name = "患者",
|
||||
Role = "User",
|
||||
DoctorId = doctor.Id,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
var service = new AdminService(db);
|
||||
|
||||
var result = await service.DeleteDoctorAsync(doctor.Id, CancellationToken.None);
|
||||
|
||||
Assert.NotEqual(0, result.Code);
|
||||
Assert.NotNull(await db.Doctors.FindAsync(doctor.Id));
|
||||
Assert.NotNull(await db.Users.FindAsync(user.Id));
|
||||
Assert.NotNull(await db.DoctorProfiles.FindAsync(profile.Id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteUnusedDoctor_RemovesLoginProfileAndRefreshTokens()
|
||||
{
|
||||
await using var db = CreateDbContext();
|
||||
var (doctor, user, _) = await SeedDoctorAsync(db);
|
||||
db.RefreshTokens.Add(new RefreshToken
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
UserId = user.Id,
|
||||
Token = "refresh-token",
|
||||
ExpiresAt = DateTime.UtcNow.AddDays(1),
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
var service = new AdminService(db);
|
||||
|
||||
var result = await service.DeleteDoctorAsync(doctor.Id, CancellationToken.None);
|
||||
|
||||
Assert.Equal(0, result.Code);
|
||||
Assert.Empty(db.Doctors);
|
||||
Assert.Empty(db.DoctorProfiles);
|
||||
Assert.Empty(db.Users);
|
||||
Assert.Empty(db.RefreshTokens);
|
||||
}
|
||||
|
||||
private static async Task<(Doctor Doctor, User User, DoctorProfile Profile)> SeedDoctorAsync(AppDbContext db)
|
||||
{
|
||||
var doctor = new Doctor
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Phone = "13800138003",
|
||||
Name = "原姓名",
|
||||
Title = "医师",
|
||||
Department = "内科",
|
||||
IsActive = true,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
};
|
||||
var user = new User
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Phone = doctor.Phone,
|
||||
Name = doctor.Name,
|
||||
Role = "Doctor",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
};
|
||||
var profile = new DoctorProfile
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
DoctorId = doctor.Id,
|
||||
UserId = user.Id,
|
||||
Name = doctor.Name,
|
||||
Title = doctor.Title,
|
||||
Department = doctor.Department,
|
||||
IsActive = true,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
};
|
||||
db.AddRange(doctor, user, profile);
|
||||
await db.SaveChangesAsync();
|
||||
return (doctor, user, profile);
|
||||
}
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
# 小脉健康项目交接文档
|
||||
|
||||
更新时间:2026-07-16
|
||||
工作目录:`D:\health_project`
|
||||
当前分支:`main`
|
||||
|
||||
## 1. 项目当前阶段
|
||||
|
||||
项目主体已经完成,包括 Flutter App 和 .NET 后端。目前处于:
|
||||
|
||||
> Android 本地真机测试、功能稳定优化、前端 UI 统一、合规准备,以及等待正式环境和资质流程。
|
||||
|
||||
当前不是“马上提交应用商店审核”的状态。
|
||||
|
||||
- Android 一直以本地真机为主要测试平台。
|
||||
- iOS 代码已经合入并做过基础适配,但尚未完成本地真实 iPhone 的完整回归。
|
||||
- 后端及 H5 合规页面仍以本地环境为主,正式服务器、域名和 HTTPS 尚未最终切换。
|
||||
- 正式 API、数据库、JWT、短信、文件存储和 CORS 要在服务器及域名确定后统一配置。
|
||||
- 正式 Android keystore、发布签名、APK/AAB 仍取决于外部资质和正式配置交付。
|
||||
- 苹果开发者账号、证书、Bundle ID、签名和 TestFlight 权限仍取决于外部流程。
|
||||
- ICP、公安备案、软著、安全评估和应用市场账号等由外部继续推进。
|
||||
- 项目明确不使用 Docker,不要围绕 Docker 增加工作。
|
||||
|
||||
## 2. Git 与代码状态
|
||||
|
||||
- 当前分支:`main`,不要创建额外分支。
|
||||
- 当前提交:`5288596 merge: integrate sccsbc release preparation safely`。
|
||||
- `origin/main` 当前为 `fade61a`,本地 `main` 比远端多 6 个提交。
|
||||
- `sccsbc` 的 Apple 登录、上线准备和 Android 签名相关提交已经通过合并提交进入本地 `main`。
|
||||
- 合并采用“保留当前新版业务和 UI、吸收对方上线准备”的方式,没有用对方旧快照覆盖现有代码。
|
||||
- 当前工作区有大量未提交修改。这些包含用户现阶段 UI、iOS 适配和交互调整,不能执行 `git reset --hard`、`git checkout --` 或用旧分支覆盖。
|
||||
- 开始新修改前必须先查看 `git status` 和相关文件差异,只改当前任务涉及的代码。
|
||||
|
||||
当前主要未跟踪正式资源:
|
||||
|
||||
- `health_app/assets/branding/login_background_v2.png`
|
||||
- `health_app/assets/branding/drawer_background_v2.png`
|
||||
- `health_app/assets/branding/health_login_character_transparent.png`
|
||||
- `health_app/test/native_navigation_test.dart`
|
||||
|
||||
## 3. 用户的协作习惯
|
||||
|
||||
- 先用用户视角解释,不要堆技术术语。
|
||||
- 一次讨论一个明确问题,说明表现、原因和修改结果。
|
||||
- 用户说“先讨论”时不能直接修改。
|
||||
- 用户说“开始改”“动手”“去做”后直接实现,不要反复确认。
|
||||
- 不要擅自扩大范围,不要增加与当前目标无关的工作量。
|
||||
- 用户可能同时修改其他文件,必须保留并兼容用户改动。
|
||||
- 用户通常自己构建和安装;除非明确要求,不要运行耗时构建或安装。
|
||||
- 简单改动只做快速格式或静态检查,不要反复跑长测试。
|
||||
- 数据删除、注销、历史对话等操作必须对应真实后端结果,不能只改前端显示。
|
||||
- 修改聊天相关代码时,必须保证恢复历史对话后仍可继续聊天。
|
||||
|
||||
## 4. 已确认的 UI 方向
|
||||
|
||||
### 整体基调
|
||||
|
||||
- 首页现有品牌化紫色背景和整体结构基本保留。
|
||||
- 普通二级页面以白色内容区为主,使用极浅中性灰建立页面与内容组边界。
|
||||
- 不允许把模块颜色铺满整个页面、标题栏或大卡片。
|
||||
- 风格要求干净、克制、专业、柔和,避免大面积紫色、重橙色和过亮颜色。
|
||||
|
||||
### 列表
|
||||
|
||||
- 同一内容组内连续排列,不要每行单独套白卡片。
|
||||
- 分隔线只从文字区域开始,不贯穿左侧图标区域。
|
||||
- 删除背景默认完全隐藏,左滑后才显示。
|
||||
- 删除失败时不能提前从前端移除真实数据。
|
||||
|
||||
### 图标
|
||||
|
||||
- 全 App 图标样式必须统一,颜色可以按模块变化。
|
||||
- 优先使用同一套线性、圆润图标。
|
||||
- 同类列表的图标底座尺寸、圆角、图标尺寸和对齐保持一致。
|
||||
- 运动模块已统一使用更合适的跑步图标,修改时要同步首页今日健康、胶囊和运动页面等所有入口。
|
||||
|
||||
### 色彩
|
||||
|
||||
- 通用输入焦点、选中和品牌操作继续使用 App 紫色体系。
|
||||
- 模块色只用于模块识别、图标、状态和少量关键数字。
|
||||
- 成功、警告、错误和信息颜色必须按语义使用,不能与模块色混用。
|
||||
- 当前页面背景为 `#F3F5F8`,白色内容区用于建立层次。
|
||||
- 当前健康模块为克制青绿色体系;运动模块为蓝靛体系;用药模块保持原有蓝青色体系。
|
||||
- 今日健康异常状态已从偏黑的棕红色改为鲜明红橙色 `#E8562A`。
|
||||
|
||||
### 圆角、阴影和字体
|
||||
|
||||
- 所有圆角优先使用项目已有的 `AppRadius`,不要随手写不同圆角。
|
||||
- 卡片不能层层嵌套,也不能同时堆重描边和重阴影。
|
||||
- 不要随意缩小字体;列表紧凑但必须清楚可读。
|
||||
- 选中状态不能改变文字大小、字重或位置。
|
||||
- 为避免 Android 跟随系统楷书时粗体失控,项目已减少 `w800/w900` 的使用,主要层级使用 `w600/w700`。
|
||||
|
||||
完整基础规范见:`docs/ui-design-system.md`。实际逐页精修仍以真机截图和用户确认优先。
|
||||
|
||||
## 5. 最近完成的界面与交互修改
|
||||
|
||||
### 登录页
|
||||
|
||||
- 登录页使用新背景:`login_background_v2.png`。
|
||||
- 新背景去掉旧版气泡、玻璃方块和心电线,改为低饱和蓝紫柔光,中央保持安静。
|
||||
- App 图标继续使用原来的白底人物版本,没有继续使用错误生成的紫色底图标。
|
||||
- 登录页单独使用透明人物资源:`health_login_character_transparent.png`。
|
||||
- 登录键盘掉帧已针对性优化:
|
||||
- 背景使用独立重绘边界,键盘弹出时背景不重复重绘。
|
||||
- 删除原来每次键盘高度变化都会重启的 `AnimatedPadding`。
|
||||
- 表单改为轻量 `Transform.translate` 位移,最大抬升 150 px。
|
||||
- 下滑表单可以关闭键盘。
|
||||
- 这项键盘优化只做了格式和差异检查,尚未经过用户重新安装后的真机确认。
|
||||
- 透明人物由原人物参考生成并去除背景。用户非常重视人物不变形;需要真机确认其造型是否与原人物完全一致。如果仍有偏差,应使用确定性的抠图方式处理原图,不能再次重新设计人物。
|
||||
|
||||
### App 图标与启动页
|
||||
|
||||
- Android 和 iOS 已恢复原来的白底人物图标及周围小元素。
|
||||
- 已撤销错误的紫色底图标和重新生成的人物衍生图。
|
||||
- Flutter 启动页恢复使用 `health_splash_master.png`。
|
||||
- Android 原生启动图恢复使用原 `launch_brand.png`。
|
||||
- iOS AppIcon 和 LaunchImage 配置恢复引用原文件。
|
||||
|
||||
### 侧边栏
|
||||
|
||||
- 使用新背景:`drawer_background_v2.png`。
|
||||
- 背景改为顶部淡蓝紫、向下过渡白色,遮罩同步调轻。
|
||||
- 对话记录区域继续保留当前结构,不要因为“区域转换突然”擅自重排;用户认为类似蚂蚁阿福的结构可以接受。
|
||||
- 当前侧边栏仍是:系统整页拖拽关闭,只在中间对话流区域使用自定义右滑触发;智能体胶囊和输入区不应触发侧边栏。
|
||||
- 顶部菜单按钮仍可打开侧边栏。
|
||||
- 不要再次擅自改成推页式侧栏或另一套 Drawer 手势,除非用户重新明确要求。
|
||||
|
||||
### 首页和今日健康
|
||||
|
||||
- 首页整体结构用户基本满意,不要进行大面积重构。
|
||||
- 今日健康加载策略已调整,避免返回首页时先显示两行再闪成三行。
|
||||
- 健康概览图标已统一为“记数据”中使用的图标风格。
|
||||
- 跑步、用药等入口图标需与智能体胶囊保持同样样式。
|
||||
- 今日健康异常文字和右侧警告图标当前统一为 `#E8562A`。
|
||||
- 首页键盘布局保持原来的结构;上一轮误加的首页键盘悬浮布局已经撤回。
|
||||
|
||||
### 通知中心
|
||||
|
||||
- 通知列表重新压缩并调整信息布局。
|
||||
- 用户指定单行最低高度约 82 px,不要再次压到 68 px。
|
||||
- 标签和时间已重新安排,时间位于右侧区域,减少不必要的独立行。
|
||||
- 列表内容要保持视觉垂直居中。
|
||||
- 未读提醒区域不能使用大面积强紫色。
|
||||
|
||||
### 用药、运动、报告和设备
|
||||
|
||||
- 用药与运动列表的红色删除背景“提前露出”问题已处理过;后续修改需继续检查右侧红底不能浮出。
|
||||
- 运动计划列表已向用药、报告的连续列表形式统一,并补充前置运动图标。
|
||||
- 报告页面以靛紫色为模块识别,但“查看原始报告”不能使用突兀的大紫色实心按钮。
|
||||
- 蓝牙设备管理仅允许修改 UI,不得改变扫描、连接、自动读取、上传和解绑逻辑。
|
||||
- 蓝牙页右下角自动扫描动画必须保留,用于表达页面正在持续检测设备。
|
||||
|
||||
## 6. 功能与平台适配状态
|
||||
|
||||
### 已合并/已处理
|
||||
|
||||
- `sccsbc` 分支的 Apple 登录和部分上线准备代码已经合并。
|
||||
- Apple 登录前端按钮、服务端身份映射和相关迁移已进入当前代码历史。
|
||||
- Android 签名相关配置结构已合入,但真实 keystore、密码和正式证书不应写入 Git。
|
||||
- iOS 页面导航已加入原生风格返回适配相关测试文件,但尚未在真实 iPhone 全量验证。
|
||||
- iOS 与 Android 共用同一套 Flutter 业务页面;平台差异主要在权限、签名、Apple 登录和系统交互。
|
||||
- Android 本地电脑与手机同 Wi-Fi 的开发 API 地址方式继续保留;iPhone 真机调试时需要配置为电脑局域网 IP,而不是 `localhost`。
|
||||
|
||||
### 暂不投入的功能
|
||||
|
||||
- 医生端尚未正式完成。
|
||||
- 医患实时交流、问诊和随访目前不是近期上线重点。
|
||||
- 未启用的医生端、问诊和随访页面不需要继续做 UI 精修,也不要为它们扩大工作量。
|
||||
- 但已有页面和入口不能伪装成已经可用的正式医疗服务。
|
||||
|
||||
## 7. Apple 审核与医疗合规风险
|
||||
|
||||
苹果反馈涉及 Guideline 1.4.1 和 2.1,要求:
|
||||
|
||||
- 外接医疗硬件的监管批准材料。
|
||||
- 能证明 App 与硬件按描述工作的硬件测试报告或同行评议研究。
|
||||
- 在真实 Apple 设备上完成硬件首次配对和完整流程的演示视频。
|
||||
- 涉及医疗数据、诊断或治疗建议时提供相应监管批准文件。
|
||||
|
||||
当前本地测试主要使用欧姆龙 J735 血压计,但代码定位为通用 BLE 设备。后续必须在产品表述和审核材料之间作出一致选择:
|
||||
|
||||
- 如果继续声明支持医疗硬件,需要设备授权、监管文件、测试材料和真实 iPhone 演示。
|
||||
- 如果定位为个人健康记录工具,需要削弱“医疗服务、诊断、治疗建议、恢复健康”等可能触发医疗器械审查的表述,并明确 AI 仅提供一般健康信息,不替代医生。
|
||||
- 不要在没有材料时直接回复苹果称已经满足要求。
|
||||
|
||||
## 8. 正式环境前仍需完成
|
||||
|
||||
- 正式服务器、域名、HTTPS。
|
||||
- 正式数据库与备份方案。
|
||||
- 正式 JWT 密钥和密钥轮换。
|
||||
- 正式短信服务。
|
||||
- 正式文件/对象存储及删除策略。
|
||||
- 正式 CORS 白名单。
|
||||
- Android 正式 keystore、release 签名、APK/AAB。
|
||||
- Apple 开发者证书、Bundle ID、签名、TestFlight 真机流程。
|
||||
- 隐私政策、服务协议、个人信息清单、第三方 SDK 清单和关于我们的最终定稿。
|
||||
- ICP、公安备案、软著、安全评估及各应用市场账号。
|
||||
- Apple 医疗硬件与医疗建议相关审核材料或产品定位调整。
|
||||
|
||||
## 9. 当前验证情况
|
||||
|
||||
- 最近图片和 UI 修改只做了 `dart format`、`git diff --check`、资源引用和配置文件检查。
|
||||
- 用户明确要求不要反复运行耗时测试,因此最近没有执行完整 Flutter build、安装或全量回归。
|
||||
- Android 和 iOS 图标恢复后尚需用户重新构建查看系统桌面实际裁切。
|
||||
- 登录页透明人物、新背景和键盘流畅度尚需 Android 真机确认。
|
||||
- iOS 尚需真实 iPhone 验证 Apple 登录、蓝牙权限、页面侧滑返回、键盘和 TestFlight 包。
|
||||
|
||||
## 10. 下一窗口建议的第一步
|
||||
|
||||
1. 先运行 `git status --short`,确认用户是否又修改了文件。
|
||||
2. 不要回退当前工作区,不要重新合并 `sccsbc`。
|
||||
3. 让用户先安装当前 Android 包,优先确认:
|
||||
- 登录页透明人物是否仍保持原人物造型。
|
||||
- 登录键盘弹出是否明显更流畅,输入框是否始终可见。
|
||||
- App 图标是否恢复白底且人物显示完整。
|
||||
- 新登录背景和侧边栏背景在真机上的亮度与边界。
|
||||
- 今日健康异常红橙色是否清楚但不过重。
|
||||
4. 根据用户真机截图逐项微调,每次只改明确页面。
|
||||
5. 用户确认当前视觉效果后,再整理未使用的项目图片并提交代码;删除前必须确认没有 Android、iOS 或 Flutter 配置引用。
|
||||
|
||||
## 11. 禁止事项
|
||||
|
||||
- 不使用 Docker。
|
||||
- 不创建其他分支。
|
||||
- 不覆盖或回退用户正在修改的文件。
|
||||
- 不用旧快照替换当前 main。
|
||||
- 不在用户说“先讨论”时直接修改。
|
||||
- 不随意扩大到未启用的医生端、问诊和随访页面。
|
||||
- 不重新设计“小脉健康”人物形象,只允许适配背景、留白、尺寸和系统裁切。
|
||||
- 不为了 UI 修改蓝牙、聊天、删除、注销和历史恢复等业务逻辑。
|
||||
- 不声称构建、安装或真机验证成功,除非实际执行并看到结果。
|
||||
|
||||
219
docs/HANDOFF-2026-07-17.md
Normal file
219
docs/HANDOFF-2026-07-17.md
Normal file
@@ -0,0 +1,219 @@
|
||||
# 小脉健康项目交接报告(2026-07-17)
|
||||
|
||||
## 1. 本轮工作范围
|
||||
|
||||
本轮工作集中在以下三项:
|
||||
|
||||
1. 对医生端和管理员端进行患者端风格的轻量统一。
|
||||
2. 检查并修复医生、登录账号、医生资料之间的同步逻辑。
|
||||
3. 进行源码级逻辑检查和小范围自动化验证。
|
||||
|
||||
本轮没有生成 APK、没有进行真机或截图测试、没有启动 Web API、没有部署、没有推送远程代码,也没有修改真实数据库数据。
|
||||
|
||||
## 2. 医生端与管理员端 UI 改造
|
||||
|
||||
### 2.1 共用视觉层
|
||||
|
||||
新增后台共用展示组件:
|
||||
|
||||
- `health_app/lib/widgets/backoffice_ui.dart`
|
||||
- `health_app/lib/utils/backoffice_formatters.dart`
|
||||
- `health_app/lib/providers/backoffice_refresh_providers.dart`
|
||||
|
||||
统一内容包括:
|
||||
|
||||
- 使用患者端现有的紫蓝渐变和浅色页面背景。
|
||||
- 使用白色圆角卡片、轻边框和统一阴影。
|
||||
- 统一加载、空数据、加载失败和重试状态。
|
||||
- 统一管理员端、医生端侧边栏的选中态。
|
||||
- 对空姓名头像和不完整时间字符串进行安全展示。
|
||||
|
||||
### 2.2 医生端
|
||||
|
||||
已覆盖的主要页面:
|
||||
|
||||
- 工作台
|
||||
- 患者列表与患者详情
|
||||
- 问诊列表
|
||||
- 报告列表与报告详情
|
||||
- 随访列表与新增/编辑随访
|
||||
- 医生资料
|
||||
- 医生设置
|
||||
- 医生侧边栏
|
||||
|
||||
已修复的页面问题:
|
||||
|
||||
- “新建随访”以前会被路由器当成缺少 ID 的详情页,现在可以正常进入新建模式。
|
||||
- 新增或编辑随访后,返回列表会自动刷新。
|
||||
- 随访和报告日期不再直接强制截取 16 个字符,避免空值或短字符串导致 `RangeError`。
|
||||
- 空患者姓名不再因为直接读取第一个字符而导致崩溃。
|
||||
- 患者列表加载失败后不再反复自动请求。
|
||||
- 医生资料页面重建时不再反复覆盖用户正在编辑的输入内容。
|
||||
- 停用医生登录后,工作台显示“账号已停用,新患者暂时无法选择您”的提示。
|
||||
|
||||
### 2.3 管理员端
|
||||
|
||||
已覆盖的主要页面:
|
||||
|
||||
- 医生管理
|
||||
- 患者管理
|
||||
- 新增医生
|
||||
- 编辑医生
|
||||
- 管理员侧边栏
|
||||
|
||||
已修复的页面问题:
|
||||
|
||||
- 管理员接口失败时不再无限显示加载状态。
|
||||
- 医生列表增加“编辑”入口,复用新增医生表单。
|
||||
- 新增或编辑医生后,返回列表会自动刷新。
|
||||
- 停用和删除失败时显示后端返回的具体原因,不再静默失败。
|
||||
- 删除确认文案改为安全规则:有绑定患者或问诊记录时只能停用,不能删除。
|
||||
- 停用医生在管理员列表中继续显示“已停用”状态。
|
||||
|
||||
## 3. 医生账号三层数据同步
|
||||
|
||||
医生相关数据由以下三部分组成:
|
||||
|
||||
- `Doctor`:患者选择、医生展示和业务归属。
|
||||
- `User(Role=Doctor)`:医生登录账号。
|
||||
- `DoctorProfile`:医生端资料和医生实体关联。
|
||||
|
||||
本轮修改了 `backend/src/Health.Infrastructure/Admin/AdminService.cs`,规则如下。
|
||||
|
||||
### 3.1 新增医生
|
||||
|
||||
- 一次性创建 `Doctor`、医生登录 `User` 和 `DoctorProfile`。
|
||||
- 三者使用相同的手机号和姓名,并建立正确 ID 关联。
|
||||
- 手机号已被患者、医生或其他账号使用时拒绝新增。
|
||||
|
||||
### 3.2 编辑医生
|
||||
|
||||
- 手机号同步更新 `Doctor` 和登录 `User`。
|
||||
- 姓名同步更新 `Doctor`、登录 `User` 和 `DoctorProfile`。
|
||||
- 职称、科室同步更新 `Doctor` 和 `DoctorProfile`。
|
||||
- 专业方向更新到 `Doctor`。
|
||||
- 修改手机号前检查其他账号和医生是否已经占用。
|
||||
- 医生登录资料缺失时拒绝局部修改,避免继续扩大不一致数据。
|
||||
|
||||
### 3.3 停用医生
|
||||
|
||||
- 同步更新 `Doctor.IsActive` 和 `DoctorProfile.IsActive`。
|
||||
- 医生登录账号保持 `Role=Doctor`,仍可正常登录并服务已绑定患者。
|
||||
- 患者与医生的原有绑定关系保持不变。
|
||||
- 公开医生列表原本已经只查询 `Doctor.IsActive == true`,因此新患者注册时不会再看到已停用医生。
|
||||
- 注册接口原本已经再次校验医生必须有效且启用。
|
||||
|
||||
### 3.4 删除医生
|
||||
|
||||
- 医生仍有绑定患者时拒绝删除。
|
||||
- 医生已有问诊记录时拒绝删除。
|
||||
- 无绑定患者和问诊记录时,删除 `Doctor`、对应登录 `User`、`DoctorProfile` 和刷新令牌。
|
||||
- 有历史数据的医生应使用“停用”,不应通过物理删除清理。
|
||||
|
||||
## 4. 自动化验证
|
||||
|
||||
本轮最终验证结果:
|
||||
|
||||
- `flutter analyze`:通过,零问题。
|
||||
- 后端 `Health.Tests`:56 项通过,0 项失败,0 项跳过。
|
||||
- 医生/管理员 UI、路由和刷新相关测试:通过。
|
||||
|
||||
新增或更新的测试包括:
|
||||
|
||||
- `backend/tests/Health.Tests/admin_service_tests.cs`
|
||||
- `health_app/test/backoffice_ui_test.dart`
|
||||
- `health_app/test/backoffice_formatters_test.dart`
|
||||
- `health_app/test/backoffice_refresh_test.dart`
|
||||
- `health_app/test/app_router_test.dart`
|
||||
|
||||
说明:`dotnet test` 会自动编译测试程序集,但本轮没有执行发布构建,没有生成 Android APK/AAB,也没有执行 iOS 构建。
|
||||
|
||||
## 5. 数据库核对结果
|
||||
|
||||
本轮只进行了只读连接检查,没有修改数据库。
|
||||
|
||||
- 项目本地配置指向 `localhost:5432 / health_manager`。
|
||||
- 本机 PostgreSQL 没有运行,因此无法读取本地实际数据。
|
||||
- 开发 API `http://10.4.237.12:5000` 当前无法连接。
|
||||
- 正式 API `https://erpapi.datalumina.cn/xiaomai/api/doctors` 可以访问,但公开接口返回的启用医生数量为 0。
|
||||
- 交接资料显示正式数据库和备份方案尚未最终配置。
|
||||
|
||||
因此目前无法确认数据库中是否已经存在以下旧数据问题:
|
||||
|
||||
- `Doctor` 存在但没有医生登录 `User`。
|
||||
- `DoctorProfile` 缺失或关联错误。
|
||||
- 三层手机号、姓名或启用状态不一致。
|
||||
- 重复医生手机号。
|
||||
- 患者 `DoctorId` 指向不存在的医生。
|
||||
|
||||
新代码可以防止以后继续产生这些不一致,但不会自动修改已有数据。获得生产 PostgreSQL 只读连接或实际数据库备份后,应单独执行数据核对。
|
||||
|
||||
## 6. 仍未解决的高优先级问题
|
||||
|
||||
### P0:固定管理员验证码
|
||||
|
||||
`backend/src/Health.Infrastructure/Auth/AuthService.cs` 仍保留固定管理员手机号和固定验证码 `000000`。上线前必须移除,管理员需要使用受控的创建和认证方式。
|
||||
|
||||
### P0:短信服务仍是开发实现
|
||||
|
||||
`backend/src/Health.Infrastructure/Services/sms_service.cs` 只向服务端控制台输出验证码,没有接入真实短信服务。生产环境不会把验证码返回 App,因此普通用户无法正常接收验证码。
|
||||
|
||||
### P0:问诊 SignalR Hub 未鉴权
|
||||
|
||||
`backend/src/Health.WebApi/Hubs/ConsultationHub.cs` 没有强制 JWT 身份验证,也没有校验用户或医生是否属于指定问诊。调用者可以传入 `senderType` 和 `senderName`,存在加入其他问诊、伪造医生消息和写入数据库的风险。
|
||||
|
||||
### P1:医生聊天错误复用患者聊天流程
|
||||
|
||||
医生问诊列表进入的 `DoctorChatPage` 复用了患者端 `consultationChatProvider`:
|
||||
|
||||
- 把问诊 ID 当成医生 ID。
|
||||
- 调用患者配额接口。
|
||||
- 尝试创建新问诊。
|
||||
- 发送消息时使用患者身份。
|
||||
- 医生需要回复的 `WaitingDoctor` 状态反而不能发送。
|
||||
|
||||
医生实时问诊目前不能视为可用功能。需要拆分独立医生聊天 Provider 和页面,并与 Hub 鉴权一起处理。
|
||||
|
||||
### P1:AI SSE 鉴权和上传文件隐私
|
||||
|
||||
此前检查发现:
|
||||
|
||||
- AI SSE 接口允许从 query token 中直接读取 JWT claims,没有完整验证签名、签发者、受众和有效期。
|
||||
- 上传的医疗图片和报告通过 `/uploads` 静态公开访问。
|
||||
- 附件本地路径解析缺少完整的目录边界和文件归属校验。
|
||||
- CORS 当前允许任意来源并携带凭据。
|
||||
|
||||
这些问题应在正式上线前统一修复。
|
||||
|
||||
### P1:iOS 蓝牙流程仍需修复和真机验证
|
||||
|
||||
此前检查发现 iOS 页面仍请求 Android 风格蓝牙权限,并调用仅 Android 支持的 `FlutterBluePlus.turnOn()`。iOS Pods 也需要在 macOS 上重新安装并验证。当前 Windows 环境不能证明 iOS 构建和真机蓝牙可用。
|
||||
|
||||
## 7. Apple 医疗硬件审核准备
|
||||
|
||||
如果首版明确只支持欧姆龙 J735,建议准备:
|
||||
|
||||
- J735 当前有效的医疗器械注册或批准材料。
|
||||
- 小脉健康 App 与 J735 的联调测试报告。
|
||||
- 真实 iPhone、J735 和当前版本 App 的完整配对及测量演示视频。
|
||||
- App、审核说明、兼容设备清单和宣传文案全部明确首版支持范围。
|
||||
|
||||
注册证只能证明血压计本身合规,不能替代 App 与硬件联调测试报告和演示视频。
|
||||
|
||||
## 8. 建议后续顺序
|
||||
|
||||
1. 修复固定管理员验证码并接入正式短信服务。
|
||||
2. 拆分医生聊天流程并为 SignalR Hub 增加 JWT、角色和问诊归属校验。
|
||||
3. 修复 AI SSE 鉴权、上传文件访问控制、路径边界和 CORS。
|
||||
4. 获得真实数据库只读连接,核对并修复旧医生账号数据。
|
||||
5. 在 macOS 和真实 iPhone 上修复并验证 iOS 蓝牙流程。
|
||||
6. 准备 J735 监管材料、联调报告和真实设备演示视频。
|
||||
7. 完成正式服务器、数据库、短信、对象存储、域名和 HTTPS 配置后,再进入发布构建和应用商店提交。
|
||||
|
||||
## 9. 当前操作边界
|
||||
|
||||
- 本轮代码修改和本交接报告均未进行新的 Git 提交或远程推送。
|
||||
- 没有执行数据库迁移。
|
||||
- 没有写入、更新或删除真实数据库数据。
|
||||
- 没有生成或上传发布安装包。
|
||||
- 没有启动需要额外关闭的前端或后端常驻服务。
|
||||
@@ -0,0 +1,73 @@
|
||||
# 医生端与管理员端 UI 统一设计
|
||||
|
||||
## 目标
|
||||
|
||||
在不改变现有业务流程、接口协议和导航结构的前提下,使医生端与管理员端的全部现有页面统一到患者端当前的视觉语言,并在修改过程中进行源码级逻辑检查。
|
||||
|
||||
## 范围
|
||||
|
||||
- 覆盖 `health_app/lib/pages/doctor/` 下全部现有页面。
|
||||
- 覆盖 `health_app/lib/pages/admin/` 下全部现有页面。
|
||||
- 覆盖医生端和管理员端侧边栏及其直接使用的共用展示组件。
|
||||
- 复用患者端已有的 `AppColors`、主题、卡片阴影、圆角、渐变和页面背景。
|
||||
- 检查前端状态处理、异步调用、空数据、错误反馈、导航和字段映射中的明显逻辑错误。
|
||||
- 检查后端与医生端、管理员端直接相关的鉴权、数据归属、参数验证和异常处理。
|
||||
|
||||
## 不在范围内
|
||||
|
||||
- 不新增医生端或管理员端业务功能。
|
||||
- 不修改 API 协议、数据库结构或现有权限规则,除非发现明确的高风险缺陷并经用户另行确认。
|
||||
- 不重做患者端。
|
||||
- 不截图、不做视觉回归平台、不进行真机测试或发布。
|
||||
- 不为了视觉统一进行无关的大规模重构。
|
||||
|
||||
## 视觉方案
|
||||
|
||||
### 页面骨架
|
||||
|
||||
- 页面使用患者端的浅灰背景和统一安全区处理。
|
||||
- 顶部标题栏保持轻量、透明或白色表面,标题、返回和菜单图标统一使用患者端文字颜色。
|
||||
- 页面内容统一使用 16 像素水平边距;主要区块之间保持稳定的 12–16 像素间距。
|
||||
|
||||
### 卡片与操作
|
||||
|
||||
- 内容容器统一为白色圆角卡片,使用 `AppColors.borderLight` 和轻阴影。
|
||||
- 主操作使用患者端紫蓝主渐变;次操作使用浅色表面和边框;危险操作使用现有错误色。
|
||||
- 列表项、统计卡片、筛选控件、表单和弹窗使用同一套圆角、文字层级和状态色。
|
||||
- 医疗业务的警告、成功、待处理和异常状态继续保持语义颜色,不用装饰色覆盖含义。
|
||||
|
||||
### 状态反馈
|
||||
|
||||
- 加载状态保留明确进度反馈,避免空白页面。
|
||||
- 空状态说明当前没有数据,并保留用户可执行的下一步操作(如果原流程已有操作)。
|
||||
- 错误状态显示可理解的中文信息和重试入口(如果原页面已有重载能力)。
|
||||
- 长文本和动态数据使用弹性布局与省略处理,降低窄屏溢出风险。
|
||||
|
||||
## 组件边界
|
||||
|
||||
- 优先使用现有 `AppColors` 和 `AppTheme`,不建立第二套颜色系统。
|
||||
- 仅在多个医生端和管理员端页面确实重复时,新增小型共用展示组件,例如页面标题、区块卡片、状态占位和标签。
|
||||
- 共用组件只负责展示与交互外观,不持有业务状态、不直接调用服务。
|
||||
- 页面继续通过现有 Riverpod Provider 和 Service 获取数据,避免视觉改造改变数据流。
|
||||
|
||||
## 逻辑检查原则
|
||||
|
||||
- UI 改造过程中检查 `mounted`、重复提交、加载状态复位、空集合、空字段、分页/筛选和导航返回后的刷新。
|
||||
- 检查医生与管理员 API 是否要求正确角色,并验证用户或患者数据归属。
|
||||
- 明确的低风险页面错误可随 UI 修改修正;涉及鉴权、删除、隐私、医疗数据或接口行为的缺陷先记录并向用户说明,不擅自改变规则。
|
||||
- 已知的全局上线风险单独列入最终检查报告,不与本次视觉修改混在一起扩大范围。
|
||||
|
||||
## 验证
|
||||
|
||||
- 运行 `flutter analyze`。
|
||||
- 运行受修改页面影响的现有相关测试;不新增复杂测试框架。
|
||||
- 运行一次 Android 编译验证,确认 Flutter 与原生依赖能完成编译。
|
||||
- 不运行截图测试、真机测试、iOS 构建或发布流程。
|
||||
- 最终说明修改过的页面、发现的逻辑问题、验证结果和仍需人工确认的事项。
|
||||
|
||||
## 完成标准
|
||||
|
||||
- 医生端和管理员端全部现有页面在颜色、卡片、间距、按钮、文字层级和状态反馈上与患者端一致。
|
||||
- 原有页面入口、导航、数据加载和操作流程不被视觉改造改变。
|
||||
- 修改代码通过静态分析、相关测试和一次 Android 编译验证。
|
||||
- 逻辑检查结果按严重程度清晰列出,高风险业务问题没有未经确认的行为变更。
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB |
@@ -9,7 +9,7 @@ const String baseUrl = String.fromEnvironment(
|
||||
'API_BASE_URL',
|
||||
defaultValue: kReleaseMode
|
||||
? 'https://erpapi.datalumina.cn/xiaomai'
|
||||
: 'http://10.4.237.12:5000',
|
||||
: 'http://10.4.159.130:5000',
|
||||
);
|
||||
|
||||
class ApiException implements Exception {
|
||||
|
||||
@@ -57,7 +57,14 @@ Widget buildPage(RouteInfo route, WidgetRef ref) {
|
||||
case 'adminHome':
|
||||
return const AdminHomePage();
|
||||
case 'adminAddDoctor':
|
||||
return const AdminAddDoctorPage();
|
||||
return AdminAddDoctorPage(
|
||||
id: params['id'],
|
||||
initialPhone: params['phone'] ?? '',
|
||||
initialName: params['name'] ?? '',
|
||||
initialTitle: params['title'] ?? '',
|
||||
initialDepartment: params['department'] ?? '',
|
||||
initialDirection: params['direction'] ?? '',
|
||||
);
|
||||
case 'trend':
|
||||
return TrendPage(
|
||||
metricType: params['type']?.isNotEmpty == true ? params['type'] : null,
|
||||
@@ -109,8 +116,7 @@ Widget buildPage(RouteInfo route, WidgetRef ref) {
|
||||
final id = _requiredParam(params, 'id');
|
||||
return id == null ? _missingParamPage() : DoctorReportDetailPage(id: id);
|
||||
case 'doctorFollowUpEdit':
|
||||
final id = _requiredParam(params, 'id');
|
||||
return id == null ? _missingParamPage() : DoctorFollowUpEditPage(id: id);
|
||||
return DoctorFollowUpEditPage(id: params['id']);
|
||||
case 'devices':
|
||||
return const DeviceManagementPage();
|
||||
case 'deviceScan':
|
||||
|
||||
@@ -4,22 +4,51 @@ import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/data_providers.dart'
|
||||
show adminServiceProvider, doctorListProvider;
|
||||
import '../../providers/backoffice_refresh_providers.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
class AdminAddDoctorPage extends ConsumerStatefulWidget {
|
||||
const AdminAddDoctorPage({super.key});
|
||||
final String? id;
|
||||
final String initialPhone;
|
||||
final String initialName;
|
||||
final String initialTitle;
|
||||
final String initialDepartment;
|
||||
final String initialDirection;
|
||||
|
||||
const AdminAddDoctorPage({
|
||||
super.key,
|
||||
this.id,
|
||||
this.initialPhone = '',
|
||||
this.initialName = '',
|
||||
this.initialTitle = '',
|
||||
this.initialDepartment = '',
|
||||
this.initialDirection = '',
|
||||
});
|
||||
@override
|
||||
ConsumerState<AdminAddDoctorPage> createState() => _AdminAddDoctorPageState();
|
||||
}
|
||||
|
||||
class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
final _phoneCtrl = TextEditingController();
|
||||
final _nameCtrl = TextEditingController();
|
||||
final _titleCtrl = TextEditingController();
|
||||
final _deptCtrl = TextEditingController();
|
||||
final _directionCtrl = TextEditingController();
|
||||
late final TextEditingController _phoneCtrl;
|
||||
late final TextEditingController _nameCtrl;
|
||||
late final TextEditingController _titleCtrl;
|
||||
late final TextEditingController _deptCtrl;
|
||||
late final TextEditingController _directionCtrl;
|
||||
bool _saving = false;
|
||||
|
||||
bool get _isEdit => widget.id?.isNotEmpty == true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_phoneCtrl = TextEditingController(text: widget.initialPhone);
|
||||
_nameCtrl = TextEditingController(text: widget.initialName);
|
||||
_titleCtrl = TextEditingController(text: widget.initialTitle);
|
||||
_deptCtrl = TextEditingController(text: widget.initialDepartment);
|
||||
_directionCtrl = TextEditingController(text: widget.initialDirection);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneCtrl.dispose();
|
||||
@@ -41,21 +70,35 @@ class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
}
|
||||
setState(() => _saving = true);
|
||||
try {
|
||||
await ref.read(adminServiceProvider).addDoctor({
|
||||
final data = {
|
||||
'phone': _phoneCtrl.text.trim(),
|
||||
'name': _nameCtrl.text.trim(),
|
||||
'title': _titleCtrl.text.trim(),
|
||||
'department': _deptCtrl.text.trim(),
|
||||
'professionalDirection': _directionCtrl.text.trim(),
|
||||
});
|
||||
};
|
||||
if (_isEdit) {
|
||||
await ref.read(adminServiceProvider).updateDoctor(widget.id!, data);
|
||||
} else {
|
||||
await ref.read(adminServiceProvider).addDoctor(data);
|
||||
}
|
||||
if (mounted) {
|
||||
ref.invalidate(doctorListProvider);
|
||||
AppToast.show(context, '添加成功', type: AppToastType.success);
|
||||
ref.read(adminDoctorsRefreshSignalProvider.notifier).trigger();
|
||||
AppToast.show(
|
||||
context,
|
||||
_isEdit ? '修改成功' : '添加成功',
|
||||
type: AppToastType.success,
|
||||
);
|
||||
popRoute(ref);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
AppToast.show(context, '添加失败: $e', type: AppToastType.error);
|
||||
AppToast.show(
|
||||
context,
|
||||
'${_isEdit ? '修改' : '添加'}失败: $e',
|
||||
type: AppToastType.error,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _saving = false);
|
||||
@@ -70,13 +113,14 @@ class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
title: const Text(
|
||||
'新增医生',
|
||||
style: TextStyle(color: AppColors.textPrimary),
|
||||
title: Text(
|
||||
_isEdit ? '编辑医生' : '新增医生',
|
||||
style: const TextStyle(color: AppColors.textPrimary),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.textPrimary),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
body: BackofficeSurface(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -103,15 +147,19 @@ class _AdminAddDoctorPageState extends ConsumerState<AdminAddDoctorPage> {
|
||||
),
|
||||
child: _saving
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
: const Text(
|
||||
'保存',
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
: Text(
|
||||
_isEdit ? '保存修改' : '保存',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/data_providers.dart' show adminServiceProvider;
|
||||
import '../../providers/backoffice_refresh_providers.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
|
||||
class AdminDoctorsPage extends ConsumerStatefulWidget {
|
||||
const AdminDoctorsPage({super.key});
|
||||
@@ -13,6 +16,7 @@ class AdminDoctorsPage extends ConsumerStatefulWidget {
|
||||
class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
List<Map<String, dynamic>> _doctors = [];
|
||||
bool _loading = true;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -21,25 +25,40 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
setState(() => _loading = true);
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
try {
|
||||
final res = await ref.read(adminServiceProvider).getDoctors();
|
||||
if (res['code'] == 0 && mounted) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
if (res['code'] == 0) {
|
||||
_doctors = List<Map<String, dynamic>>.from(res['data'] ?? []);
|
||||
} else {
|
||||
_error = res['message']?.toString() ?? '医生列表加载失败';
|
||||
}
|
||||
_loading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = '医生列表加载失败';
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _toggleActive(String id) async {
|
||||
try {
|
||||
await ref.read(adminServiceProvider).toggleDoctorActive(id);
|
||||
_load();
|
||||
} catch (_) {}
|
||||
await _load();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
AppToast.show(context, '状态修改失败:$e', type: AppToastType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _delete(String id) async {
|
||||
@@ -47,7 +66,7 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('确认删除'),
|
||||
content: const Text('删除后患者关联将被清除,确定吗?'),
|
||||
content: const Text('只有没有绑定患者和问诊记录的医生才能删除;有历史数据的医生请使用“停用”。'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
@@ -64,13 +83,20 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
if (ok == true) {
|
||||
try {
|
||||
await ref.read(adminServiceProvider).deleteDoctor(id);
|
||||
_load();
|
||||
} catch (_) {}
|
||||
await _load();
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
AppToast.show(context, '删除失败:$e', type: AppToastType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.listen(adminDoctorsRefreshSignalProvider, (previous, next) {
|
||||
if (previous != null && previous != next) _load();
|
||||
});
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.pageGrey,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
@@ -79,13 +105,14 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
child: const Icon(Icons.add, color: Colors.white),
|
||||
),
|
||||
body: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
? const BackofficeLoadingState(message: '正在加载医生')
|
||||
: _error != null
|
||||
? BackofficeErrorState(message: _error!, onRetry: _load)
|
||||
: _doctors.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'暂无医生',
|
||||
style: TextStyle(color: AppColors.textHint, fontSize: 16),
|
||||
),
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.medical_services_outlined,
|
||||
title: '暂无医生',
|
||||
description: '点击右下角按钮添加第一位医生',
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -93,14 +120,8 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
itemBuilder: (_, i) {
|
||||
final d = _doctors[i];
|
||||
final active = d['isActive'] != false;
|
||||
return Card(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: const BorderSide(color: AppColors.border),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -153,7 +174,7 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${d['title'] ?? ''} 路 ${d['department'] ?? ''}',
|
||||
'${d['title'] ?? ''} · ${d['department'] ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
@@ -172,10 +193,27 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (v) {
|
||||
if (v == 'edit') {
|
||||
pushRoute(
|
||||
ref,
|
||||
'adminAddDoctor',
|
||||
params: {
|
||||
'id': d['id']?.toString() ?? '',
|
||||
'phone': d['phone']?.toString() ?? '',
|
||||
'name': d['name']?.toString() ?? '',
|
||||
'title': d['title']?.toString() ?? '',
|
||||
'department': d['department']?.toString() ?? '',
|
||||
'direction':
|
||||
d['professionalDirection']?.toString() ??
|
||||
'',
|
||||
},
|
||||
);
|
||||
}
|
||||
if (v == 'toggle') _toggleActive(d['id']);
|
||||
if (v == 'delete') _delete(d['id']);
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
const PopupMenuItem(value: 'edit', child: Text('编辑')),
|
||||
PopupMenuItem(
|
||||
value: 'toggle',
|
||||
child: Text(active ? '停用' : '启用'),
|
||||
@@ -191,7 +229,6 @@ class _AdminDoctorsPageState extends ConsumerState<AdminDoctorsPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../widgets/admin_drawer.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
import 'admin_doctors_page.dart';
|
||||
import 'admin_patients_page.dart';
|
||||
|
||||
@@ -27,18 +28,20 @@ class AdminHomePage extends ConsumerWidget {
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
title: const Text(
|
||||
'系统管理',
|
||||
title: Text(
|
||||
page == 'patients' ? '患者管理' : '医生管理',
|
||||
style: TextStyle(color: AppColors.textPrimary),
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.textPrimary),
|
||||
),
|
||||
drawer: const AdminDrawer(),
|
||||
body: switch (page) {
|
||||
body: BackofficeSurface(
|
||||
child: switch (page) {
|
||||
'doctors' => const AdminDoctorsPage(),
|
||||
'patients' => const AdminPatientsPage(),
|
||||
_ => const AdminDoctorsPage(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../providers/data_providers.dart' show adminServiceProvider;
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
class AdminPatientsPage extends ConsumerStatefulWidget {
|
||||
const AdminPatientsPage({super.key});
|
||||
@@ -16,6 +18,7 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
int _page = 1;
|
||||
bool _loading = true;
|
||||
bool _loadingMore = false;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -35,13 +38,15 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_patients = [];
|
||||
_error = null;
|
||||
});
|
||||
}
|
||||
try {
|
||||
final res = await ref
|
||||
.read(adminServiceProvider)
|
||||
.getPatients(search: _searchCtrl.text.trim(), page: _page);
|
||||
if (res['code'] == 0 && mounted) {
|
||||
if (!mounted) return;
|
||||
if (res['code'] == 0) {
|
||||
final data = res['data'] as Map<String, dynamic>? ?? {};
|
||||
setState(() {
|
||||
_total = data['total'] ?? 0;
|
||||
@@ -54,12 +59,19 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
_loading = false;
|
||||
_loadingMore = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_loadingMore = false;
|
||||
_error = res['message']?.toString() ?? '患者列表加载失败';
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_loadingMore = false;
|
||||
_error = '患者列表加载失败';
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -123,13 +135,14 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
// 患者列表
|
||||
Expanded(
|
||||
child: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
? const BackofficeLoadingState(message: '正在加载患者')
|
||||
: _error != null
|
||||
? BackofficeErrorState(message: _error!, onRetry: _load)
|
||||
: _patients.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'暂无患者',
|
||||
style: TextStyle(color: AppColors.textHint, fontSize: 16),
|
||||
),
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.people_outline,
|
||||
title: '暂无患者',
|
||||
description: '注册患者会显示在这里',
|
||||
)
|
||||
: NotificationListener<ScrollNotification>(
|
||||
onNotification: (n) {
|
||||
@@ -152,20 +165,14 @@ class _AdminPatientsPageState extends ConsumerState<AdminPatientsPage> {
|
||||
);
|
||||
}
|
||||
final p = _patients[i];
|
||||
return Card(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
side: const BorderSide(color: AppColors.border),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: AppColors.iconBg,
|
||||
child: Text(
|
||||
p['name']?.toString().isNotEmpty == true
|
||||
? p['name']!.toString()[0]
|
||||
: '?',
|
||||
backofficeInitial(p['name']),
|
||||
style: const TextStyle(color: AppColors.primary),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _consListProvider = FutureProvider<List<Map<String, dynamic>>>((
|
||||
ref,
|
||||
@@ -18,11 +20,15 @@ class DoctorConsultationsPage extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final list = ref.watch(_consListProvider);
|
||||
return list.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => const Center(child: Text('加载失败')),
|
||||
loading: () => const BackofficeLoadingState(message: '正在加载问诊'),
|
||||
error: (_, _) => BackofficeErrorState(
|
||||
onRetry: () => ref.invalidate(_consListProvider),
|
||||
),
|
||||
data: (items) => items.isEmpty
|
||||
? const Center(
|
||||
child: Text('暂无问诊', style: TextStyle(color: AppColors.textHint)),
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.chat_bubble_outline,
|
||||
title: '暂无问诊',
|
||||
description: '患者发起问诊后会显示在这里',
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -31,22 +37,16 @@ class DoctorConsultationsPage extends ConsumerWidget {
|
||||
final c = items[i];
|
||||
final status = c['status'] ?? '';
|
||||
final msg = c['lastMessage'] as Map<String, dynamic>?;
|
||||
return Container(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColors.border),
|
||||
boxShadow: AppColors.cardShadowLight,
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: CircleAvatar(
|
||||
radius: 22,
|
||||
backgroundColor: AppColors.avatarBg,
|
||||
child: Text(
|
||||
(c['patientName'] ?? '?')[0],
|
||||
backofficeInitial(c['patientName']),
|
||||
style: const TextStyle(color: AppColors.primary),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
import '../doctor/doctor_home_page.dart' show doctorPageProvider;
|
||||
|
||||
final _dashboardProvider = FutureProvider<Map<String, dynamic>?>((ref) async {
|
||||
@@ -16,14 +18,14 @@ class DoctorDashboardPage extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final dash = ref.watch(_dashboardProvider);
|
||||
final hasProfile = dash is AsyncData && dash.value != null;
|
||||
final missingProfile = dash.hasValue && dash.value == null;
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => ref.refresh(_dashboardProvider.future),
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
if (!hasProfile)
|
||||
if (missingProfile)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
@@ -48,7 +50,7 @@ class DoctorDashboardPage extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => {},
|
||||
onTap: () => pushRoute(ref, 'doctorProfile'),
|
||||
child: const Text(
|
||||
'去完善',
|
||||
style: TextStyle(
|
||||
@@ -62,8 +64,10 @@ class DoctorDashboardPage extends ConsumerWidget {
|
||||
),
|
||||
|
||||
dash.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => const Center(child: Text('加载失败')),
|
||||
loading: () => const BackofficeLoadingState(message: '正在加载工作台'),
|
||||
error: (_, _) => BackofficeErrorState(
|
||||
onRetry: () => ref.invalidate(_dashboardProvider),
|
||||
),
|
||||
data: (data) => _buildContent(context, ref, data),
|
||||
),
|
||||
],
|
||||
@@ -80,6 +84,8 @@ class DoctorDashboardPage extends ConsumerWidget {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
if (data?['doctorActive'] == false)
|
||||
const BackofficeInactiveDoctorBanner(),
|
||||
// 统计卡片
|
||||
Row(
|
||||
children: [
|
||||
|
||||
@@ -4,7 +4,9 @@ import '../../core/app_colors.dart';
|
||||
import '../../core/app_theme.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../providers/backoffice_refresh_providers.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _ptsSimple = FutureProvider<List<Map<String, dynamic>>>((ref) async {
|
||||
final api = ref.read(apiClientProvider);
|
||||
@@ -74,7 +76,8 @@ class _DoctorFollowUpEditPageState
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
body: BackofficeSurface(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
const Text(
|
||||
@@ -102,6 +105,7 @@ class _DoctorFollowUpEditPageState
|
||||
_submitBtn(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -265,6 +269,7 @@ class _DoctorFollowUpEditPageState
|
||||
await api.post('/api/doctor/follow-ups', data: data);
|
||||
}
|
||||
if (mounted) {
|
||||
ref.read(doctorFollowupsRefreshSignalProvider.notifier).trigger();
|
||||
_snack(isEdit ? '修改成功' : '创建成功', ok: true);
|
||||
popRoute(ref);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../providers/backoffice_refresh_providers.dart';
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _fupRefresh = FutureProvider<String?>((ref) async {
|
||||
final api = ref.read(apiClientProvider);
|
||||
@@ -44,6 +47,10 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.listen(doctorFollowupsRefreshSignalProvider, (previous, next) {
|
||||
if (previous != null && previous != next) ref.invalidate(_fupRefresh);
|
||||
});
|
||||
final refresh = ref.watch(_fupRefresh);
|
||||
var items = ref.watch(_fupList);
|
||||
if (_filter == 'Upcoming') {
|
||||
items = items.where((f) => f['status'] == 'Upcoming').toList();
|
||||
@@ -79,16 +86,21 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
child: items.isEmpty && refresh.isLoading
|
||||
? const BackofficeLoadingState(message: '正在加载随访')
|
||||
: items.isEmpty && refresh.hasError
|
||||
? BackofficeErrorState(onRetry: () => ref.invalidate(_fupRefresh))
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => ref.refresh(_fupRefresh.future),
|
||||
child: items.isEmpty
|
||||
? ListView(
|
||||
children: const [
|
||||
SizedBox(height: 100),
|
||||
Center(
|
||||
child: Text(
|
||||
'暂无随访',
|
||||
style: TextStyle(color: AppColors.textHint),
|
||||
SizedBox(
|
||||
height: 360,
|
||||
child: BackofficeEmptyState(
|
||||
icon: Icons.event_note_outlined,
|
||||
title: '暂无随访',
|
||||
description: '新建的复查随访会显示在这里',
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -99,15 +111,9 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
itemBuilder: (_, i) {
|
||||
final f = items[i];
|
||||
final upcoming = f['status'] == 'Upcoming';
|
||||
return Container(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColors.border),
|
||||
boxShadow: AppColors.cardShadowLight,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -133,7 +139,9 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
? AppColors.warning
|
||||
: AppColors.success)
|
||||
.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(
|
||||
8,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
upcoming ? '待完成' : '已完成',
|
||||
@@ -149,7 +157,8 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${f['patientName'] ?? ''} · ${(f['scheduledAt'] ?? '').toString().substring(0, 16)}',
|
||||
'${f['patientName'] ?? ''} · '
|
||||
'${formatBackofficeDateTime(f['scheduledAt'])}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textHint,
|
||||
@@ -175,7 +184,9 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
onPressed: () => pushRoute(
|
||||
ref,
|
||||
'doctorFollowUpEdit',
|
||||
params: {'id': f['id']?.toString() ?? ''},
|
||||
params: {
|
||||
'id': f['id']?.toString() ?? '',
|
||||
},
|
||||
),
|
||||
child: const Text(
|
||||
'编辑',
|
||||
@@ -192,7 +203,9 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
);
|
||||
ref
|
||||
.read(_fupList.notifier)
|
||||
.markDone(f['id']?.toString() ?? '');
|
||||
.markDone(
|
||||
f['id']?.toString() ?? '',
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
'完成',
|
||||
@@ -211,7 +224,9 @@ class _DoctorFollowupsPageState extends ConsumerState<DoctorFollowupsPage> {
|
||||
);
|
||||
ref
|
||||
.read(_fupList.notifier)
|
||||
.remove(f['id']?.toString() ?? '');
|
||||
.remove(
|
||||
f['id']?.toString() ?? '',
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
'删除',
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../widgets/doctor_drawer.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
import 'doctor_dashboard_page.dart';
|
||||
import 'doctor_patients_page.dart';
|
||||
import 'doctor_consultations_page.dart';
|
||||
@@ -38,7 +39,7 @@ class DoctorHomePage extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
drawer: const DoctorDrawer(),
|
||||
body: _bodyFor(page),
|
||||
body: BackofficeSurface(child: _bodyFor(page)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _patientDetailProvider =
|
||||
FutureProvider.family<Map<String, dynamic>?, String>((ref, id) async {
|
||||
@@ -33,13 +35,20 @@ class DoctorPatientDetailPage extends ConsumerWidget {
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
),
|
||||
body: detail.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => const Center(child: Text('加载失败')),
|
||||
body: BackofficeSurface(
|
||||
child: detail.when(
|
||||
loading: () => const BackofficeLoadingState(message: '正在加载患者详情'),
|
||||
error: (_, _) => BackofficeErrorState(
|
||||
onRetry: () => ref.invalidate(_patientDetailProvider(id)),
|
||||
),
|
||||
data: (data) => data == null
|
||||
? const Center(child: Text('患者不存在'))
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.person_off_outlined,
|
||||
title: '患者不存在',
|
||||
)
|
||||
: _buildBody(data),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,7 +73,7 @@ class DoctorPatientDetailPage extends ConsumerWidget {
|
||||
radius: 28,
|
||||
backgroundColor: AppColors.avatarBg,
|
||||
child: Text(
|
||||
(profile['name'] ?? '患')[0],
|
||||
backofficeInitial(profile['name']),
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: AppColors.primary,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
class DoctorPatientsPage extends ConsumerStatefulWidget {
|
||||
const DoctorPatientsPage({super.key});
|
||||
@@ -17,6 +18,7 @@ class _DoctorPatientsPageState extends ConsumerState<DoctorPatientsPage> {
|
||||
bool _loading = false;
|
||||
bool _hasMore = true;
|
||||
int _total = 0;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -35,6 +37,7 @@ class _DoctorPatientsPageState extends ConsumerState<DoctorPatientsPage> {
|
||||
if (reset) {
|
||||
_page = 1;
|
||||
_patients.clear();
|
||||
_error = null;
|
||||
}
|
||||
setState(() => _loading = true);
|
||||
try {
|
||||
@@ -47,6 +50,7 @@ class _DoctorPatientsPageState extends ConsumerState<DoctorPatientsPage> {
|
||||
queryParameters: params,
|
||||
);
|
||||
final data = res.data['data'];
|
||||
if (!mounted) return;
|
||||
if (data != null) {
|
||||
final items =
|
||||
(data['items'] as List?)?.cast<Map<String, dynamic>>() ?? [];
|
||||
@@ -62,6 +66,7 @@ class _DoctorPatientsPageState extends ConsumerState<DoctorPatientsPage> {
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) setState(() => _error = '患者列表加载失败');
|
||||
} finally {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
@@ -115,16 +120,24 @@ class _DoctorPatientsPageState extends ConsumerState<DoctorPatientsPage> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
child: _patients.isEmpty && _loading
|
||||
? const BackofficeLoadingState(message: '正在加载患者')
|
||||
: _patients.isEmpty && _error != null
|
||||
? BackofficeErrorState(
|
||||
message: _error!,
|
||||
onRetry: () => _load(reset: true),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => _load(reset: true),
|
||||
child: _patients.isEmpty && !_loading
|
||||
? ListView(
|
||||
children: const [
|
||||
SizedBox(height: 100),
|
||||
Center(
|
||||
child: Text(
|
||||
'暂无患者数据',
|
||||
style: TextStyle(color: AppColors.textHint),
|
||||
SizedBox(
|
||||
height: 360,
|
||||
child: BackofficeEmptyState(
|
||||
icon: Icons.people_outline,
|
||||
title: '暂无患者数据',
|
||||
description: '与您关联的患者会显示在这里',
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -134,11 +147,18 @@ class _DoctorPatientsPageState extends ConsumerState<DoctorPatientsPage> {
|
||||
itemCount: _patients.length + (_hasMore ? 1 : 0),
|
||||
itemBuilder: (_, i) {
|
||||
if (i >= _patients.length) {
|
||||
_loadMore();
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
child: _loading
|
||||
? const CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
)
|
||||
: TextButton.icon(
|
||||
onPressed: _loadMore,
|
||||
icon: const Icon(Icons.expand_more),
|
||||
label: const Text('加载更多'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _docProfileProvider = FutureProvider<Map<String, dynamic>?>((ref) async {
|
||||
final api = ref.read(apiClientProvider);
|
||||
@@ -24,6 +25,7 @@ class _DoctorProfileEditPageState extends ConsumerState<DoctorProfileEditPage> {
|
||||
final _dept = TextEditingController();
|
||||
final _hosp = TextEditingController();
|
||||
bool _saving = false;
|
||||
bool _profileLoaded = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -52,15 +54,19 @@ class _DoctorProfileEditPageState extends ConsumerState<DoctorProfileEditPage> {
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
),
|
||||
body: prof.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => const Center(child: Text('加载失败')),
|
||||
body: BackofficeSurface(
|
||||
child: prof.when(
|
||||
loading: () => const BackofficeLoadingState(message: '正在加载个人信息'),
|
||||
error: (_, _) => BackofficeErrorState(
|
||||
onRetry: () => ref.invalidate(_docProfileProvider),
|
||||
),
|
||||
data: (d) {
|
||||
if (d != null) {
|
||||
if (d != null && !_profileLoaded) {
|
||||
_name.text = d['name'] ?? '';
|
||||
_title.text = d['title'] ?? '';
|
||||
_dept.text = d['department'] ?? '';
|
||||
_hosp.text = d['hospital'] ?? '';
|
||||
_profileLoaded = true;
|
||||
}
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -94,6 +100,7 @@ class _DoctorProfileEditPageState extends ConsumerState<DoctorProfileEditPage> {
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/app_toast.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _reportDetailProvider =
|
||||
FutureProvider.family<Map<String, dynamic>?, String>((ref, id) async {
|
||||
@@ -69,6 +71,7 @@ class _DoctorReportDetailPageState
|
||||
'recommendation': _recommendation,
|
||||
},
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() => _submitted = true);
|
||||
ref.invalidate(_reportDetailProvider(widget.id));
|
||||
if (mounted) {
|
||||
@@ -102,13 +105,20 @@ class _DoctorReportDetailPageState
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
),
|
||||
body: detail.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => const Center(child: Text('加载失败')),
|
||||
body: BackofficeSurface(
|
||||
child: detail.when(
|
||||
loading: () => const BackofficeLoadingState(message: '正在加载报告详情'),
|
||||
error: (_, _) => BackofficeErrorState(
|
||||
onRetry: () => ref.invalidate(_reportDetailProvider(widget.id)),
|
||||
),
|
||||
data: (data) => data == null
|
||||
? const Center(child: Text('报告不存在'))
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.description_outlined,
|
||||
title: '报告不存在',
|
||||
)
|
||||
: _buildBody(data),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,7 +149,7 @@ class _DoctorReportDetailPageState
|
||||
radius: 24,
|
||||
backgroundColor: AppColors.avatarBg,
|
||||
child: Text(
|
||||
(data['patientName'] ?? '?')[0],
|
||||
backofficeInitial(data['patientName']),
|
||||
style: const TextStyle(color: AppColors.primary),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../utils/backoffice_formatters.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
final _reportsProvider =
|
||||
FutureProvider.family<List<Map<String, dynamic>>, String>((
|
||||
@@ -62,29 +64,24 @@ class _DoctorReportsPageState extends ConsumerState<DoctorReportsPage> {
|
||||
),
|
||||
Expanded(
|
||||
child: reports.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => const Center(child: Text('加载失败')),
|
||||
data: (items) => items.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'暂无报告',
|
||||
style: TextStyle(color: AppColors.textHint),
|
||||
loading: () => const BackofficeLoadingState(message: '正在加载报告'),
|
||||
error: (_, _) => BackofficeErrorState(
|
||||
onRetry: () => ref.invalidate(_reportsProvider(_filter)),
|
||||
),
|
||||
data: (items) => items.isEmpty
|
||||
? const BackofficeEmptyState(
|
||||
icon: Icons.description_outlined,
|
||||
title: '暂无报告',
|
||||
description: '患者上传的待审核报告会显示在这里',
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: items.length,
|
||||
itemBuilder: (_, i) {
|
||||
final r = items[i];
|
||||
return Container(
|
||||
return BackofficeSectionCard(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColors.border),
|
||||
boxShadow: AppColors.cardShadowLight,
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Container(
|
||||
@@ -104,9 +101,8 @@ class _DoctorReportsPageState extends ConsumerState<DoctorReportsPage> {
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
subtitle: Text(
|
||||
'${r['category'] ?? ''} · ${r['createdAt'] ?? ''}'
|
||||
.replaceAll('T', ' ')
|
||||
.substring(0, 16),
|
||||
'${r['category'] ?? '未分类'} · '
|
||||
'${formatBackofficeDateTime(r['createdAt'])}',
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.chevron_right,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../widgets/backoffice_ui.dart';
|
||||
|
||||
class DoctorSettingsPage extends ConsumerWidget {
|
||||
const DoctorSettingsPage({super.key});
|
||||
@@ -20,7 +21,8 @@ class DoctorSettingsPage extends ConsumerWidget {
|
||||
onPressed: () => popRoute(ref),
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
body: BackofficeSurface(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_SettingTile(
|
||||
@@ -72,6 +74,7 @@ class DoctorSettingsPage extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1870,7 +1870,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
onTap: onTap,
|
||||
borderRadius: AppRadius.smBorder,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 5),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 7),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
14
health_app/lib/providers/backoffice_refresh_providers.dart
Normal file
14
health_app/lib/providers/backoffice_refresh_providers.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class BackofficeRefreshSignal extends Notifier<int> {
|
||||
@override
|
||||
int build() => 0;
|
||||
|
||||
void trigger() => state++;
|
||||
}
|
||||
|
||||
final adminDoctorsRefreshSignalProvider =
|
||||
NotifierProvider<BackofficeRefreshSignal, int>(BackofficeRefreshSignal.new);
|
||||
|
||||
final doctorFollowupsRefreshSignalProvider =
|
||||
NotifierProvider<BackofficeRefreshSignal, int>(BackofficeRefreshSignal.new);
|
||||
12
health_app/lib/utils/backoffice_formatters.dart
Normal file
12
health_app/lib/utils/backoffice_formatters.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
String formatBackofficeDateTime(Object? value) {
|
||||
final raw = value?.toString().trim() ?? '';
|
||||
if (raw.isEmpty) return '时间未知';
|
||||
|
||||
final normalized = raw.replaceFirst('T', ' ');
|
||||
return normalized.length <= 16 ? normalized : normalized.substring(0, 16);
|
||||
}
|
||||
|
||||
String backofficeInitial(Object? value) {
|
||||
final text = value?.toString().trim() ?? '';
|
||||
return text.isEmpty ? '?' : text.substring(0, 1);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class AdminDrawer extends ConsumerWidget {
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.doctorGradient,
|
||||
gradient: AppColors.primaryGradient,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: AppColors.buttonShadow,
|
||||
),
|
||||
@@ -145,7 +145,7 @@ class _MenuItem extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
gradient: selected
|
||||
? AppColors.doctorGradient
|
||||
? AppColors.primaryGradient
|
||||
: AppColors.surfaceGradient,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../core/app_design_tokens.dart';
|
||||
|
||||
class AppStatusBadge extends StatelessWidget {
|
||||
final String label;
|
||||
final Color color;
|
||||
final Color? backgroundColor;
|
||||
final IconData? icon;
|
||||
|
||||
const AppStatusBadge({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.color,
|
||||
this.backgroundColor,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Container(
|
||||
constraints: const BoxConstraints(minHeight: 24),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? color.withValues(alpha: 0.10),
|
||||
borderRadius: AppRadius.pillBorder,
|
||||
border: Border.all(color: color.withValues(alpha: 0.18)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 14, color: color),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
Text(label, style: AppTextStyles.tag.copyWith(color: color)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
225
health_app/lib/widgets/backoffice_ui.dart
Normal file
225
health_app/lib/widgets/backoffice_ui.dart
Normal file
@@ -0,0 +1,225 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../core/app_colors.dart';
|
||||
|
||||
/// Shared visual building blocks for doctor and administrator pages.
|
||||
///
|
||||
/// These widgets intentionally contain no business state so the back-office
|
||||
/// screens keep using their existing providers and services.
|
||||
class BackofficeSurface extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const BackofficeSurface({super.key, required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DecoratedBox(
|
||||
decoration: const BoxDecoration(gradient: AppColors.bgGradient),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BackofficeSectionCard extends StatelessWidget {
|
||||
final Widget child;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
|
||||
const BackofficeSectionCard({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.padding = const EdgeInsets.all(16),
|
||||
this.margin,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: margin,
|
||||
padding: padding,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.94),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: Colors.white),
|
||||
boxShadow: AppColors.cardShadowLight,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BackofficeLoadingState extends StatelessWidget {
|
||||
final String message;
|
||||
|
||||
const BackofficeLoadingState({super.key, this.message = '正在加载'});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: BackofficeSectionCard(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 28,
|
||||
height: 28,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.5,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(message, style: const TextStyle(color: AppColors.textHint)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BackofficeEmptyState extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String? description;
|
||||
final String? actionLabel;
|
||||
final VoidCallback? onAction;
|
||||
|
||||
const BackofficeEmptyState({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.description,
|
||||
this.actionLabel,
|
||||
this.onAction,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: BackofficeSectionCard(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 30),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.primaryLight,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 30, color: AppColors.primary),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
if (description != null) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
description!,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.5,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (actionLabel != null && onAction != null) ...[
|
||||
const SizedBox(height: 18),
|
||||
FilledButton(
|
||||
onPressed: onAction,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 22,
|
||||
vertical: 11,
|
||||
),
|
||||
),
|
||||
child: Text(actionLabel!),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BackofficeErrorState extends StatelessWidget {
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
const BackofficeErrorState({super.key, this.message = '加载失败', this.onRetry});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BackofficeEmptyState(
|
||||
icon: Icons.cloud_off_outlined,
|
||||
title: message,
|
||||
description: '请检查网络后重试',
|
||||
actionLabel: onRetry == null ? null : '重新加载',
|
||||
onAction: onRetry,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BackofficeInactiveDoctorBanner extends StatelessWidget {
|
||||
const BackofficeInactiveDoctorBanner({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.warningLight,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppColors.warning.withValues(alpha: 0.35)),
|
||||
),
|
||||
child: const Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(Icons.pause_circle_outline, color: AppColors.warningText),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'账号已停用',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.warningText,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 3),
|
||||
Text(
|
||||
'您仍可服务已绑定患者,但新患者暂时无法选择您。',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.4,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class _DrawerHeader extends StatelessWidget {
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.doctorGradient,
|
||||
gradient: AppColors.primaryGradient,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: AppColors.buttonShadow,
|
||||
),
|
||||
@@ -212,7 +212,7 @@ class _DrawerItem extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
gradient: selected
|
||||
? AppColors.doctorGradient
|
||||
? AppColors.primaryGradient
|
||||
: AppColors.surfaceGradient,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
|
||||
@@ -214,9 +214,9 @@ class _HealthDashboard extends StatelessWidget {
|
||||
),
|
||||
titleColor: Colors.white,
|
||||
backgroundGradient: const LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [Color(0xFF4FACFE), Color(0xFF00F2FE)],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFF89F7FE), Color(0xFF66A6FF)],
|
||||
),
|
||||
child: latestHealth.when(
|
||||
data: (data) => _DashboardMetrics(data: data, ref: ref),
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:health_app/core/app_router.dart';
|
||||
import 'package:health_app/core/navigation_provider.dart';
|
||||
import 'package:health_app/pages/report/report_pages.dart';
|
||||
import 'package:health_app/pages/doctor/doctor_followup_edit_page.dart';
|
||||
import 'package:health_app/pages/admin/admin_add_doctor_page.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -47,4 +49,51 @@ void main() {
|
||||
expect(page, isA<ReportListPage>());
|
||||
expect((page as ReportListPage).openUploadOnEnter, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('follow-up editor route supports create mode without an id', (
|
||||
tester,
|
||||
) async {
|
||||
late Widget page;
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
page = buildPage(const RouteInfo('doctorFollowUpEdit'), ref);
|
||||
return const MaterialApp(home: SizedBox());
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(page, isA<DoctorFollowUpEditPage>());
|
||||
expect((page as DoctorFollowUpEditPage).id, isNull);
|
||||
});
|
||||
|
||||
testWidgets('admin doctor form route supports edit mode', (tester) async {
|
||||
late Widget page;
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
page = buildPage(
|
||||
const RouteInfo(
|
||||
'adminAddDoctor',
|
||||
params: {
|
||||
'id': 'doctor-1',
|
||||
'phone': '13800138000',
|
||||
'name': '王医生',
|
||||
},
|
||||
),
|
||||
ref,
|
||||
);
|
||||
return const MaterialApp(home: SizedBox());
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(page, isA<AdminAddDoctorPage>());
|
||||
expect((page as AdminAddDoctorPage).id, 'doctor-1');
|
||||
expect((page as AdminAddDoctorPage).initialName, '王医生');
|
||||
});
|
||||
}
|
||||
|
||||
21
health_app/test/backoffice_formatters_test.dart
Normal file
21
health_app/test/backoffice_formatters_test.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:health_app/utils/backoffice_formatters.dart';
|
||||
|
||||
void main() {
|
||||
test('formats report time without assuming a minimum string length', () {
|
||||
expect(formatBackofficeDateTime(null), '时间未知');
|
||||
expect(formatBackofficeDateTime(''), '时间未知');
|
||||
expect(formatBackofficeDateTime('2026-07-17'), '2026-07-17');
|
||||
expect(
|
||||
formatBackofficeDateTime('2026-07-17T10:20:30Z'),
|
||||
'2026-07-17 10:20',
|
||||
);
|
||||
});
|
||||
|
||||
test('builds a safe avatar initial for empty or missing names', () {
|
||||
expect(backofficeInitial(null), '?');
|
||||
expect(backofficeInitial(''), '?');
|
||||
expect(backofficeInitial(' '), '?');
|
||||
expect(backofficeInitial('小脉'), '小');
|
||||
});
|
||||
}
|
||||
18
health_app/test/backoffice_refresh_test.dart
Normal file
18
health_app/test/backoffice_refresh_test.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:health_app/providers/backoffice_refresh_providers.dart';
|
||||
|
||||
void main() {
|
||||
test('back-office refresh signals advance independently', () {
|
||||
final container = ProviderContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
expect(container.read(adminDoctorsRefreshSignalProvider), 0);
|
||||
expect(container.read(doctorFollowupsRefreshSignalProvider), 0);
|
||||
|
||||
container.read(adminDoctorsRefreshSignalProvider.notifier).trigger();
|
||||
|
||||
expect(container.read(adminDoctorsRefreshSignalProvider), 1);
|
||||
expect(container.read(doctorFollowupsRefreshSignalProvider), 0);
|
||||
});
|
||||
}
|
||||
60
health_app/test/backoffice_ui_test.dart
Normal file
60
health_app/test/backoffice_ui_test.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:health_app/widgets/backoffice_ui.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('backoffice surface provides the shared patient-style canvas', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(home: BackofficeSurface(child: Text('内容'))),
|
||||
);
|
||||
|
||||
expect(find.text('内容'), findsOneWidget);
|
||||
expect(find.byType(DecoratedBox), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('empty state shows its message and optional action', (
|
||||
tester,
|
||||
) async {
|
||||
var tapped = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: BackofficeEmptyState(
|
||||
icon: Icons.people_outline,
|
||||
title: '暂无患者',
|
||||
description: '患者加入后会显示在这里',
|
||||
actionLabel: '刷新',
|
||||
onAction: () => tapped = true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('暂无患者'), findsOneWidget);
|
||||
expect(find.text('患者加入后会显示在这里'), findsOneWidget);
|
||||
await tester.tap(find.text('刷新'));
|
||||
expect(tapped, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('error state exposes a retry action', (tester) async {
|
||||
var retried = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(home: BackofficeErrorState(onRetry: () => retried = true)),
|
||||
);
|
||||
|
||||
expect(find.text('加载失败'), findsOneWidget);
|
||||
await tester.tap(find.text('重新加载'));
|
||||
expect(retried, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('inactive doctor banner explains the registration impact', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(home: BackofficeInactiveDoctorBanner()),
|
||||
);
|
||||
|
||||
expect(find.text('账号已停用'), findsOneWidget);
|
||||
expect(find.textContaining('新患者暂时无法选择您'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -16,8 +16,26 @@ echo.
|
||||
|
||||
echo [2/2] Starting .NET Backend...
|
||||
start "Backend" cmd /k "cd /d D:\health_project\backend\src\Health.WebApi && dotnet run"
|
||||
echo Waiting for backend...
|
||||
timeout /t 8 /nobreak >nul
|
||||
echo Waiting for backend readiness...
|
||||
set /a BACKEND_WAIT_SECONDS=0
|
||||
|
||||
:wait_backend
|
||||
powershell -NoProfile -NonInteractive -Command "try { $response = Invoke-WebRequest -UseBasicParsing -Uri 'http://127.0.0.1:5000/openapi/v1.json' -TimeoutSec 2; if ($response.StatusCode -eq 200) { exit 0 } } catch {}; exit 1" >nul 2>&1
|
||||
if not errorlevel 1 goto backend_ready
|
||||
set /a BACKEND_WAIT_SECONDS+=1
|
||||
if %BACKEND_WAIT_SECONDS% GEQ 30 goto backend_failed
|
||||
timeout /t 1 /nobreak >nul
|
||||
goto wait_backend
|
||||
|
||||
:backend_failed
|
||||
echo.
|
||||
echo ERROR: Backend failed to become ready within 30 seconds.
|
||||
echo Check the Backend window for the detailed error.
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:backend_ready
|
||||
echo Backend is ready at http://127.0.0.1:5000
|
||||
echo.
|
||||
|
||||
echo All done. Phone connects via WiFi to this PC.
|
||||
|
||||
Reference in New Issue
Block a user