-
Notifications
You must be signed in to change notification settings - Fork 3
简化代码 #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
简化代码 #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR simplifies the codebase by removing duplicate functionality and streamlining import logic. It eliminates redundant file handling and reduces complexity in Content-Disposition header management.
- Removed duplicate
rimetool/rimetool_core/main.pyfile that provided redundant functionality - Simplified import logic in GUI module by removing fallback mechanisms
- Hardcoded UTF-8 encoding for Content-Disposition headers while preserving commented ASCII fallback code
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| rimetool/rimetool_gui/new_app.py | Simplified import logic and Content-Disposition handling to use only UTF-8 encoding |
| rimetool/rimetool_core/main.py | Completely removed duplicate main.py file |
| pyproject.toml | Updated version number from 2.4.3 to 2.4.4 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # 若未来需要兼容极老旧浏览器(仅识别 filename 的 ASCII),可恢复以下逻辑: | ||
| # try: | ||
| # original_filename.encode('ascii') | ||
| # response.headers["Content-Disposition"] = f'attachment; filename="{original_filename}"' | ||
| # logger.info(f"文件名使用ASCII编码: {original_filename}") | ||
| # except UnicodeEncodeError: | ||
| # encoded_filename = quote(original_filename) | ||
| # response.headers["Content-Disposition"] = f"attachment; filename*=UTF-8''{encoded_filename}" | ||
| # logger.info(f"设置UTF-8编码文件名: {encoded_filename}") |
Copilot
AI
Oct 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider removing the large commented code block instead of keeping it inline. If this fallback logic needs to be preserved, move it to documentation or version control history to maintain code readability.
| # 若未来需要兼容极老旧浏览器(仅识别 filename 的 ASCII),可恢复以下逻辑: | |
| # try: | |
| # original_filename.encode('ascii') | |
| # response.headers["Content-Disposition"] = f'attachment; filename="{original_filename}"' | |
| # logger.info(f"文件名使用ASCII编码: {original_filename}") | |
| # except UnicodeEncodeError: | |
| # encoded_filename = quote(original_filename) | |
| # response.headers["Content-Disposition"] = f"attachment; filename*=UTF-8''{encoded_filename}" | |
| # logger.info(f"设置UTF-8编码文件名: {encoded_filename}") | |
| # 若未来需要兼容极老旧浏览器(仅识别 filename 的 ASCII),可从版本控制历史恢复相关逻辑。 |
这个改动也挺好,加上 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
主要更新
rimetool/rimetool_core/main.py, 目前负责传入参数、命令行操作的是rimetool/main.pyrimetool/rimetool_gui/new_app.py里importrimetool/main.py相关的代码,写死了rimetool/rimetool_gui/new_app.py里关于Content-Disposition相关的内容,写死为utf-8(因为我们的用户基本都使用现代的chromium、firefox,基本都支持UTF-8),但仍保留了 修复文件名乱码 #50 里完善好的同时支持utf-8和ASCII的代码(ASCII用于支持老浏览器),未来如果有需要就启用次要更新
更新pypi包版本号为2.4.4