feat(配置对话框): 添加Playwright目录浏览功能
在配置对话框中新增Playwright目录选择功能,允许用户手动指定浏览器路径
This commit is contained in:
84
build.spec
84
build.spec
@@ -1,84 +0,0 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
|
||||
|
||||
# 添加当前目录到路径
|
||||
current_dir = os.getcwd()
|
||||
sys.path.append(current_dir)
|
||||
|
||||
block_cipher = None
|
||||
|
||||
# 收集Playwright的数据文件
|
||||
playwright_data = collect_data_files('playwright')
|
||||
|
||||
# 添加额外的隐藏导入
|
||||
hiddenimports = [
|
||||
'PySide6.Qt6Compat',
|
||||
'loguru',
|
||||
'playwright._impl._driver',
|
||||
'playwright._impl._api_structures',
|
||||
'playwright._impl._connection',
|
||||
'playwright._impl._transport',
|
||||
]
|
||||
|
||||
# 排除PyQt5,避免冲突
|
||||
excludes = ['PyQt5', 'PyQt6']
|
||||
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[
|
||||
*playwright_data,
|
||||
('guba.ico', '.'),
|
||||
('indicator.ico', '.'),
|
||||
('config.json', '.'),
|
||||
],
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=excludes,
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
# 添加必要的二进制文件
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name='guba-indicator',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False, # 不显示控制台窗口
|
||||
icon='guba.ico',
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
|
||||
# 如果需要单文件,使用以下配置
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name='guba-indicator',
|
||||
)
|
||||
@@ -4,7 +4,7 @@ PySide6 GUI界面模块
|
||||
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel,
|
||||
QPushButton, QSlider, QDialog, QFormLayout,
|
||||
QLineEdit, QSpinBox, QMessageBox, QSystemTrayIcon,
|
||||
QMenu, QTextEdit, QGroupBox, QDialogButtonBox, QCheckBox, QScrollArea)
|
||||
QMenu, QTextEdit, QGroupBox, QDialogButtonBox, QCheckBox, QScrollArea, QFileDialog)
|
||||
from PySide6.QtCore import Qt, QTimer, Signal, QPoint
|
||||
from PySide6.QtGui import QFont, QColor, QPainter, QBrush, QPen, QIcon, QAction, QPixmap
|
||||
from typing import Callable, Optional
|
||||
@@ -153,6 +153,16 @@ 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)
|
||||
|
||||
# UI 配置
|
||||
ui_config = self.config_manager.ui_config
|
||||
|
||||
@@ -186,6 +196,17 @@ class ConfigDialog(QDialog):
|
||||
button_box.rejected.connect(self.reject)
|
||||
layout.addRow(button_box)
|
||||
|
||||
def _browse_playwright_dir(self):
|
||||
"""浏览Playwright目录"""
|
||||
directory = QFileDialog.getExistingDirectory(
|
||||
self,
|
||||
"选择Playwright浏览器目录",
|
||||
"",
|
||||
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks
|
||||
)
|
||||
if directory:
|
||||
self.playwright_dir_edit.setText(directory)
|
||||
|
||||
def _save_config(self):
|
||||
"""保存配置"""
|
||||
# LLM API
|
||||
@@ -201,7 +222,8 @@ class ConfigDialog(QDialog):
|
||||
target_url=self.url_edit.text(),
|
||||
xpath=self.xpath_edit.text(),
|
||||
user_agent=self.user_agent_edit.text(),
|
||||
fetch_interval=self.interval_spin.value()
|
||||
fetch_interval=self.interval_spin.value(),
|
||||
playwright_dir=self.playwright_dir_edit.text()
|
||||
)
|
||||
|
||||
# UI
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 58 KiB |
Reference in New Issue
Block a user