[feat] 为添加课程页面提供更自由的时间选项#128
Conversation
- Added CustomClass and CustomClassTimeRange models for handling custom classes and their time ranges. - Introduced CustomClassController to manage the lifecycle of custom classes, including adding, editing, and deleting classes and their time ranges. - Updated ClassTableWidgetState to integrate custom class data and provide methods for managing custom classes. - Enhanced ClassCard to support displaying and interacting with custom classes. - Created CustomClassDetailCard for detailed view and actions on custom classes. - Implemented DateSelectorFree for selecting date ranges and time slots for classes. - Updated class organization logic to include custom classes in the timetable. - Refactored existing code to accommodate new custom class features and ensure smooth integration with the existing class table functionality.
…on desktop platform
BenderBlog
left a comment
There was a problem hiding this comment.
我接下来一周会忙其他的事情,所以您先慢慢改。现在没有发版本压力,所以不着急。
There was a problem hiding this comment.
其实我没有设计多时间段的卡片。用户点开的哪张卡片就会显示哪张卡片的时间细节(不过确实可以加上一个多时间段的显示,然后将当前点击的用高亮的方式展示,这样也不错)
Co-authored-by: Copilot <copilot@github.com>
…s file - Introduced a new `clearAll` method in `CustomClassController` to clear all custom class data. - Updated `CustomClassController` to filter out invalid entries when loading custom classes. - Removed the `UserDefinedClassFile` class and its associated methods, consolidating functionality into `CustomClassController`. - Updated various controllers and pages to utilize the new custom class management system. - Added a Swift model for custom classes to support iOS widget integration, and so did Android.
|
已经完成的工作:
剩余工作:
与原计划不同的地方: 我完全放弃了在添加课程界面对周重复索引的支持相关回复,由于新的数据结构使用的是 |
|
|
ContentClassTablePageState 这块,应该仅在热重载时候触发,对日常使用无影响。热重载时候先把输入课程信息页面退了吧。 |
好的,那我就这两天再改改 |
上面提到的先修改列表后写入文件,我觉得不太稳妥,因为文件是同步写入的,如果文件写入失败的话,列表就不会更新,这样可以一定程度上保证数据内容的一致。 然后我完成了将文件IO重构到repository的工作。 以下是更改总结,来自deepseek v4 pro: 提示词:
CustomClass 功能演进总结
一、提交概览本分支包含 14 个提交(11 个功能提交 + 3 次 main 合并),围绕自定义课程功能的实现、集成和重构展开。 1.1 功能提交(按时间顺序)
1.2 Main 分支合并
二、架构演进2.1 初始架构(d752d63e)
2.2 重构后架构(f1a59652 → 7c67974)关键变化:
2.3 数据流三、涉及文件3.1 新增文件
3.2 重大修改文件
四、代码质量评估4.1 优点
4.2 待改进
4.3 总体评价代码整体质量 良好。从初始实现到两轮重构,架构越来越清晰:
主要技术债务是 |
| } | ||
| } | ||
|
|
||
| @Serializable |
There was a problem hiding this comment.
记得 Kotlin 要想解析 Dart 的 Record 对象要这么搞?需要核实下面的代码。
There was a problem hiding this comment.
这块的映射应该是没问题的,虽然我不太懂kotlin代码,但是这个映射应该是没问题的:p
| @@ -165,14 +160,32 @@ struct ClassTableData : Codable { | |||
There was a problem hiding this comment.
需要观察接下来这玩意咋搞的,userDefinedDetail 现在已经作废了
There was a problem hiding this comment.
这块是没有清除干净的遗留代码,最新的推送中已经清除,由于没有ios,这边可能需要仔细调试一下
| var timeArrangement : [TimeArrangement] | ||
| var classChanges : [ClassChange] | ||
|
|
||
|
|
There was a problem hiding this comment.
这边可能真的需要您仔细调试一下了。。。。(ai率100%)
| userDefinedClassSignal.value = UserDefinedClassData.empty(); | ||
| ClassTableSession.deleteCache(); | ||
| UserDefinedClassFile.clearUserDefinedClass(); | ||
| unawaited(CustomClassController.i.clearAll()); |
There was a problem hiding this comment.
有必要上 unawaited 吗,需要看看这个控制器里面的方法。因为都是对小文件的读写,用同步方法没有任何问题。
There was a problem hiding this comment.
看情况吧,如果没问题也可以去掉,我觉得影响不大
| import 'package:watermeter/repository/custom_class_service.dart'; | ||
| import 'package:watermeter/repository/logger.dart'; | ||
|
|
||
| enum CustomClassState { fetching, fetched, error, none } |
There was a problem hiding this comment.
可能是的,状态机的思想,我只对这个思想稍微熟悉点:p(sz代码的耳濡目染)
| } | ||
|
|
||
| /// 通过周索引、日索引和学期开始日期来找到有日程的那天 | ||
| List<CustomClassOccurrence> getOccurrenceOfDay({ |
There was a problem hiding this comment.
这个相当于是对原有的ClassState的一个兼容,,


新增自定义课程类支持,包含对应的数据模型、控制器与界面集成;为所有支持的语言添加了月份翻译,并完善课程表相关的本地化文案;同时包含若干代码优化与问题修复(例如,使用散列空间更大的通知ID生成器)。
Closes: #116