feat: add semantic risk indicators

This commit is contained in:
chengma
2026-07-02 09:06:52 +08:00
parent ba6f3e4af4
commit 9bad70f425
6 changed files with 65 additions and 16 deletions
+36 -2
View File
@@ -10,7 +10,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
try:
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt
from PySide6.QtGui import QColor, QPixmap
from PySide6.QtGui import QColor, QIcon, QPainter, QPixmap
from PySide6.QtWidgets import (
QAbstractItemView,
QApplication,
@@ -137,6 +137,34 @@ if QT_IMPORT_ERROR is None:
)
def _login_status_display(status):
return f"● {status or '未知'}"
def _login_status_color(status):
status_text = str(status or "")
if status_text == "已登录":
return _qcolor(COLOR_SUCCESS)
if status_text == "检测中":
return _qcolor(COLOR_INFO)
if "未登录" in status_text or "失败" in status_text:
return _qcolor(COLOR_DANGER)
return _qcolor(COLOR_MUTED)
def _warning_dot_icon(size=12):
pixmap = QPixmap(size, size)
pixmap.fill(Qt.transparent)
painter = QPainter(pixmap)
painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(Qt.NoPen)
painter.setBrush(QColor(COLOR_WARNING))
margin = max(1, size // 6)
painter.drawEllipse(margin, margin, size - margin * 2, size - margin * 2)
painter.end()
return QIcon(pixmap)
def _database_path(db_path=None, config=None) -> str:
return db_path or appconfig.db_path(config)
@@ -2113,6 +2141,7 @@ if QT_IMPORT_ERROR is None:
self.batch_filter.setObjectName("collectBatchFilter")
self.delete_batch_button = QPushButton("删除批次")
self.delete_batch_button.setObjectName("deleteBatchButton")
self.delete_batch_button.setStyleSheet(_danger_outline_button_style("deleteBatchButton"))
self.delete_batch_button.setEnabled(False)
toolbar = QHBoxLayout()
@@ -5286,6 +5315,8 @@ if QT_IMPORT_ERROR is None:
self.add_button = QPushButton("新增")
self.edit_button = QPushButton("编辑")
self.delete_button = QPushButton("删除")
self.delete_button.setObjectName("deleteAccountButton")
self.delete_button.setStyleSheet(_danger_outline_button_style("deleteAccountButton"))
self.launch_button = QPushButton("启动登录")
self.check_button = QPushButton("检测登录")
self.shortcut_button = QPushButton("快捷方式")
@@ -5363,11 +5394,13 @@ if QT_IMPORT_ERROR is None:
account.alias,
account.region_host,
str(account.debug_port),
status,
_login_status_display(status),
account.note or "",
]
for column, value in enumerate(values):
item = QTableWidgetItem(value)
if column == 4:
item.setForeground(_login_status_color(status))
self.table.setItem(row, column, item)
self.empty_label.setText("" if self.account_rows else "暂无账号")
self._update_button_state()
@@ -5617,6 +5650,7 @@ if QT_IMPORT_ERROR is None:
self.tabs.currentChanged.connect(self._on_tab_changed)
for title in TAB_TITLES:
self.tabs.addTab(self._build_tab(title), title)
self.tabs.setTabIcon(TAB_TITLES.index("③ 更新shopee"), _warning_dot_icon())
self.setCentralWidget(self.tabs)
self.statusBar().showMessage("就绪")