合并一下 #29

Merged
p9o3yklam merged 7 commits from main into maziang 4 months ago

@ -4,6 +4,18 @@
格式基于 [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
版本遵循 [语义化版本](https://semver.org/spec/v2.0.0.html)。
库依赖:
- PyQt5
- python-docx
- PyPDF2
- requests
- beautifulsoup4
依赖地址:
- [PyQt5](https://pypi.org/project/PyQt5/)
- [python-docx](https://pypi.org/project/python-docx/)
- [PyPDF2](https://pypi.org/project/PyPDF2/)
- [requests](https://pypi.org/project/requests/)
- [beautifulsoup4](https://pypi.org/project/beautifulsoup4/)
## [0.1.0] - 2025-10-12
@ -42,4 +54,8 @@
- 云同步功能
- 社区功能和内容分享
[0.1.0]: https://github.com/your-repo/magicword/releases/tag/v0.1.0
## [0.2.0] - 2025-10-16
### 修复
- 页面更新到Microsoft Word

@ -1,35 +0,0 @@
# 使用说明
## 启动应用程序
### 方法一:使用启动脚本(推荐)
```bash
./run_app.sh
```
### 方法二直接运行Python代码
```bash
/usr/bin/python3 src/main.py
```
## 使用步骤
1. 启动应用程序后,点击顶部菜单栏的"文件"选项
2. 选择"打开"或使用快捷键 Ctrl+O
3. 在弹出的文件选择对话框中,选择您要练习的文本文件(支持 .txt 和 .docx 格式)
4. 选择文件后,文件内容将加载到应用程序中,但不会立即显示
5. 在底部的输入区域开始打字练习
6. 随着您的输入,文本内容会逐步显示在主显示区域
7. 应用程序会实时显示打字进度和准确率统计
## 功能说明
- **文本显示**:随着您的输入逐步显示文件内容
- **进度统计**显示WPM每分钟单词数和准确率
- **状态栏**:显示当前操作状态和文件信息
## 注意事项
- 请确保使用系统Python运行应用程序以避免Qt平台插件问题
- 应用程序设计为只有在用户输入时才显示文本内容,这是正常行为
- 支持的文件格式:.txt 和 .docx

@ -5,7 +5,7 @@ class FileParser:
@staticmethod
def parse_file(file_path: str) -> str:
# 验证文件路径
# 验证文件路径123
if not FileParser.validate_file_path(file_path):
raise ValueError(f"Invalid file path: {file_path}")

@ -74,12 +74,18 @@ class WordStyleMainWindow(QMainWindow):
def set_window_icon(self):
"""设置窗口图标"""
# 创建简单的Word风格图标
icon = QIcon()
pixmap = QPixmap(32, 32)
pixmap.fill(QColor("#2B579A"))
icon.addPixmap(pixmap)
self.setWindowIcon(icon)
# 使用我们创建的Word风格图标
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
icon_path = os.path.join(project_root, 'resources', 'icons', 'app_icon.png')
if os.path.exists(icon_path):
self.setWindowIcon(QIcon(icon_path))
else:
# 如果图标文件不存在创建简单的Word风格图标
icon = QIcon()
pixmap = QPixmap(32, 32)
pixmap.fill(QColor("#2B579A"))
icon.addPixmap(pixmap)
self.setWindowIcon(icon)
def setup_ui(self):
"""设置Word风格的UI界面"""
@ -513,8 +519,16 @@ class WordStyleMainWindow(QMainWindow):
"""保存文件"""
if self.current_file_path:
try:
with open(self.current_file_path, 'w', encoding='utf-8') as f:
f.write(self.text_edit.toPlainText())
# 如果是.docx文件创建一个基本的Word文档
if self.current_file_path.endswith('.docx'):
from docx import Document
doc = Document()
doc.add_paragraph(self.text_edit.toPlainText())
doc.save(self.current_file_path)
else:
# 对于其他格式,保持原有逻辑
with open(self.current_file_path, 'w', encoding='utf-8') as f:
f.write(self.text_edit.toPlainText())
self.is_modified = False
self.update_window_title()
@ -528,13 +542,25 @@ class WordStyleMainWindow(QMainWindow):
def save_as_file(self):
"""另存为"""
file_path, _ = QFileDialog.getSaveFileName(
self, "另存为", "", "文本文档 (*.txt);;所有文件 (*.*)"
self, "另存为", "", "Word文档 (*.docx);;文本文档 (*.txt);;所有文件 (*.*)"
)
if file_path:
# 如果用户没有指定扩展名,自动添加.docx扩展名
if not os.path.splitext(file_path)[1]:
file_path += ".docx"
try:
with open(file_path, 'w', encoding='utf-8') as f:
f.write(self.text_edit.toPlainText())
# 如果是.docx文件创建一个基本的Word文档
if file_path.endswith('.docx'):
from docx import Document
doc = Document()
doc.add_paragraph(self.text_edit.toPlainText())
doc.save(file_path)
else:
# 对于其他格式,保持原有逻辑
with open(file_path, 'w', encoding='utf-8') as f:
f.write(self.text_edit.toPlainText())
self.current_file_path = file_path
self.is_modified = False

Loading…
Cancel
Save