@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,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(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>
|
|
@@ -6,32 +6,28 @@ import { retiredSystemPlugin } from '../workspace-plugins';
|
|
|
6
6
|
import { t } from '../../i18n/i18n';
|
|
7
7
|
import { computed, nextTick, ref, watch } from 'vue';
|
|
8
8
|
import {
|
|
9
|
-
ArrowUpRight,
|
|
10
9
|
Check,
|
|
11
10
|
ChevronDown,
|
|
12
11
|
Download,
|
|
13
12
|
LoaderCircle,
|
|
14
13
|
Package,
|
|
14
|
+
Plus,
|
|
15
15
|
Search,
|
|
16
16
|
ShieldCheck,
|
|
17
17
|
Upload,
|
|
18
18
|
X,
|
|
19
19
|
} from 'lucide-vue-next';
|
|
20
|
-
import {
|
|
21
|
-
import type { PluginManifest, PluginPackage } from '@tano/protocol';
|
|
20
|
+
import type { PluginManifest } from '@tano/protocol';
|
|
22
21
|
import PluginRuntimePanel from './PluginRuntimePanel.vue';
|
|
23
22
|
|
|
24
|
-
import PluginChangeSummary from './PluginChangeSummary.vue';
|
|
25
23
|
import PluginRepositoryStorage from './PluginRepositoryStorage.vue';
|
|
26
24
|
import PluginCatalogBrowser from './PluginCatalogBrowser.vue';
|
|
27
25
|
import PluginConnections from './PluginConnections.vue';
|
|
28
26
|
import PluginAutomations from './PluginAutomations.vue';
|
|
29
|
-
import
|
|
27
|
+
import PluginImportDialog from './PluginImportDialog.vue';
|
|
30
28
|
|
|
31
29
|
import { useWorkspaceStore } from '../../stores/workspace';
|
|
32
30
|
|
|
33
|
-
import PluginDialog from './PluginDialog.vue';
|
|
34
|
-
|
|
35
31
|
import PluginListItem from './PluginListItem.vue';
|
|
36
32
|
import { bundledPluginCatalog, type PluginCatalogEntry } from '../plugin-catalog';
|
|
37
33
|
|
|
@@ -40,16 +36,14 @@ const props = withDefaults(defineProps<{ catalog?: readonly PluginCatalogEntry[]
|
|
|
40
36
|
});
|
|
41
37
|
const store = useWorkspaceStore();
|
|
42
38
|
const { error, status, pending, busy, change, installFromCatalog } = usePluginActions(undefined, () => props.catalog);
|
|
43
|
-
watch(status, value => { if (value && importing.value) { importing.value = false; preview.value = undefined; manifestText.value = ''; chooseView('installed'); } });
|
|
44
39
|
defineExpose({ openImport });
|
|
45
|
-
const emit = defineEmits<{
|
|
40
|
+
const emit = defineEmits<{ createObject: [type: string]; feedback: [status: string, error: string] }>();
|
|
41
|
+
const pluginObjectTypes = computed(() =>
|
|
42
|
+
store.objectDefinitions.filter((type) => type.category === 'plugin' && type.storage === 'record'),
|
|
43
|
+
);
|
|
46
44
|
watch([status, error], ([message, failure]) => emit('feedback', message, failure));
|
|
47
|
-
const input = ref<HTMLInputElement>();
|
|
48
45
|
const search = ref<HTMLInputElement>();
|
|
49
|
-
|
|
50
|
-
const preview = ref<PluginManifest>();
|
|
51
|
-
const previewPackage = ref<PluginPackage>();
|
|
52
|
-
type View = 'discover' | 'installed' | 'community' | 'publishing';
|
|
46
|
+
type View = 'discover' | 'installed' | 'community' | 'forge' | 'publishing';
|
|
53
47
|
const view = ref<View>('discover');
|
|
54
48
|
const publishingOpened = ref(false);
|
|
55
49
|
const query = ref('');
|
|
@@ -72,8 +66,6 @@ const installedById = computed(
|
|
|
72
66
|
() => new Map(store.installedPlugins.map((item) => [item.manifest.id, item])),
|
|
73
67
|
);
|
|
74
68
|
const feedbackError = computed(() => error.value || store.pluginError);
|
|
75
|
-
const hasDialog = computed(() => importing.value);
|
|
76
|
-
let importSequence = 0;
|
|
77
69
|
|
|
78
70
|
const matches = (plugin: PluginManifest) => matchesPlugin(plugin, query.value);
|
|
79
71
|
const catalog = computed(() =>
|
|
@@ -136,72 +128,15 @@ function openImport() {
|
|
|
136
128
|
status.value = '';
|
|
137
129
|
importing.value = true;
|
|
138
130
|
}
|
|
139
|
-
function closeDialog() {
|
|
140
|
-
if (busy.value) return;
|
|
141
|
-
importSequence++;
|
|
142
|
-
|
|
143
|
-
importing.value = false;
|
|
144
|
-
manifestText.value = '';
|
|
145
|
-
preview.value = undefined;
|
|
146
|
-
error.value = '';
|
|
147
|
-
}
|
|
148
131
|
watch(
|
|
149
132
|
() => store.workspace?.id,
|
|
150
133
|
() => {
|
|
151
|
-
importSequence++;
|
|
152
134
|
importing.value = false;
|
|
153
|
-
|
|
154
|
-
manifestText.value = '';
|
|
155
|
-
preview.value = undefined;
|
|
156
135
|
error.value = '';
|
|
157
136
|
status.value = '';
|
|
158
137
|
chooseView('discover');
|
|
159
138
|
},
|
|
160
139
|
);
|
|
161
|
-
watch(manifestText, () => {
|
|
162
|
-
preview.value = undefined;
|
|
163
|
-
previewPackage.value = undefined;
|
|
164
|
-
});
|
|
165
|
-
function inspect() {
|
|
166
|
-
error.value = '';
|
|
167
|
-
status.value = '';
|
|
168
|
-
preview.value = undefined;
|
|
169
|
-
try {
|
|
170
|
-
previewPackage.value = parsePluginPackage(manifestText.value);
|
|
171
|
-
preview.value = previewPackage.value.manifest;
|
|
172
|
-
} catch (cause) {
|
|
173
|
-
error.value =
|
|
174
|
-
cause instanceof SyntaxError
|
|
175
|
-
? t('JSON 格式有误,请检查引号、逗号和括号后重试。')
|
|
176
|
-
: String(cause);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
async function importFile(event: Event) {
|
|
180
|
-
const file = (event.target as HTMLInputElement).files?.[0];
|
|
181
|
-
(event.target as HTMLInputElement).value = '';
|
|
182
|
-
if (!file) return;
|
|
183
|
-
preview.value = undefined;
|
|
184
|
-
error.value = '';
|
|
185
|
-
status.value = '';
|
|
186
|
-
const workspace = store.workspace?.id;
|
|
187
|
-
const sequence = ++importSequence;
|
|
188
|
-
try {
|
|
189
|
-
if (file.size > pluginPackageLimit) throw new Error(t('插件包不能超过 4 MiB'));
|
|
190
|
-
const content = await file.text();
|
|
191
|
-
if (store.workspace?.id !== workspace || sequence !== importSequence) return;
|
|
192
|
-
manifestText.value = content;
|
|
193
|
-
// Watch invalidation must finish before publishing the inspected preview.
|
|
194
|
-
await nextTick();
|
|
195
|
-
if (store.workspace?.id === workspace && sequence === importSequence) inspect();
|
|
196
|
-
} catch (cause) {
|
|
197
|
-
if (store.workspace?.id === workspace && sequence === importSequence)
|
|
198
|
-
error.value = String(cause);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
async function importCachedPackage() {
|
|
202
|
-
try { await store.cachePluginPackage(manifestText.value); status.value = t('插件包已保存到此设备,请在详情中授权运行'); await store.refresh(); }
|
|
203
|
-
catch (cause) { error.value = String(cause); }
|
|
204
|
-
}
|
|
205
140
|
</script>
|
|
206
141
|
|
|
207
142
|
<template>
|
|
@@ -260,6 +195,14 @@ async function importCachedPackage() {
|
|
|
260
195
|
>
|
|
261
196
|
{{ t('已安装') }} <span class="nav-count">{{ store.installedPlugins.length }}</span>
|
|
262
197
|
</button>
|
|
198
|
+
<button
|
|
199
|
+
v-if="$slots.forge"
|
|
200
|
+
:class="{ active: view === 'forge' }"
|
|
201
|
+
:aria-pressed="view === 'forge'"
|
|
202
|
+
@click="chooseView('forge')"
|
|
203
|
+
>
|
|
204
|
+
{{ t('工坊与微调') }}
|
|
205
|
+
</button>
|
|
263
206
|
<button v-if="$slots.publishing" :class="{ active: view === 'publishing' }" :aria-pressed="view === 'publishing'" @click="chooseView('publishing')">{{ t('我的投稿') }}</button>
|
|
264
207
|
</nav>
|
|
265
208
|
<label v-if="view === 'discover' || view === 'installed'" class="catalog-filter">
|
|
@@ -279,7 +222,7 @@ async function importCachedPackage() {
|
|
|
279
222
|
</div>
|
|
280
223
|
</div>
|
|
281
224
|
|
|
282
|
-
<template v-if="!
|
|
225
|
+
<template v-if="!importing && view !== 'publishing'">
|
|
283
226
|
<p v-if="feedbackError" class="pc-feedback error" role="alert">{{ feedbackError }}</p>
|
|
284
227
|
<p v-if="status" class="pc-feedback success" role="status">
|
|
285
228
|
<Check :size="15" />{{ status }}
|
|
@@ -287,6 +230,12 @@ async function importCachedPackage() {
|
|
|
287
230
|
</template>
|
|
288
231
|
|
|
289
232
|
<PluginCatalogBrowser v-if="view === 'community'" />
|
|
233
|
+
<slot
|
|
234
|
+
v-else-if="view === 'forge' && $slots.forge"
|
|
235
|
+
name="forge"
|
|
236
|
+
:can-publish="!!$slots.publishing"
|
|
237
|
+
:open-publishing="() => chooseView('publishing')"
|
|
238
|
+
/>
|
|
290
239
|
<section v-else-if="view !== 'publishing'"
|
|
291
240
|
class="catalog-results"
|
|
292
241
|
:aria-label="view === 'discover' ? t('可安装插件') : t('已安装插件')"
|
|
@@ -304,6 +253,7 @@ async function importCachedPackage() {
|
|
|
304
253
|
:plugin="plugin"
|
|
305
254
|
:installed="installedById.has(plugin.id)"
|
|
306
255
|
:enabled="installedById.get(plugin.id)?.enabled"
|
|
256
|
+
:scope="installedById.get(plugin.id)?.scope"
|
|
307
257
|
:show-state="view === 'installed'"
|
|
308
258
|
:busy="busy || !store.canManagePlugins"
|
|
309
259
|
:pending="pending === plugin.id"
|
|
@@ -329,7 +279,7 @@ async function importCachedPackage() {
|
|
|
329
279
|
><span>{{ t('已显示') }} {{ visiblePlugins.length }} / {{ resultCount }}</span>
|
|
330
280
|
</div>
|
|
331
281
|
<p v-if="view === 'installed' && visiblePlugins.length" class="installed-note">
|
|
332
|
-
{{ t('
|
|
282
|
+
{{ t('工作区插件与共享设置跟随工作区;全局插件、个人启用和代码授权保存在此设备,跨工作区生效。卸载后保留已有内容。') }}
|
|
333
283
|
</p>
|
|
334
284
|
</section>
|
|
335
285
|
|
|
@@ -343,77 +293,21 @@ async function importCachedPackage() {
|
|
|
343
293
|
<PluginRepositoryStorage />
|
|
344
294
|
</template>
|
|
345
295
|
<footer v-if="view !== 'publishing'" class="center-footer">
|
|
346
|
-
<span>{{ store.pluginCatalogSource ? t('社区目录已接入 · 版本由工作区管理员选择') : t('当前提供内置插件与文件导入 · 社区目录尚未配置') }}</span
|
|
347
|
-
|
|
296
|
+
<span>{{ store.pluginCatalogSource ? t('社区目录已接入 · 版本由工作区管理员选择') : t('当前提供内置插件与文件导入 · 社区目录尚未配置') }}</span>
|
|
297
|
+
<button
|
|
298
|
+
v-if="pluginObjectTypes.length"
|
|
299
|
+
:disabled="!store.workspace || store.workspace.readOnly || !store.capabilities.features.objectReferences"
|
|
300
|
+
@click="emit('createObject', pluginObjectTypes[0]!.type)"
|
|
301
|
+
>
|
|
302
|
+
<Plus :size="13" />{{ t('新建插件对象') }}
|
|
303
|
+
</button>
|
|
348
304
|
</footer>
|
|
349
|
-
<
|
|
350
|
-
v-if="
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
@
|
|
354
|
-
|
|
355
|
-
<p v-if="feedbackError" class="pc-feedback error" role="alert">{{ feedbackError }}</p>
|
|
356
|
-
<p v-if="status" class="pc-feedback success" role="status">
|
|
357
|
-
<Check :size="16" />{{ status }}
|
|
358
|
-
</p>
|
|
359
|
-
<template v-if="importing">
|
|
360
|
-
<p class="dialog-intro">{{ t('导入声明式清单或代码插件包。管理员为工作区安装,成员可补充此设备缺少的插件包。') }}</p>
|
|
361
|
-
<button class="pc-button pc-secondary" @click="manifestText = JSON.stringify(documentOverviewPlugin, null, 2)">{{ t('载入文档总览示例') }}</button>
|
|
362
|
-
<input
|
|
363
|
-
ref="input"
|
|
364
|
-
type="file"
|
|
365
|
-
accept=".json,application/json"
|
|
366
|
-
hidden
|
|
367
|
-
@change="importFile"
|
|
368
|
-
/>
|
|
369
|
-
<button class="import-file" :disabled="busy" @click="input?.click()">
|
|
370
|
-
<Upload :size="25" /><strong>{{ t('选择 JSON 文件') }}</strong
|
|
371
|
-
><span>{{ t('支持 .json 文件,最大 4 MiB') }}</span>
|
|
372
|
-
</button>
|
|
373
|
-
<label class="manifest-label" for="plugin-manifest">{{ t('或粘贴插件清单') }}</label>
|
|
374
|
-
<textarea
|
|
375
|
-
id="plugin-manifest"
|
|
376
|
-
v-model="manifestText"
|
|
377
|
-
:aria-label="t('插件 JSON 清单')"
|
|
378
|
-
:disabled="busy"
|
|
379
|
-
spellcheck="false"
|
|
380
|
-
:placeholder="t('在此粘贴 JSON 内容…')"
|
|
381
|
-
rows="6"
|
|
382
|
-
/>
|
|
383
|
-
<div class="import-check">
|
|
384
|
-
<span>{{ t('代码插件需要单独授权;导入和检查不会执行脚本。') }}</span
|
|
385
|
-
><button
|
|
386
|
-
class="pc-button pc-secondary"
|
|
387
|
-
:disabled="!manifestText.trim() || busy"
|
|
388
|
-
@click="inspect"
|
|
389
|
-
>
|
|
390
|
-
{{ t('检查清单') }}
|
|
391
|
-
</button>
|
|
392
|
-
</div>
|
|
393
|
-
<div v-if="preview" class="plugin-preview">
|
|
394
|
-
<div>
|
|
395
|
-
<Check :size="17" /><strong>{{ preview.name }}</strong
|
|
396
|
-
><span>v{{ preview.version }}</span>
|
|
397
|
-
</div>
|
|
398
|
-
<p>{{ preview.description }}</p>
|
|
399
|
-
<PluginChangeSummary :before="installedById.get(preview.id)?.manifest" :after="preview" :workspace="store.workspace?.name" />
|
|
400
|
-
<p>
|
|
401
|
-
{{ preview.objectTypes.map((item) => item.label).join('、') || t('无新增对象类型') }} ·
|
|
402
|
-
{{ preview.relationTypes.length }} {{ t('种关系') }}
|
|
403
|
-
</p>
|
|
404
|
-
<button
|
|
405
|
-
class="pc-button pc-primary"
|
|
406
|
-
:disabled="busy || !store.canManagePlugins"
|
|
407
|
-
@click="change({ install: preview, package: previewPackage })"
|
|
408
|
-
>
|
|
409
|
-
<Download :size="15" />{{
|
|
410
|
-
installedById.has(preview.id) ? t('更新并启用插件') : t('安装此插件')
|
|
411
|
-
}}
|
|
412
|
-
</button>
|
|
413
|
-
<button v-if="preview.manifestVersion === 2" class="pc-button pc-secondary" :disabled="busy" @click="importCachedPackage">{{ t('仅保存到此设备') }}</button>
|
|
414
|
-
</div>
|
|
415
|
-
</template>
|
|
416
|
-
</PluginDialog></Teleport>
|
|
305
|
+
<PluginImportDialog
|
|
306
|
+
v-if="importing"
|
|
307
|
+
@close="importing = false"
|
|
308
|
+
@installed="chooseView('installed')"
|
|
309
|
+
@feedback="(message, failure) => { status = message; error = failure; }"
|
|
310
|
+
/>
|
|
417
311
|
</div>
|
|
418
312
|
</div>
|
|
419
313
|
</template>
|