@tano.page/workbench 0.15.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.
- package/package.json +35 -14
- package/src/App.vue +68 -797
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantPanel.vue +1 -1
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -585
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/language.ts +10 -37
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -65
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/store.ts +87 -554
- package/src/assistant/structures.ts +1 -157
- package/src/assistant/tasks.ts +8 -94
- package/src/assistant/tool-rules.ts +1 -7
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +37 -1022
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +23 -1
- package/src/i18n/locales/en-US.json +23 -1
- package/src/i18n/locales/es-ES.json +23 -1
- package/src/i18n/locales/ja-JP.json +23 -1
- package/src/i18n/locales/zh-TW.json +23 -1
- package/src/mail/components/MailAccountDialog.vue +1 -0
- package/src/mail/components/MailComposerDialog.vue +1 -0
- package/src/mail/components/MailWorkspaceView.vue +1 -0
- package/src/mail/components/SidebarMail.vue +1 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +2 -3
- package/src/plans/calendar.ts +2 -2
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +162 -2106
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plugins/components/PluginDetailPage.vue +10 -6
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginExplorer.vue +6 -4
- package/src/plugins/components/PluginImportDialog.vue +1 -1
- package/src/plugins/components/PluginInstaller.vue +269 -178
- package/src/plugins/components/PluginMaintenance.vue +37 -49
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginSettingsForm.vue +2 -1
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -260
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/queries.ts +1 -75
- package/src/plugins/view-header.ts +2 -7
- package/src/runtime.ts +3 -2
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/WorkbenchContextMenus.vue +37 -26
- package/src/shell/components/WorkbenchModals.vue +22 -18
- package/src/shell/components/WorkbenchPanes.vue +358 -1512
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +488 -1081
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +1 -1
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +71 -599
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +1 -1
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +163 -1345
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -11
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/assistant/locales/de-DE.json +0 -129
- package/src/assistant/locales/en-US.json +0 -129
- package/src/assistant/locales/es-ES.json +0 -129
- package/src/assistant/locales/ja-JP.json +0 -129
- package/src/assistant/locales/zh-CN.json +0 -129
- package/src/assistant/locales/zh-TW.json +0 -129
- package/src/assistant/task-prompts.json +0 -39
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { nextTick, onBeforeUnmount, onMounted, watch, type Ref } from 'vue';
|
|
2
|
+
import { storeToRefs } from 'pinia';
|
|
3
|
+
import type { useAgentInboxController } from '../assistant/agent-controller';
|
|
4
|
+
import { ASSISTANT_TAB_ID, openAssistantPage } from '../assistant/navigation';
|
|
5
|
+
import type { useAssistantStore, useInlineAssistantStore } from '../assistant/store';
|
|
6
|
+
import { tableFileId } from '../data-tables/data-tables';
|
|
7
|
+
import { t } from '../i18n/i18n';
|
|
8
|
+
import { LocalReminderScheduler } from '../plans/local-reminders';
|
|
9
|
+
import { expandRecurringPlans } from '../plans/recurrence';
|
|
10
|
+
import { nativeListen as listen } from '../platform/native-bridge';
|
|
11
|
+
import { mobile } from '../platform/platform';
|
|
12
|
+
import type { WorkbenchExtensions } from '../runtime';
|
|
13
|
+
import type { retainWorkbenchSession } from '../shell/workbench-session';
|
|
14
|
+
import type { usePlanStore } from '../stores/plans';
|
|
15
|
+
import type { useUpdatesStore } from '../stores/updates';
|
|
16
|
+
import type { useWorkspaceStore } from '../stores/workspace';
|
|
17
|
+
import type { WindowContext } from '../windows/context';
|
|
18
|
+
import type { useAuxiliaryWindows } from '../windows/manager';
|
|
19
|
+
import { native } from '../workspace/adapter';
|
|
20
|
+
import type { useDocumentActions } from './use-document-actions';
|
|
21
|
+
import type { useFileTreeController } from './use-file-tree-controller';
|
|
22
|
+
import type { useWorkbenchCalendar } from './use-workbench-calendar';
|
|
23
|
+
import type { useWorkbenchHistory } from './use-workbench-history';
|
|
24
|
+
import type { useWorkbenchModals } from './use-workbench-modals';
|
|
25
|
+
import type { useWorkbenchOutline } from './use-workbench-outline';
|
|
26
|
+
|
|
27
|
+
export interface WorkbenchLifecycleDeps {
|
|
28
|
+
props: {
|
|
29
|
+
initialWorkspace?: string;
|
|
30
|
+
resolveInitialWorkspace?: () => Promise<string | undefined>;
|
|
31
|
+
createWorkspace?: boolean;
|
|
32
|
+
};
|
|
33
|
+
emitReady: () => void;
|
|
34
|
+
mainWindow: WindowContext;
|
|
35
|
+
store: ReturnType<typeof useWorkspaceStore>;
|
|
36
|
+
assistant: ReturnType<typeof useAssistantStore>;
|
|
37
|
+
inlineRunner: ReturnType<typeof useInlineAssistantStore>;
|
|
38
|
+
agentInbox: ReturnType<typeof useAgentInboxController>;
|
|
39
|
+
plans: ReturnType<typeof usePlanStore>;
|
|
40
|
+
updates: ReturnType<typeof useUpdatesStore>;
|
|
41
|
+
editing: WorkbenchExtensions['editing'];
|
|
42
|
+
auxiliaryWindows: ReturnType<typeof useAuxiliaryWindows>;
|
|
43
|
+
workbenchSession: ReturnType<typeof retainWorkbenchSession>;
|
|
44
|
+
localNative: boolean;
|
|
45
|
+
startupPending: Ref<boolean>;
|
|
46
|
+
compactPanes: Ref<boolean>;
|
|
47
|
+
sidebar: Ref<boolean>;
|
|
48
|
+
navigationContext: Ref<'home' | 'workspace'>;
|
|
49
|
+
navigationModule: Ref<string>;
|
|
50
|
+
restoreNavigation: () => void;
|
|
51
|
+
homeModule: Ref<string>;
|
|
52
|
+
getPersonalPlanScope: () => ReturnType<typeof usePlanStore>['view'];
|
|
53
|
+
extensionViews: NonNullable<WorkbenchExtensions['views']>;
|
|
54
|
+
agentPanel: Ref<boolean>;
|
|
55
|
+
selectedDiff: Ref<unknown>;
|
|
56
|
+
recyclePanel: Ref<boolean>;
|
|
57
|
+
workspaceMenu: Ref<boolean>;
|
|
58
|
+
settingsPanel: Ref<boolean>;
|
|
59
|
+
historyPanel: Ref<boolean>;
|
|
60
|
+
menu: Ref<boolean>;
|
|
61
|
+
calendar: ReturnType<typeof useWorkbenchCalendar>;
|
|
62
|
+
docs: ReturnType<typeof useDocumentActions>;
|
|
63
|
+
tree: ReturnType<typeof useFileTreeController>;
|
|
64
|
+
outlineCtrl: ReturnType<typeof useWorkbenchOutline>;
|
|
65
|
+
modals: ReturnType<typeof useWorkbenchModals>;
|
|
66
|
+
history: ReturnType<typeof useWorkbenchHistory>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function useWorkbenchLifecycle(deps: WorkbenchLifecycleDeps) {
|
|
70
|
+
const {
|
|
71
|
+
props,
|
|
72
|
+
emitReady,
|
|
73
|
+
mainWindow,
|
|
74
|
+
store,
|
|
75
|
+
assistant,
|
|
76
|
+
inlineRunner,
|
|
77
|
+
agentInbox,
|
|
78
|
+
plans,
|
|
79
|
+
updates,
|
|
80
|
+
editing,
|
|
81
|
+
auxiliaryWindows,
|
|
82
|
+
workbenchSession,
|
|
83
|
+
localNative,
|
|
84
|
+
startupPending,
|
|
85
|
+
compactPanes,
|
|
86
|
+
sidebar,
|
|
87
|
+
navigationContext,
|
|
88
|
+
navigationModule,
|
|
89
|
+
restoreNavigation,
|
|
90
|
+
homeModule,
|
|
91
|
+
getPersonalPlanScope,
|
|
92
|
+
extensionViews,
|
|
93
|
+
agentPanel,
|
|
94
|
+
selectedDiff,
|
|
95
|
+
recyclePanel,
|
|
96
|
+
workspaceMenu,
|
|
97
|
+
settingsPanel,
|
|
98
|
+
historyPanel,
|
|
99
|
+
menu,
|
|
100
|
+
calendar,
|
|
101
|
+
docs,
|
|
102
|
+
tree,
|
|
103
|
+
outlineCtrl,
|
|
104
|
+
modals,
|
|
105
|
+
history,
|
|
106
|
+
} = deps;
|
|
107
|
+
const { activeId } = storeToRefs(store);
|
|
108
|
+
|
|
109
|
+
let unmounted = false;
|
|
110
|
+
let reminderTimer: ReturnType<typeof setInterval> | undefined;
|
|
111
|
+
let unlistenClose: (() => void) | undefined;
|
|
112
|
+
let unlistenWatchError: (() => void) | undefined;
|
|
113
|
+
|
|
114
|
+
const reminderScheduler = new LocalReminderScheduler({
|
|
115
|
+
onRemind: (item) => {
|
|
116
|
+
store.report(t('日程提醒:{0}', [item.record.object.name]));
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function checkPlanReminders() {
|
|
121
|
+
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return;
|
|
122
|
+
const now = new Date();
|
|
123
|
+
const windowStart = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
|
|
124
|
+
const windowEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 2);
|
|
125
|
+
const records = expandRecurringPlans(plans.recordsFor('all'), windowStart, windowEnd);
|
|
126
|
+
reminderScheduler.check(records, now.getTime());
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
watch(
|
|
130
|
+
() => store.workspace?.id,
|
|
131
|
+
(id, previous) => {
|
|
132
|
+
agentPanel.value = false;
|
|
133
|
+
selectedDiff.value = undefined;
|
|
134
|
+
recyclePanel.value = false;
|
|
135
|
+
if (navigationModule.value === 'workspace') {
|
|
136
|
+
if (previous) calendar.rememberCalendar(previous);
|
|
137
|
+
calendar.restoreCalendar(id);
|
|
138
|
+
}
|
|
139
|
+
calendar.calendarModeOpen.value = false;
|
|
140
|
+
workspaceMenu.value = false;
|
|
141
|
+
settingsPanel.value = false;
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
watch(activeId, (id) => {
|
|
146
|
+
calendar.calendarModeOpen.value = false;
|
|
147
|
+
if (id === ASSISTANT_TAB_ID && compactPanes.value) sidebar.value = false;
|
|
148
|
+
docs.closePageContextMenu();
|
|
149
|
+
const treeId = activeId.value.startsWith('table:')
|
|
150
|
+
? tableFileId(activeId.value)
|
|
151
|
+
: activeId.value;
|
|
152
|
+
if (!tree.pendingTreeOpenIds.has(treeId) || !tree.selectedEntryIds.value.has(treeId))
|
|
153
|
+
tree.selectActiveFileInTree();
|
|
154
|
+
historyPanel.value = false;
|
|
155
|
+
menu.value = false;
|
|
156
|
+
outlineCtrl.resetOnActiveChange();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
watch(
|
|
160
|
+
() => [store.activeId, assistant.loading, store.busy] as const,
|
|
161
|
+
([id, loading, switching]) => {
|
|
162
|
+
if (id === ASSISTANT_TAB_ID && !loading && !switching) openAssistantPage(store, assistant);
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
watch(sidebar, (visible) => {
|
|
167
|
+
if (!visible) {
|
|
168
|
+
tree.closeFileContextMenu();
|
|
169
|
+
tree.closeDirectoryContextMenu();
|
|
170
|
+
outlineCtrl.closeOutlineContextMenu();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
onMounted(async () => {
|
|
175
|
+
reminderTimer = setInterval(checkPlanReminders, 60_000);
|
|
176
|
+
if (history.webPageRouting) {
|
|
177
|
+
history.initializePageHistory();
|
|
178
|
+
window.addEventListener('popstate', history.handlePagePopState);
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
await workbenchSession.initialize(async () => {
|
|
182
|
+
if (props.createWorkspace) await modals.createNewWorkspace();
|
|
183
|
+
else
|
|
184
|
+
await store.initialize(
|
|
185
|
+
history.initialPageRoute?.workspaceId ??
|
|
186
|
+
(props.resolveInitialWorkspace
|
|
187
|
+
? await props.resolveInitialWorkspace()
|
|
188
|
+
: props.initialWorkspace),
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
} finally {
|
|
192
|
+
restoreNavigation();
|
|
193
|
+
if (
|
|
194
|
+
homeModule.value !== 'plan' &&
|
|
195
|
+
!extensionViews.some((view) => view.id === homeModule.value && view.sidebar)
|
|
196
|
+
)
|
|
197
|
+
homeModule.value = 'plan';
|
|
198
|
+
plans.view = navigationContext.value === 'home' ? getPersonalPlanScope() : 'workspace';
|
|
199
|
+
startupPending.value = false;
|
|
200
|
+
}
|
|
201
|
+
if (unmounted) return;
|
|
202
|
+
emitReady();
|
|
203
|
+
await nextTick();
|
|
204
|
+
|
|
205
|
+
await history.finishInitialPageRouting(props.createWorkspace);
|
|
206
|
+
if (native && !mobile) {
|
|
207
|
+
void updates.initialize();
|
|
208
|
+
}
|
|
209
|
+
if (native) {
|
|
210
|
+
if (localNative)
|
|
211
|
+
unlistenWatchError = await listen<string>('workspace-watch-error', (event) => {
|
|
212
|
+
store.enableWorkspacePolling();
|
|
213
|
+
store.report(t('文件监听遇到错误:{0}。目录仍会定期自动检查。', [event.payload]));
|
|
214
|
+
});
|
|
215
|
+
if (!mobile)
|
|
216
|
+
unlistenClose = await mainWindow.native!.onCloseRequested(async (event) => {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
if (updates.state.phase === 'installing') return;
|
|
219
|
+
try {
|
|
220
|
+
await editing.flush();
|
|
221
|
+
if (await store.flush()) {
|
|
222
|
+
await assistant.settle();
|
|
223
|
+
await inlineRunner.settle();
|
|
224
|
+
await agentInbox.settle();
|
|
225
|
+
if (!(await auxiliaryWindows.closeAll())) {
|
|
226
|
+
agentInbox.resume();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
await editing.suspendAll();
|
|
230
|
+
await mainWindow.native!.destroy();
|
|
231
|
+
} else store.report(t('还有未保存的内容,窗口已保留。请先保存或另存副本。'));
|
|
232
|
+
} catch (error) {
|
|
233
|
+
agentInbox.resume();
|
|
234
|
+
store.report(error);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
onBeforeUnmount(() => {
|
|
241
|
+
unmounted = true;
|
|
242
|
+
clearInterval(reminderTimer);
|
|
243
|
+
document.documentElement.style.removeProperty('--sidebar-width');
|
|
244
|
+
workbenchSession.release();
|
|
245
|
+
window.removeEventListener('popstate', history.handlePagePopState);
|
|
246
|
+
unlistenClose?.();
|
|
247
|
+
unlistenWatchError?.();
|
|
248
|
+
});
|
|
249
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { computed, ref, type Ref } from 'vue';
|
|
2
|
+
import { isMarkdown, isWorkspaceInternalPath, type WorkspaceAdapter } from '@tano/protocol';
|
|
3
|
+
import { version as appVersion } from '../../package.json';
|
|
4
|
+
import { t } from '../i18n/i18n';
|
|
5
|
+
import { mobile } from '../platform/platform';
|
|
6
|
+
import type { WorkbenchExtensions } from '../runtime';
|
|
7
|
+
import { readSettingsPage } from '../settings/settings-preference';
|
|
8
|
+
import { SETTINGS_TAB_ID } from '../settings/settings-tab';
|
|
9
|
+
import type { SettingsPageId } from '../settings/settings-window';
|
|
10
|
+
import type { useUpdatesStore } from '../stores/updates';
|
|
11
|
+
import type { useWorkspaceStore } from '../stores/workspace';
|
|
12
|
+
import type { WindowContext } from '../windows/context';
|
|
13
|
+
import type { useAuxiliaryWindows } from '../windows/manager';
|
|
14
|
+
import { native } from '../workspace/adapter';
|
|
15
|
+
import type { useWorkbenchModals } from './use-workbench-modals';
|
|
16
|
+
import type { useWorkbenchOutline } from './use-workbench-outline';
|
|
17
|
+
import type { useWorkbenchPreferences } from './use-workbench-preferences';
|
|
18
|
+
|
|
19
|
+
export interface WorkbenchSettingsDeps {
|
|
20
|
+
store: ReturnType<typeof useWorkspaceStore>;
|
|
21
|
+
updates: ReturnType<typeof useUpdatesStore>;
|
|
22
|
+
workspaceAdapter: WorkspaceAdapter;
|
|
23
|
+
extensions: WorkbenchExtensions;
|
|
24
|
+
auxiliaryWindows: ReturnType<typeof useAuxiliaryWindows>;
|
|
25
|
+
activeWindow: Ref<WindowContext>;
|
|
26
|
+
navigationContext: Ref<'home' | 'workspace'>;
|
|
27
|
+
compactPanes: Ref<boolean>;
|
|
28
|
+
sidebar: Ref<boolean>;
|
|
29
|
+
tabsEnabled: boolean;
|
|
30
|
+
menu: Ref<boolean>;
|
|
31
|
+
workspaceMenu: Ref<boolean>;
|
|
32
|
+
settingsPanel: Ref<boolean>;
|
|
33
|
+
agentPanel: Ref<boolean>;
|
|
34
|
+
recyclePanel: Ref<boolean>;
|
|
35
|
+
prefs: ReturnType<typeof useWorkbenchPreferences>;
|
|
36
|
+
outlineCtrl: ReturnType<typeof useWorkbenchOutline>;
|
|
37
|
+
modals: ReturnType<typeof useWorkbenchModals>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function useWorkbenchSettings(deps: WorkbenchSettingsDeps) {
|
|
41
|
+
const {
|
|
42
|
+
store,
|
|
43
|
+
updates,
|
|
44
|
+
workspaceAdapter,
|
|
45
|
+
extensions,
|
|
46
|
+
auxiliaryWindows,
|
|
47
|
+
activeWindow,
|
|
48
|
+
navigationContext,
|
|
49
|
+
compactPanes,
|
|
50
|
+
sidebar,
|
|
51
|
+
tabsEnabled,
|
|
52
|
+
menu,
|
|
53
|
+
workspaceMenu,
|
|
54
|
+
settingsPanel,
|
|
55
|
+
agentPanel,
|
|
56
|
+
recyclePanel,
|
|
57
|
+
prefs,
|
|
58
|
+
outlineCtrl,
|
|
59
|
+
modals,
|
|
60
|
+
} = deps;
|
|
61
|
+
|
|
62
|
+
const settingsPage = ref<SettingsPageId>(readSettingsPage());
|
|
63
|
+
const settingsWorkspace = computed(() =>
|
|
64
|
+
navigationContext.value === 'workspace' ? store.workspace : null,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
function openSettingsTab(page: SettingsPageId) {
|
|
68
|
+
settingsPage.value = page;
|
|
69
|
+
store.openViewTab(SETTINGS_TAB_ID);
|
|
70
|
+
settingsPanel.value = false;
|
|
71
|
+
if (compactPanes.value) sidebar.value = false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const openingSettingsWindow = ref(false);
|
|
75
|
+
async function openSettingsInNewWindow(page: SettingsPageId) {
|
|
76
|
+
if (!native || mobile || !tabsEnabled) return;
|
|
77
|
+
settingsPage.value = page;
|
|
78
|
+
if (openingSettingsWindow.value) return;
|
|
79
|
+
openingSettingsWindow.value = true;
|
|
80
|
+
settingsPanel.value = false;
|
|
81
|
+
try {
|
|
82
|
+
activeWindow.value = (
|
|
83
|
+
await auxiliaryWindows.open('settings', 'settings', t('设置') + ' — Tano / 同页')
|
|
84
|
+
).context;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
settingsPanel.value = true;
|
|
87
|
+
store.report(error);
|
|
88
|
+
} finally {
|
|
89
|
+
openingSettingsWindow.value = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function openSettings(page: SettingsPageId = readSettingsPage(settingsPage.value)) {
|
|
94
|
+
menu.value = false;
|
|
95
|
+
workspaceMenu.value = false;
|
|
96
|
+
settingsPage.value = page === 'preferences' ? 'appearance' : page;
|
|
97
|
+
const pane = store.panes.find((pane) => pane.tabs.includes(SETTINGS_TAB_ID));
|
|
98
|
+
if (pane) {
|
|
99
|
+
store.focusPane(pane.id);
|
|
100
|
+
openSettingsTab(settingsPage.value);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
settingsPanel.value = true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function settingsAction(
|
|
107
|
+
action: 'open-folder' | 'switch-mode' | 'reveal' | 'agent' | 'history' | 'recycle' | 'sign-out',
|
|
108
|
+
) {
|
|
109
|
+
if (!settingsWorkspace.value && ['reveal', 'agent', 'history', 'recycle'].includes(action))
|
|
110
|
+
return;
|
|
111
|
+
settingsPanel.value = false;
|
|
112
|
+
if (action === 'open-folder') void store.openWorkspace();
|
|
113
|
+
else if (action === 'reveal') void store.reveal();
|
|
114
|
+
else if (action === 'agent') agentPanel.value = true;
|
|
115
|
+
else if (action === 'history') extensions.showHistory?.();
|
|
116
|
+
else if (action === 'recycle') recyclePanel.value = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const settingsContext = computed(() => ({
|
|
120
|
+
pluginPages: settingsWorkspace.value ? store.pluginSettingsPages : [],
|
|
121
|
+
workspace: settingsWorkspace.value
|
|
122
|
+
? {
|
|
123
|
+
id: settingsWorkspace.value.id,
|
|
124
|
+
name: settingsWorkspace.value.name,
|
|
125
|
+
path: settingsWorkspace.value.path,
|
|
126
|
+
readOnly: settingsWorkspace.value.readOnly,
|
|
127
|
+
canDelete: settingsWorkspace.value.canDelete,
|
|
128
|
+
canManageSettings: settingsWorkspace.value.canManageSettings,
|
|
129
|
+
}
|
|
130
|
+
: null,
|
|
131
|
+
activeFile:
|
|
132
|
+
settingsWorkspace.value && store.active
|
|
133
|
+
? { id: store.active.id, path: store.active.path }
|
|
134
|
+
: null,
|
|
135
|
+
workspaceSettings: store.workspaceSettings,
|
|
136
|
+
workspacePages:
|
|
137
|
+
settingsWorkspace.value?.files
|
|
138
|
+
.filter(
|
|
139
|
+
(file) =>
|
|
140
|
+
file.kind === 'file' && isMarkdown(file.path) && !isWorkspaceInternalPath(file.path),
|
|
141
|
+
)
|
|
142
|
+
.map((file) => ({ id: file.id, path: file.path })) ?? [],
|
|
143
|
+
workspaceSettingsError: store.workspaceSettingsError,
|
|
144
|
+
workspaceSettingsSaving: store.workspaceSettingsSaving,
|
|
145
|
+
workspaceExporting: modals.workspaceExporting.value,
|
|
146
|
+
workspaceExportError: modals.workspaceExportError.value,
|
|
147
|
+
workspaceDeletionSupported: !!workspaceAdapter.deleteWorkspace,
|
|
148
|
+
workspaceDeleting: modals.workspaceDeleting.value || store.busy,
|
|
149
|
+
workspaceDeletionError: modals.workspaceDeletionError.value,
|
|
150
|
+
mode: store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local',
|
|
151
|
+
defaultSource: prefs.defaultSource.value,
|
|
152
|
+
theme: prefs.theme.value,
|
|
153
|
+
appearance: prefs.appearance.value,
|
|
154
|
+
visualFontChoice: prefs.visualFontChoice.value,
|
|
155
|
+
customFontName: prefs.customFontName.value,
|
|
156
|
+
splitFontSettings: prefs.splitFontSettings.value,
|
|
157
|
+
revealMarkdown: prefs.revealMarkdown.value,
|
|
158
|
+
toolbarMode: prefs.toolbarMode.value,
|
|
159
|
+
shortcuts: prefs.shortcuts.value,
|
|
160
|
+
showPageTitle: prefs.showPageTitle.value,
|
|
161
|
+
showDocumentProperties: prefs.showDocumentProperties.value,
|
|
162
|
+
showDocumentDiscussion: prefs.showDocumentDiscussion.value,
|
|
163
|
+
showOutline: outlineCtrl.showOutline.value,
|
|
164
|
+
outlineOnLeft: outlineCtrl.outlineOnLeft.value,
|
|
165
|
+
visualFontSize: prefs.visualFontSize.value,
|
|
166
|
+
sourceFontSize: prefs.sourceFontSize.value,
|
|
167
|
+
editorPreferences: prefs.editorPreferences.value,
|
|
168
|
+
historyEnabled: !!extensions.historyEnabled,
|
|
169
|
+
capabilities: store.capabilities,
|
|
170
|
+
capabilityError: store.capabilityError,
|
|
171
|
+
capabilitySaving: store.capabilitySaving,
|
|
172
|
+
version: updates.state.status?.currentVersion ?? appVersion,
|
|
173
|
+
updates: updates.state,
|
|
174
|
+
}));
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
settingsPage,
|
|
178
|
+
openingSettingsWindow,
|
|
179
|
+
openSettingsTab,
|
|
180
|
+
openSettingsInNewWindow,
|
|
181
|
+
openSettings,
|
|
182
|
+
settingsAction,
|
|
183
|
+
settingsContext,
|
|
184
|
+
};
|
|
185
|
+
}
|