@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
|
@@ -1,56 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
source: ReferenceTarget;
|
|
8
|
-
target: ReferenceIdentity;
|
|
9
|
-
name: string;
|
|
10
|
-
path?: string;
|
|
11
|
-
excerpt: string;
|
|
12
|
-
missing: boolean;
|
|
13
|
-
archived: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface ReferenceContext { outgoing: ContentReference[]; incoming: ContentReference[]; errors: string[] }
|
|
16
|
-
|
|
17
|
-
/** A rebuildable directed index. Content is authoritative; no duplicate relation rows are persisted. */
|
|
18
|
-
export function contentReferences(targets: readonly ReferenceTarget[], contents: ReadonlyMap<string, string>,
|
|
19
|
-
readLinks: (content: string) => readonly DocumentLinkDetail[] = documentLinkDetails): ContentReference[] {
|
|
20
|
-
const counts = new Map<string, number>();
|
|
21
|
-
for (const target of targets) counts.set(referenceKey(target), (counts.get(referenceKey(target)) ?? 0) + 1);
|
|
22
|
-
const byKey = new Map(targets.filter(target => counts.get(referenceKey(target)) === 1).map(target => [referenceKey(target), target]));
|
|
23
|
-
const documents = targets.filter(target => target.type === 'document')
|
|
24
|
-
.map(target => ({ id: target.id, path: target.path, name: target.name, kind: 'file' as const, size: 0, modified: 0 }));
|
|
25
|
-
const edges: ContentReference[] = [];
|
|
26
|
-
for (const source of targets) {
|
|
27
|
-
if (counts.get(referenceKey(source)) !== 1) continue;
|
|
28
|
-
const content = contents.get(referenceKey(source));
|
|
29
|
-
if (content === undefined) continue;
|
|
30
|
-
const seen = new Set<string>();
|
|
31
|
-
for (const link of readLinks(content)) {
|
|
32
|
-
let identity = parseReferenceUrl(link.target);
|
|
33
|
-
if (!identity && link.kind === 'wiki') {
|
|
34
|
-
const resolved = resolveWikiLink(documents, source.path, link.target);
|
|
35
|
-
if ('file' in resolved) identity = { type: 'document', id: resolved.file.id };
|
|
36
|
-
} else if (!identity) {
|
|
37
|
-
const path = resolveWorkspaceReference(source.path, link.target);
|
|
38
|
-
const target = targets.find(target => ['document', 'asset'].includes(target.type) && target.path === path);
|
|
39
|
-
if (target) identity = { type: target.type, id: target.id };
|
|
40
|
-
}
|
|
41
|
-
if (!identity || seen.has(referenceKey(identity))) continue;
|
|
42
|
-
seen.add(referenceKey(identity));
|
|
43
|
-
const target = byKey.get(referenceKey(identity));
|
|
44
|
-
const origin = { workspace: source.workspace, type: source.type, id: source.id, name: source.name, path: source.path, archived: source.archived };
|
|
45
|
-
edges.push({ source: origin, target: identity, name: target?.name ?? link.label ?? link.target,
|
|
46
|
-
path: target?.path, excerpt: link.excerpt, missing: !target, archived: !!target?.archived });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return edges;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function referenceContext(edges: readonly ContentReference[], identity: ReferenceIdentity, errors: string[] = []): ReferenceContext {
|
|
53
|
-
const key = referenceKey(identity);
|
|
54
|
-
return { outgoing: edges.filter(edge => referenceKey(edge.source) === key),
|
|
55
|
-
incoming: edges.filter(edge => referenceKey(edge.target) === key), errors };
|
|
56
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
contentReferences,
|
|
3
|
+
referenceContext,
|
|
4
|
+
type ContentReference,
|
|
5
|
+
type ReferenceContext,
|
|
6
|
+
} from '@tano/editor/content-references';
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { FileEntry } from '@tano/protocol';
|
|
3
|
-
|
|
4
|
-
type WikiResolution =
|
|
5
|
-
{ file: FileEntry; heading: string } | { error: 'invalid' | 'missing' | 'ambiguous' };
|
|
6
|
-
|
|
7
|
-
/** Resolve Obsidian-style forward links without depending on a path as file identity. */
|
|
8
|
-
export function resolveWikiLink(
|
|
9
|
-
files: FileEntry[],
|
|
10
|
-
currentPath: string,
|
|
11
|
-
target: string,
|
|
12
|
-
): WikiResolution {
|
|
13
|
-
const separator = target.indexOf('#');
|
|
14
|
-
const name = (separator < 0 ? target : target.slice(0, separator)).trim();
|
|
15
|
-
const heading = separator < 0 ? '' : target.slice(separator + 1).trim();
|
|
16
|
-
const notes = files.filter((file) => file.kind === 'file' && isMarkdown(file.path));
|
|
17
|
-
const current = notes.find((file) => file.path === currentPath);
|
|
18
|
-
if (!name) return current && heading ? { file: current, heading } : { error: 'invalid' };
|
|
19
|
-
if (/^[\\/]|[\\:\u0000-\u001f]/.test(name) || name.includes('\\')) return { error: 'invalid' };
|
|
20
|
-
|
|
21
|
-
const spellings = isMarkdown(name) ? [name] : [`${name}.md`, `${name}.markdown`];
|
|
22
|
-
const paths: string[] = [];
|
|
23
|
-
for (const spelling of spellings) {
|
|
24
|
-
const relative = resolveWorkspaceReference(currentPath, spelling);
|
|
25
|
-
if (relative) paths.push(relative);
|
|
26
|
-
if (!spelling.includes('/')) {
|
|
27
|
-
const parents = currentPath.split('/').slice(0, -1);
|
|
28
|
-
for (let depth = parents.length - 1; depth >= 0; depth--)
|
|
29
|
-
paths.push([...parents.slice(0, depth), spelling].join('/'));
|
|
30
|
-
} else if (!spelling.startsWith('../') && !spelling.startsWith('./')) paths.push(spelling);
|
|
31
|
-
}
|
|
32
|
-
for (const path of paths) {
|
|
33
|
-
const exact = notes.find((file) => file.path === path);
|
|
34
|
-
if (exact) return { file: exact, heading };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// A short wiki target can name a page anywhere in the workspace. Never pick
|
|
38
|
-
// an arbitrary page when multiple folders contain the same title.
|
|
39
|
-
const names = new Set(spellings.map((spelling) => spelling.toLocaleLowerCase()));
|
|
40
|
-
const matches = notes.filter((file) => {
|
|
41
|
-
const path = file.path.toLocaleLowerCase();
|
|
42
|
-
return name.includes('/')
|
|
43
|
-
? spellings.some((spelling) => path.endsWith(`/${spelling.toLocaleLowerCase()}`))
|
|
44
|
-
: names.has(path.split('/').at(-1)!);
|
|
45
|
-
});
|
|
46
|
-
if (matches.length === 1) return { file: matches[0], heading };
|
|
47
|
-
return { error: matches.length ? 'ambiguous' : 'missing' };
|
|
48
|
-
}
|
|
1
|
+
export { resolveWikiLink } from '@tano/editor/content-references';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
validateObjectProperties,
|
|
7
7
|
} from '@tano/protocol';
|
|
8
8
|
import type { FileSnapshot, Workspace, WorkspaceAdapter, WorkspaceObject } from '@tano/protocol';
|
|
9
|
-
import {
|
|
9
|
+
import { mergeObject } from '@tano/editor/workspace-objects';
|
|
10
10
|
|
|
11
11
|
export interface ObjectRecord {
|
|
12
12
|
object: WorkspaceObject;
|
|
@@ -26,7 +26,7 @@ export async function loadObjects(adapter: Pick<ObjectStorage, 'read'>, workspac
|
|
|
26
26
|
const snapshot = await adapter.read(file.path);
|
|
27
27
|
const object = parseObject(snapshot.content);
|
|
28
28
|
const definition = objectTypeRegistry.get(object.type);
|
|
29
|
-
if (definition
|
|
29
|
+
if (definition) {
|
|
30
30
|
try {
|
|
31
31
|
validateObjectProperties(object.type, object.properties);
|
|
32
32
|
} catch (error) {
|
|
@@ -44,8 +44,7 @@ export async function loadObjects(adapter: Pick<ObjectStorage, 'read'>, workspac
|
|
|
44
44
|
if (count > 1) errors.push(`对象 ID ${id} 重复,引用已停用;请修复重复文件`);
|
|
45
45
|
return { records: records.filter((record) => ids.get(record.object.id) === 1), errors };
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
export const mergeObject = (base: WorkspaceObject, ours: WorkspaceObject, theirs: WorkspaceObject) => mergeWorkspaceObject(base, ours, theirs, mergeDescription);
|
|
47
|
+
export { mergeObject };
|
|
49
48
|
export async function saveObject(
|
|
50
49
|
adapter: Pick<ObjectStorage, 'write'> & Partial<Pick<ObjectStorage, 'create'>>,
|
|
51
50
|
record: ObjectRecord,
|
package/src/plan-sync/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlanCompleted } from '@tano/protocol';
|
|
1
2
|
import type { ObjectRecord } from '../objects/workspace-objects';
|
|
2
3
|
export type SyncKind = 'calendar' | 'todo';
|
|
3
4
|
export type ProviderId = 'google' | 'icloud' | 'feishu' | 'caldav' | 'todoist' | 'microsoft';
|
|
@@ -49,10 +50,12 @@ export const sameValue = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.
|
|
|
49
50
|
export function localValue(record: ObjectRecord, kind: SyncKind): ItemValue {
|
|
50
51
|
const p = record.object.properties;
|
|
51
52
|
if (kind === 'todo') return { name: record.object.name, description: record.object.description, archived: record.object.archived,
|
|
52
|
-
completed:
|
|
53
|
+
completed: isPlanCompleted(record.object), ...(typeof p.due === 'string' && p.due ? { date: p.due } : {}) };
|
|
53
54
|
if (typeof p.date === 'string' && p.date && !p.start) {
|
|
54
|
-
const start = new Date(`${p.date}T00:00:00`)
|
|
55
|
-
|
|
55
|
+
const start = new Date(`${p.date}T00:00:00`);
|
|
56
|
+
const endBase = typeof p.endDate === 'string' && p.endDate >= p.date ? new Date(`${p.endDate}T00:00:00`) : new Date(start);
|
|
57
|
+
endBase.setDate(endBase.getDate() + 1);
|
|
58
|
+
return { name: record.object.name, description: record.object.description, archived: record.object.archived, start: start.toISOString(), end: endBase.toISOString(), allDay: true };
|
|
56
59
|
}
|
|
57
60
|
return {
|
|
58
61
|
name: record.object.name, description: record.object.description, archived: record.object.archived,
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { WorkspaceObject } from '@tano/protocol';
|
|
2
|
+
import { validEventDate, validEventTime } from '@tano/protocol';
|
|
3
|
+
import { localDateTime, localDayKey } from './calendar';
|
|
4
|
+
import type { PlanDateValue } from './plan-date';
|
|
5
|
+
|
|
6
|
+
export const PLAN_DRAG_MIME = 'application/x-tano-plan-key';
|
|
7
|
+
export const SNAP_MINUTES = 15;
|
|
8
|
+
export const MIN_DURATION_MINUTES = 15;
|
|
9
|
+
export const DEFAULT_CLICK_DURATION_MINUTES = 60;
|
|
10
|
+
const DAY_MINUTES = 24 * 60;
|
|
11
|
+
|
|
12
|
+
export function snapMinutes(minutes: number, step = SNAP_MINUTES): number {
|
|
13
|
+
const clamped = Math.max(0, Math.min(DAY_MINUTES, minutes));
|
|
14
|
+
return Math.max(0, Math.min(DAY_MINUTES, Math.round(clamped / step) * step));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function minutesFromOffsetY(offsetY: number, hourHeight: number, step = SNAP_MINUTES): number {
|
|
18
|
+
if (!Number.isFinite(offsetY) || hourHeight <= 0) return 0;
|
|
19
|
+
return snapMinutes((offsetY / hourHeight) * 60, step);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function selectionRangeFromOffsets(
|
|
23
|
+
anchorY: number,
|
|
24
|
+
currentY: number,
|
|
25
|
+
hourHeight: number,
|
|
26
|
+
step = SNAP_MINUTES,
|
|
27
|
+
): { startMinutes: number; endMinutes: number } {
|
|
28
|
+
if (Math.abs(currentY - anchorY) < 6) {
|
|
29
|
+
const raw = Math.max(0, Math.min(DAY_MINUTES - step, (anchorY / hourHeight) * 60));
|
|
30
|
+
const startMinutes = Math.floor(raw / step) * step;
|
|
31
|
+
const endMinutes = Math.min(DAY_MINUTES, startMinutes + DEFAULT_CLICK_DURATION_MINUTES);
|
|
32
|
+
return { startMinutes, endMinutes };
|
|
33
|
+
}
|
|
34
|
+
const a = minutesFromOffsetY(anchorY, hourHeight, step);
|
|
35
|
+
const b = minutesFromOffsetY(currentY, hourHeight, step);
|
|
36
|
+
const startMinutes = Math.min(a, b);
|
|
37
|
+
const endMinutes = Math.min(DAY_MINUTES, Math.max(startMinutes + 30, Math.max(a, b)));
|
|
38
|
+
if (startMinutes >= DAY_MINUTES) {
|
|
39
|
+
return { startMinutes: DAY_MINUTES - 30, endMinutes: DAY_MINUTES };
|
|
40
|
+
}
|
|
41
|
+
return { startMinutes, endMinutes };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function formatMinutesLabel(minutes: number): string {
|
|
45
|
+
const clamped = Math.max(0, Math.min(DAY_MINUTES, Math.round(minutes)));
|
|
46
|
+
const h = Math.floor(clamped / 60);
|
|
47
|
+
const m = clamped % 60;
|
|
48
|
+
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function planDateFromSlot(day: Date, startMinutes: number, endMinutes: number): PlanDateValue {
|
|
52
|
+
const start = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, startMinutes);
|
|
53
|
+
const end = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, Math.max(startMinutes + MIN_DURATION_MINUTES, endMinutes));
|
|
54
|
+
const startLocal = localDateTime(start);
|
|
55
|
+
return {
|
|
56
|
+
date: startLocal.slice(0, 10),
|
|
57
|
+
time: startLocal.slice(11, 16),
|
|
58
|
+
end: localDateTime(end),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function buildTimedProperties(
|
|
63
|
+
properties: Record<string, unknown>,
|
|
64
|
+
day: Date,
|
|
65
|
+
startMinutes: number,
|
|
66
|
+
endMinutes: number,
|
|
67
|
+
): Record<string, unknown> {
|
|
68
|
+
const safeStart = Math.max(0, Math.min(DAY_MINUTES - MIN_DURATION_MINUTES, startMinutes));
|
|
69
|
+
const safeEnd = Math.max(safeStart + MIN_DURATION_MINUTES, Math.min(DAY_MINUTES, endMinutes));
|
|
70
|
+
const start = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, safeStart);
|
|
71
|
+
const end = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, safeEnd);
|
|
72
|
+
const next: Record<string, unknown> = { ...properties };
|
|
73
|
+
delete next.date;
|
|
74
|
+
delete next.endDate;
|
|
75
|
+
delete next.allDay;
|
|
76
|
+
next.start = start.toISOString();
|
|
77
|
+
next.end = end.toISOString();
|
|
78
|
+
return next;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function addCalendarDays(dateKey: string, deltaDays: number): string {
|
|
82
|
+
const date = new Date(`${dateKey}T00:00:00`);
|
|
83
|
+
date.setDate(date.getDate() + deltaDays);
|
|
84
|
+
return localDayKey(date);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function calendarDayDelta(fromDayKey: string, toDayKey: string): number {
|
|
88
|
+
return Math.round(
|
|
89
|
+
(Date.parse(`${toDayKey}T00:00:00Z`) - Date.parse(`${fromDayKey}T00:00:00Z`)) / 86_400_000,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Moves an event or task to a target calendar day, preserving its time-of-day duration or span. */
|
|
94
|
+
export function moveRecordToDay<T extends WorkspaceObject>(object: T, targetDay: Date): T {
|
|
95
|
+
const p = object.properties;
|
|
96
|
+
const targetKey = localDayKey(targetDay);
|
|
97
|
+
const next: Record<string, unknown> = { ...p };
|
|
98
|
+
|
|
99
|
+
if (validEventTime(p.start) && validEventTime(p.end)) {
|
|
100
|
+
const startDate = new Date(p.start);
|
|
101
|
+
const endDate = new Date(p.end);
|
|
102
|
+
const delta = calendarDayDelta(localDayKey(startDate), targetKey);
|
|
103
|
+
if (p.allDay === true) {
|
|
104
|
+
const movedStart = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + delta);
|
|
105
|
+
const movedEnd = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate() + delta);
|
|
106
|
+
next.start = movedStart.toISOString();
|
|
107
|
+
next.end = movedEnd.toISOString();
|
|
108
|
+
next.allDay = true;
|
|
109
|
+
} else {
|
|
110
|
+
const durationMs = Math.max(0, endDate.getTime() - startDate.getTime());
|
|
111
|
+
const movedStart = new Date(
|
|
112
|
+
targetDay.getFullYear(),
|
|
113
|
+
targetDay.getMonth(),
|
|
114
|
+
targetDay.getDate(),
|
|
115
|
+
startDate.getHours(),
|
|
116
|
+
startDate.getMinutes(),
|
|
117
|
+
startDate.getSeconds(),
|
|
118
|
+
startDate.getMilliseconds(),
|
|
119
|
+
);
|
|
120
|
+
next.start = movedStart.toISOString();
|
|
121
|
+
next.end = new Date(movedStart.getTime() + durationMs).toISOString();
|
|
122
|
+
}
|
|
123
|
+
return { ...object, properties: next };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
delete next.start;
|
|
127
|
+
delete next.end;
|
|
128
|
+
delete next.allDay;
|
|
129
|
+
if (validEventDate(p.date) && validEventDate(p.endDate)) {
|
|
130
|
+
const delta = calendarDayDelta(p.date, targetKey);
|
|
131
|
+
next.date = targetKey;
|
|
132
|
+
next.endDate = addCalendarDays(p.endDate, delta);
|
|
133
|
+
} else {
|
|
134
|
+
delete next.endDate;
|
|
135
|
+
next.date = targetKey;
|
|
136
|
+
}
|
|
137
|
+
return { ...object, properties: next };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Moves or timeblocks a record into a specific timed slot on a target day, preserving existing duration if timed. */
|
|
141
|
+
export function moveRecordToSlot<T extends WorkspaceObject>(
|
|
142
|
+
object: T,
|
|
143
|
+
targetDay: Date,
|
|
144
|
+
startMinutes: number,
|
|
145
|
+
fallbackDurationMinutes = DEFAULT_CLICK_DURATION_MINUTES,
|
|
146
|
+
): T {
|
|
147
|
+
const p = object.properties;
|
|
148
|
+
let durationMinutes = fallbackDurationMinutes;
|
|
149
|
+
if (validEventTime(p.start) && validEventTime(p.end) && p.allDay !== true) {
|
|
150
|
+
const existing = Math.round((Date.parse(p.end) - Date.parse(p.start)) / 60_000);
|
|
151
|
+
if (existing >= MIN_DURATION_MINUTES) durationMinutes = existing;
|
|
152
|
+
else if (existing === 0) durationMinutes = 0;
|
|
153
|
+
}
|
|
154
|
+
const safeStart = Math.max(0, Math.min(DAY_MINUTES - MIN_DURATION_MINUTES, snapMinutes(startMinutes)));
|
|
155
|
+
const start = new Date(targetDay.getFullYear(), targetDay.getMonth(), targetDay.getDate(), 0, safeStart);
|
|
156
|
+
const end = durationMinutes === 0
|
|
157
|
+
? new Date(start.getTime())
|
|
158
|
+
: new Date(
|
|
159
|
+
targetDay.getFullYear(),
|
|
160
|
+
targetDay.getMonth(),
|
|
161
|
+
targetDay.getDate(),
|
|
162
|
+
0,
|
|
163
|
+
Math.min(DAY_MINUTES, safeStart + Math.max(MIN_DURATION_MINUTES, durationMinutes)),
|
|
164
|
+
);
|
|
165
|
+
const next: Record<string, unknown> = { ...p };
|
|
166
|
+
delete next.date;
|
|
167
|
+
delete next.endDate;
|
|
168
|
+
delete next.allDay;
|
|
169
|
+
next.start = start.toISOString();
|
|
170
|
+
next.end = end.toISOString();
|
|
171
|
+
return { ...object, properties: next };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Resizes a timed event's end time on the given day while keeping start intact and >= 15 minutes duration. */
|
|
175
|
+
export function resizeRecordEnd<T extends WorkspaceObject>(
|
|
176
|
+
object: T,
|
|
177
|
+
day: Date,
|
|
178
|
+
newEndMinutes: number,
|
|
179
|
+
): T {
|
|
180
|
+
const p = object.properties;
|
|
181
|
+
if (!validEventTime(p.start)) return object;
|
|
182
|
+
const startMs = Date.parse(p.start);
|
|
183
|
+
const dayStart = new Date(day.getFullYear(), day.getMonth(), day.getDate()).getTime();
|
|
184
|
+
const clampedMinutes = Math.max(MIN_DURATION_MINUTES, Math.min(DAY_MINUTES, snapMinutes(newEndMinutes)));
|
|
185
|
+
const targetEndMs = dayStart + clampedMinutes * 60_000;
|
|
186
|
+
const safeEndMs = Math.max(startMs + MIN_DURATION_MINUTES * 60_000, targetEndMs);
|
|
187
|
+
return {
|
|
188
|
+
...object,
|
|
189
|
+
properties: {
|
|
190
|
+
...p,
|
|
191
|
+
end: new Date(safeEndMs).toISOString(),
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
package/src/plans/calendar.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isActionableTask,
|
|
3
|
+
isPlanCompleted,
|
|
4
|
+
isPlanObject,
|
|
5
|
+
validEventDate,
|
|
6
|
+
validEventTime,
|
|
7
|
+
validateObjectProperties,
|
|
8
|
+
} from '@tano/protocol';
|
|
2
9
|
import type { ObjectRecord } from '../objects/workspace-objects';
|
|
10
|
+
import { localDayKey } from '@tano/protocol/assistant-tasks';
|
|
3
11
|
import { uiLocale } from '../i18n/i18n';
|
|
4
12
|
|
|
5
13
|
export const CALENDAR_TAB_ID = 'view:calendar';
|
|
6
14
|
export type CalendarViewMode = 'day' | 'four-days' | 'week' | 'month' | 'year' | 'agenda';
|
|
7
15
|
|
|
8
|
-
export
|
|
9
|
-
`${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
|
16
|
+
export { localDayKey };
|
|
10
17
|
export const localDateTime = (date: Date) =>
|
|
11
18
|
`${localDayKey(date)}T${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
|
12
19
|
export function weekDays(date: Date) {
|
|
@@ -58,18 +65,47 @@ export function monthDays(month: Date) {
|
|
|
58
65
|
(_, index) => new Date(month.getFullYear(), month.getMonth(), index - offset + 1),
|
|
59
66
|
);
|
|
60
67
|
}
|
|
61
|
-
export const isCheckableEvent = ({ object }: ObjectRecord) =>
|
|
62
|
-
|
|
63
|
-
export const isEventCompleted = ({ object }: ObjectRecord) =>
|
|
64
|
-
object.properties.completed === true || (object.type === 'task' && ['done', 'completed'].includes(String(object.properties.status)));
|
|
68
|
+
export const isCheckableEvent = ({ object }: ObjectRecord) => isActionableTask(object);
|
|
69
|
+
export const isEventCompleted = ({ object }: ObjectRecord) => isPlanCompleted(object);
|
|
65
70
|
export const hasEventTime = ({ object: { properties } }: ObjectRecord) =>
|
|
66
71
|
validEventTime(properties.start) && validEventTime(properties.end) && Date.parse(properties.end) >= Date.parse(properties.start);
|
|
72
|
+
export const eventDueDate = ({ object: { properties } }: ObjectRecord): string | null =>
|
|
73
|
+
validEventDate(properties.due) ? properties.due : null;
|
|
74
|
+
export const isEventOverdue = (record: ObjectRecord, today = localDayKey(new Date())) => {
|
|
75
|
+
const due = eventDueDate(record);
|
|
76
|
+
return isCheckableEvent(record) && !isEventCompleted(record) && due !== null && due < today;
|
|
77
|
+
};
|
|
78
|
+
export const isDateOnlyOnDay = ({ object: { properties } }: ObjectRecord, day: Date) => {
|
|
79
|
+
if (validEventTime(properties.start) && validEventTime(properties.end)) return false;
|
|
80
|
+
if (!validEventDate(properties.date)) return false;
|
|
81
|
+
const key = localDayKey(day);
|
|
82
|
+
if (validEventDate(properties.endDate)) return properties.date <= key && key <= properties.endDate;
|
|
83
|
+
return properties.date === key;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export interface CalendarFilter {
|
|
87
|
+
kind: 'all' | 'task' | 'event';
|
|
88
|
+
showCompleted: boolean;
|
|
89
|
+
query: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function filterCalendarRecords(records: readonly ObjectRecord[], filter: CalendarFilter) {
|
|
93
|
+
const needle = filter.query.trim().toLocaleLowerCase();
|
|
94
|
+
return records.filter((record) => {
|
|
95
|
+
const checkable = isCheckableEvent(record);
|
|
96
|
+
if (filter.kind === 'task' && !checkable) return false;
|
|
97
|
+
if (filter.kind === 'event' && checkable) return false;
|
|
98
|
+
if (!filter.showCompleted && checkable && isEventCompleted(record)) return false;
|
|
99
|
+
if (needle && !`${record.object.name}\n${record.object.description}`.toLocaleLowerCase().includes(needle)) return false;
|
|
100
|
+
return true;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
67
103
|
|
|
68
104
|
/** Planning includes date-only and unscheduled tasks as well as timed events. */
|
|
69
105
|
export function planningEvents(records: readonly ObjectRecord[]) {
|
|
70
106
|
return records
|
|
71
107
|
.filter(({ object }) => {
|
|
72
|
-
if (!
|
|
108
|
+
if (!isPlanObject(object) || object.archived) return false;
|
|
73
109
|
try {
|
|
74
110
|
validateObjectProperties(object.type, object.properties);
|
|
75
111
|
return true;
|
|
@@ -89,7 +125,27 @@ export function calendarEvents(records: readonly ObjectRecord[]) {
|
|
|
89
125
|
}
|
|
90
126
|
export function plannedEventsOnDay(records: readonly ObjectRecord[], day: Date) {
|
|
91
127
|
const timed = new Set(eventsOnDay(records.filter(hasEventTime), day));
|
|
92
|
-
return records.filter(record => timed.has(record) || (
|
|
128
|
+
return records.filter(record => timed.has(record) || isDateOnlyOnDay(record, day));
|
|
129
|
+
}
|
|
130
|
+
export interface CalendarDayEntry {
|
|
131
|
+
record: ObjectRecord;
|
|
132
|
+
kind: 'timed' | 'all-day' | 'due';
|
|
133
|
+
}
|
|
134
|
+
/** Combines scheduled items on a day with tasks whose due date falls on that day. */
|
|
135
|
+
export function calendarDayEntries(records: readonly ObjectRecord[], day: Date): CalendarDayEntry[] {
|
|
136
|
+
const dayKey = localDayKey(day);
|
|
137
|
+
const timed = new Set(eventsOnDay(records.filter(hasEventTime), day));
|
|
138
|
+
const entries: CalendarDayEntry[] = [];
|
|
139
|
+
for (const record of records) {
|
|
140
|
+
if (timed.has(record)) {
|
|
141
|
+
entries.push({ record, kind: record.object.properties.allDay === true ? 'all-day' : 'timed' });
|
|
142
|
+
} else if (isDateOnlyOnDay(record, day)) {
|
|
143
|
+
entries.push({ record, kind: 'all-day' });
|
|
144
|
+
} else if (eventDueDate(record) === dayKey) {
|
|
145
|
+
entries.push({ record, kind: 'due' });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return entries;
|
|
93
149
|
}
|
|
94
150
|
export function unscheduledTasks(records: readonly ObjectRecord[]) {
|
|
95
151
|
return records.filter(record => isCheckableEvent(record) && !hasEventTime(record) && !validEventDate(record.object.properties.date));
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { Circle, CircleCheck, Flag } from 'lucide-vue-next';
|
|
4
|
+
import { t, uiLocale } from '../../i18n/i18n';
|
|
5
|
+
import type { ObjectRecord } from '../../objects/workspace-objects';
|
|
6
|
+
import {
|
|
7
|
+
calendarDayEntries,
|
|
8
|
+
isCheckableEvent,
|
|
9
|
+
isEventCompleted,
|
|
10
|
+
isEventOverdue,
|
|
11
|
+
localDayKey,
|
|
12
|
+
} from '../calendar';
|
|
13
|
+
import { planKey, planSourceLabel, sourcePlanKey } from '../personal-plans';
|
|
14
|
+
import type { CalendarInteractions } from '../composables/use-calendar-interactions';
|
|
15
|
+
|
|
16
|
+
const props = defineProps<{
|
|
17
|
+
date: Date;
|
|
18
|
+
planned: readonly ObjectRecord[];
|
|
19
|
+
today: string;
|
|
20
|
+
weekdays: readonly string[];
|
|
21
|
+
interactions: CalendarInteractions;
|
|
22
|
+
}>();
|
|
23
|
+
|
|
24
|
+
const emit = defineEmits<{
|
|
25
|
+
'select-event': [id: string];
|
|
26
|
+
}>();
|
|
27
|
+
|
|
28
|
+
function dayEntries(day: Date) {
|
|
29
|
+
return calendarDayEntries(props.planned, day);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const agendaDates = computed(() => {
|
|
33
|
+
const year = props.date.getFullYear();
|
|
34
|
+
const month = props.date.getMonth();
|
|
35
|
+
const length = new Date(year, month + 1, 0).getDate();
|
|
36
|
+
return Array.from({ length }, (_, index) => new Date(year, month, index + 1))
|
|
37
|
+
.filter((day) => dayEntries(day).length > 0);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
function weekday(day: Date) {
|
|
41
|
+
return props.weekdays[(day.getDay() + 6) % 7];
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div class="calendar-agenda-view">
|
|
47
|
+
<p v-if="!agendaDates.length" class="calendar-agenda-empty">{{ t('本月没有日程') }}</p>
|
|
48
|
+
<section v-for="day in agendaDates" :key="localDayKey(day)" class="calendar-agenda-day">
|
|
49
|
+
<time
|
|
50
|
+
class="calendar-agenda-date"
|
|
51
|
+
:class="{ today: localDayKey(day) === today }"
|
|
52
|
+
:datetime="localDayKey(day)"
|
|
53
|
+
:aria-label="day.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric', weekday: 'long' })"
|
|
54
|
+
>
|
|
55
|
+
<strong>{{ day.getDate() }}</strong>
|
|
56
|
+
<span>{{ day.toLocaleDateString(uiLocale, { month: 'short' }) }} · {{ uiLocale === 'zh-CN' ? t('周') : '' }}{{ weekday(day) }}</span>
|
|
57
|
+
</time>
|
|
58
|
+
<div class="calendar-agenda-events">
|
|
59
|
+
<div
|
|
60
|
+
v-for="entry in dayEntries(day)"
|
|
61
|
+
:key="`${planKey(entry.record)}:${entry.kind}`"
|
|
62
|
+
class="calendar-agenda-row"
|
|
63
|
+
:class="interactions.itemClasses(entry.record, entry.kind)"
|
|
64
|
+
>
|
|
65
|
+
<button
|
|
66
|
+
v-if="isCheckableEvent(entry.record)"
|
|
67
|
+
type="button"
|
|
68
|
+
class="calendar-inline-check"
|
|
69
|
+
:aria-label="`${isEventCompleted(entry.record) ? t('标记未完成') : t('完成')}:${entry.record.object.name}`"
|
|
70
|
+
:disabled="!interactions.canToggleComplete(entry.record)"
|
|
71
|
+
@click.stop="interactions.toggleComplete(entry.record)"
|
|
72
|
+
>
|
|
73
|
+
<CircleCheck v-if="isEventCompleted(entry.record)" :size="15" aria-hidden="true" />
|
|
74
|
+
<Circle v-else :size="15" aria-hidden="true" />
|
|
75
|
+
</button>
|
|
76
|
+
<span v-else class="calendar-agenda-marker" aria-hidden="true" />
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
class="calendar-agenda-item"
|
|
80
|
+
@click="emit('select-event', sourcePlanKey(entry.record))"
|
|
81
|
+
>
|
|
82
|
+
<time>{{ interactions.entryTime(entry) }}</time>
|
|
83
|
+
<span>
|
|
84
|
+
<Flag v-if="entry.kind === 'due'" :size="12" class="calendar-due-flag" aria-hidden="true" />
|
|
85
|
+
{{ entry.record.object.name }}
|
|
86
|
+
<small>{{ planSourceLabel(entry.record) }}<template v-if="isEventOverdue(entry.record, today)"> · {{ t('逾期') }}</template></small>
|
|
87
|
+
</span>
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</section>
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<style scoped>
|
|
96
|
+
.calendar-agenda-view { max-width: 900px; margin: 0 auto; padding: 20px 32px 40px; }
|
|
97
|
+
.calendar-agenda-empty { padding: 60px 0; color: var(--muted); text-align: center; }
|
|
98
|
+
.calendar-agenda-day { display: flex; align-items: flex-start; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); line-height: 20px; }
|
|
99
|
+
.calendar-agenda-day:last-child { border-bottom: 0; }
|
|
100
|
+
.calendar-agenda-date {
|
|
101
|
+
position: sticky;
|
|
102
|
+
top: 12px;
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: baseline;
|
|
105
|
+
gap: 8px;
|
|
106
|
+
width: 112px;
|
|
107
|
+
flex-shrink: 0;
|
|
108
|
+
padding: 7px 0;
|
|
109
|
+
color: var(--muted);
|
|
110
|
+
font-size: 12px;
|
|
111
|
+
font-variant-numeric: tabular-nums;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
}
|
|
114
|
+
.calendar-agenda-date strong {
|
|
115
|
+
display: inline-grid;
|
|
116
|
+
place-items: center;
|
|
117
|
+
min-width: 28px;
|
|
118
|
+
height: 28px;
|
|
119
|
+
padding: 0 4px;
|
|
120
|
+
border-radius: 14px;
|
|
121
|
+
color: var(--text);
|
|
122
|
+
font-size: 18px;
|
|
123
|
+
font-weight: 500;
|
|
124
|
+
}
|
|
125
|
+
.calendar-agenda-date.today strong { color: var(--on-accent, white); background: var(--green-fill); font-size: 14px; }
|
|
126
|
+
.calendar-agenda-date.today span { color: var(--text); }
|
|
127
|
+
.calendar-agenda-events { flex: 1; min-width: 0; }
|
|
128
|
+
.calendar-agenda-row {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
gap: 10px;
|
|
132
|
+
padding: 0 8px;
|
|
133
|
+
border-radius: 7px;
|
|
134
|
+
transition: background-color var(--motion-quick) var(--ease-standard);
|
|
135
|
+
}
|
|
136
|
+
.calendar-agenda-row:hover,
|
|
137
|
+
.calendar-agenda-row:focus-within { background: var(--hover); }
|
|
138
|
+
.calendar-agenda-row .calendar-inline-check { width: 18px; height: 18px; }
|
|
139
|
+
.calendar-agenda-marker {
|
|
140
|
+
flex: none;
|
|
141
|
+
display: grid;
|
|
142
|
+
place-items: center;
|
|
143
|
+
width: 18px;
|
|
144
|
+
height: 18px;
|
|
145
|
+
}
|
|
146
|
+
.calendar-agenda-marker::before {
|
|
147
|
+
content: '';
|
|
148
|
+
width: 7px;
|
|
149
|
+
height: 7px;
|
|
150
|
+
border-radius: 50%;
|
|
151
|
+
background: color-mix(in srgb, var(--tone) 65%, var(--paper));
|
|
152
|
+
}
|
|
153
|
+
.calendar-agenda-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; padding: 8px 0; color: var(--text); text-align: left; }
|
|
154
|
+
.calendar-agenda-item:hover { color: var(--text); }
|
|
155
|
+
.calendar-agenda-item time { width: 46px; flex-shrink: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
156
|
+
.calendar-agenda-item span { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
|
|
157
|
+
.calendar-agenda-item span .calendar-due-flag { align-self: center; }
|
|
158
|
+
.calendar-agenda-item small { color: var(--muted); font-size: 11px; }
|
|
159
|
+
.calendar-agenda-row.is-overdue .calendar-agenda-item small { color: var(--cal-overdue); }
|
|
160
|
+
@media (max-width: 700px) {
|
|
161
|
+
.calendar-agenda-view { padding: 18px; }
|
|
162
|
+
.calendar-agenda-day { gap: 10px; }
|
|
163
|
+
.calendar-agenda-date { width: 88px; flex-direction: column; gap: 2px; }
|
|
164
|
+
}
|
|
165
|
+
</style>
|