@tano.page/workbench 0.14.0 → 0.15.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.
- package/package.json +21 -8
- package/src/App.vue +76 -17
- package/src/appearance/appearance.ts +14 -4
- package/src/appearance/components/ThemePresetPreview.vue +52 -8
- package/src/appearance/interface-font.ts +99 -0
- package/src/appearance/theme.ts +26 -10
- package/src/appearance/use-interface-font.ts +30 -0
- package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
- package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
- package/src/assets/mail-provider-icons/gmail.svg +1 -0
- package/src/assets/mail-provider-icons/icloud.svg +12 -0
- package/src/assets/mail-provider-icons/netease-126.svg +5 -0
- package/src/assets/mail-provider-icons/netease-163.svg +5 -0
- package/src/assets/mail-provider-icons/qq.svg +9 -0
- package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
- package/src/assistant/components/AssistantChangeList.vue +98 -21
- package/src/assistant/components/AssistantPanel.vue +424 -7
- package/src/assistant/components/PluginToolProposalCard.vue +235 -0
- package/src/assistant/engine.ts +56 -3
- package/src/assistant/files.ts +5 -13
- package/src/assistant/inbox.ts +1 -148
- package/src/assistant/locales/de-DE.json +4 -1
- package/src/assistant/locales/en-US.json +4 -1
- package/src/assistant/locales/es-ES.json +4 -1
- package/src/assistant/locales/ja-JP.json +4 -1
- package/src/assistant/locales/zh-CN.json +4 -1
- package/src/assistant/locales/zh-TW.json +4 -1
- package/src/assistant/mention-autocomplete.ts +69 -0
- package/src/assistant/prompts.ts +7 -0
- package/src/assistant/results.ts +20 -86
- package/src/assistant/store.ts +319 -12
- package/src/assistant/structures.ts +7 -5
- package/src/assistant/tasks.ts +3 -5
- package/src/assistant/workspace-bridge.ts +1 -1
- package/src/composables/use-document-actions.ts +38 -20
- package/src/composables/use-file-tree-controller.ts +7 -12
- package/src/composables/use-workbench-history.ts +2 -4
- package/src/composables/use-workbench-modals.ts +6 -1
- package/src/composables/use-workbench-outline.ts +0 -5
- package/src/composables/use-workbench-shortcuts.ts +26 -22
- package/src/data-tables/data-tables.ts +1 -2
- package/src/documents/components/DocumentHistoryPanel.vue +3 -1
- package/src/features.ts +1 -0
- package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
- package/src/fonts/Inter-Latin.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
- package/src/help/help-milestones.ts +3 -5
- package/src/i18n/locales/de-DE.json +349 -3
- package/src/i18n/locales/en-US.json +349 -2
- package/src/i18n/locales/es-ES.json +349 -3
- package/src/i18n/locales/ja-JP.json +348 -2
- package/src/i18n/locales/zh-TW.json +348 -2
- package/src/mail/components/MailAccountDialog.vue +449 -0
- package/src/mail/components/MailComposerDialog.vue +325 -0
- package/src/mail/components/MailProviderIcon.vue +30 -0
- package/src/mail/components/MailWorkspaceView.vue +820 -0
- package/src/mail/components/SidebarMail.vue +133 -0
- package/src/mail/mail-avatar.ts +17 -0
- package/src/mail/mail-bridge.ts +68 -0
- package/src/mail/mail-calendar.ts +208 -0
- package/src/mail/mail-markdown.ts +195 -0
- package/src/mail/types.ts +226 -0
- package/src/objects/components/ObjectDetailModal.vue +1001 -0
- package/src/objects/workspace-objects.ts +1 -1
- package/src/plan-sync/types.ts +6 -3
- package/src/plans/calendar-interaction.ts +194 -0
- package/src/plans/calendar.ts +63 -7
- package/src/plans/components/CalendarDayPopover.vue +172 -39
- package/src/plans/components/CalendarView.vue +1736 -276
- package/src/plans/components/PlanArchiveDialog.vue +295 -0
- package/src/plans/components/PlanDateField.vue +6 -4
- package/src/plans/components/PlanDetailPanel.vue +227 -32
- package/src/plans/components/PlanEventList.vue +16 -4
- package/src/plans/components/SidebarPlan.vue +22 -15
- package/src/plans/components/TaskRepeatControls.vue +169 -30
- package/src/plans/local-reminders.ts +149 -0
- package/src/plans/personal-plans.ts +10 -1
- package/src/plans/plan-date.ts +8 -1
- package/src/plans/plan-migration.ts +95 -0
- package/src/plans/recurrence.ts +95 -0
- package/src/plans/task-repeat.ts +8 -8
- package/src/plans/timeline-layout.ts +92 -0
- package/src/plugins/assistant-bridge.ts +520 -0
- package/src/plugins/attachment-reader.ts +3 -1
- package/src/plugins/cache-storage.ts +42 -2
- package/src/plugins/components/PluginAutomations.vue +3 -3
- package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
- package/src/plugins/components/PluginChangeSummary.vue +16 -3
- package/src/plugins/components/PluginConnections.vue +1 -1
- package/src/plugins/components/PluginCustomView.vue +2 -2
- package/src/plugins/components/PluginDetailPage.vue +129 -54
- package/src/plugins/components/PluginDocumentSlot.vue +63 -0
- package/src/plugins/components/PluginExplorer.vue +15 -21
- package/src/plugins/components/PluginImportDialog.vue +410 -0
- package/src/plugins/components/PluginInstaller.vue +39 -145
- package/src/plugins/components/PluginListItem.vue +3 -0
- package/src/plugins/components/PluginMaintenance.vue +21 -6
- package/src/plugins/components/PluginRuntimePanel.vue +3 -3
- package/src/plugins/components/PluginSettingsForm.vue +111 -0
- package/src/plugins/components/PluginStatusBar.vue +161 -0
- package/src/plugins/components/PluginSurface.vue +18 -6
- package/src/plugins/components/PluginUiDialog.vue +452 -0
- package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
- package/src/plugins/excalidraw/manifest.json +12 -1
- package/src/plugins/host.ts +662 -43
- package/src/plugins/native.ts +2 -10
- package/src/plugins/overlay-mapping.ts +125 -0
- package/src/plugins/packages.ts +73 -1
- package/src/plugins/plugin-permissions.ts +57 -0
- package/src/plugins/plugin-sdk.ts +174 -8
- package/src/plugins/policy.ts +53 -3
- package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/presentation-preview/manifest.json +2 -1
- package/src/plugins/queries.ts +3 -1
- package/src/plugins/sandbox.ts +15 -1
- package/src/plugins/use-plugin-actions.ts +67 -20
- package/src/plugins/user-plugins.ts +254 -0
- package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/word-preview/manifest.json +13 -1
- package/src/plugins/workbench.ts +175 -2
- package/src/plugins/worker.js +105 -8
- package/src/plugins/workspace-plugin-runtime.ts +23 -7
- package/src/plugins/workspace-plugins.ts +212 -21
- package/src/runtime.ts +101 -3
- package/src/settings/components/SettingsAppearancePage.vue +46 -0
- package/src/settings/components/SettingsDocumentsPage.vue +0 -1
- package/src/settings/components/settings-search.ts +2 -3
- package/src/shell/components/SidebarNavigation.vue +22 -2
- package/src/shell/components/WorkbenchContextMenus.vue +21 -8
- package/src/shell/components/WorkbenchModals.vue +27 -46
- package/src/shell/components/WorkbenchPanes.vue +267 -84
- package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
- package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
- package/src/shell/use-workbench.ts +116 -145
- package/src/shell/workbench-async-components.ts +14 -5
- package/src/stores/mail.ts +414 -0
- package/src/stores/plan-sync.ts +2 -1
- package/src/stores/plans.ts +2 -9
- package/src/stores/workspace-knowledge.ts +1 -113
- package/src/stores/workspace-plugins-state.ts +537 -14
- package/src/stores/workspace-tabs-layout.ts +5 -43
- package/src/stores/workspace.ts +69 -66
- package/src/styles/agent-diff-modals.css +0 -7
- package/src/styles/dark-theme.css +3 -3
- package/src/styles/inspector.css +0 -59
- package/src/styles/layout-themes.css +346 -0
- package/src/styles/mail.css +1568 -0
- package/src/styles/mobile.css +2 -2
- package/src/styles/recent-and-media.css +0 -17
- package/src/styles/theme-contract.css +3 -3
- package/src/styles/workbench-shell.css +110 -17
- package/src/styles/workspace-states.css +9 -33
- package/src/styles.css +1 -1
- package/src/tabs/components/DesktopTabs.vue +0 -3
- package/src/tabs/components/NewTabPicker.vue +10 -4
- package/src/tabs/tab-label.ts +0 -1
- package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
- package/src/workspace/components/WorkspaceIconPicker.vue +28 -6
- package/src/workspace/workspace-comments.ts +11 -151
- package/src/workspace/workspace-welcome.ts +1 -1
- package/src/documents/components/FormulaMenu.vue +0 -50
- package/src/files/components/FileDatabasePage.vue +0 -152
- package/src/files/components/FolderHomeIcon.vue +0 -12
- package/src/objects/components/ObjectDatabasePage.vue +0 -100
- package/src/objects/components/ObjectPanel.vue +0 -554
- package/src/plans/components/PersonalPlanDialog.vue +0 -105
- package/src/shell/components/WorkspaceViewPage.vue +0 -127
- package/src/shell/components/WorkspaceViewTab.vue +0 -24
- package/src/styles/object-panel.css +0 -163
- package/src/workspace/components/GitInspectionPanel.vue +0 -35
- package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
- package/src/workspace/welcome-slogans.ts +0 -11
- package/src/workspace/workspace-git.ts +0 -35
- package/src/workspace/workspace-sync.ts +0 -46
- package/src/workspace/workspace-views.ts +0 -48
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
import { defineStore } from 'pinia';
|
|
4
|
+
import { isFeatureEnabled } from '../features';
|
|
5
|
+
import { useWorkbenchRuntime } from '../runtime';
|
|
6
|
+
import { mailBridge } from '../mail/mail-bridge';
|
|
7
|
+
import type {
|
|
8
|
+
MailAccount,
|
|
9
|
+
MailAccountInput,
|
|
10
|
+
MailCacheStats,
|
|
11
|
+
MailComposeSeed,
|
|
12
|
+
MailCredentials,
|
|
13
|
+
MailDraft,
|
|
14
|
+
MailFilter,
|
|
15
|
+
MailFolder,
|
|
16
|
+
MailMessageDetail,
|
|
17
|
+
MailMessageSummary,
|
|
18
|
+
MailPreset,
|
|
19
|
+
MailSendRequest,
|
|
20
|
+
} from '../mail/types';
|
|
21
|
+
|
|
22
|
+
export const useMailStore = defineStore('mail', () => {
|
|
23
|
+
const runtime = useWorkbenchRuntime();
|
|
24
|
+
const available = computed(
|
|
25
|
+
() => isFeatureEnabled('desktopMailClient') && runtime.native && !runtime.mobile,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const presets = ref<MailPreset[]>([]);
|
|
29
|
+
const accounts = ref<MailAccount[]>([]);
|
|
30
|
+
const folders = ref<MailFolder[]>([]);
|
|
31
|
+
const messages = ref<MailMessageSummary[]>([]);
|
|
32
|
+
const drafts = ref<MailDraft[]>([]);
|
|
33
|
+
const cacheStats = ref<MailCacheStats | null>(null);
|
|
34
|
+
|
|
35
|
+
const selectedFolderId = ref('');
|
|
36
|
+
const selectedMessageId = ref('');
|
|
37
|
+
const currentDetail = ref<MailMessageDetail | null>(null);
|
|
38
|
+
|
|
39
|
+
const filter = ref<MailFilter>('all');
|
|
40
|
+
const searchQuery = ref('');
|
|
41
|
+
const loading = ref(false);
|
|
42
|
+
const loadingMessage = ref(false);
|
|
43
|
+
const syncingAccountId = ref('');
|
|
44
|
+
const error = ref('');
|
|
45
|
+
const initialized = ref(false);
|
|
46
|
+
|
|
47
|
+
const accountDialogOpen = ref(false);
|
|
48
|
+
/** Provider preset to preselect the next time the account dialog opens. */
|
|
49
|
+
const accountDialogPreset = ref('');
|
|
50
|
+
const composerOpen = ref(false);
|
|
51
|
+
const composeSeed = ref<MailComposeSeed | null>(null);
|
|
52
|
+
|
|
53
|
+
const totalUnread = computed(() =>
|
|
54
|
+
folders.value
|
|
55
|
+
.filter((folder) => folder.specialUse === 'inbox')
|
|
56
|
+
.reduce((sum, folder) => sum + folder.unreadCount, 0),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const selectedFolder = computed(() =>
|
|
60
|
+
folders.value.find((folder) => folder.id === selectedFolderId.value),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const foldersByAccount = computed(() => {
|
|
64
|
+
const map = new Map<string, MailFolder[]>();
|
|
65
|
+
for (const account of accounts.value) map.set(account.id, []);
|
|
66
|
+
for (const folder of folders.value) {
|
|
67
|
+
const list = map.get(folder.accountId);
|
|
68
|
+
if (list) list.push(folder);
|
|
69
|
+
}
|
|
70
|
+
return map;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
async function init() {
|
|
74
|
+
if (!available.value) return;
|
|
75
|
+
if (initialized.value) return;
|
|
76
|
+
loading.value = true;
|
|
77
|
+
error.value = '';
|
|
78
|
+
try {
|
|
79
|
+
const [presetList, accountList, folderList, draftList, stats] = await Promise.all([
|
|
80
|
+
mailBridge.presetsList(),
|
|
81
|
+
mailBridge.accountsList(),
|
|
82
|
+
mailBridge.foldersList(),
|
|
83
|
+
mailBridge.draftsList(),
|
|
84
|
+
mailBridge.cacheStats(),
|
|
85
|
+
]);
|
|
86
|
+
presets.value = presetList;
|
|
87
|
+
accounts.value = accountList;
|
|
88
|
+
folders.value = folderList;
|
|
89
|
+
drafts.value = draftList;
|
|
90
|
+
cacheStats.value = stats;
|
|
91
|
+
initialized.value = true;
|
|
92
|
+
|
|
93
|
+
if (!selectedFolderId.value && folderList.length) {
|
|
94
|
+
const firstInbox = folderList.find((f) => f.specialUse === 'inbox') ?? folderList[0]!;
|
|
95
|
+
await selectFolder(firstInbox.id);
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
99
|
+
} finally {
|
|
100
|
+
loading.value = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function refreshAccounts() {
|
|
105
|
+
if (!available.value) return;
|
|
106
|
+
accounts.value = await mailBridge.accountsList();
|
|
107
|
+
folders.value = await mailBridge.foldersList();
|
|
108
|
+
cacheStats.value = await mailBridge.cacheStats();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function testAccount(input: MailAccountInput, credentials: MailCredentials) {
|
|
112
|
+
if (!available.value) throw new Error('仅桌面端支持原生邮箱连接');
|
|
113
|
+
return mailBridge.accountTest(input, credentials);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function saveAccount(input: MailAccountInput, credentials?: MailCredentials) {
|
|
117
|
+
if (!available.value) throw new Error('仅桌面端支持原生邮箱连接');
|
|
118
|
+
const saved = await mailBridge.accountSave(input, credentials);
|
|
119
|
+
await refreshAccounts();
|
|
120
|
+
return saved;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function removeAccount(accountId: string) {
|
|
124
|
+
if (!available.value) return;
|
|
125
|
+
await mailBridge.accountRemove(accountId);
|
|
126
|
+
if (selectedFolder.value?.accountId === accountId) {
|
|
127
|
+
selectedFolderId.value = '';
|
|
128
|
+
selectedMessageId.value = '';
|
|
129
|
+
currentDetail.value = null;
|
|
130
|
+
messages.value = [];
|
|
131
|
+
}
|
|
132
|
+
await refreshAccounts();
|
|
133
|
+
if (!selectedFolderId.value && folders.value.length) {
|
|
134
|
+
const next = folders.value.find((f) => f.specialUse === 'inbox') ?? folders.value[0]!;
|
|
135
|
+
await selectFolder(next.id);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function syncAccount(accountId: string) {
|
|
140
|
+
if (!available.value || syncingAccountId.value) return;
|
|
141
|
+
syncingAccountId.value = accountId;
|
|
142
|
+
error.value = '';
|
|
143
|
+
try {
|
|
144
|
+
await mailBridge.syncAccount(accountId);
|
|
145
|
+
folders.value = await mailBridge.foldersList();
|
|
146
|
+
if (selectedFolderId.value) {
|
|
147
|
+
await reloadMessages();
|
|
148
|
+
} else {
|
|
149
|
+
const inbox =
|
|
150
|
+
folders.value.find((f) => f.accountId === accountId && f.specialUse === 'inbox') ??
|
|
151
|
+
folders.value.find((f) => f.accountId === accountId);
|
|
152
|
+
if (inbox) await selectFolder(inbox.id);
|
|
153
|
+
}
|
|
154
|
+
cacheStats.value = await mailBridge.cacheStats();
|
|
155
|
+
} catch (err) {
|
|
156
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
157
|
+
throw err;
|
|
158
|
+
} finally {
|
|
159
|
+
syncingAccountId.value = '';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function syncSelectedFolder() {
|
|
164
|
+
if (!available.value || !selectedFolderId.value || syncingAccountId.value) return;
|
|
165
|
+
const folder = selectedFolder.value;
|
|
166
|
+
if (!folder) return;
|
|
167
|
+
syncingAccountId.value = folder.accountId;
|
|
168
|
+
error.value = '';
|
|
169
|
+
try {
|
|
170
|
+
await mailBridge.syncFolder(folder.id);
|
|
171
|
+
folders.value = await mailBridge.foldersList();
|
|
172
|
+
await reloadMessages();
|
|
173
|
+
cacheStats.value = await mailBridge.cacheStats();
|
|
174
|
+
} catch (err) {
|
|
175
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
176
|
+
throw err;
|
|
177
|
+
} finally {
|
|
178
|
+
syncingAccountId.value = '';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function selectFolder(folderId: string) {
|
|
183
|
+
if (!available.value) return;
|
|
184
|
+
selectedFolderId.value = folderId;
|
|
185
|
+
searchQuery.value = '';
|
|
186
|
+
await reloadMessages();
|
|
187
|
+
if (messages.value.length && !messages.value.some((m) => m.id === selectedMessageId.value)) {
|
|
188
|
+
await selectMessage(messages.value[0]!.id);
|
|
189
|
+
} else if (!messages.value.length) {
|
|
190
|
+
selectedMessageId.value = '';
|
|
191
|
+
currentDetail.value = null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function reloadMessages() {
|
|
196
|
+
if (!available.value) return;
|
|
197
|
+
if (searchQuery.value.trim()) {
|
|
198
|
+
messages.value = await mailBridge.messagesSearch(
|
|
199
|
+
searchQuery.value.trim(),
|
|
200
|
+
selectedFolder.value?.accountId,
|
|
201
|
+
);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (!selectedFolderId.value) {
|
|
205
|
+
messages.value = [];
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
messages.value = await mailBridge.messagesList(selectedFolderId.value, {
|
|
209
|
+
limit: 80,
|
|
210
|
+
offset: 0,
|
|
211
|
+
filter: filter.value,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function setFilter(next: MailFilter) {
|
|
216
|
+
filter.value = next;
|
|
217
|
+
await reloadMessages();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function search(query: string) {
|
|
221
|
+
searchQuery.value = query;
|
|
222
|
+
await reloadMessages();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async function selectMessage(messageId: string, forceRefresh = false) {
|
|
226
|
+
if (!available.value) return;
|
|
227
|
+
selectedMessageId.value = messageId;
|
|
228
|
+
loadingMessage.value = true;
|
|
229
|
+
error.value = '';
|
|
230
|
+
try {
|
|
231
|
+
const detail = await mailBridge.messageGet(messageId, forceRefresh);
|
|
232
|
+
if (selectedMessageId.value !== messageId) return;
|
|
233
|
+
currentDetail.value = detail;
|
|
234
|
+
if (!detail.summary.seen) {
|
|
235
|
+
const updated = await mailBridge.updateFlags(messageId, { seen: true });
|
|
236
|
+
if (selectedMessageId.value === messageId) currentDetail.value = updated;
|
|
237
|
+
syncSummaryInList(updated.summary);
|
|
238
|
+
folders.value = await mailBridge.foldersList();
|
|
239
|
+
} else {
|
|
240
|
+
syncSummaryInList(detail.summary);
|
|
241
|
+
}
|
|
242
|
+
cacheStats.value = await mailBridge.cacheStats();
|
|
243
|
+
} catch (err) {
|
|
244
|
+
error.value = err instanceof Error ? err.message : String(err);
|
|
245
|
+
} finally {
|
|
246
|
+
loadingMessage.value = false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function syncSummaryInList(summary: MailMessageSummary) {
|
|
251
|
+
messages.value = messages.value.map((item) => (item.id === summary.id ? summary : item));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async function toggleSeen(messageId: string, nextSeen: boolean) {
|
|
255
|
+
if (!available.value) return;
|
|
256
|
+
const updated = await mailBridge.updateFlags(messageId, { seen: nextSeen });
|
|
257
|
+
syncSummaryInList(updated.summary);
|
|
258
|
+
if (currentDetail.value?.summary.id === messageId) currentDetail.value = updated;
|
|
259
|
+
folders.value = await mailBridge.foldersList();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function toggleFlagged(messageId: string, nextFlagged: boolean) {
|
|
263
|
+
if (!available.value) return;
|
|
264
|
+
const updated = await mailBridge.updateFlags(messageId, { flagged: nextFlagged });
|
|
265
|
+
syncSummaryInList(updated.summary);
|
|
266
|
+
if (currentDetail.value?.summary.id === messageId) currentDetail.value = updated;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function moveToSpecialFolder(messageId: string, specialUse: 'trash' | 'archive') {
|
|
270
|
+
if (!available.value) return;
|
|
271
|
+
const summary = messages.value.find((m) => m.id === messageId) ?? currentDetail.value?.summary;
|
|
272
|
+
if (!summary) return;
|
|
273
|
+
const target = folders.value.find(
|
|
274
|
+
(f) => f.accountId === summary.accountId && f.specialUse === specialUse,
|
|
275
|
+
);
|
|
276
|
+
if (!target) {
|
|
277
|
+
throw new Error(specialUse === 'trash' ? '该邮箱未提供废纸篓文件夹' : '该邮箱未提供归档文件夹');
|
|
278
|
+
}
|
|
279
|
+
await mailBridge.moveMessage(messageId, target.id);
|
|
280
|
+
messages.value = messages.value.filter((m) => m.id !== messageId);
|
|
281
|
+
if (selectedMessageId.value === messageId) {
|
|
282
|
+
selectedMessageId.value = '';
|
|
283
|
+
currentDetail.value = null;
|
|
284
|
+
}
|
|
285
|
+
folders.value = await mailBridge.foldersList();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function markInviteState(
|
|
289
|
+
inviteId: string,
|
|
290
|
+
importedObjectId?: string | null,
|
|
291
|
+
rsvpStatus?: string | null,
|
|
292
|
+
) {
|
|
293
|
+
if (!available.value) return;
|
|
294
|
+
await mailBridge.updateInvite(inviteId, importedObjectId, rsvpStatus);
|
|
295
|
+
if (currentDetail.value) {
|
|
296
|
+
currentDetail.value = {
|
|
297
|
+
...currentDetail.value,
|
|
298
|
+
invites: currentDetail.value.invites.map((inv) =>
|
|
299
|
+
inv.id === inviteId
|
|
300
|
+
? {
|
|
301
|
+
...inv,
|
|
302
|
+
importedObjectId: importedObjectId ?? inv.importedObjectId,
|
|
303
|
+
rsvpStatus: rsvpStatus ?? inv.rsvpStatus,
|
|
304
|
+
}
|
|
305
|
+
: inv,
|
|
306
|
+
),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async function downloadAttachment(attachmentId: string) {
|
|
312
|
+
if (!available.value) throw new Error('仅桌面端支持下载邮件附件');
|
|
313
|
+
const result = await mailBridge.downloadAttachment(attachmentId);
|
|
314
|
+
if (currentDetail.value) {
|
|
315
|
+
currentDetail.value = {
|
|
316
|
+
...currentDetail.value,
|
|
317
|
+
attachments: currentDetail.value.attachments.map((att) =>
|
|
318
|
+
att.id === attachmentId ? { ...att, downloaded: true } : att,
|
|
319
|
+
),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
cacheStats.value = await mailBridge.cacheStats();
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async function sendMail(request: MailSendRequest) {
|
|
327
|
+
if (!available.value) throw new Error('仅桌面端支持原生发信');
|
|
328
|
+
return mailBridge.sendMail(request);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async function clearCache() {
|
|
332
|
+
if (!available.value) return;
|
|
333
|
+
cacheStats.value = await mailBridge.cacheClear();
|
|
334
|
+
currentDetail.value = null;
|
|
335
|
+
selectedMessageId.value = '';
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function saveDraft(draft: MailDraft) {
|
|
339
|
+
if (!available.value) return;
|
|
340
|
+
const saved = await mailBridge.draftSave(draft);
|
|
341
|
+
drafts.value = [saved, ...drafts.value.filter((d) => d.id !== saved.id)];
|
|
342
|
+
return saved;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async function deleteDraft(draftId: string) {
|
|
346
|
+
if (!available.value) return;
|
|
347
|
+
await mailBridge.draftDelete(draftId);
|
|
348
|
+
drafts.value = drafts.value.filter((d) => d.id !== draftId);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function openComposer(seed: MailComposeSeed = {}) {
|
|
352
|
+
if (!available.value) return;
|
|
353
|
+
composeSeed.value = {
|
|
354
|
+
accountId: seed.accountId ?? selectedFolder.value?.accountId ?? accounts.value[0]?.id,
|
|
355
|
+
...seed,
|
|
356
|
+
};
|
|
357
|
+
composerOpen.value = true;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function closeComposer() {
|
|
361
|
+
composerOpen.value = false;
|
|
362
|
+
composeSeed.value = null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
available,
|
|
367
|
+
presets,
|
|
368
|
+
accounts,
|
|
369
|
+
folders,
|
|
370
|
+
foldersByAccount,
|
|
371
|
+
messages,
|
|
372
|
+
drafts,
|
|
373
|
+
cacheStats,
|
|
374
|
+
selectedFolderId,
|
|
375
|
+
selectedFolder,
|
|
376
|
+
selectedMessageId,
|
|
377
|
+
currentDetail,
|
|
378
|
+
filter,
|
|
379
|
+
searchQuery,
|
|
380
|
+
loading,
|
|
381
|
+
loadingMessage,
|
|
382
|
+
syncingAccountId,
|
|
383
|
+
error,
|
|
384
|
+
initialized,
|
|
385
|
+
totalUnread,
|
|
386
|
+
accountDialogOpen,
|
|
387
|
+
accountDialogPreset,
|
|
388
|
+
composerOpen,
|
|
389
|
+
composeSeed,
|
|
390
|
+
init,
|
|
391
|
+
refreshAccounts,
|
|
392
|
+
testAccount,
|
|
393
|
+
saveAccount,
|
|
394
|
+
removeAccount,
|
|
395
|
+
syncAccount,
|
|
396
|
+
syncSelectedFolder,
|
|
397
|
+
selectFolder,
|
|
398
|
+
reloadMessages,
|
|
399
|
+
setFilter,
|
|
400
|
+
search,
|
|
401
|
+
selectMessage,
|
|
402
|
+
toggleSeen,
|
|
403
|
+
toggleFlagged,
|
|
404
|
+
moveToSpecialFolder,
|
|
405
|
+
markInviteState,
|
|
406
|
+
downloadAttachment,
|
|
407
|
+
sendMail,
|
|
408
|
+
clearCache,
|
|
409
|
+
saveDraft,
|
|
410
|
+
deleteDraft,
|
|
411
|
+
openComposer,
|
|
412
|
+
closeComposer,
|
|
413
|
+
};
|
|
414
|
+
});
|
package/src/stores/plan-sync.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, onScopeDispose, ref } from 'vue';
|
|
2
2
|
import { defineStore } from 'pinia';
|
|
3
3
|
import { nativeInvoke as invoke } from '../platform/native-bridge';
|
|
4
|
+
import { isPlanObject } from '@tano/protocol';
|
|
4
5
|
import type { WorkspaceObject } from '@tano/protocol';
|
|
5
6
|
import { useWorkbenchRuntime } from '../runtime';
|
|
6
7
|
import { useWorkspaceStore } from './workspace';
|
|
@@ -64,7 +65,7 @@ export const usePlanSyncStore = defineStore('plan-sync', () => {
|
|
|
64
65
|
return { type: 'event', name: value.name, description: value.description, archived: value.archived, properties: { ...itemProperties(value, kind), ...extra } };
|
|
65
66
|
}
|
|
66
67
|
function port(connection: Connection): LocalSyncPort {
|
|
67
|
-
const list = async () => (await records(connection.scope, connection.workspaceId)).filter(r =>
|
|
68
|
+
const list = async () => (await records(connection.scope, connection.workspaceId)).filter(r => isPlanObject(r.object) && (connection.kind === 'todo' ? isCheckableEvent(r) : !isCheckableEvent(r)));
|
|
68
69
|
return {
|
|
69
70
|
list,
|
|
70
71
|
create: (value, remoteId, readOnly) => plans.create(draft(value, connection.kind, { syncConnection: connection.id, syncRemoteId: remoteId, syncReadOnly: readOnly }), connection.scope, connection.workspaceId),
|
package/src/stores/plans.ts
CHANGED
|
@@ -56,6 +56,7 @@ export const usePlanStore = defineStore('plans', () => {
|
|
|
56
56
|
const personalWritable = computed(
|
|
57
57
|
() => !!personalId.value && !loadError.value && !errors.value.length,
|
|
58
58
|
);
|
|
59
|
+
const workspaceId = computed(() => workspace.workspace?.id);
|
|
59
60
|
const workspaceWritable = computed(
|
|
60
61
|
() =>
|
|
61
62
|
!!workspace.workspace &&
|
|
@@ -152,14 +153,6 @@ export const usePlanStore = defineStore('plans', () => {
|
|
|
152
153
|
if (!id) throw new Error('工作区已关闭');
|
|
153
154
|
return workspace.updateObject(record, value, id);
|
|
154
155
|
}
|
|
155
|
-
const panel = computed(() => ({
|
|
156
|
-
id: personalId.value,
|
|
157
|
-
records: personal.value,
|
|
158
|
-
errors: [...errors.value, ...(loadError.value ? [loadError.value] : [])],
|
|
159
|
-
writable: personalWritable.value,
|
|
160
|
-
createObject: createPersonal,
|
|
161
|
-
updateObject: updatePersonal,
|
|
162
|
-
}));
|
|
163
156
|
const onFocus = () => {
|
|
164
157
|
if (!requiresDesktopRestart.value) void refreshPersonal();
|
|
165
158
|
};
|
|
@@ -189,9 +182,9 @@ export const usePlanStore = defineStore('plans', () => {
|
|
|
189
182
|
records,
|
|
190
183
|
recordsFor,
|
|
191
184
|
defaultScope,
|
|
185
|
+
workspaceId,
|
|
192
186
|
personalWritable,
|
|
193
187
|
workspaceWritable,
|
|
194
|
-
panel,
|
|
195
188
|
refreshPersonal,
|
|
196
189
|
canEdit,
|
|
197
190
|
create,
|
|
@@ -2,10 +2,7 @@ import { computed, onScopeDispose, ref, type Ref } from 'vue';
|
|
|
2
2
|
import type { WorkspaceCapabilities } from '@tano/editor/runtime';
|
|
3
3
|
import {
|
|
4
4
|
assetTargets,
|
|
5
|
-
basename,
|
|
6
5
|
coreRelationTypes,
|
|
7
|
-
defaultFileDatabaseQuery,
|
|
8
|
-
defaultObjectViewQuery,
|
|
9
6
|
documentTargets,
|
|
10
7
|
FileRegistry,
|
|
11
8
|
isMarkdown,
|
|
@@ -14,14 +11,11 @@ import {
|
|
|
14
11
|
objectDirectory,
|
|
15
12
|
objectTypeRegistry,
|
|
16
13
|
parseObject,
|
|
17
|
-
parseWorkspaceView,
|
|
18
14
|
referenceKey,
|
|
19
|
-
RelationIndex,
|
|
20
15
|
relationKey,
|
|
21
16
|
validateObjectProperties,
|
|
22
17
|
validateRelation,
|
|
23
18
|
WorkspaceAccessRevokedError,
|
|
24
|
-
workspaceViewPath,
|
|
25
19
|
type FileSnapshot,
|
|
26
20
|
type ReferenceIdentity,
|
|
27
21
|
type ReferenceTarget,
|
|
@@ -29,7 +23,6 @@ import {
|
|
|
29
23
|
type WorkspaceAdapter,
|
|
30
24
|
type WorkspaceObject,
|
|
31
25
|
type WorkspaceRelation,
|
|
32
|
-
type WorkspaceViewDefinition,
|
|
33
26
|
} from '@tano/protocol';
|
|
34
27
|
import { contentReferences, referenceContext } from '../objects/content-references';
|
|
35
28
|
import type { useDocumentIndex } from '../documents/document-index';
|
|
@@ -47,7 +40,6 @@ import { loadObjects, saveObject, type ObjectRecord } from '../objects/workspace
|
|
|
47
40
|
import type { InstalledObjectPlugin } from '../plugins/workspace-plugins';
|
|
48
41
|
import { loadRelations, saveRelationChange, type RelationChange } from '../objects/workspace-relations';
|
|
49
42
|
import { loadTemplates, saveTemplate, type DocumentTemplate } from '../workspace/workspace-templates';
|
|
50
|
-
import { loadWorkspaceViews, type WorkspaceViewRecord } from '../workspace/workspace-views';
|
|
51
43
|
import type { Activity } from './workspace';
|
|
52
44
|
|
|
53
45
|
export interface WorkspaceKnowledgeDeps {
|
|
@@ -67,12 +59,11 @@ export interface WorkspaceKnowledgeDeps {
|
|
|
67
59
|
change?: Activity['change'],
|
|
68
60
|
) => void;
|
|
69
61
|
loadWorkspacePart: (
|
|
70
|
-
part: 'plugins' | 'objects' | '
|
|
62
|
+
part: 'plugins' | 'objects' | 'relations',
|
|
71
63
|
load: () => Promise<unknown>,
|
|
72
64
|
) => Promise<void>;
|
|
73
65
|
refreshPlugins: (current: Workspace) => Promise<void>;
|
|
74
66
|
disposePluginExecutor: () => void;
|
|
75
|
-
openWorkspaceView: (id: string, options?: { newTab?: boolean; historyIndex?: number }) => Promise<void>;
|
|
76
67
|
}
|
|
77
68
|
|
|
78
69
|
export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
@@ -90,11 +81,8 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
90
81
|
loadWorkspacePart,
|
|
91
82
|
refreshPlugins,
|
|
92
83
|
disposePluginExecutor,
|
|
93
|
-
openWorkspaceView,
|
|
94
84
|
} = deps;
|
|
95
85
|
|
|
96
|
-
const workspaceViews = ref<WorkspaceViewRecord[]>([]);
|
|
97
|
-
const workspaceViewErrors = ref<string[]>([]);
|
|
98
86
|
const objects = ref<ObjectRecord[]>([]);
|
|
99
87
|
const objectErrors = ref<string[]>([]);
|
|
100
88
|
const relations = ref<WorkspaceRelation[]>([]);
|
|
@@ -107,7 +95,6 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
107
95
|
.filter((item) => item.enabled)
|
|
108
96
|
.flatMap((item) => item.manifest.relationTypes),
|
|
109
97
|
]);
|
|
110
|
-
const relationIndex = computed(() => new RelationIndex(relations.value));
|
|
111
98
|
const objectDefinitions = ref(objectTypeRegistry.list());
|
|
112
99
|
onScopeDispose(
|
|
113
100
|
objectTypeRegistry.subscribe(() => {
|
|
@@ -133,7 +120,6 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
133
120
|
objectDefinitions.value.find((entry) => entry.type === object.type) ??
|
|
134
121
|
objectTypeRegistry.get(object.type);
|
|
135
122
|
if (definition?.storage !== 'record') return false;
|
|
136
|
-
if (definition.retired) return true;
|
|
137
123
|
try {
|
|
138
124
|
validateObjectProperties(object.type, object.properties);
|
|
139
125
|
return true;
|
|
@@ -219,16 +205,6 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
219
205
|
objects.value = loaded.records;
|
|
220
206
|
objectErrors.value = loaded.errors;
|
|
221
207
|
}),
|
|
222
|
-
loadWorkspacePart('views', async () => {
|
|
223
|
-
try {
|
|
224
|
-
const loadedViews = await loadWorkspaceViews(adapter, current);
|
|
225
|
-
workspaceViews.value = loadedViews.records;
|
|
226
|
-
workspaceViewErrors.value = loadedViews.errors;
|
|
227
|
-
} catch (error) {
|
|
228
|
-
workspaceViews.value = [];
|
|
229
|
-
workspaceViewErrors.value = [`无法读取工作区视图:${String(error)}`];
|
|
230
|
-
}
|
|
231
|
-
}),
|
|
232
208
|
loadWorkspacePart('relations', async () => {
|
|
233
209
|
try {
|
|
234
210
|
const loadedRelations = await loadRelations(adapter, current);
|
|
@@ -279,86 +255,6 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
279
255
|
return saved;
|
|
280
256
|
});
|
|
281
257
|
|
|
282
|
-
// Workspace databases / views
|
|
283
|
-
async function createObjectDatabase() {
|
|
284
|
-
const scope = workspace.value?.id;
|
|
285
|
-
const id = `objects-${crypto.randomUUID()}`;
|
|
286
|
-
await serial(async () => {
|
|
287
|
-
if (!scope || workspace.value?.id !== scope) throw new Error(t('工作区已切换'));
|
|
288
|
-
writable();
|
|
289
|
-
if (!capabilities.value.features.objectReferences)
|
|
290
|
-
throw new Error('「工作区对象与引用」已关闭');
|
|
291
|
-
const view = parseWorkspaceView(
|
|
292
|
-
JSON.stringify({
|
|
293
|
-
version: 1,
|
|
294
|
-
layer: 'view',
|
|
295
|
-
workspaceId: scope,
|
|
296
|
-
id,
|
|
297
|
-
name: '对象数据库',
|
|
298
|
-
kind: 'objects',
|
|
299
|
-
sources: [],
|
|
300
|
-
objectDatabase: defaultObjectViewQuery(),
|
|
301
|
-
}),
|
|
302
|
-
);
|
|
303
|
-
await adapter.create(workspaceViewPath(id), JSON.stringify(view, null, 2) + '\n');
|
|
304
|
-
workspace.value = await adapter.refresh();
|
|
305
|
-
await refreshObjects();
|
|
306
|
-
});
|
|
307
|
-
await openWorkspaceView(id, { newTab: true });
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async function createFileDatabase(directory = '') {
|
|
311
|
-
const scope = workspace.value?.id;
|
|
312
|
-
const id = `files-${crypto.randomUUID()}`;
|
|
313
|
-
await serial(async () => {
|
|
314
|
-
if (!scope || workspace.value?.id !== scope) throw new Error(t('工作区已切换'));
|
|
315
|
-
writable();
|
|
316
|
-
if (
|
|
317
|
-
directory &&
|
|
318
|
-
!workspace.value.files.some((f) => f.kind === 'directory' && f.path === directory)
|
|
319
|
-
)
|
|
320
|
-
throw new Error('目录已不存在');
|
|
321
|
-
const view = parseWorkspaceView(
|
|
322
|
-
JSON.stringify({
|
|
323
|
-
version: 1,
|
|
324
|
-
layer: 'view',
|
|
325
|
-
workspaceId: scope,
|
|
326
|
-
id,
|
|
327
|
-
name: `${directory ? basename(directory) : workspace.value.name} · 文件数据库`,
|
|
328
|
-
kind: 'files',
|
|
329
|
-
sources: [],
|
|
330
|
-
database: defaultFileDatabaseQuery(directory),
|
|
331
|
-
}),
|
|
332
|
-
);
|
|
333
|
-
await adapter.create(workspaceViewPath(id), JSON.stringify(view, null, 2) + '\n');
|
|
334
|
-
workspace.value = await adapter.refresh();
|
|
335
|
-
await refreshObjects();
|
|
336
|
-
});
|
|
337
|
-
await openWorkspaceView(id, { newTab: true });
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const saveFileDatabase = (view: WorkspaceViewDefinition, base: FileSnapshot) =>
|
|
341
|
-
serial(async () => {
|
|
342
|
-
if (workspace.value?.id !== view.workspaceId) throw new Error(t('工作区已切换'));
|
|
343
|
-
writable();
|
|
344
|
-
const checked = parseWorkspaceView(JSON.stringify(view));
|
|
345
|
-
const result = await adapter.write(
|
|
346
|
-
workspaceViewPath(checked.id),
|
|
347
|
-
JSON.stringify(checked, null, 2) + '\n',
|
|
348
|
-
base.hash,
|
|
349
|
-
);
|
|
350
|
-
if (result.status !== 'saved') {
|
|
351
|
-
const copy = `.tano/conflicts/view-${checked.id}-${crypto.randomUUID()}.tano.json`;
|
|
352
|
-
await adapter.create(copy, JSON.stringify(checked, null, 2) + '\n');
|
|
353
|
-
throw new Error(
|
|
354
|
-
t('视图已被外部修改或删除,外部版本未覆盖;当前设置已保留在 {0}', [copy]),
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
workspace.value = await adapter.refresh();
|
|
358
|
-
await refreshObjects();
|
|
359
|
-
return result.snapshot;
|
|
360
|
-
});
|
|
361
|
-
|
|
362
258
|
// Relations CRUD
|
|
363
259
|
async function editRelation(change: RelationChange, expectedWorkspace: string) {
|
|
364
260
|
return serial(async () => {
|
|
@@ -704,16 +600,12 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
704
600
|
function resetKnowledge(clearErrors = false) {
|
|
705
601
|
objects.value = [];
|
|
706
602
|
objectErrors.value = [];
|
|
707
|
-
workspaceViews.value = [];
|
|
708
|
-
workspaceViewErrors.value = [];
|
|
709
603
|
relations.value = [];
|
|
710
604
|
relationBase = null;
|
|
711
605
|
if (clearErrors) relationError.value = '';
|
|
712
606
|
}
|
|
713
607
|
|
|
714
608
|
return {
|
|
715
|
-
workspaceViews,
|
|
716
|
-
workspaceViewErrors,
|
|
717
609
|
objects,
|
|
718
610
|
objectErrors,
|
|
719
611
|
objectDefinitions,
|
|
@@ -721,7 +613,6 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
721
613
|
relationError,
|
|
722
614
|
getRelationBase: () => relationBase,
|
|
723
615
|
relationDefinitions,
|
|
724
|
-
relationIndex,
|
|
725
616
|
referenceTargets,
|
|
726
617
|
referenceRevision,
|
|
727
618
|
referenceDocumentCache,
|
|
@@ -729,9 +620,6 @@ export function createWorkspaceKnowledge(deps: WorkspaceKnowledgeDeps) {
|
|
|
729
620
|
refreshObjects,
|
|
730
621
|
readFileMetadata,
|
|
731
622
|
updateFileMetadata,
|
|
732
|
-
createObjectDatabase,
|
|
733
|
-
createFileDatabase,
|
|
734
|
-
saveFileDatabase,
|
|
735
623
|
createRelation,
|
|
736
624
|
removeRelation,
|
|
737
625
|
setRelationSource,
|