feat: 添加名单表格搜索筛选功能#240
Conversation
在点名表格和抽奖表格中添加搜索栏,支持按关键词实时筛选表格行。 - 点名表格:支持按学号、姓名、性别、小组、标签筛选 - 抽奖表格:支持按序号、奖品、权重、标签、数量筛选 - 使用 SearchLineEdit 组件,带防抖处理(300ms) - 添加中/英/日三语国际化翻译 - 刷新数据后自动重新应用搜索过滤 Closes SECTL#232
在点名历史记录和抽奖历史记录表格中添加导出按钮, 支持将当前表格数据导出为 xlsx、csv、txt 格式。 - 点名历史记录:支持导出全部记录、按时间查看、个人统计三种模式的数据 - 抽奖历史记录:支持导出全部记录、按时间查看、奖品统计三种模式的数据 - 导出内容与用户当前看到的表格一致(包括筛选和排序状态) - 添加中/英/日三语国际化翻译 - 添加 QFileDialog 翻译配置 Closes SECTL#232
| export_type = ( | ||
| "excel" | ||
| if "Excel 文件 (*.xlsx)" in selected_filter | ||
| else "csv" | ||
| if "CSV 文件 (*.csv)" in selected_filter | ||
| else "txt" | ||
| ) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| export_type = ( | ||
| "excel" | ||
| if "Excel 文件 (*.xlsx)" in selected_filter | ||
| else "csv" | ||
| if "CSV 文件 (*.csv)" in selected_filter | ||
| else "txt" | ||
| ) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
修复非中文语言环境下导出格式判断失败的问题。 将 'Excel 文件 (*.xlsx)' 改为 '.xlsx' 匹配, 确保所有语言下都能正确识别导出格式。
Signed-off-by: Hongbro886 <hongbroyier@gmail.com>
| content=get_any_position_value_async( | ||
| "notification", | ||
| "lottery", | ||
| "export", | ||
| "content", | ||
| "error", | ||
| "name", | ||
| ).format(message=str(e)), |
There was a problem hiding this comment.
Bug: The code calls .format() on the result of get_any_position_value_async without checking if it's None, causing a crash when a translation is missing for the user's language.
Severity: HIGH
Suggested Fix
Add a check to ensure the value returned from get_any_position_value_async is not None before calling .format() on it. Provide a default or fallback string if the translation is missing to prevent the crash. Additionally, add the missing "JA_JP" translations to the notification module in app/Language/modules/list_management.py to match the other modules.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: app/view/settings/history/lottery_history_table.py#L1117-L1124
Potential issue: The function `get_any_position_value_async` is used to retrieve
translation strings for notifications. It returns `None` if a translation for the
current language is not found. The code then calls the `.format()` method directly on
the return value of this function without a null check. The `notification` translation
module is missing the `"JA_JP"` (Japanese) language key. Consequently, when a user with
their language set to Japanese exports history, `get_any_position_value_async` returns
`None`, leading to an `AttributeError: 'NoneType' object has no attribute 'format'`.
This crash occurs in both the success and error handling paths, preventing the user from
seeing the export status notification.
Also affects:
app/view/settings/history/lottery_history_table.py:1093~1100app/view/settings/history/roll_call_history_table.py:1283~1290app/view/settings/history/roll_call_history_table.py:1259~1266
概述
实现 #232 请求的功能:在查看名单时添加搜索/筛选功能。
变更内容
新增功能
技术实现
SearchLineEdit组件(qfluentwidgets),与项目现有搜索组件风格一致ic_fluent_search_20_filled图标,与 Fluent Design 风格一致国际化
修改文件
app/view/settings/list_management/roll_call_table.py— 点名表格添加搜索功能app/view/settings/list_management/lottery_table.py— 抽奖表格添加搜索功能app/Language/modules/list_management.py— 添加搜索相关翻译截图
搜索栏位于班级/奖池选择器下方、表格上方,输入关键词即可实时筛选。
Closes #232