@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.
- package/package.json +50 -16
- package/src/App.vue +82 -752
- 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/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/AssistantChangeList.vue +98 -21
- package/src/assistant/components/AssistantPanel.vue +425 -8
- package/src/assistant/components/PluginToolProposalCard.vue +235 -0
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -532
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/files.ts +5 -13
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/inbox.ts +1 -148
- package/src/assistant/language.ts +10 -37
- package/src/assistant/mention-autocomplete.ts +69 -0
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -58
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/results.ts +20 -86
- package/src/assistant/store.ts +167 -327
- package/src/assistant/structures.ts +1 -155
- package/src/assistant/tasks.ts +8 -96
- package/src/assistant/tool-rules.ts +1 -7
- 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-help.ts +177 -0
- package/src/composables/use-workbench-history.ts +2 -4
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-modals.ts +6 -1
- package/src/composables/use-workbench-outline.ts +0 -5
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +40 -1021
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/data-tables/data-tables.ts +1 -2
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentHistoryPanel.vue +3 -1
- 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/features.ts +1 -0
- package/src/files/components/FileMetadataPanel.vue +49 -15
- 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/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +371 -3
- package/src/i18n/locales/en-US.json +371 -2
- package/src/i18n/locales/es-ES.json +371 -3
- package/src/i18n/locales/ja-JP.json +370 -2
- package/src/i18n/locales/zh-TW.json +370 -2
- package/src/mail/components/MailAccountDialog.vue +450 -0
- package/src/mail/components/MailComposerDialog.vue +326 -0
- package/src/mail/components/MailProviderIcon.vue +30 -0
- package/src/mail/components/MailWorkspaceView.vue +821 -0
- package/src/mail/components/SidebarMail.vue +134 -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/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +3 -4
- package/src/plan-sync/types.ts +6 -3
- package/src/plans/calendar-interaction.ts +194 -0
- package/src/plans/calendar.ts +65 -9
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarDayPopover.vue +172 -39
- 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 +264 -748
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanArchiveDialog.vue +295 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- 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/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/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 +136 -57
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginDocumentSlot.vue +63 -0
- package/src/plugins/components/PluginExplorer.vue +21 -25
- package/src/plugins/components/PluginImportDialog.vue +410 -0
- package/src/plugins/components/PluginInstaller.vue +273 -288
- package/src/plugins/components/PluginListItem.vue +3 -0
- package/src/plugins/components/PluginMaintenance.vue +37 -34
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginRuntimePanel.vue +3 -3
- package/src/plugins/components/PluginSettingsForm.vue +112 -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/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/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-data.ts +2 -3
- package/src/plugins/plugin-permissions.ts +57 -0
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -94
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- 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 +1 -73
- 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/view-header.ts +2 -7
- 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 +103 -4
- package/src/settings/components/SettingsAppearancePage.vue +46 -0
- package/src/settings/components/SettingsDocumentsPage.vue +0 -1
- 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/components/settings-search.ts +2 -3
- 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/SidebarNavigation.vue +22 -2
- package/src/shell/components/WorkbenchContextMenus.vue +58 -34
- package/src/shell/components/WorkbenchModals.vue +47 -62
- package/src/shell/components/WorkbenchPanes.vue +371 -1342
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
- package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
- 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 +531 -1153
- package/src/shell/workbench-async-components.ts +14 -5
- package/src/shell/workbench-context.ts +30 -3
- 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-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +2 -114
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +254 -259
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +6 -44
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +184 -1363
- 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 +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -14
- package/src/tabs/components/NewTabPicker.vue +10 -4
- package/src/tabs/tab-label.ts +0 -1
- 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/WorkspaceGeneralSettings.vue +0 -13
- package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/workspace/workspace-comments.ts +11 -151
- package/src/workspace/workspace-welcome.ts +1 -1
- package/src/assistant/locales/de-DE.json +0 -126
- package/src/assistant/locales/en-US.json +0 -126
- package/src/assistant/locales/es-ES.json +0 -126
- package/src/assistant/locales/ja-JP.json +0 -126
- package/src/assistant/locales/zh-CN.json +0 -126
- package/src/assistant/locales/zh-TW.json +0 -126
- package/src/assistant/task-prompts.json +0 -39
- 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,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import type { PluginRuntimeState } from '../host';
|
|
4
|
+
import type { PluginInteraction, PluginWorkbenchView } from '../workbench';
|
|
5
|
+
import PluginSurface from './PluginSurface.vue';
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
location: 'documentHeader' | 'documentFooter';
|
|
9
|
+
views: readonly PluginWorkbenchView[];
|
|
10
|
+
runtimes: readonly PluginRuntimeState[];
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
execute: (interaction: PluginInteraction) => Promise<void>;
|
|
13
|
+
}>();
|
|
14
|
+
|
|
15
|
+
const renderedSlots = computed(() =>
|
|
16
|
+
props.views
|
|
17
|
+
.filter((view) => view.location === props.location)
|
|
18
|
+
.map((view) => {
|
|
19
|
+
const runtime = props.runtimes.find((rt) => rt.id === view.pluginId);
|
|
20
|
+
const state = runtime?.views.find((entry) => entry.id === view.id);
|
|
21
|
+
return { view, runtime, hasContent: !!state && (!!state.tree || !!state.custom) };
|
|
22
|
+
})
|
|
23
|
+
.filter((entry) => entry.runtime?.status === 'running' && entry.hasContent),
|
|
24
|
+
);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div
|
|
29
|
+
v-if="renderedSlots.length"
|
|
30
|
+
class="plugin-document-slot"
|
|
31
|
+
:class="`slot-${location}`"
|
|
32
|
+
:data-slot="location"
|
|
33
|
+
>
|
|
34
|
+
<PluginSurface
|
|
35
|
+
v-for="{ view, runtime } in renderedSlots"
|
|
36
|
+
:key="`${workspaceId}:${view.key}`"
|
|
37
|
+
:view="view"
|
|
38
|
+
:workspace-id="workspaceId"
|
|
39
|
+
:runtime="runtime"
|
|
40
|
+
:execute="execute"
|
|
41
|
+
compact
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<style scoped>
|
|
47
|
+
.plugin-document-slot {
|
|
48
|
+
width: 100%;
|
|
49
|
+
max-width: var(--page-width, 820px);
|
|
50
|
+
margin: 0 auto;
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
gap: 8px;
|
|
54
|
+
}
|
|
55
|
+
.plugin-document-slot.slot-documentHeader {
|
|
56
|
+
margin-bottom: 12px;
|
|
57
|
+
}
|
|
58
|
+
.plugin-document-slot.slot-documentFooter {
|
|
59
|
+
margin-top: 20px;
|
|
60
|
+
padding-top: 12px;
|
|
61
|
+
border-top: 1px solid var(--line);
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, defineAsyncComponent, onMounted, onBeforeUnmount } from 'vue';
|
|
2
|
+
import { computed, inject, ref, defineAsyncComponent, onMounted, onBeforeUnmount } from 'vue';
|
|
3
3
|
import {
|
|
4
4
|
Settings,
|
|
5
5
|
MoreHorizontal,
|
|
@@ -19,6 +19,7 @@ import { bundledPluginCatalog } from '../plugin-catalog';
|
|
|
19
19
|
import { retiredSystemPlugin } from '../workspace-plugins';
|
|
20
20
|
import { matchesPlugin, usePluginActions } from '../use-plugin-actions';
|
|
21
21
|
import PluginIcon from './PluginIcon.vue';
|
|
22
|
+
import { workbenchPrefsKey } from '../../shell/workbench-context';
|
|
22
23
|
import { useWindowContext } from '../../windows/context';
|
|
23
24
|
const { window } = useWindowContext();
|
|
24
25
|
const root = ref<HTMLElement>();
|
|
@@ -44,12 +45,13 @@ onBeforeUnmount(() => {
|
|
|
44
45
|
window.removeEventListener('pointerdown', dismissMenus);
|
|
45
46
|
window.removeEventListener('keydown', dismissMenus);
|
|
46
47
|
});
|
|
47
|
-
const
|
|
48
|
+
const PluginImportDialog = defineAsyncComponent(() => import('./PluginImportDialog.vue'));
|
|
49
|
+
const props = defineProps<{ developerMode?: boolean }>();
|
|
50
|
+
const workbench = inject(workbenchPrefsKey, null);
|
|
51
|
+
const isDeveloperMode = computed(() => props.developerMode ?? Boolean(workbench?.developerMode));
|
|
48
52
|
const store = useWorkspaceStore();
|
|
49
53
|
const query = ref(''),
|
|
50
|
-
menu = ref(''),
|
|
51
54
|
importing = ref(false);
|
|
52
|
-
const importer = ref<{ openImport(): void }>();
|
|
53
55
|
const installedOpen = ref(true),
|
|
54
56
|
recommendedOpen = ref(!store.installedPlugins.length);
|
|
55
57
|
const { error, status, pending, busy, change, installFromCatalog } = usePluginActions();
|
|
@@ -67,10 +69,8 @@ const recommended = computed(() =>
|
|
|
67
69
|
function closeMenu(event: Event) {
|
|
68
70
|
(event.currentTarget as HTMLElement).closest('details')?.removeAttribute('open');
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
else importing.value = true;
|
|
73
|
-
menu.value = '';
|
|
72
|
+
function openImport() {
|
|
73
|
+
importing.value = true;
|
|
74
74
|
}
|
|
75
75
|
</script>
|
|
76
76
|
<template>
|
|
@@ -88,7 +88,7 @@ async function openImport() {
|
|
|
88
88
|
<MoreHorizontal :size="16" />
|
|
89
89
|
</summary>
|
|
90
90
|
<div class="dropdown compact-action-menu actions-menu" @click="closeMenu">
|
|
91
|
-
<button @click="openImport"><Upload :size="14" />{{ t('导入插件…') }}</button
|
|
91
|
+
<button v-if="isDeveloperMode" @click="openImport"><Upload :size="14" />{{ t('导入插件…') }}</button
|
|
92
92
|
><button @click="store.openPluginsTab()">
|
|
93
93
|
<Puzzle :size="14" />{{ t('插件中心…') }}
|
|
94
94
|
</button>
|
|
@@ -117,6 +117,7 @@ async function openImport() {
|
|
|
117
117
|
<PluginIcon :id="item.manifest.id" /><span
|
|
118
118
|
><strong
|
|
119
119
|
>{{ item.manifest.name }}
|
|
120
|
+
<small v-if="item.scope === 'user'">{{ t('全局') }}</small>
|
|
120
121
|
<small v-if="!item.enabled">{{ t('已停用') }}</small></strong
|
|
121
122
|
><span class="description">{{ item.manifest.description }}</span></span
|
|
122
123
|
>
|
|
@@ -131,7 +132,7 @@ async function openImport() {
|
|
|
131
132
|
<Power :size="14" />{{ item.enabled ? t('停用插件') : t('启用插件') }}</button
|
|
132
133
|
><button
|
|
133
134
|
v-if="!item.system"
|
|
134
|
-
:disabled="busy || !store.canManagePlugins"
|
|
135
|
+
:disabled="busy || (item.scope !== 'user' && !store.canManagePlugins)"
|
|
135
136
|
@click="change({ uninstall: item.manifest.id })"
|
|
136
137
|
>
|
|
137
138
|
<Trash2 :size="14" />{{ t('卸载插件') }}</button
|
|
@@ -174,18 +175,16 @@ async function openImport() {
|
|
|
174
175
|
</button>
|
|
175
176
|
</div>
|
|
176
177
|
</section>
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
/>
|
|
188
|
-
</div>
|
|
178
|
+
<PluginImportDialog
|
|
179
|
+
v-if="importing"
|
|
180
|
+
@close="importing = false"
|
|
181
|
+
@feedback="
|
|
182
|
+
(message, failure) => {
|
|
183
|
+
status = message;
|
|
184
|
+
error = failure;
|
|
185
|
+
}
|
|
186
|
+
"
|
|
187
|
+
/>
|
|
189
188
|
</div>
|
|
190
189
|
</template>
|
|
191
190
|
<style scoped>
|
|
@@ -313,7 +312,4 @@ strong {
|
|
|
313
312
|
font-size: 13px;
|
|
314
313
|
font-weight: 500;
|
|
315
314
|
}
|
|
316
|
-
.import-host {
|
|
317
|
-
display: none;
|
|
318
|
-
}
|
|
319
315
|
</style>
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, ref, watch } from 'vue';
|
|
3
|
+
import { Check, Download, Upload } from 'lucide-vue-next';
|
|
4
|
+
import {
|
|
5
|
+
checkPluginCompatibility,
|
|
6
|
+
isPluginArchiveV2Bytes,
|
|
7
|
+
parsePluginPackage,
|
|
8
|
+
PLUGIN_ARCHIVE_V2_LIMIT,
|
|
9
|
+
pluginPackageLimit,
|
|
10
|
+
unpackPluginArchiveV2,
|
|
11
|
+
} from '@tano/protocol';
|
|
12
|
+
import type { PluginManifest, PluginPackage } from '@tano/protocol';
|
|
13
|
+
import { t } from '../../i18n/i18n';
|
|
14
|
+
import { useWorkspaceStore } from '../../stores/workspace';
|
|
15
|
+
import { isAppearanceOnlyPlugin, userScopeUnsupportedReason } from '../user-plugins';
|
|
16
|
+
import { usePluginActions } from '../use-plugin-actions';
|
|
17
|
+
import { documentOverviewPlugin } from '../example';
|
|
18
|
+
import PluginChangeSummary from './PluginChangeSummary.vue';
|
|
19
|
+
import PluginDialog from './PluginDialog.vue';
|
|
20
|
+
|
|
21
|
+
const emit = defineEmits<{
|
|
22
|
+
close: [];
|
|
23
|
+
installed: [];
|
|
24
|
+
feedback: [status: string, error: string];
|
|
25
|
+
}>();
|
|
26
|
+
|
|
27
|
+
const store = useWorkspaceStore();
|
|
28
|
+
const { error, status, busy, change } = usePluginActions();
|
|
29
|
+
const input = ref<HTMLInputElement>();
|
|
30
|
+
const manifestText = ref('');
|
|
31
|
+
const preview = ref<PluginManifest>();
|
|
32
|
+
const previewPackage = ref<PluginPackage>();
|
|
33
|
+
const previewBinaryAssets = ref<Record<string, Uint8Array>>();
|
|
34
|
+
const importScope = ref<'workspace' | 'user'>('workspace');
|
|
35
|
+
let importSequence = 0;
|
|
36
|
+
|
|
37
|
+
const installedById = computed(
|
|
38
|
+
() => new Map(store.installedPlugins.map((item) => [item.manifest.id, item])),
|
|
39
|
+
);
|
|
40
|
+
const importUserReason = computed(() =>
|
|
41
|
+
preview.value ? userScopeUnsupportedReason(preview.value) : undefined,
|
|
42
|
+
);
|
|
43
|
+
const importCompat = computed(() =>
|
|
44
|
+
preview.value
|
|
45
|
+
? checkPluginCompatibility(preview.value, store.pluginHostEnvironment)
|
|
46
|
+
: { compatible: true },
|
|
47
|
+
);
|
|
48
|
+
const feedbackError = computed(() => error.value || store.pluginError);
|
|
49
|
+
|
|
50
|
+
watch([status, error], ([message, failure]) => emit('feedback', message, failure));
|
|
51
|
+
watch(status, (value) => {
|
|
52
|
+
if (!value) return;
|
|
53
|
+
emit('installed');
|
|
54
|
+
emit('close');
|
|
55
|
+
});
|
|
56
|
+
watch(
|
|
57
|
+
() => store.workspace?.id,
|
|
58
|
+
() => {
|
|
59
|
+
importSequence++;
|
|
60
|
+
emit('close');
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
watch(manifestText, () => {
|
|
64
|
+
preview.value = undefined;
|
|
65
|
+
previewPackage.value = undefined;
|
|
66
|
+
previewBinaryAssets.value = undefined;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
function closeDialog() {
|
|
70
|
+
if (busy.value) return;
|
|
71
|
+
importSequence++;
|
|
72
|
+
emit('close');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function inspect() {
|
|
76
|
+
error.value = '';
|
|
77
|
+
status.value = '';
|
|
78
|
+
preview.value = undefined;
|
|
79
|
+
try {
|
|
80
|
+
previewPackage.value = parsePluginPackage(manifestText.value);
|
|
81
|
+
preview.value = previewPackage.value.manifest;
|
|
82
|
+
importScope.value =
|
|
83
|
+
isAppearanceOnlyPlugin(preview.value) && !userScopeUnsupportedReason(preview.value)
|
|
84
|
+
? 'user'
|
|
85
|
+
: 'workspace';
|
|
86
|
+
} catch (cause) {
|
|
87
|
+
error.value =
|
|
88
|
+
cause instanceof SyntaxError
|
|
89
|
+
? t('JSON 格式有误,请检查引号、逗号和括号后重试。')
|
|
90
|
+
: String(cause);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function importFile(event: Event) {
|
|
95
|
+
const file = (event.target as HTMLInputElement).files?.[0];
|
|
96
|
+
(event.target as HTMLInputElement).value = '';
|
|
97
|
+
if (!file) return;
|
|
98
|
+
preview.value = undefined;
|
|
99
|
+
error.value = '';
|
|
100
|
+
status.value = '';
|
|
101
|
+
const workspace = store.workspace?.id;
|
|
102
|
+
const sequence = ++importSequence;
|
|
103
|
+
try {
|
|
104
|
+
const lowerName = typeof file.name === 'string' ? file.name.toLowerCase() : '';
|
|
105
|
+
const isZip = lowerName.endsWith('.zip') || lowerName.endsWith('.tano-plugin');
|
|
106
|
+
if (file.size > (isZip ? PLUGIN_ARCHIVE_V2_LIMIT : pluginPackageLimit)) {
|
|
107
|
+
throw new Error(isZip ? t('插件归档包不能超过 16 MiB') : t('插件包不能超过 4 MiB'));
|
|
108
|
+
}
|
|
109
|
+
let content: string;
|
|
110
|
+
let unpackedBinaryAssets: Record<string, Uint8Array> | undefined;
|
|
111
|
+
if (typeof file.arrayBuffer === 'function') {
|
|
112
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
113
|
+
if (isPluginArchiveV2Bytes(bytes)) {
|
|
114
|
+
const archive = unpackPluginArchiveV2(bytes);
|
|
115
|
+
content = JSON.stringify(archive.pkg);
|
|
116
|
+
if (Object.keys(archive.binaryAssets).length) {
|
|
117
|
+
unpackedBinaryAssets = archive.binaryAssets;
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
content = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
content = await file.text();
|
|
124
|
+
}
|
|
125
|
+
if (store.workspace?.id !== workspace || sequence !== importSequence) return;
|
|
126
|
+
manifestText.value = content;
|
|
127
|
+
await nextTick();
|
|
128
|
+
if (store.workspace?.id === workspace && sequence === importSequence) {
|
|
129
|
+
previewBinaryAssets.value = unpackedBinaryAssets;
|
|
130
|
+
inspect();
|
|
131
|
+
}
|
|
132
|
+
} catch (cause) {
|
|
133
|
+
if (store.workspace?.id === workspace && sequence === importSequence)
|
|
134
|
+
error.value = String(cause);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function importCachedPackage() {
|
|
139
|
+
try {
|
|
140
|
+
await store.cachePluginPackage(manifestText.value, previewBinaryAssets.value);
|
|
141
|
+
status.value = t('插件包已保存到此设备,请在详情中授权运行');
|
|
142
|
+
await store.refresh();
|
|
143
|
+
} catch (cause) {
|
|
144
|
+
error.value = String(cause);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<template>
|
|
150
|
+
<Teleport to="body">
|
|
151
|
+
<PluginDialog :title="t('导入插件')" :busy="busy" @close="closeDialog">
|
|
152
|
+
<p v-if="feedbackError" class="pc-feedback error" role="alert">{{ feedbackError }}</p>
|
|
153
|
+
<p v-if="status" class="pc-feedback success" role="status">
|
|
154
|
+
<Check :size="16" />{{ status }}
|
|
155
|
+
</p>
|
|
156
|
+
<p class="dialog-intro">
|
|
157
|
+
{{ t('导入声明式清单或代码插件包。管理员为工作区安装,成员可补充此设备缺少的插件包。') }}
|
|
158
|
+
</p>
|
|
159
|
+
<button
|
|
160
|
+
class="pc-button pc-secondary"
|
|
161
|
+
@click="manifestText = JSON.stringify(documentOverviewPlugin, null, 2)"
|
|
162
|
+
>
|
|
163
|
+
{{ t('载入文档总览示例') }}
|
|
164
|
+
</button>
|
|
165
|
+
<input
|
|
166
|
+
ref="input"
|
|
167
|
+
type="file"
|
|
168
|
+
accept=".json,.zip,.tano-plugin,application/json,application/zip"
|
|
169
|
+
hidden
|
|
170
|
+
@change="importFile"
|
|
171
|
+
/>
|
|
172
|
+
<button class="import-file" :disabled="busy" @click="input?.click()">
|
|
173
|
+
<Upload :size="25" /><strong>{{ t('选择插件包文件') }}</strong>
|
|
174
|
+
<span>{{ t('支持 .json 或 .tano-plugin.zip 文件') }}</span>
|
|
175
|
+
</button>
|
|
176
|
+
<label class="manifest-label" for="plugin-manifest">{{ t('或粘贴插件清单') }}</label>
|
|
177
|
+
<textarea
|
|
178
|
+
id="plugin-manifest"
|
|
179
|
+
v-model="manifestText"
|
|
180
|
+
:aria-label="t('插件 JSON 清单')"
|
|
181
|
+
:disabled="busy"
|
|
182
|
+
spellcheck="false"
|
|
183
|
+
:placeholder="t('在此粘贴 JSON 内容…')"
|
|
184
|
+
rows="6"
|
|
185
|
+
/>
|
|
186
|
+
<div class="import-check">
|
|
187
|
+
<span>{{ t('代码插件需要单独授权;导入和检查不会执行脚本。') }}</span>
|
|
188
|
+
<button
|
|
189
|
+
class="pc-button pc-secondary"
|
|
190
|
+
:disabled="!manifestText.trim() || busy"
|
|
191
|
+
@click="inspect"
|
|
192
|
+
>
|
|
193
|
+
{{ t('检查清单') }}
|
|
194
|
+
</button>
|
|
195
|
+
</div>
|
|
196
|
+
<div v-if="preview" class="plugin-preview">
|
|
197
|
+
<div>
|
|
198
|
+
<Check :size="17" /><strong>{{ preview.name }}</strong>
|
|
199
|
+
<span>v{{ preview.version }}</span>
|
|
200
|
+
</div>
|
|
201
|
+
<p>{{ preview.description }}</p>
|
|
202
|
+
<PluginChangeSummary
|
|
203
|
+
:before="installedById.get(preview.id)?.manifest"
|
|
204
|
+
:after="preview"
|
|
205
|
+
:workspace="store.workspace?.name"
|
|
206
|
+
/>
|
|
207
|
+
<p>
|
|
208
|
+
{{ preview.objectTypes.map((item) => item.label).join('、') || t('无新增对象类型') }} ·
|
|
209
|
+
{{ preview.relationTypes.length }} {{ t('种关系') }}
|
|
210
|
+
</p>
|
|
211
|
+
<label class="import-scope">
|
|
212
|
+
{{ t('安装范围') }}
|
|
213
|
+
<select v-model="importScope" :aria-label="t('插件安装范围')" :disabled="busy">
|
|
214
|
+
<option value="workspace">{{ t('当前工作区(随工作区同步)') }}</option>
|
|
215
|
+
<option value="user" :disabled="!!importUserReason">
|
|
216
|
+
{{ t('全局插件(跨工作区生效)') }}
|
|
217
|
+
</option>
|
|
218
|
+
</select>
|
|
219
|
+
</label>
|
|
220
|
+
<p v-if="!importCompat.compatible" class="pc-feedback error" role="alert">
|
|
221
|
+
{{ importCompat.reason }}
|
|
222
|
+
</p>
|
|
223
|
+
<p v-if="importUserReason" class="dialog-intro">{{ importUserReason }}</p>
|
|
224
|
+
<button
|
|
225
|
+
class="pc-button pc-primary"
|
|
226
|
+
:disabled="busy || (importScope === 'workspace' ? !store.canManagePlugins : !!importUserReason)"
|
|
227
|
+
@click="
|
|
228
|
+
change({
|
|
229
|
+
install: preview,
|
|
230
|
+
package: previewPackage,
|
|
231
|
+
binaryAssets: previewBinaryAssets,
|
|
232
|
+
scope: importScope,
|
|
233
|
+
})
|
|
234
|
+
"
|
|
235
|
+
>
|
|
236
|
+
<Download :size="15" />{{
|
|
237
|
+
installedById.has(preview.id) ? t('更新并启用插件') : t('安装此插件')
|
|
238
|
+
}}
|
|
239
|
+
</button>
|
|
240
|
+
<button
|
|
241
|
+
v-if="preview.manifestVersion === 2"
|
|
242
|
+
class="pc-button pc-secondary"
|
|
243
|
+
:disabled="busy"
|
|
244
|
+
@click="importCachedPackage"
|
|
245
|
+
>
|
|
246
|
+
{{ t('仅保存到此设备') }}
|
|
247
|
+
</button>
|
|
248
|
+
</div>
|
|
249
|
+
</PluginDialog>
|
|
250
|
+
</Teleport>
|
|
251
|
+
</template>
|
|
252
|
+
|
|
253
|
+
<style scoped>
|
|
254
|
+
.pc-button {
|
|
255
|
+
display: inline-flex;
|
|
256
|
+
align-items: center;
|
|
257
|
+
justify-content: center;
|
|
258
|
+
gap: 7px;
|
|
259
|
+
min-height: 32px;
|
|
260
|
+
padding: 6px 12px;
|
|
261
|
+
border: 1px solid transparent;
|
|
262
|
+
border-radius: 6px;
|
|
263
|
+
font: inherit;
|
|
264
|
+
font-size: 12px;
|
|
265
|
+
font-weight: 500;
|
|
266
|
+
line-height: 1.5;
|
|
267
|
+
white-space: nowrap;
|
|
268
|
+
cursor: pointer;
|
|
269
|
+
}
|
|
270
|
+
.pc-button:disabled {
|
|
271
|
+
opacity: 0.45;
|
|
272
|
+
cursor: default;
|
|
273
|
+
}
|
|
274
|
+
.pc-button svg {
|
|
275
|
+
flex: none;
|
|
276
|
+
}
|
|
277
|
+
.pc-primary {
|
|
278
|
+
color: var(--on-accent, #fff);
|
|
279
|
+
background: var(--green-fill);
|
|
280
|
+
}
|
|
281
|
+
.pc-primary:hover:not(:disabled) {
|
|
282
|
+
background: var(--green-fill-hover);
|
|
283
|
+
}
|
|
284
|
+
.pc-secondary {
|
|
285
|
+
border-color: var(--line);
|
|
286
|
+
color: var(--text-secondary);
|
|
287
|
+
background: var(--paper);
|
|
288
|
+
}
|
|
289
|
+
.pc-secondary:hover:not(:disabled) {
|
|
290
|
+
background: var(--surface);
|
|
291
|
+
border-color: var(--control-border, var(--line));
|
|
292
|
+
}
|
|
293
|
+
.pc-feedback {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: 7px;
|
|
297
|
+
margin: 0 0 12px;
|
|
298
|
+
padding: 8px 12px;
|
|
299
|
+
border-radius: 6px;
|
|
300
|
+
font-size: 12px;
|
|
301
|
+
overflow-wrap: anywhere;
|
|
302
|
+
}
|
|
303
|
+
.pc-feedback svg {
|
|
304
|
+
flex: none;
|
|
305
|
+
}
|
|
306
|
+
.pc-feedback.error {
|
|
307
|
+
background: var(--danger-bg);
|
|
308
|
+
color: var(--danger);
|
|
309
|
+
}
|
|
310
|
+
.pc-feedback.success {
|
|
311
|
+
color: var(--green);
|
|
312
|
+
}
|
|
313
|
+
.dialog-intro {
|
|
314
|
+
margin: 0 0 18px;
|
|
315
|
+
color: var(--muted);
|
|
316
|
+
font-size: 13px;
|
|
317
|
+
line-height: 1.8;
|
|
318
|
+
}
|
|
319
|
+
.import-file {
|
|
320
|
+
display: flex;
|
|
321
|
+
flex-direction: column;
|
|
322
|
+
align-items: center;
|
|
323
|
+
gap: 8px;
|
|
324
|
+
width: 100%;
|
|
325
|
+
margin-top: 12px;
|
|
326
|
+
padding: 24px;
|
|
327
|
+
border: 1px dashed var(--control-border);
|
|
328
|
+
border-radius: 10px;
|
|
329
|
+
color: var(--green);
|
|
330
|
+
background: var(--surface);
|
|
331
|
+
cursor: pointer;
|
|
332
|
+
}
|
|
333
|
+
.import-file:hover:not(:disabled) {
|
|
334
|
+
border-color: var(--green);
|
|
335
|
+
background: var(--accent);
|
|
336
|
+
}
|
|
337
|
+
.import-file strong {
|
|
338
|
+
font-size: 13px;
|
|
339
|
+
font-weight: 500;
|
|
340
|
+
}
|
|
341
|
+
.import-file span {
|
|
342
|
+
color: var(--muted);
|
|
343
|
+
font-size: 11px;
|
|
344
|
+
}
|
|
345
|
+
.manifest-label {
|
|
346
|
+
display: block;
|
|
347
|
+
margin: 22px 0 8px;
|
|
348
|
+
font-size: 12px;
|
|
349
|
+
font-weight: 500;
|
|
350
|
+
}
|
|
351
|
+
#plugin-manifest {
|
|
352
|
+
display: block;
|
|
353
|
+
width: 100%;
|
|
354
|
+
min-height: 140px;
|
|
355
|
+
padding: 12px;
|
|
356
|
+
border: 1px solid var(--line);
|
|
357
|
+
border-radius: 8px;
|
|
358
|
+
background: var(--paper);
|
|
359
|
+
color: var(--text);
|
|
360
|
+
font: 12px/1.7 var(--font-mono);
|
|
361
|
+
resize: vertical;
|
|
362
|
+
box-sizing: border-box;
|
|
363
|
+
}
|
|
364
|
+
.import-check {
|
|
365
|
+
display: flex;
|
|
366
|
+
align-items: center;
|
|
367
|
+
justify-content: space-between;
|
|
368
|
+
flex-wrap: wrap;
|
|
369
|
+
gap: 10px;
|
|
370
|
+
margin-top: 12px;
|
|
371
|
+
}
|
|
372
|
+
.import-check > span {
|
|
373
|
+
color: var(--muted);
|
|
374
|
+
font-size: 11px;
|
|
375
|
+
}
|
|
376
|
+
.plugin-preview {
|
|
377
|
+
margin-top: 20px;
|
|
378
|
+
padding: 18px;
|
|
379
|
+
border-radius: 10px;
|
|
380
|
+
background: var(--accent);
|
|
381
|
+
font-size: 12px;
|
|
382
|
+
}
|
|
383
|
+
.plugin-preview > div {
|
|
384
|
+
display: flex;
|
|
385
|
+
align-items: center;
|
|
386
|
+
flex-wrap: wrap;
|
|
387
|
+
gap: 7px;
|
|
388
|
+
color: var(--green);
|
|
389
|
+
}
|
|
390
|
+
.plugin-preview p {
|
|
391
|
+
color: var(--text-secondary);
|
|
392
|
+
overflow-wrap: anywhere;
|
|
393
|
+
}
|
|
394
|
+
.import-scope {
|
|
395
|
+
display: flex;
|
|
396
|
+
flex-direction: column;
|
|
397
|
+
gap: 6px;
|
|
398
|
+
margin: 12px 0;
|
|
399
|
+
color: var(--text);
|
|
400
|
+
font-size: 12px;
|
|
401
|
+
}
|
|
402
|
+
.import-scope select {
|
|
403
|
+
padding: 6px 10px;
|
|
404
|
+
border: 1px solid var(--line);
|
|
405
|
+
border-radius: 6px;
|
|
406
|
+
background: var(--paper);
|
|
407
|
+
color: var(--text);
|
|
408
|
+
font: inherit;
|
|
409
|
+
}
|
|
410
|
+
</style>
|