@tano.page/workbench 0.14.0 → 0.16.0

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 (248) hide show
  1. package/package.json +50 -16
  2. package/src/App.vue +82 -752
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/agent-identities.ts +1 -97
  17. package/src/assistant/agent-task-context.ts +1 -54
  18. package/src/assistant/attachments.ts +1 -1
  19. package/src/assistant/completion.ts +1 -61
  20. package/src/assistant/components/AssistantChangeList.vue +98 -21
  21. package/src/assistant/components/AssistantPanel.vue +425 -8
  22. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  23. package/src/assistant/connection-actions.ts +237 -0
  24. package/src/assistant/document-mentions.ts +1 -33
  25. package/src/assistant/engine.ts +1 -532
  26. package/src/assistant/execution.ts +6 -33
  27. package/src/assistant/files.ts +5 -13
  28. package/src/assistant/hash.ts +1 -4
  29. package/src/assistant/inbox.ts +1 -148
  30. package/src/assistant/language.ts +10 -37
  31. package/src/assistant/mention-autocomplete.ts +69 -0
  32. package/src/assistant/plugin-bridge-builder.ts +146 -0
  33. package/src/assistant/prompts.ts +1 -58
  34. package/src/assistant/proposal-actions.ts +336 -0
  35. package/src/assistant/results.ts +20 -86
  36. package/src/assistant/store.ts +167 -327
  37. package/src/assistant/structures.ts +1 -155
  38. package/src/assistant/tasks.ts +8 -96
  39. package/src/assistant/tool-rules.ts +1 -7
  40. package/src/assistant/workspace-bridge.ts +1 -1
  41. package/src/composables/use-document-actions.ts +38 -20
  42. package/src/composables/use-file-tree-controller.ts +7 -12
  43. package/src/composables/use-workbench-help.ts +177 -0
  44. package/src/composables/use-workbench-history.ts +2 -4
  45. package/src/composables/use-workbench-lifecycle.ts +249 -0
  46. package/src/composables/use-workbench-modals.ts +6 -1
  47. package/src/composables/use-workbench-outline.ts +0 -5
  48. package/src/composables/use-workbench-settings.ts +185 -0
  49. package/src/composables/use-workbench-shortcuts.ts +40 -1021
  50. package/src/composables/use-workbench-views.ts +325 -0
  51. package/src/data-tables/data-tables.ts +1 -2
  52. package/src/documents/components/DocumentActionMenu.vue +279 -0
  53. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  54. package/src/documents/components/DocumentInspector.vue +168 -0
  55. package/src/documents/components/DocumentPane.vue +482 -0
  56. package/src/documents/description-merge.ts +1 -9
  57. package/src/features.ts +1 -0
  58. package/src/files/components/FileMetadataPanel.vue +49 -15
  59. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  60. package/src/fonts/Inter-Latin.woff2 +0 -0
  61. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  62. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  63. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  64. package/src/help/help-milestones.ts +3 -5
  65. package/src/i18n/locale-catalogs.ts +7 -6
  66. package/src/i18n/locale-registry.ts +8 -6
  67. package/src/i18n/locales/de-DE.json +371 -3
  68. package/src/i18n/locales/en-US.json +371 -2
  69. package/src/i18n/locales/es-ES.json +371 -3
  70. package/src/i18n/locales/ja-JP.json +370 -2
  71. package/src/i18n/locales/zh-TW.json +370 -2
  72. package/src/mail/components/MailAccountDialog.vue +450 -0
  73. package/src/mail/components/MailComposerDialog.vue +326 -0
  74. package/src/mail/components/MailProviderIcon.vue +30 -0
  75. package/src/mail/components/MailWorkspaceView.vue +821 -0
  76. package/src/mail/components/SidebarMail.vue +134 -0
  77. package/src/mail/mail-avatar.ts +17 -0
  78. package/src/mail/mail-bridge.ts +68 -0
  79. package/src/mail/mail-calendar.ts +208 -0
  80. package/src/mail/mail-markdown.ts +195 -0
  81. package/src/mail/types.ts +226 -0
  82. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  83. package/src/objects/content-references.ts +6 -56
  84. package/src/objects/wiki-links.ts +1 -48
  85. package/src/objects/workspace-objects.ts +3 -4
  86. package/src/plan-sync/types.ts +6 -3
  87. package/src/plans/calendar-interaction.ts +194 -0
  88. package/src/plans/calendar.ts +65 -9
  89. package/src/plans/components/CalendarAgendaView.vue +165 -0
  90. package/src/plans/components/CalendarDayPopover.vue +172 -39
  91. package/src/plans/components/CalendarFilterBar.vue +128 -0
  92. package/src/plans/components/CalendarMonthView.vue +224 -0
  93. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  94. package/src/plans/components/CalendarTimelineView.vue +517 -0
  95. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  96. package/src/plans/components/CalendarView.vue +264 -748
  97. package/src/plans/components/CalendarYearView.vue +138 -0
  98. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  99. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  100. package/src/plans/components/PlanDateField.vue +6 -4
  101. package/src/plans/components/PlanDetailPanel.vue +227 -32
  102. package/src/plans/components/PlanEventList.vue +16 -4
  103. package/src/plans/components/SidebarPlan.vue +22 -15
  104. package/src/plans/components/TaskRepeatControls.vue +169 -30
  105. package/src/plans/components/calendar-shared.css +192 -0
  106. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  107. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  108. package/src/plans/local-reminders.ts +149 -0
  109. package/src/plans/personal-plans.ts +10 -1
  110. package/src/plans/plan-date.ts +8 -1
  111. package/src/plans/plan-migration.ts +95 -0
  112. package/src/plans/recurrence.ts +95 -0
  113. package/src/plans/task-repeat.ts +8 -8
  114. package/src/plans/timeline-layout.ts +92 -0
  115. package/src/plugins/assistant-bridge.ts +520 -0
  116. package/src/plugins/attachment-reader.ts +3 -1
  117. package/src/plugins/cache-storage.ts +42 -2
  118. package/src/plugins/components/PluginAutomations.vue +3 -3
  119. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  120. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  121. package/src/plugins/components/PluginConnections.vue +1 -1
  122. package/src/plugins/components/PluginCustomView.vue +2 -2
  123. package/src/plugins/components/PluginDetailPage.vue +136 -57
  124. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  125. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  126. package/src/plugins/components/PluginExplorer.vue +21 -25
  127. package/src/plugins/components/PluginImportDialog.vue +410 -0
  128. package/src/plugins/components/PluginInstaller.vue +273 -288
  129. package/src/plugins/components/PluginListItem.vue +3 -0
  130. package/src/plugins/components/PluginMaintenance.vue +37 -34
  131. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  132. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  133. package/src/plugins/components/PluginSettingsForm.vue +112 -0
  134. package/src/plugins/components/PluginStatusBar.vue +161 -0
  135. package/src/plugins/components/PluginSurface.vue +18 -6
  136. package/src/plugins/components/PluginUiDialog.vue +452 -0
  137. package/src/plugins/components/PluginsTabPage.vue +61 -0
  138. package/src/plugins/components/plugin-center.css +5 -0
  139. package/src/plugins/data.ts +9 -86
  140. package/src/plugins/editor-plugin-adapters.ts +169 -0
  141. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  142. package/src/plugins/excalidraw/manifest.json +12 -1
  143. package/src/plugins/host.ts +662 -43
  144. package/src/plugins/native.ts +2 -10
  145. package/src/plugins/overlay-mapping.ts +125 -0
  146. package/src/plugins/packages.ts +73 -1
  147. package/src/plugins/plugin-data.ts +2 -3
  148. package/src/plugins/plugin-permissions.ts +57 -0
  149. package/src/plugins/plugin-rpc-router.ts +558 -0
  150. package/src/plugins/plugin-sdk.ts +1 -94
  151. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  152. package/src/plugins/policy.ts +53 -3
  153. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  154. package/src/plugins/presentation-preview/manifest.json +2 -1
  155. package/src/plugins/queries.ts +1 -73
  156. package/src/plugins/sandbox.ts +15 -1
  157. package/src/plugins/use-plugin-actions.ts +67 -20
  158. package/src/plugins/user-plugins.ts +254 -0
  159. package/src/plugins/view-header.ts +2 -7
  160. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  161. package/src/plugins/word-preview/manifest.json +13 -1
  162. package/src/plugins/workbench.ts +175 -2
  163. package/src/plugins/worker.js +105 -8
  164. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  165. package/src/plugins/workspace-plugins.ts +212 -21
  166. package/src/runtime.ts +103 -4
  167. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  168. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  169. package/src/settings/components/SettingsPanel.vue +8 -3
  170. package/src/settings/components/WorkbenchSettings.vue +20 -7
  171. package/src/settings/components/settings-context.ts +1 -1
  172. package/src/settings/components/settings-search.ts +2 -3
  173. package/src/settings/settings-tab.ts +1 -0
  174. package/src/shell/command-palette.ts +3 -3
  175. package/src/shell/components/EditorToolbar.vue +8 -9
  176. package/src/shell/components/EditorTools.vue +1 -5
  177. package/src/shell/components/PaneTopbar.vue +393 -0
  178. package/src/shell/components/SelectionToolbar.vue +0 -2
  179. package/src/shell/components/SidebarNavigation.vue +22 -2
  180. package/src/shell/components/WorkbenchContextMenus.vue +58 -34
  181. package/src/shell/components/WorkbenchModals.vue +47 -62
  182. package/src/shell/components/WorkbenchPanes.vue +371 -1342
  183. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  184. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  185. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  186. package/src/shell/pane-registry.ts +69 -0
  187. package/src/shell/use-surface-dismissal.ts +219 -0
  188. package/src/shell/use-workbench-commands.ts +599 -0
  189. package/src/shell/use-workbench-keybindings.ts +337 -0
  190. package/src/shell/use-workbench.ts +531 -1153
  191. package/src/shell/workbench-async-components.ts +14 -5
  192. package/src/shell/workbench-context.ts +30 -3
  193. package/src/stores/mail.ts +414 -0
  194. package/src/stores/plan-sync.ts +2 -1
  195. package/src/stores/plans.ts +2 -9
  196. package/src/stores/workspace-document-io.ts +807 -0
  197. package/src/stores/workspace-file-ops.ts +1 -1
  198. package/src/stores/workspace-knowledge.ts +2 -114
  199. package/src/stores/workspace-lifecycle.ts +459 -0
  200. package/src/stores/workspace-plugins-state.ts +254 -259
  201. package/src/stores/workspace-session.ts +287 -0
  202. package/src/stores/workspace-tabs-layout.ts +6 -44
  203. package/src/stores/workspace-types.ts +50 -0
  204. package/src/stores/workspace.ts +184 -1363
  205. package/src/styles/agent-diff-modals.css +0 -7
  206. package/src/styles/dark-theme.css +3 -3
  207. package/src/styles/inspector.css +0 -59
  208. package/src/styles/layout-themes.css +346 -0
  209. package/src/styles/mail.css +1568 -0
  210. package/src/styles/mobile.css +2 -2
  211. package/src/styles/recent-and-media.css +0 -17
  212. package/src/styles/theme-contract.css +3 -3
  213. package/src/styles/workbench-shell.css +110 -17
  214. package/src/styles/workspace-states.css +9 -33
  215. package/src/styles.css +0 -1
  216. package/src/tabs/components/DesktopTabs.vue +19 -14
  217. package/src/tabs/components/NewTabPicker.vue +10 -4
  218. package/src/tabs/tab-label.ts +0 -1
  219. package/src/windows/AuxiliaryWindows.vue +2 -2
  220. package/src/windows/use-window-event-bridge.ts +152 -0
  221. package/src/workspace/components/TemplateLibrary.vue +1 -1
  222. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  223. package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
  224. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  225. package/src/workspace/workspace-comments.ts +11 -151
  226. package/src/workspace/workspace-welcome.ts +1 -1
  227. package/src/assistant/locales/de-DE.json +0 -126
  228. package/src/assistant/locales/en-US.json +0 -126
  229. package/src/assistant/locales/es-ES.json +0 -126
  230. package/src/assistant/locales/ja-JP.json +0 -126
  231. package/src/assistant/locales/zh-CN.json +0 -126
  232. package/src/assistant/locales/zh-TW.json +0 -126
  233. package/src/assistant/task-prompts.json +0 -39
  234. package/src/documents/components/FormulaMenu.vue +0 -50
  235. package/src/files/components/FileDatabasePage.vue +0 -152
  236. package/src/files/components/FolderHomeIcon.vue +0 -12
  237. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  238. package/src/objects/components/ObjectPanel.vue +0 -554
  239. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  240. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  241. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  242. package/src/styles/object-panel.css +0 -163
  243. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  244. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  245. package/src/workspace/welcome-slogans.ts +0 -11
  246. package/src/workspace/workspace-git.ts +0 -35
  247. package/src/workspace/workspace-sync.ts +0 -46
  248. package/src/workspace/workspace-views.ts +0 -48
@@ -0,0 +1,450 @@
1
+ <script setup lang="ts">
2
+ import '../../styles/mail.css';
3
+ import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
4
+ import {
5
+ AlertTriangle,
6
+ CheckCircle2,
7
+ ChevronLeft,
8
+ ChevronRight,
9
+ ShieldCheck,
10
+ Trash2,
11
+ X,
12
+ } from 'lucide-vue-next';
13
+ import { t } from '../../i18n/i18n';
14
+ import { useMailStore } from '../../stores/mail';
15
+ import type { AppendSentPolicy, MailAccountInput, MailPreset, TlsMode } from '../types';
16
+ import MailProviderIcon from './MailProviderIcon.vue';
17
+
18
+ const mail = useMailStore();
19
+
20
+ function close() {
21
+ if (testing.value || saving.value) return;
22
+ mail.accountDialogOpen = false;
23
+ }
24
+
25
+ function onKeydown(event: KeyboardEvent) {
26
+ if (!mail.accountDialogOpen || event.key !== 'Escape' || mail.composerOpen) return;
27
+ event.stopPropagation();
28
+ close();
29
+ }
30
+ onMounted(() => window.addEventListener('keydown', onKeydown, true));
31
+ onBeforeUnmount(() => window.removeEventListener('keydown', onKeydown, true));
32
+
33
+ const selectedPresetId = ref('qq');
34
+ const label = ref('QQ 邮箱');
35
+ const email = ref('');
36
+ const displayName = ref('');
37
+ const username = ref('');
38
+ const password = ref('');
39
+ const imapHost = ref('imap.qq.com');
40
+ const imapPort = ref(993);
41
+ const imapTls = ref<TlsMode>('tls');
42
+ const smtpHost = ref('smtp.qq.com');
43
+ const smtpPort = ref(465);
44
+ const smtpTls = ref<TlsMode>('tls');
45
+ const appendSent = ref<AppendSentPolicy>('never');
46
+ const sendImapId = ref(false);
47
+
48
+ const testing = ref(false);
49
+ const saving = ref(false);
50
+ const clearingCache = ref(false);
51
+ const error = ref('');
52
+ const statusMessage = ref('');
53
+
54
+ /** 'pick' = accounts + provider list, 'form' = credentials for one provider. */
55
+ const step = ref<'pick' | 'form'>('pick');
56
+ const emailInput = ref<HTMLInputElement>();
57
+ const isCustom = computed(() => selectedPresetId.value === 'custom');
58
+
59
+ async function pickProvider(presetId: string) {
60
+ applyPreset(presetId);
61
+ step.value = 'form';
62
+ await nextTick();
63
+ emailInput.value?.focus();
64
+ }
65
+
66
+ function backToPick() {
67
+ if (testing.value || saving.value) return;
68
+ step.value = 'pick';
69
+ error.value = '';
70
+ statusMessage.value = '';
71
+ }
72
+
73
+ const currentPreset = computed<MailPreset | undefined>(() =>
74
+ mail.presets.find((item) => item.id === selectedPresetId.value),
75
+ );
76
+
77
+ function applyPreset(presetId: string) {
78
+ selectedPresetId.value = presetId;
79
+ const preset = mail.presets.find((item) => item.id === presetId);
80
+ if (!preset) return;
81
+ label.value = preset.name;
82
+ imapHost.value = preset.imapHost;
83
+ imapPort.value = preset.imapPort;
84
+ imapTls.value = preset.imapTls;
85
+ smtpHost.value = preset.smtpHost;
86
+ smtpPort.value = preset.smtpPort;
87
+ smtpTls.value = preset.smtpTls;
88
+ appendSent.value = preset.appendSent;
89
+ sendImapId.value = preset.sendImapId;
90
+ error.value = '';
91
+ statusMessage.value = '';
92
+ }
93
+
94
+ watch(
95
+ () => mail.accountDialogOpen,
96
+ async (open) => {
97
+ if (!open) return;
98
+ await mail.init();
99
+ const requested = mail.accountDialogPreset;
100
+ mail.accountDialogPreset = '';
101
+ error.value = '';
102
+ statusMessage.value = '';
103
+ if (requested && mail.presets.some((item) => item.id === requested)) {
104
+ await pickProvider(requested);
105
+ } else {
106
+ step.value = 'pick';
107
+ }
108
+ },
109
+ { immediate: true },
110
+ );
111
+
112
+ function buildInput(): MailAccountInput {
113
+ return {
114
+ provider: selectedPresetId.value,
115
+ label: label.value.trim(),
116
+ email: email.value.trim(),
117
+ displayName: displayName.value.trim() || email.value.trim(),
118
+ imapHost: imapHost.value.trim(),
119
+ imapPort: Number(imapPort.value),
120
+ imapTls: imapTls.value,
121
+ smtpHost: smtpHost.value.trim(),
122
+ smtpPort: Number(smtpPort.value),
123
+ smtpTls: smtpTls.value,
124
+ appendSent: appendSent.value,
125
+ sendImapId: sendImapId.value,
126
+ };
127
+ }
128
+
129
+ async function testConnection() {
130
+ testing.value = true;
131
+ error.value = '';
132
+ statusMessage.value = '';
133
+ try {
134
+ const res = await mail.testAccount(buildInput(), {
135
+ username: username.value.trim() || email.value.trim(),
136
+ password: password.value,
137
+ });
138
+ statusMessage.value = res.message;
139
+ } catch (err) {
140
+ error.value = err instanceof Error ? err.message : String(err);
141
+ } finally {
142
+ testing.value = false;
143
+ }
144
+ }
145
+
146
+ async function submitAccount() {
147
+ saving.value = true;
148
+ error.value = '';
149
+ statusMessage.value = '';
150
+ try {
151
+ const saved = await mail.saveAccount(buildInput(), {
152
+ username: username.value.trim() || email.value.trim(),
153
+ password: password.value,
154
+ });
155
+ password.value = '';
156
+ statusMessage.value = t('账号已保存,正在首次同步文件夹与近期邮件…');
157
+ try {
158
+ await mail.syncAccount(saved.id);
159
+ email.value = '';
160
+ displayName.value = '';
161
+ username.value = '';
162
+ step.value = 'pick';
163
+ statusMessage.value = t('账号已连接并完成首次同步。');
164
+ } catch (syncErr) {
165
+ error.value =
166
+ syncErr instanceof Error
167
+ ? `${t('账号已保存,但首次同步失败:')}${syncErr.message}`
168
+ : String(syncErr);
169
+ }
170
+ } catch (err) {
171
+ error.value = err instanceof Error ? err.message : String(err);
172
+ } finally {
173
+ saving.value = false;
174
+ }
175
+ }
176
+
177
+ async function removeAccount(accountId: string) {
178
+ error.value = '';
179
+ try {
180
+ await mail.removeAccount(accountId);
181
+ statusMessage.value = t('已移除邮箱账号并清理本机凭据与缓存。');
182
+ } catch (err) {
183
+ error.value = err instanceof Error ? err.message : String(err);
184
+ }
185
+ }
186
+
187
+ async function clearCache() {
188
+ clearingCache.value = true;
189
+ try {
190
+ await mail.clearCache();
191
+ statusMessage.value = t('已清空本地邮件正文与附件缓存。');
192
+ } catch (err) {
193
+ error.value = err instanceof Error ? err.message : String(err);
194
+ } finally {
195
+ clearingCache.value = false;
196
+ }
197
+ }
198
+
199
+ function formatBytes(bytes: number): string {
200
+ if (bytes < 1024) return `${bytes} B`;
201
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
202
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
203
+ }
204
+ </script>
205
+
206
+ <template>
207
+ <Transition name="mail-modal">
208
+ <div
209
+ v-if="mail.accountDialogOpen"
210
+ class="mail-modal-backdrop"
211
+ @mousedown.self="close"
212
+ >
213
+ <section
214
+ class="mail-modal mail-account-modal"
215
+ role="dialog"
216
+ aria-modal="true"
217
+ :aria-label="t('邮箱账号管理')"
218
+ >
219
+ <!-- Step 1: connected accounts + choose a provider -->
220
+ <template v-if="step === 'pick'">
221
+ <header class="mail-modal-header compact">
222
+ <h2>{{ mail.accounts.length ? t('邮箱账号') : t('添加新邮箱') }}</h2>
223
+ <button
224
+ type="button"
225
+ class="icon-button"
226
+ :aria-label="t('关闭')"
227
+ :data-tooltip="t('关闭')"
228
+ @click="close"
229
+ >
230
+ <X :size="16" />
231
+ </button>
232
+ </header>
233
+
234
+ <div class="mail-modal-body">
235
+ <Transition name="mail-notice" mode="out-in">
236
+ <p v-if="error" key="err" class="mail-alert error" role="alert">
237
+ <AlertTriangle :size="14" /> <span>{{ error }}</span>
238
+ </p>
239
+ <p v-else-if="statusMessage" key="ok" class="mail-alert success" role="status">
240
+ <CheckCircle2 :size="14" /> <span>{{ statusMessage }}</span>
241
+ </p>
242
+ </Transition>
243
+
244
+ <section v-if="mail.accounts.length" class="mail-modal-section">
245
+ <ul class="mail-saved-accounts">
246
+ <li v-for="acc in mail.accounts" :key="acc.id" class="mail-saved-account-row">
247
+ <MailProviderIcon :provider="acc.provider" />
248
+ <div class="mail-saved-account-text">
249
+ <strong>{{ acc.label }}</strong>
250
+ <span>{{ acc.email }}</span>
251
+ </div>
252
+ <button
253
+ type="button"
254
+ class="icon-button danger"
255
+ :aria-label="t('移除')"
256
+ :data-tooltip="t('移除')"
257
+ @click="removeAccount(acc.id)"
258
+ >
259
+ <Trash2 :size="15" />
260
+ </button>
261
+ </li>
262
+ </ul>
263
+ <p v-if="mail.cacheStats" class="mail-cache-line">
264
+ <span>
265
+ {{
266
+ t('本机缓存:{0} 封邮件 · 正文 {1} · 附件 {2}', [
267
+ mail.cacheStats.messageCount,
268
+ formatBytes(mail.cacheStats.cachedBodyBytes),
269
+ formatBytes(mail.cacheStats.cachedAttachmentBytes),
270
+ ])
271
+ }}
272
+ </span>
273
+ <button
274
+ type="button"
275
+ class="mail-link-btn"
276
+ :disabled="clearingCache"
277
+ @click="clearCache"
278
+ >
279
+ {{ clearingCache ? t('正在清理…') : t('清空正文与附件缓存') }}
280
+ </button>
281
+ </p>
282
+ </section>
283
+
284
+ <section class="mail-modal-section">
285
+ <h3 v-if="mail.accounts.length">{{ t('添加新邮箱') }}</h3>
286
+ <div class="mail-provider-grid">
287
+ <button
288
+ v-for="preset in mail.presets"
289
+ :key="preset.id"
290
+ type="button"
291
+ class="mail-provider"
292
+ :title="preset.name"
293
+ @click="pickProvider(preset.id)"
294
+ >
295
+ <MailProviderIcon :provider="preset.id" />
296
+ <span class="mail-provider-name">{{ preset.name }}</span>
297
+ <ChevronRight :size="15" class="mail-provider-chevron" />
298
+ </button>
299
+ </div>
300
+ </section>
301
+ </div>
302
+ </template>
303
+
304
+ <!-- Step 2: only what this provider needs -->
305
+ <template v-else>
306
+ <header class="mail-modal-header compact">
307
+ <div class="mail-form-title">
308
+ <button
309
+ type="button"
310
+ class="icon-button"
311
+ :disabled="testing || saving"
312
+ :aria-label="t('返回')"
313
+ :data-tooltip="t('返回')"
314
+ @click="backToPick"
315
+ >
316
+ <ChevronLeft :size="16" />
317
+ </button>
318
+ <MailProviderIcon :provider="selectedPresetId" />
319
+ <h2>{{ currentPreset?.name ?? label }}</h2>
320
+ </div>
321
+ <button
322
+ type="button"
323
+ class="icon-button"
324
+ :aria-label="t('关闭')"
325
+ :data-tooltip="t('关闭')"
326
+ @click="close"
327
+ >
328
+ <X :size="16" />
329
+ </button>
330
+ </header>
331
+
332
+ <form class="mail-modal-body mail-account-form" @submit.prevent="submitAccount">
333
+ <p v-if="currentPreset?.authHint" class="mail-auth-hint">{{ currentPreset.authHint }}</p>
334
+
335
+ <label class="mail-field">
336
+ <span>{{ t('邮箱地址') }}</span>
337
+ <input
338
+ ref="emailInput"
339
+ v-model="email"
340
+ type="email"
341
+ autocomplete="email"
342
+ placeholder="name@example.com"
343
+ />
344
+ </label>
345
+ <label class="mail-field">
346
+ <span>{{ t('授权码 / App 专用密码') }}</span>
347
+ <input v-model="password" type="password" autocomplete="off" />
348
+ </label>
349
+
350
+ <!-- A custom server cannot work without hosts: keep them in view. -->
351
+ <div v-if="isCustom" class="mail-form-grid">
352
+ <label class="mail-field">
353
+ <span>IMAP {{ t('服务器') }}</span>
354
+ <input v-model="imapHost" type="text" placeholder="imap.example.com" />
355
+ </label>
356
+ <label class="mail-field">
357
+ <span>SMTP {{ t('服务器') }}</span>
358
+ <input v-model="smtpHost" type="text" placeholder="smtp.example.com" />
359
+ </label>
360
+ </div>
361
+
362
+ <details class="mail-advanced">
363
+ <summary>
364
+ <ChevronRight :size="14" class="mail-advanced-chevron" />
365
+ {{ t('更多设置') }}
366
+ </summary>
367
+ <div class="mail-form-grid">
368
+ <label class="mail-field">
369
+ <span>{{ t('连接名称') }}</span>
370
+ <input v-model="label" type="text" />
371
+ </label>
372
+ <label class="mail-field">
373
+ <span>{{ t('发件人显示名(可选)') }}</span>
374
+ <input v-model="displayName" type="text" />
375
+ </label>
376
+ <label class="mail-field mail-form-full">
377
+ <span>{{ t('登录用户名(留空同邮箱)') }}</span>
378
+ <input v-model="username" type="text" />
379
+ </label>
380
+ <label v-if="!isCustom" class="mail-field">
381
+ <span>IMAP {{ t('服务器') }}</span>
382
+ <input v-model="imapHost" type="text" />
383
+ </label>
384
+ <label class="mail-field">
385
+ <span>IMAP {{ t('端口与加密') }}</span>
386
+ <div class="mail-inline-pair">
387
+ <input v-model.number="imapPort" type="number" min="1" max="65535" />
388
+ <select v-model="imapTls">
389
+ <option value="tls">TLS (993)</option>
390
+ <option value="starttls">STARTTLS (143)</option>
391
+ </select>
392
+ </div>
393
+ </label>
394
+ <label v-if="!isCustom" class="mail-field">
395
+ <span>SMTP {{ t('服务器') }}</span>
396
+ <input v-model="smtpHost" type="text" />
397
+ </label>
398
+ <label class="mail-field">
399
+ <span>SMTP {{ t('端口与加密') }}</span>
400
+ <div class="mail-inline-pair">
401
+ <input v-model.number="smtpPort" type="number" min="1" max="65535" />
402
+ <select v-model="smtpTls">
403
+ <option value="tls">TLS (465)</option>
404
+ <option value="starttls">STARTTLS (587)</option>
405
+ </select>
406
+ </div>
407
+ </label>
408
+ </div>
409
+ </details>
410
+
411
+ <Transition name="mail-notice" mode="out-in">
412
+ <p v-if="error" key="err" class="mail-alert error" role="alert">
413
+ <AlertTriangle :size="14" /> <span>{{ error }}</span>
414
+ </p>
415
+ <p v-else-if="statusMessage" key="ok" class="mail-alert success" role="status">
416
+ <CheckCircle2 :size="14" /> <span>{{ statusMessage }}</span>
417
+ </p>
418
+ </Transition>
419
+ <button type="submit" hidden />
420
+ </form>
421
+
422
+ <footer class="mail-modal-footer">
423
+ <p class="mail-footer-note">
424
+ <ShieldCheck :size="13" />
425
+ <span>{{ t('授权码仅保存在本机系统凭据库') }}</span>
426
+ </p>
427
+ <button
428
+ type="button"
429
+ class="mail-btn-ghost"
430
+ :disabled="testing || saving"
431
+ @click="testConnection"
432
+ >
433
+ <span v-if="testing" class="mail-btn-spinner" aria-hidden="true" />
434
+ {{ testing ? t('正在测试…') : t('测试连接') }}
435
+ </button>
436
+ <button
437
+ type="button"
438
+ class="mail-btn-primary"
439
+ :disabled="testing || saving"
440
+ @click="submitAccount"
441
+ >
442
+ <span v-if="saving" class="mail-btn-spinner" aria-hidden="true" />
443
+ {{ saving ? t('正在保存…') : t('保存并同步') }}
444
+ </button>
445
+ </footer>
446
+ </template>
447
+ </section>
448
+ </div>
449
+ </Transition>
450
+ </template>