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
@@ -1,37 +1,97 @@
1
- """书签页:只处理书签与正文遗留文字,不动数据。"""
2
-
3
- from __future__ import annotations
4
-
5
- from PySide6.QtWidgets import QWidget
6
-
7
- from ... import api
8
- from ._page import BasePage
9
-
10
-
11
- class BookmarkPage(BasePage):
12
- title = "书签工具"
13
- subtitle = "按内容重新对齐书签,不改动数据。"
14
-
15
- def build(self, body: QWidget) -> None:
16
- card = self.card(body)
17
- self.button_row(card, lambda: self._start(True), lambda: self._start(False), "仅预演", "开始处理")
18
-
19
- def _start(self, dry_run: bool) -> None:
20
- if not self.ctx.require_docx():
21
- return
22
- if not dry_run:
23
- message = (
24
- f"将处理 Word 书签与正文遗留文字:\n\nWord:{self.ctx.docx}\n\n"
25
- "若有改动,写盘前会自动备份。确认开始?"
26
- )
27
- if not self.ctx.confirm("确认处理书签", message):
28
- self.ctx.log("已取消书签处理。", "muted")
29
- return
30
- self.ctx.run_steps(
31
- [
32
- (
33
- "处理书签(预演)" if dry_run else "处理书签",
34
- lambda: api.run_bookmark(self.ctx.docx, self.ctx.excel, dry_run=dry_run),
35
- )
36
- ]
37
- )
1
+ """书签页:只处理书签与正文遗留文字,不动数据。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from PySide6.QtWidgets import QWidget
6
+
7
+ from ... import api
8
+ from ..widgets.chips import ChipRow
9
+ from ._page import BasePage
10
+
11
+
12
+ class BookmarkPage(BasePage):
13
+ title = "书签工具"
14
+ subtitle = "修复书签与 Word/Excel 跳转链接,不改动数据。"
15
+
16
+ def build(self, body: QWidget) -> None:
17
+ card = self.card(body)
18
+ self.options = ChipRow([
19
+ ("refresh_links", "刷新表格定位链接", True, "保持 Excel 可跳回 Word"),
20
+ ("backup", "处理前备份", True, "关闭则不可回滚", True),
21
+ ])
22
+ card.layout().addWidget(self.options)
23
+ self.links = self.options["refresh_links"]
24
+ self.backup = self.options["backup"]
25
+ self.bind_defaults(card.layout(), {"excel_links": self.links, "auto_backup": self.backup})
26
+ self.button_row(card, lambda: self._start(True), lambda: self._start(False), "仅预演", "开始处理")
27
+
28
+ links_card = self.card(body)
29
+ self.tip_label(
30
+ links_card,
31
+ "文件移动或改名后,修复 Excel 定位链接;不改 Word、数据和公式。",
32
+ )
33
+ self.button_row(
34
+ links_card,
35
+ lambda: self._repair_links(True),
36
+ lambda: self._repair_links(False),
37
+ "仅预演",
38
+ "修复跳转链接",
39
+ )
40
+
41
+ def _start(self, dry_run: bool) -> None:
42
+ if not self.ctx.require_docx():
43
+ return
44
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
45
+ links, backup = self.links.isChecked(), self.backup.isChecked()
46
+ if not dry_run:
47
+ message = (
48
+ f"将处理 Word 书签与正文遗留文字:\n\nWord:{self.ctx.docx}\n\n"
49
+ "若有改动,写盘前会自动备份。确认开始?"
50
+ if self.backup.isChecked()
51
+ else "本次已取消备份,将直接保存。确认开始?"
52
+ )
53
+ if not self.ctx.confirm("确认处理书签", message):
54
+ self.ctx.log("已取消书签处理。", "muted")
55
+ return
56
+ self.ctx.run_steps(
57
+ [
58
+ (
59
+ "处理书签(预演)" if dry_run else "处理书签",
60
+ lambda: api.run_bookmark(
61
+ docx, custom_excel, dry_run=dry_run,
62
+ with_excel_links=links, backup=backup,
63
+ ),
64
+ )
65
+ ]
66
+ )
67
+
68
+ def _repair_links(self, dry_run: bool) -> None:
69
+ if not self.ctx.require_docx():
70
+ return
71
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
72
+ backup = self.backup.isChecked()
73
+ excel = api.workbook_path(docx, custom_excel)
74
+ if not excel.exists():
75
+ self.ctx.error("未找到工作簿", f"未找到工作簿:\n{excel}\n\n请先执行「导出表格到 Excel」或「增量导出」。")
76
+ return
77
+ if not dry_run:
78
+ message = (
79
+ "将修复 Excel 中表格和标注的 Word 定位链接:\n\n"
80
+ f"Word:{self.ctx.docx}\nExcel:{excel}\n\n"
81
+ "只改 Excel 链接,不改 Word 和数据;"
82
+ + ("写盘前会自动备份。" if self.backup.isChecked() else "本次已取消备份。")
83
+ + "确认开始?"
84
+ )
85
+ if not self.ctx.confirm("确认修复跳转链接", message):
86
+ self.ctx.log("已取消修复跳转链接。", "muted")
87
+ return
88
+ self.ctx.run_steps(
89
+ [
90
+ (
91
+ "修复跳转链接(预演)" if dry_run else "修复跳转链接",
92
+ lambda: api.run_repair_links(
93
+ docx, custom_excel, dry_run=dry_run, backup=backup
94
+ ),
95
+ )
96
+ ]
97
+ )
@@ -1,88 +1,141 @@
1
- """导出页:Word → Excel。"""
2
-
3
- from __future__ import annotations
4
-
5
- from PySide6.QtWidgets import QPushButton, QWidget
6
-
7
- from ... import api
8
- from ..widgets.cards import make_checkbutton
9
- from ._page import BasePage
10
-
11
-
12
- class ExportPage(BasePage):
13
- title = "创建Excel"
14
- subtitle = "Word 全部表格 → 工作簿(正文含 {字段名} 时自动生成「正文信息」表,重导出保留已填值;默认覆盖前自动备份,可取消勾选)。"
15
-
16
- def build(self, body: QWidget) -> None:
17
- card = self.card(body)
18
- self.links = make_checkbutton(card, "在 Excel 写入「→定位Word表」跳转链接", True)
19
- card.layout().addWidget(self.links)
20
- self.totals = make_checkbutton(card, "合计行自动写求和公式(在 Excel 改明细后合计自动更新,同步时按公式结果回写)", True)
21
- card.layout().addWidget(self.totals)
22
- self.backup = make_checkbutton(card, "覆盖前备份原文件到 _backup(取消勾选则直接覆盖、不可回滚)", True)
23
- card.layout().addWidget(self.backup)
24
-
25
- row = self.button_row(card, lambda: self._start(True), lambda: self._start(False), "仅预演", "开始导出")
26
- rejudge_btn = QPushButton("重新判定✓/✕")
27
- rejudge_btn.setToolTip("在 Excel 改过内容后,按当前内容重判 B 列表头/✓/✕(只改标记,不改数据;「已删」行保持原样)")
28
- rejudge_btn.clicked.connect(lambda _checked=False: self._rejudge())
29
- row.layout().insertWidget(row.layout().count() - 1, rejudge_btn)
30
- btn = QPushButton("清理 Word 书签")
31
- btn.clicked.connect(lambda _checked=False: self._clear_bookmarks())
32
- row.layout().insertWidget(row.layout().count() - 1, btn)
33
-
34
- def _rejudge(self) -> None:
35
- if not self.ctx.require_docx():
36
- return
37
- backup = self.backup.isChecked()
38
- self.ctx.run_steps(
39
- [("重新判定✓/✕", lambda: api.run_rejudge(self.ctx.docx, self.ctx.excel, backup=backup))]
40
- )
41
-
42
- def _clear_bookmarks(self) -> None:
43
- if not self.ctx.require_docx():
44
- return
45
- if not self.ctx.confirm(
46
- "清理 Word 书签",
47
- f"将删除 Word 里所有本工具写入的书签(CPAH_/TBL_/MRK_):\n\nWord:{self.ctx.docx}\n\n"
48
- "保留 Word 自带书签(如 _Toc 目录书签)。写盘前会自动备份,确认清理?",
49
- ):
50
- self.ctx.log("已取消清理书签。", "muted")
51
- return
52
- self.ctx.run_steps([("清理 Word 书签", lambda: api.run_clear_bookmarks(self.ctx.docx))])
53
-
54
- def _start(self, dry_run: bool) -> None:
55
- if not self.ctx.require_docx():
56
- return
57
- excel = self.ctx.workbook_path()
58
- with_links = self.links.isChecked()
59
- totals_formula = self.totals.isChecked()
60
- backup = self.backup.isChecked()
61
- if not dry_run:
62
- backup_note = (
63
- "原工作簿(若存在)会先备份到 _backup,确认开始导出?"
64
- if backup
65
- else "已取消备份:原工作簿(若存在)将被直接覆盖、不可回滚,确认开始导出?"
66
- )
67
- message = (
68
- f"将按当前 Word 重建工作簿:\n\nWord:{self.ctx.docx}\nExcel:{excel}\n\n"
69
- + backup_note
70
- )
71
- if not self.ctx.confirm("确认导出", message):
72
- self.ctx.log("已取消导出。", "muted")
73
- return
74
- self.ctx.run_steps(
75
- [
76
- (
77
- "导出到 Excel(预演)" if dry_run else "导出到 Excel",
78
- lambda: api.run_export(
79
- self.ctx.docx,
80
- self.ctx.excel,
81
- dry_run=dry_run,
82
- with_excel_links=with_links,
83
- totals_formula=totals_formula,
84
- backup=backup,
85
- ),
86
- )
87
- ]
1
+ """导出页:Word → Excel。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from PySide6.QtWidgets import QWidget
6
+
7
+ from ... import api
8
+ from ..widgets.cards import make_action_bar
9
+ from ..widgets.chips import ChipRow
10
+ from ._page import BasePage
11
+
12
+
13
+ class ExportPage(BasePage):
14
+ title = "创建Excel"
15
+ subtitle = "导出全部表格;保留已填值,默认备份。"
16
+
17
+ def build(self, body: QWidget) -> None:
18
+ card = self.card(body)
19
+ self.tip_label(card, "导出选项").setObjectName("SectionTitle")
20
+ self.options = ChipRow([
21
+ ("links", "Excel 链接回 Word", True, "从工作簿跳回 Word 表格"),
22
+ ("totals", "合计自动求和", True, "修改明细后合计自动更新"),
23
+ ("backup", "覆盖前备份", True, "关闭则不可回滚", True),
24
+ ])
25
+ self.links = self.options["links"]
26
+ self.totals = self.options["totals"]
27
+ self.backup = self.options["backup"]
28
+ # 「本次调整」开关放在选项上方(它控制选项的可用性),故先建它再放选项
29
+ self.adjustment = self.bind_defaults(card.layout(), {
30
+ "excel_links": self.links,
31
+ "totals_formula": self.totals,
32
+ "auto_backup": self.backup,
33
+ })
34
+ # 「本次调整」块已在上面,选项追加在它之后
35
+ card.layout().addWidget(self.options)
36
+ actions = make_action_bar(
37
+ card,
38
+ "全量导出",
39
+ lambda: self._start(False),
40
+ (
41
+ ("仅预演", lambda: self._start(True)),
42
+ ("增量导出", self._incremental),
43
+ ("重新判定✓/✕", self._rejudge),
44
+ ("清理 Word 书签", self._clear_bookmarks),
45
+ ),
46
+ primary_index=1,
47
+ )
48
+ actions.setObjectName("ExportActions")
49
+ action_layout = actions.layout()
50
+ action_layout.itemAt(3).widget().setToolTip("按 Excel 当前内容重判 B 列✓/✕,只改标记")
51
+ action_layout.itemAt(4).widget().setToolTip("只清理本工具写入的书签,保留 Word 自带书签")
52
+ card.layout().addWidget(actions)
53
+
54
+ def _incremental(self) -> None:
55
+ if not self.ctx.require_docx():
56
+ return
57
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
58
+ links, totals, backup = self.links.isChecked(), self.totals.isChecked(), self.backup.isChecked()
59
+ excel = api.workbook_path(docx, custom_excel)
60
+ if not excel.exists():
61
+ self.ctx.error("未找到工作簿", f"未找到工作簿:\n{excel}\n\n请先执行一次「全量导出」。")
62
+ return
63
+ if not self.ctx.confirm(
64
+ "确认增量导出",
65
+ f"只登记 Word 中尚未锚定的新增表格、标注与占位符:\n\nWord:{self.ctx.docx}\nExcel:{excel}\n\n"
66
+ "既有工作簿行、编号与公式位置不会改动;新表格按发现顺序写入「新增表格」(XT01、XT02…)。\n"
67
+ + ("写盘前会自动备份,确认开始?" if self.backup.isChecked() else "本次已取消备份,确认开始?"),
68
+ ):
69
+ self.ctx.log("已取消增量导出。", "muted")
70
+ return
71
+ self.ctx.run_steps(
72
+ [("增量导出", lambda: api.run_incremental_export(
73
+ docx, custom_excel,
74
+ with_excel_links=links,
75
+ totals_formula=totals,
76
+ backup=backup,
77
+ ))]
78
+ )
79
+
80
+ def _rejudge(self) -> None:
81
+ if not self.ctx.require_docx():
82
+ return
83
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
84
+ backup = self.backup.isChecked()
85
+ self.ctx.run_steps(
86
+ [("重新判定✓/✕", lambda: api.run_rejudge(docx, custom_excel, backup=backup))]
87
+ )
88
+
89
+ def _clear_bookmarks(self) -> None:
90
+ if not self.ctx.require_docx():
91
+ return
92
+ docx = self.ctx.docx
93
+ backup = self.backup.isChecked()
94
+ if not self.ctx.confirm(
95
+ "清理 Word 书签",
96
+ f"将删除 Word 里所有本工具写入的书签(CPAH_/TBL_/MRK_):\n\nWord:{self.ctx.docx}\n\n"
97
+ "保留 Word 自带书签(如 _Toc 目录书签)。"
98
+ + ("写盘前会自动备份,确认清理?" if self.backup.isChecked() else "本次已取消备份,确认清理?"),
99
+ ):
100
+ self.ctx.log("已取消清理书签。", "muted")
101
+ return
102
+ self.ctx.run_steps([("清理 Word 书签", lambda: api.run_clear_bookmarks(
103
+ docx, backup=backup
104
+ ))])
105
+
106
+ def _start(self, dry_run: bool) -> None:
107
+ if not self.ctx.require_docx():
108
+ return
109
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
110
+ excel = api.workbook_path(docx, custom_excel)
111
+ with_links = self.links.isChecked()
112
+ totals_formula = self.totals.isChecked()
113
+ backup = self.backup.isChecked()
114
+ if not dry_run:
115
+ backup_note = (
116
+ "原工作簿(若存在)会先备份到 _backup,确认全量导出?"
117
+ if backup
118
+ else "已取消备份:原工作簿(若存在)将被直接覆盖、不可回滚,确认全量导出?"
119
+ )
120
+ message = (
121
+ f"将按当前 Word 重建工作簿:\n\nWord:{docx}\nExcel:{excel}\n\n"
122
+ + backup_note
123
+ )
124
+ if not self.ctx.confirm("确认导出", message):
125
+ self.ctx.log("已取消导出。", "muted")
126
+ return
127
+ self.ctx.run_steps(
128
+ [
129
+ (
130
+ "导出到 Excel(预演)" if dry_run else "导出到 Excel",
131
+ lambda: api.run_export(
132
+ docx,
133
+ custom_excel,
134
+ dry_run=dry_run,
135
+ with_excel_links=with_links,
136
+ totals_formula=totals_formula,
137
+ backup=backup,
138
+ ),
139
+ )
140
+ ]
88
141
  )
@@ -0,0 +1,196 @@
1
+ """问题反馈页:联系邮箱、反馈草稿与功能建议。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from urllib.parse import urlencode
6
+
7
+ from PySide6.QtCore import QUrl, Qt
8
+ from PySide6.QtGui import QDesktopServices
9
+ from PySide6.QtWidgets import (
10
+ QApplication,
11
+ QComboBox,
12
+ QFrame,
13
+ QHBoxLayout,
14
+ QLabel,
15
+ QLineEdit,
16
+ QPlainTextEdit,
17
+ QPushButton,
18
+ QVBoxLayout,
19
+ QWidget,
20
+ )
21
+
22
+ from ... import __version__
23
+ from ._page import BasePage
24
+
25
+
26
+ class FeedbackPage(BasePage):
27
+ title = "问题反馈"
28
+ subtitle = "问题、建议或使用困难,都可以整理成邮件草稿后联系;仅生成草稿,不自动发送。"
29
+ EMAIL = "auditlg@163.com"
30
+
31
+ _PAGE_QSS = """
32
+ QFrame#Card { border-radius: 10px; }
33
+ """
34
+
35
+ def build(self, body: QWidget) -> None:
36
+ self.setStyleSheet(self._PAGE_QSS)
37
+ self._build_actions(body)
38
+
39
+ contact = self.card(body)
40
+ contact.setObjectName("ContactBanner")
41
+ row = QWidget()
42
+ layout = QHBoxLayout(row)
43
+ layout.setContentsMargins(0, 0, 0, 0)
44
+ layout.setSpacing(18)
45
+ email_box = QWidget()
46
+ email_layout = QVBoxLayout(email_box)
47
+ email_layout.setContentsMargins(0, 0, 0, 0)
48
+ email_layout.setSpacing(2)
49
+ email_layout.addWidget(QLabel("联系邮箱"))
50
+ email = QLabel(self.EMAIL)
51
+ email.setObjectName("ContactEmail")
52
+ email_layout.addWidget(email)
53
+ layout.addWidget(email_box, 1)
54
+ hint = QLabel("建议附上软件版本、文件类型和问题截图")
55
+ hint.setObjectName("ContactTag")
56
+ hint.setAlignment(Qt.AlignCenter)
57
+ hint.setWordWrap(True)
58
+ layout.addWidget(hint, 1)
59
+ contact.layout().addWidget(row)
60
+
61
+ self._build_donation_card(body)
62
+ self._build_feedback_card(body)
63
+ self._build_suggestion_card(body)
64
+
65
+ def _build_actions(self, body: QWidget) -> None:
66
+ row = QWidget()
67
+ layout = QHBoxLayout(row)
68
+ layout.setContentsMargins(0, 0, 0, 0)
69
+ layout.setSpacing(10)
70
+ layout.addStretch(1)
71
+ copy = QPushButton("复制邮箱")
72
+ copy.clicked.connect(lambda _checked=False: self._copy_email())
73
+ layout.addWidget(copy)
74
+ write = QPushButton("写邮件")
75
+ write.setObjectName("Primary")
76
+ write.clicked.connect(lambda _checked=False: self._write_email())
77
+ layout.addWidget(write)
78
+ body.layout().insertWidget(body.layout().count() - 1, row)
79
+
80
+ @staticmethod
81
+ def _card_title(card: QWidget, step: str, title: str) -> None:
82
+ heading = QLabel(f"{step} {title}")
83
+ heading.setObjectName("SectionTitle")
84
+ card.layout().addWidget(heading)
85
+
86
+ def _field_label(self, card: QWidget, text: str) -> None:
87
+ label = QLabel(text)
88
+ label.setObjectName("CardDesc")
89
+ card.layout().addWidget(label)
90
+
91
+ def _build_donation_card(self, body: QWidget) -> None:
92
+ card = self.card(body)
93
+ self._card_title(card, "1", "打赏支持")
94
+ self.tip_label(card, "如果工具帮到了你,可自愿打赏;不影响使用。")
95
+ placeholder = QFrame()
96
+ placeholder.setObjectName("DonationPlaceholder")
97
+ placeholder.setMinimumHeight(150)
98
+ layout = QVBoxLayout(placeholder)
99
+ layout.setAlignment(Qt.AlignCenter)
100
+ layout.setSpacing(5)
101
+ title = QLabel("打赏码预留位置")
102
+ title.setAlignment(Qt.AlignCenter)
103
+ title.setStyleSheet("font-size: 14px; font-weight: 600;")
104
+ layout.addWidget(title)
105
+ note = QLabel("后续放入真实收款码\n当前仅展示,不收款")
106
+ note.setAlignment(Qt.AlignCenter)
107
+ note.setWordWrap(True)
108
+ layout.addWidget(note)
109
+ card.layout().addWidget(placeholder)
110
+
111
+ def _build_feedback_card(self, body: QWidget) -> None:
112
+ card = self.card(body)
113
+ self._card_title(card, "2", "问题反馈")
114
+
115
+ self._field_label(card, "问题类型")
116
+ self.type_combo = QComboBox()
117
+ self.type_combo.setMaximumWidth(360)
118
+ for item in ("请选择问题类型", "导出", "同步", "标注与占位", "格式调整", "备份与回滚", "其他"):
119
+ self.type_combo.addItem(item)
120
+ card.layout().addWidget(self.type_combo)
121
+
122
+ self._field_label(card, "软件版本")
123
+ self.version_edit = QLineEdit(f"v{__version__}")
124
+ self.version_edit.setMaximumWidth(180)
125
+ card.layout().addWidget(self.version_edit)
126
+
127
+ self._field_label(card, "文件类型")
128
+ self.file_type_edit = QLineEdit()
129
+ self.file_type_edit.setMaximumWidth(360)
130
+ self.file_type_edit.setPlaceholderText("例如:Word + Excel")
131
+ card.layout().addWidget(self.file_type_edit)
132
+
133
+ self._field_label(card, "问题描述")
134
+ self.description_edit = QPlainTextEdit()
135
+ self.description_edit.setPlaceholderText("请说明做了什么、期望结果和实际结果;如需附截图,请在邮件客户端中添加。")
136
+ self.description_edit.setMinimumHeight(110)
137
+ card.layout().addWidget(self.description_edit)
138
+
139
+ def _build_suggestion_card(self, body: QWidget) -> None:
140
+ card = self.card(body)
141
+ self._card_title(card, "3", "功能建议")
142
+ self._field_label(card, "希望增加或改进什么")
143
+ self.suggestion_edit = QPlainTextEdit()
144
+ self.suggestion_edit.setPlaceholderText("欢迎描述你的使用场景和期望效果。")
145
+ self.suggestion_edit.setMinimumHeight(110)
146
+ card.layout().addWidget(self.suggestion_edit)
147
+ compose = QPushButton("整理成邮件")
148
+ compose.setObjectName("Primary")
149
+ compose.clicked.connect(lambda _checked=False: self._compose_mail())
150
+ card.layout().addWidget(compose)
151
+
152
+ def _copy_email(self) -> None:
153
+ QApplication.clipboard().setText(self.EMAIL)
154
+ self.ctx.info("已复制邮箱", f"联系邮箱 {self.EMAIL} 已复制到剪贴板。")
155
+
156
+ def _open_mail(self, url: QUrl, fallback_text: str) -> None:
157
+ if QDesktopServices.openUrl(url):
158
+ return
159
+ QApplication.clipboard().setText(fallback_text)
160
+ self.ctx.info("邮件草稿已复制", "未能打开系统邮件客户端,已将邮件内容或邮箱地址复制到剪贴板。")
161
+
162
+ def _write_email(self) -> None:
163
+ self._open_mail(QUrl(f"mailto:{self.EMAIL}"), self.EMAIL)
164
+
165
+ def _compose_mail(self) -> None:
166
+ description = self.description_edit.toPlainText().strip()
167
+ suggestion = self.suggestion_edit.toPlainText().strip()
168
+ if not description and not suggestion:
169
+ self.ctx.info("尚未填写内容", "请先填写问题描述或功能建议,再整理成邮件。")
170
+ return
171
+
172
+ problem_type = self.type_combo.currentText()
173
+ if problem_type == "请选择问题类型":
174
+ problem_type = "未选择"
175
+ version = self.version_edit.text().strip() or "未填写"
176
+ file_type = self.file_type_edit.text().strip() or "未填写"
177
+ if description and suggestion:
178
+ subject_kind = "问题反馈与功能建议"
179
+ elif description:
180
+ subject_kind = "问题反馈"
181
+ else:
182
+ subject_kind = "功能建议"
183
+ subject = f"[审计工具箱] {subject_kind}"
184
+ body = (
185
+ "审计工具箱反馈邮件草稿\n"
186
+ "\n【问题反馈】\n"
187
+ f"问题类型:{problem_type}\n"
188
+ f"软件版本:{version}\n"
189
+ f"文件类型:{file_type}\n"
190
+ f"问题描述:\n{description or '(未填写)'}\n"
191
+ "\n【功能建议】\n"
192
+ f"{suggestion or '(未填写)'}\n"
193
+ "\n说明:本邮件由审计工具箱“问题反馈”页面整理,尚未发送。\n"
194
+ )
195
+ query = urlencode({"subject": subject, "body": body})
196
+ self._open_mail(QUrl(f"mailto:{self.EMAIL}?{query}"), f"收件人:{self.EMAIL}\n主题:{subject}\n\n{body}")