From e8210b4d88394daf085a8c74b3bcb108a7caa406 Mon Sep 17 00:00:00 2001 From: xiaji Date: Fri, 23 Jan 2026 14:12:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E5=B0=86playwright=E9=85=8D=E7=BD=AE=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=B8=BAchrome=E8=B7=AF=E5=BE=84=E9=85=8D=E7=BD=AE=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BD=BF=E7=94=A8=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新配置管理器、主窗口界面和使用说明文档,将原有的playwright目录配置改为chrome浏览器路径配置 --- .trae/skills/pyinstaller-one/SKILL.md | 26 +++++++------- config_manager.py | 8 ++--- main_window.py | 34 +++++++++---------- 使用说明.md | 49 +++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 34 deletions(-) create mode 100644 使用说明.md diff --git a/.trae/skills/pyinstaller-one/SKILL.md b/.trae/skills/pyinstaller-one/SKILL.md index 346babf..16a24c4 100644 --- a/.trae/skills/pyinstaller-one/SKILL.md +++ b/.trae/skills/pyinstaller-one/SKILL.md @@ -1,17 +1,17 @@ --- name: pyinstaller-one -description: 用pyinstaller打包,执行这个技能。 +description: 用pyinstaller打包时,执行这个技能。 --- -## 元数据 -name: pyinstaller个性化打包 -description: 打包的时候,要求生成为一个exe文件,使用ico等等 - -## 概述 -此 Skill 用于给有GUI界面的python代码,打包的时候,生成一个统一的要求:生成一个exe文件,去掉控制台窗口,使用本目录下的ico文件作为程序的图标。打包时,如果之前有打包过的文件(dist/build 文件夹),自动覆盖旧文件,不用手动确认,一键打包到底。 - -## 打包命令示例 -pyinstaller --onefile --noconsole --icon=图标文件名.ico --distpath=. --hidden-import=PySide6.Qt6Compat python程序名.py - -## 清除多余文件 -在windows环境下,执行clean.py \ No newline at end of file +## 元数据 +name: pyinstaller个性化打包 +description: 打包的时候,要求生成为一个exe文件,使用ico等等 + +## 概述 +此 Skill 用于给有GUI界面的python代码,打包的时候,生成一个统一的要求:生成一个exe文件,去掉控制台窗口,使用本目录下的ico文件作为程序的图标。打包时,如果之前有打包过的文件(dist/build 文件夹),自动覆盖旧文件,不用手动确认,一键打包到底。 + +## 打包命令示例 +pyinstaller --onefile --noconsole --icon=图标文件名.ico --distpath=. --hidden-import=PySide6.Qt6Compat python程序名.py + +## 清除多余文件 +在windows环境下,执行clean.py。 \ No newline at end of file diff --git a/config_manager.py b/config_manager.py index 2852498..94cf8d9 100644 --- a/config_manager.py +++ b/config_manager.py @@ -26,7 +26,7 @@ class ConfigManager: "fetch_interval": 60, "retry_times": 3, "retry_interval": 5, - "playwright_dir": "" + "chrome_path": "" }, "ui": { "opacity": 0.9, @@ -133,7 +133,7 @@ class ConfigManager: def update_spider(self, target_url: str = None, xpath: str = None, user_agent: str = None, fetch_interval: int = None, retry_times: int = None, retry_interval: int = None, - playwright_dir: str = None): + chrome_path: str = None): """更新爬虫配置""" if target_url: self.config["spider"]["target_url"] = target_url @@ -147,8 +147,8 @@ class ConfigManager: self.config["spider"]["retry_times"] = retry_times if retry_interval: self.config["spider"]["retry_interval"] = retry_interval - if playwright_dir: - self.config["spider"]["playwright_dir"] = playwright_dir + if chrome_path: + self.config["spider"]["chrome_path"] = chrome_path logger.info("爬虫配置已更新") self.save_config() diff --git a/main_window.py b/main_window.py index 86c2367..095d9cc 100644 --- a/main_window.py +++ b/main_window.py @@ -153,15 +153,15 @@ class ConfigDialog(QDialog): layout.addRow("User Agent:", self.user_agent_edit) layout.addRow("刷新间隔(s):", self.interval_spin) - # Playwright目录配置 - playwright_dir_layout = QHBoxLayout() - self.playwright_dir_edit = QLineEdit(spider_config.get('playwright_dir', '')) - self.playwright_dir_edit.setPlaceholderText("留空则自动查找Playwright浏览器") - self.playwright_browse_btn = QPushButton("浏览...") - self.playwright_browse_btn.clicked.connect(self._browse_playwright_dir) - playwright_dir_layout.addWidget(self.playwright_dir_edit) - playwright_dir_layout.addWidget(self.playwright_browse_btn) - layout.addRow("Playwright目录:", playwright_dir_layout) + # Chrome浏览器路径配置 + chrome_path_layout = QHBoxLayout() + self.chrome_path_edit = QLineEdit(spider_config.get('chrome_path', '')) + self.chrome_path_edit.setPlaceholderText("留空则自动查找Chrome浏览器") + self.chrome_browse_btn = QPushButton("浏览...") + self.chrome_browse_btn.clicked.connect(self._browse_chrome_path) + chrome_path_layout.addWidget(self.chrome_path_edit) + chrome_path_layout.addWidget(self.chrome_browse_btn) + layout.addRow("Chrome路径:", chrome_path_layout) # UI 配置 ui_config = self.config_manager.ui_config @@ -196,16 +196,16 @@ class ConfigDialog(QDialog): button_box.rejected.connect(self.reject) layout.addRow(button_box) - def _browse_playwright_dir(self): - """浏览Playwright目录""" - directory = QFileDialog.getExistingDirectory( + def _browse_chrome_path(self): + """浏览Chrome路径""" + file_path, _ = QFileDialog.getOpenFileName( self, - "选择Playwright浏览器目录", + "选择Chrome浏览器可执行文件", "", - QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks + "Chrome浏览器 (*.exe);;所有文件 (*.*)" ) - if directory: - self.playwright_dir_edit.setText(directory) + if file_path: + self.chrome_path_edit.setText(file_path) def _save_config(self): """保存配置""" @@ -223,7 +223,7 @@ class ConfigDialog(QDialog): xpath=self.xpath_edit.text(), user_agent=self.user_agent_edit.text(), fetch_interval=self.interval_spin.value(), - playwright_dir=self.playwright_dir_edit.text() + chrome_path=self.chrome_path_edit.text() ) # UI diff --git a/使用说明.md b/使用说明.md new file mode 100644 index 0000000..018c9d2 --- /dev/null +++ b/使用说明.md @@ -0,0 +1,49 @@ +# 股吧人气指示器 - 使用说明 + +## 系统要求 +- Windows 10/11 操作系统 +- Google Chrome 浏览器 (推荐最新版本) + +## Chrome浏览器配置 + +### 1. 下载Chrome浏览器 +如果您还没有安装Chrome浏览器,请按照以下步骤下载: +1. 打开网址:https://www.google.cn/chrome/ +2. 点击"下载Chrome" +3. 运行下载的安装程序并按照提示完成安装 + +### 2. 找到Chrome可执行文件路径 + +#### 方法1:通过开始菜单查找 +1. 打开开始菜单,找到Google Chrome +2. 右键点击,选择"打开文件所在位置" +3. 在打开的文件夹中,找到`chrome.exe`文件 +4. 右键点击`chrome.exe`,选择"属性" +5. 在"快捷方式"标签页中,"目标"字段显示了完整的路径 + +#### 方法2:默认安装路径 +- 32位系统:`C:\Program Files\Google\Chrome\Application\chrome.exe` +- 64位系统:`C:\Program Files (x86)\Google\Chrome\Application\chrome.exe` + +### 3. 在应用程序中配置Chrome路径 +1. 打开股吧人气指示器 +2. 点击"配置"按钮 +3. 在"Chrome路径"字段中输入找到的Chrome可执行文件路径 +4. 点击"确定"保存配置 + +## 常见问题 + +### Q: 应用程序无法运行? +A: 请确保您的Windows系统已安装最新的.NET Framework和Visual C++ Redistributable。 + +### Q: 无法生成截图? +A: 请检查: +1. Chrome浏览器是否正常安装 +2. Chrome路径是否正确配置 +3. 网络连接是否正常 + +### Q: 如何更新Chrome浏览器? +A: 打开Chrome浏览器,点击右上角的三个点 → "帮助" → "关于Google Chrome",Chrome会自动检查并更新到最新版本。 + +## 联系信息 +如遇到其他问题,请联系开发者。