audit-e2w 1.11.2 → 1.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +152 -148
  2. package/dsh_plugins/audit-e2w/lib/index.js +9 -1
  3. package/dsh_plugins/audit-e2w/lib/skill.js +3 -2
  4. package/excel_word/README.md +45 -37
  5. package/excel_word/qoder_engine.py +10 -11
  6. package/excel_word/wesync/__init__.py +1 -1
  7. package/excel_word/wesync/ai/__init__.py +52 -0
  8. package/excel_word/wesync/ai/actions.py +369 -0
  9. package/excel_word/wesync/ai/client.py +340 -0
  10. package/excel_word/wesync/ai/config.py +291 -0
  11. package/excel_word/wesync/ai/docs.py +177 -0
  12. package/excel_word/wesync/ai/prompts.py +288 -0
  13. package/excel_word/wesync/ai/tasks/__init__.py +26 -0
  14. package/excel_word/wesync/ai/tasks/actions_task.py +97 -0
  15. package/excel_word/wesync/ai/tasks/combined.py +123 -0
  16. package/excel_word/wesync/ai/tasks/diff_note.py +61 -0
  17. package/excel_word/wesync/ai/tasks/headings.py +119 -0
  18. package/excel_word/wesync/ai/tasks/help_task.py +69 -0
  19. package/excel_word/wesync/ai/tasks/roles.py +128 -0
  20. package/excel_word/wesync/align.py +1 -0
  21. package/excel_word/wesync/api.py +544 -92
  22. package/excel_word/wesync/backup_history.py +44 -9
  23. package/excel_word/wesync/cli.py +19 -1
  24. package/excel_word/wesync/commands/blank_cmd.py +59 -30
  25. package/excel_word/wesync/commands/bookmark_cmd.py +41 -10
  26. package/excel_word/wesync/commands/clear_cmd.py +5 -3
  27. package/excel_word/wesync/commands/export_cmd.py +270 -220
  28. package/excel_word/wesync/commands/incremental_cmd.py +157 -0
  29. package/excel_word/wesync/commands/marks_cmd.py +24 -16
  30. package/excel_word/wesync/commands/placeholders_cmd.py +12 -7
  31. package/excel_word/wesync/commands/writeback_cmd.py +72 -116
  32. package/excel_word/wesync/config.py +3 -2
  33. package/excel_word/wesync/console.py +9 -2
  34. package/excel_word/wesync/docx_bookmarks.py +12 -5
  35. package/excel_word/wesync/docx_columns.py +1 -1
  36. package/excel_word/wesync/docx_marks.py +183 -75
  37. package/excel_word/wesync/docx_placeholders.py +65 -26
  38. package/excel_word/wesync/excel_blocks.py +144 -185
  39. package/excel_word/wesync/excel_export.py +15 -8
  40. package/excel_word/wesync/excel_marks.py +265 -193
  41. package/excel_word/wesync/fsops.py +11 -6
  42. package/excel_word/wesync/gui/__init__.py +21 -2
  43. package/excel_word/wesync/gui/app.py +243 -29
  44. package/excel_word/wesync/gui/manual.py +5 -3
  45. package/excel_word/wesync/gui/pages/__init__.py +53 -4
  46. package/excel_word/wesync/gui/pages/_page.py +129 -7
  47. package/excel_word/wesync/gui/pages/ai_page.py +854 -0
  48. package/excel_word/wesync/gui/pages/batch_page.py +64 -31
  49. package/excel_word/wesync/gui/pages/blank_page.py +529 -464
  50. package/excel_word/wesync/gui/pages/bookmark_page.py +97 -37
  51. package/excel_word/wesync/gui/pages/export_page.py +140 -87
  52. package/excel_word/wesync/gui/pages/feedback_page.py +196 -0
  53. package/excel_word/wesync/gui/pages/format_page.py +551 -429
  54. package/excel_word/wesync/gui/pages/help_page.py +73 -7
  55. package/excel_word/wesync/gui/pages/history_page.py +167 -144
  56. package/excel_word/wesync/gui/pages/marks_page.py +210 -177
  57. package/excel_word/wesync/gui/pages/settings_page.py +450 -0
  58. package/excel_word/wesync/gui/pages/writeback_page.py +167 -146
  59. package/excel_word/wesync/gui/runner.py +29 -13
  60. package/excel_word/wesync/gui/store.py +23 -7
  61. package/excel_word/wesync/gui/theme.py +220 -49
  62. package/excel_word/wesync/gui/widgets/ai_config.py +362 -0
  63. package/excel_word/wesync/gui/widgets/cards.py +124 -5
  64. package/excel_word/wesync/gui/widgets/chips.py +565 -0
  65. package/excel_word/wesync/gui/widgets/filebar.py +1 -1
  66. package/excel_word/wesync/gui/widgets/logpane.py +24 -8
  67. package/excel_word/wesync/gui/widgets/nav.py +267 -12
  68. package/excel_word/wesync/gui/widgets/theme_choice.py +93 -0
  69. package/excel_word/wesync/report_format.py +9 -1
  70. package/excel_word/wesync/settings.py +35 -0
  71. package/excel_word/wesync/sort_rules.py +75 -26
  72. package/excel_word/wesync/valuefmt.py +40 -17
  73. package/package.json +53 -51
  74. package/packaging//344/275/277/347/224/250/350/257/264/346/230/216.txt +247 -0
  75. package/qoder_plugins/audit-toolbox/README.md +159 -156
  76. package/qoder_plugins/audit-toolbox/catalog.mjs +13 -13
@@ -2,7 +2,11 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from PySide6.QtCore import QEvent, Qt, QTimer
5
6
  from PySide6.QtWidgets import (
7
+ QCheckBox,
8
+ QComboBox,
9
+ QFrame,
6
10
  QHBoxLayout,
7
11
  QLabel,
8
12
  QPushButton,
@@ -11,7 +15,9 @@ from PySide6.QtWidgets import (
11
15
  QWidget,
12
16
  )
13
17
 
14
- from ..widgets.cards import make_card
18
+ from ...settings import ZERO_LABELS
19
+
20
+ from ..widgets.cards import add_option_tile, make_card, make_option_grid
15
21
 
16
22
 
17
23
  class BasePage(QWidget):
@@ -19,13 +25,17 @@ class BasePage(QWidget):
19
25
 
20
26
  title = "页面"
21
27
  subtitle = ""
28
+ CONTENT_MAX_WIDTH: int | None = 1120
29
+ # 内容自适应高度(默认):页面短时不留大片空白。
30
+ # 置 True 表示内容要撑满可用高度(如说明书页的分栏浏览区)。
31
+ FILL_HEIGHT = False
22
32
 
23
33
  def __init__(self, ctx, parent=None):
24
34
  super().__init__(parent)
25
35
  self.ctx = ctx
26
36
  layout = QVBoxLayout(self)
27
- layout.setContentsMargins(18, 12, 18, 12)
28
- layout.setSpacing(4)
37
+ layout.setContentsMargins(24, 18, 24, 16)
38
+ layout.setSpacing(8)
29
39
  title = QLabel(self.title)
30
40
  title.setObjectName("PageTitle")
31
41
  layout.addWidget(title)
@@ -38,24 +48,136 @@ class BasePage(QWidget):
38
48
 
39
49
  scroller = QScrollArea()
40
50
  scroller.setWidgetResizable(True)
51
+ if self.FILL_HEIGHT:
52
+ # 内容撑满:不要 AlignTop,否则 body 会缩到内容高度、下方留白
53
+ scroller.setAlignment(Qt.AlignmentFlag.AlignLeft)
54
+ scroller.setFrameShape(QFrame.NoFrame)
55
+ else:
56
+ scroller.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
41
57
  body = QWidget()
58
+ if self.CONTENT_MAX_WIDTH is not None:
59
+ body.setMaximumWidth(self.CONTENT_MAX_WIDTH)
42
60
  body_layout = QVBoxLayout(body)
43
61
  body_layout.setContentsMargins(0, 8, 0, 0)
44
- body_layout.setSpacing(12)
45
- body_layout.addStretch(1)
62
+ body_layout.setSpacing(14)
63
+ if not self.FILL_HEIGHT:
64
+ body_layout.addStretch(1)
46
65
  scroller.setWidget(body)
47
66
  layout.addWidget(scroller, 1)
48
67
  self.body = body
68
+ self._default_bindings = []
69
+ self._content_height = None
49
70
  self.build(body)
71
+ body.installEventFilter(self)
72
+
73
+ def eventFilter(self, watched, event):
74
+ if watched is self.body and event.type() == QEvent.Resize:
75
+ QTimer.singleShot(0, self._fit_content_height)
76
+ return super().eventFilter(watched, event)
77
+
78
+ def _fit_content_height(self) -> None:
79
+ # 撑满模式由布局自行分配高度,不能再压最小高度
80
+ if self.FILL_HEIGHT:
81
+ return
82
+ layout = self.body.layout()
83
+ layout.activate()
84
+ height = layout.sizeHint().height()
85
+ if height < 0 or height == self._content_height:
86
+ return
87
+ self._content_height = height
88
+ self.body.setMinimumHeight(height)
89
+ QTimer.singleShot(0, self._fit_content_height)
90
+
91
+ def on_show(self) -> None:
92
+ """切换到本页时调用;单次临时调整不跨页面保留。"""
93
+ for row, controls, status in self._default_bindings:
94
+ row.setChecked(False)
95
+ self._apply_defaults(controls, status)
96
+ row.setChecked(True)
97
+
98
+ def bind_defaults(self, layout, controls: dict, zero_keys=(), zero_controls: dict | None = None) -> QCheckBox:
99
+ row = QCheckBox("本次调整")
100
+ zero_controls = zero_controls if zero_controls is not None else {}
101
+ status = QLabel()
102
+ status.setObjectName("CardDesc")
103
+ status.setWordWrap(True)
104
+ adjust = QFrame()
105
+ adjust.setObjectName("AdjustBlock")
106
+ adjust_layout = QVBoxLayout(adjust)
107
+ adjust_layout.setContentsMargins(12, 10, 12, 10)
108
+ adjust_layout.setSpacing(8)
109
+ wrapper = QHBoxLayout()
110
+ wrapper.setContentsMargins(0, 0, 0, 0)
111
+ wrapper.addWidget(row)
112
+ wrapper.addWidget(status, 1)
113
+ adjust_layout.addLayout(wrapper)
114
+ zero_row = QHBoxLayout()
115
+ zero_row.setContentsMargins(0, 0, 0, 0)
116
+ zero_row.setSpacing(12)
117
+ for name, key in zero_keys:
118
+ group = QWidget()
119
+ group_layout = QHBoxLayout(group)
120
+ group_layout.setContentsMargins(0, 0, 0, 0)
121
+ group_layout.setSpacing(8)
122
+ combo = QComboBox()
123
+ combo.setMinimumWidth(120)
124
+ combo.setMaximumWidth(140)
125
+ for mode, label in ZERO_LABELS.items():
126
+ combo.addItem(label, mode)
127
+ group_layout.addWidget(QLabel(name))
128
+ group_layout.addWidget(combo)
129
+ zero_row.addWidget(group)
130
+ controls[key] = combo
131
+ zero_controls[key] = combo
132
+ if zero_keys:
133
+ zero_row.addStretch(1)
134
+ adjust_layout.addLayout(zero_row)
135
+ layout.addWidget(adjust)
136
+ row.toggled.connect(lambda checked: self._apply_defaults(controls, status, checked))
137
+ self._default_bindings.append((row, controls, status))
138
+ self._apply_defaults(controls, status)
139
+ row.setChecked(True)
140
+ return row
50
141
 
51
142
  def build(self, body: QWidget) -> None: # pragma: no cover - 子类实现
52
143
  raise NotImplementedError
53
144
 
54
- def on_show(self) -> None:
55
- """切换到本页时调用,默认什么都不做。"""
145
+ def _apply_defaults(self, controls: dict, status: QLabel, editing=False) -> None:
146
+ settings = self.ctx.global_settings()
147
+ for key, control in controls.items():
148
+ control.setEnabled(editing and not self.ctx.busy)
149
+ if isinstance(control, QComboBox):
150
+ control.setCurrentIndex(control.findData(settings[key]))
151
+ elif not editing:
152
+ control.setChecked(bool(settings[key]))
153
+ status.setText("本次临时调整 · 不保存" if editing else "当前沿用全局设置")
154
+
155
+ def refresh_button_state(self) -> None:
156
+ for row, controls, status in self._default_bindings:
157
+ self._apply_defaults(controls, status, row.isChecked())
158
+
159
+ def reload_global_defaults(self) -> None:
160
+ for row, controls, status in self._default_bindings:
161
+ editing = row.isChecked()
162
+ row.setChecked(False)
163
+ self._apply_defaults(controls, status)
164
+ row.setChecked(editing)
165
+
166
+ def run_background(self, title: str, work, on_success) -> bool:
167
+ return self.ctx.run_steps([(title, work)], on_success=on_success)
56
168
 
57
169
  # ---------- 共用构件 ----------
58
170
 
171
+ @staticmethod
172
+ def option_grid(card: QWidget, columns: int = 3) -> QWidget:
173
+ grid = make_option_grid(columns=columns)
174
+ card.layout().addWidget(grid)
175
+ return grid
176
+
177
+ @staticmethod
178
+ def option_tile(grid: QWidget, text: str, checked: bool = False, *, hint: str = "", risk: bool = False, columns: int = 3):
179
+ return add_option_tile(grid, text, checked, hint=hint, risk=risk, columns=columns)
180
+
59
181
  @staticmethod
60
182
  def card(body: QWidget) -> QWidget:
61
183
  card = make_card()