@tano.page/workbench 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +35 -14
- package/src/App.vue +68 -797
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantPanel.vue +1 -1
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -585
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/language.ts +10 -37
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -65
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/store.ts +87 -554
- package/src/assistant/structures.ts +1 -157
- package/src/assistant/tasks.ts +8 -94
- package/src/assistant/tool-rules.ts +1 -7
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +37 -1022
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +23 -1
- package/src/i18n/locales/en-US.json +23 -1
- package/src/i18n/locales/es-ES.json +23 -1
- package/src/i18n/locales/ja-JP.json +23 -1
- package/src/i18n/locales/zh-TW.json +23 -1
- package/src/mail/components/MailAccountDialog.vue +1 -0
- package/src/mail/components/MailComposerDialog.vue +1 -0
- package/src/mail/components/MailWorkspaceView.vue +1 -0
- package/src/mail/components/SidebarMail.vue +1 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +2 -3
- package/src/plans/calendar.ts +2 -2
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +162 -2106
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plugins/components/PluginDetailPage.vue +10 -6
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginExplorer.vue +6 -4
- package/src/plugins/components/PluginImportDialog.vue +1 -1
- package/src/plugins/components/PluginInstaller.vue +269 -178
- package/src/plugins/components/PluginMaintenance.vue +37 -49
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginSettingsForm.vue +2 -1
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -260
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/queries.ts +1 -75
- package/src/plugins/view-header.ts +2 -7
- package/src/runtime.ts +3 -2
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/WorkbenchContextMenus.vue +37 -26
- package/src/shell/components/WorkbenchModals.vue +22 -18
- package/src/shell/components/WorkbenchPanes.vue +358 -1512
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +488 -1081
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +1 -1
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +71 -599
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +1 -1
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +163 -1345
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -11
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/assistant/locales/de-DE.json +0 -129
- package/src/assistant/locales/en-US.json +0 -129
- package/src/assistant/locales/es-ES.json +0 -129
- package/src/assistant/locales/ja-JP.json +0 -129
- package/src/assistant/locales/zh-CN.json +0 -129
- package/src/assistant/locales/zh-TW.json +0 -129
- package/src/assistant/task-prompts.json +0 -39
|
@@ -0,0 +1,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>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Search } from 'lucide-vue-next';
|
|
3
|
+
import { t } from '../../i18n/i18n';
|
|
4
|
+
import type { CalendarFilter } from '../calendar';
|
|
5
|
+
|
|
6
|
+
const filter = defineModel<CalendarFilter>({ required: true });
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div class="calendar-filter-bar" role="region" :aria-label="t('日历筛选')">
|
|
11
|
+
<div class="calendar-filter-kinds" role="group" :aria-label="t('筛选')">
|
|
12
|
+
<button
|
|
13
|
+
v-for="option in ([
|
|
14
|
+
{ value: 'all', label: t('全部') },
|
|
15
|
+
{ value: 'task', label: t('任务') },
|
|
16
|
+
{ value: 'event', label: t('日程') },
|
|
17
|
+
] as const)"
|
|
18
|
+
:key="option.value"
|
|
19
|
+
type="button"
|
|
20
|
+
:aria-pressed="filter.kind === option.value"
|
|
21
|
+
@click="filter.kind = option.value"
|
|
22
|
+
>{{ option.label }}</button>
|
|
23
|
+
</div>
|
|
24
|
+
<label class="calendar-filter-completed">
|
|
25
|
+
<input v-model="filter.showCompleted" type="checkbox" />
|
|
26
|
+
<span>{{ t('显示已完成') }}</span>
|
|
27
|
+
</label>
|
|
28
|
+
<label class="calendar-filter-search">
|
|
29
|
+
<Search :size="13" aria-hidden="true" />
|
|
30
|
+
<input
|
|
31
|
+
v-model="filter.query"
|
|
32
|
+
type="search"
|
|
33
|
+
:aria-label="t('搜索事项…')"
|
|
34
|
+
:placeholder="t('搜索事项…')"
|
|
35
|
+
maxlength="100"
|
|
36
|
+
/>
|
|
37
|
+
</label>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<style scoped>
|
|
42
|
+
.calendar-filter-bar {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 12px;
|
|
47
|
+
padding: 8px 14px;
|
|
48
|
+
border-bottom: 1px solid var(--line);
|
|
49
|
+
background: var(--paper);
|
|
50
|
+
font-size: 12px;
|
|
51
|
+
}
|
|
52
|
+
.calendar-filter-kinds {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
gap: 2px;
|
|
55
|
+
padding: 2px;
|
|
56
|
+
border-radius: 7px;
|
|
57
|
+
background: var(--surface);
|
|
58
|
+
box-shadow: inset 0 0 0 1px var(--line);
|
|
59
|
+
}
|
|
60
|
+
.calendar-filter-kinds button {
|
|
61
|
+
min-height: 24px;
|
|
62
|
+
padding: 0 10px;
|
|
63
|
+
border-radius: 5px;
|
|
64
|
+
font-size: 12px;
|
|
65
|
+
color: var(--muted);
|
|
66
|
+
}
|
|
67
|
+
.calendar-filter-kinds button:hover { color: var(--text); background: color-mix(in srgb, var(--hover) 70%, transparent); }
|
|
68
|
+
.calendar-filter-kinds button[aria-pressed='true'] {
|
|
69
|
+
background: var(--paper);
|
|
70
|
+
color: var(--text);
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(15 15 15 / 0.08);
|
|
73
|
+
}
|
|
74
|
+
.calendar-filter-completed {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 6px;
|
|
78
|
+
min-height: 28px;
|
|
79
|
+
padding: 0 8px 0 6px;
|
|
80
|
+
border-radius: 6px;
|
|
81
|
+
color: var(--text-secondary);
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
user-select: none;
|
|
84
|
+
transition: background-color var(--motion-quick) var(--ease-standard), color var(--motion-quick) var(--ease-standard);
|
|
85
|
+
}
|
|
86
|
+
.calendar-filter-completed:hover { background: var(--hover); color: var(--text); }
|
|
87
|
+
.calendar-filter-search {
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: 6px;
|
|
91
|
+
margin-left: auto;
|
|
92
|
+
min-height: 28px;
|
|
93
|
+
padding: 0 9px;
|
|
94
|
+
border: 1px solid var(--line);
|
|
95
|
+
border-radius: 7px;
|
|
96
|
+
background: var(--surface);
|
|
97
|
+
color: var(--muted);
|
|
98
|
+
cursor: text;
|
|
99
|
+
transition: border-color var(--motion-base) var(--ease-standard), background-color var(--motion-base) var(--ease-standard), box-shadow var(--motion-base) var(--ease-standard);
|
|
100
|
+
}
|
|
101
|
+
.calendar-filter-search:hover { border-color: var(--control-border); }
|
|
102
|
+
.calendar-filter-search:focus-within {
|
|
103
|
+
border-color: color-mix(in srgb, var(--text) 35%, var(--line));
|
|
104
|
+
background: var(--paper);
|
|
105
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 7%, transparent);
|
|
106
|
+
color: var(--text-secondary);
|
|
107
|
+
}
|
|
108
|
+
.calendar-filter-search input {
|
|
109
|
+
width: 140px;
|
|
110
|
+
border: 0;
|
|
111
|
+
padding: 0;
|
|
112
|
+
background: transparent;
|
|
113
|
+
color: var(--text);
|
|
114
|
+
font: inherit;
|
|
115
|
+
font-size: 12px;
|
|
116
|
+
outline: none;
|
|
117
|
+
transition: width var(--motion-spring) var(--ease-spring-smooth);
|
|
118
|
+
}
|
|
119
|
+
.calendar-filter-search input:focus,
|
|
120
|
+
.calendar-filter-search input:not(:placeholder-shown) { width: 200px; }
|
|
121
|
+
.calendar-filter-search input:focus-visible { outline: none; }
|
|
122
|
+
@media (max-width: 700px) {
|
|
123
|
+
.calendar-filter-bar { padding: 6px 10px; gap: 8px; }
|
|
124
|
+
.calendar-filter-search input,
|
|
125
|
+
.calendar-filter-search input:focus,
|
|
126
|
+
.calendar-filter-search input:not(:placeholder-shown) { width: 110px; }
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Circle, CircleCheck, Flag, Plus } from 'lucide-vue-next';
|
|
3
|
+
import { t, uiLocale } from '../../i18n/i18n';
|
|
4
|
+
import type { ObjectRecord } from '../../objects/workspace-objects';
|
|
5
|
+
import {
|
|
6
|
+
calendarDayEntries,
|
|
7
|
+
isCheckableEvent,
|
|
8
|
+
isEventCompleted,
|
|
9
|
+
localDayKey,
|
|
10
|
+
weekDays,
|
|
11
|
+
} from '../calendar';
|
|
12
|
+
import { planKey, sourcePlanKey } from '../personal-plans';
|
|
13
|
+
import type { PlanDateValue } from '../plan-date';
|
|
14
|
+
import type { CalendarInteractions } from '../composables/use-calendar-interactions';
|
|
15
|
+
|
|
16
|
+
const props = defineProps<{
|
|
17
|
+
scrollingWeeks: readonly Date[];
|
|
18
|
+
planned: readonly ObjectRecord[];
|
|
19
|
+
today: string;
|
|
20
|
+
weekdays: readonly string[];
|
|
21
|
+
canCreate: boolean;
|
|
22
|
+
dayPopoverKey?: string;
|
|
23
|
+
dayPopoverId: string;
|
|
24
|
+
interactions: CalendarInteractions;
|
|
25
|
+
}>();
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<{
|
|
28
|
+
'select-date': [date: Date];
|
|
29
|
+
'select-event': [id: string];
|
|
30
|
+
'open-day-popover': [day: Date, event: MouseEvent];
|
|
31
|
+
'open-quick-create': [planDate: PlanDateValue, checkable?: boolean];
|
|
32
|
+
}>();
|
|
33
|
+
|
|
34
|
+
const weekKey = localDayKey;
|
|
35
|
+
|
|
36
|
+
function monthShade(day: Date) {
|
|
37
|
+
return (day.getFullYear() * 12 + day.getMonth()) % 2 === 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function dayEntries(day: Date) {
|
|
41
|
+
return calendarDayEntries(props.planned, day);
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div class="calendar-month-view">
|
|
47
|
+
<div class="calendar-month-weekdays" aria-hidden="true">
|
|
48
|
+
<span v-for="name in weekdays" :key="name">{{ uiLocale === 'zh-CN' ? t('周') : '' }}{{ name }}</span>
|
|
49
|
+
</div>
|
|
50
|
+
<div
|
|
51
|
+
v-for="week in scrollingWeeks"
|
|
52
|
+
:key="weekKey(week)"
|
|
53
|
+
class="calendar-month-week"
|
|
54
|
+
:data-week="weekKey(week)"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
v-for="day in weekDays(week)"
|
|
58
|
+
:key="localDayKey(day)"
|
|
59
|
+
class="calendar-month-cell"
|
|
60
|
+
:class="{
|
|
61
|
+
shaded: monthShade(day),
|
|
62
|
+
'is-drop-target': interactions.dropTarget.value?.zone === 'day' && interactions.dropTarget.value.dayKey === localDayKey(day),
|
|
63
|
+
}"
|
|
64
|
+
:data-day="localDayKey(day)"
|
|
65
|
+
@dblclick.self="emit('open-quick-create', { date: localDayKey(day), time: '', end: '' }, false)"
|
|
66
|
+
@dragover="interactions.onDayDragOver(day, $event)"
|
|
67
|
+
@dragleave="interactions.onDragLeave"
|
|
68
|
+
@drop.prevent="interactions.onDayDrop(day, $event)"
|
|
69
|
+
>
|
|
70
|
+
<div class="calendar-month-cell-header">
|
|
71
|
+
<button
|
|
72
|
+
v-if="canCreate"
|
|
73
|
+
type="button"
|
|
74
|
+
class="calendar-month-add"
|
|
75
|
+
:aria-label="t('为 {0} 添加事件', [localDayKey(day)])"
|
|
76
|
+
@click.stop="emit('open-quick-create', { date: localDayKey(day), time: '', end: '' }, false)"
|
|
77
|
+
><Plus :size="12" aria-hidden="true" /></button>
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="calendar-month-date"
|
|
81
|
+
:class="{ today: localDayKey(day) === today, 'month-start': day.getDate() === 1 }"
|
|
82
|
+
:aria-label="t('{0},查看日视图', [localDayKey(day)])"
|
|
83
|
+
@click="emit('select-date', day)"
|
|
84
|
+
>{{ day.getDate() === 1 ? t('{0} 月 1 日', [day.getMonth() + 1]) : day.getDate() }}</button>
|
|
85
|
+
</div>
|
|
86
|
+
<div
|
|
87
|
+
v-for="entry in dayEntries(day).slice(0, 3)"
|
|
88
|
+
:key="`${planKey(entry.record)}:${entry.kind}`"
|
|
89
|
+
class="calendar-month-event"
|
|
90
|
+
:class="interactions.itemClasses(entry.record, entry.kind)"
|
|
91
|
+
:draggable="entry.kind !== 'due' && interactions.canDragRecord(entry.record)"
|
|
92
|
+
:data-tooltip="interactions.entryTooltip(entry)"
|
|
93
|
+
@dragstart="interactions.onEventDragStart(entry.record, $event)"
|
|
94
|
+
@dragend="interactions.onEventDragEnd"
|
|
95
|
+
>
|
|
96
|
+
<button
|
|
97
|
+
v-if="isCheckableEvent(entry.record)"
|
|
98
|
+
type="button"
|
|
99
|
+
class="calendar-inline-check"
|
|
100
|
+
:aria-label="`${isEventCompleted(entry.record) ? t('标记未完成') : t('完成')}:${entry.record.object.name}`"
|
|
101
|
+
:disabled="!interactions.canToggleComplete(entry.record)"
|
|
102
|
+
@click.stop="interactions.toggleComplete(entry.record)"
|
|
103
|
+
>
|
|
104
|
+
<CircleCheck v-if="isEventCompleted(entry.record)" :size="11" aria-hidden="true" />
|
|
105
|
+
<Circle v-else :size="11" aria-hidden="true" />
|
|
106
|
+
</button>
|
|
107
|
+
<Flag v-if="entry.kind === 'due'" :size="10" class="calendar-due-flag" aria-hidden="true" />
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
class="calendar-item-trigger"
|
|
111
|
+
@click="emit('select-event', sourcePlanKey(entry.record))"
|
|
112
|
+
><time v-if="entry.kind === 'timed'" class="calendar-item-time">{{ interactions.entryTime(entry) }}</time>{{ entry.record.object.name }}</button>
|
|
113
|
+
</div>
|
|
114
|
+
<button
|
|
115
|
+
v-if="dayEntries(day).length > 3"
|
|
116
|
+
type="button"
|
|
117
|
+
class="calendar-month-more"
|
|
118
|
+
aria-haspopup="dialog"
|
|
119
|
+
:aria-expanded="localDayKey(day) === dayPopoverKey"
|
|
120
|
+
:aria-controls="localDayKey(day) === dayPopoverKey ? dayPopoverId : undefined"
|
|
121
|
+
@click="emit('open-day-popover', day, $event)"
|
|
122
|
+
>{{ t('另有 {0} 项', [dayEntries(day).length - 3]) }}</button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<style scoped>
|
|
129
|
+
.calendar-month-view { min-width: 630px; }
|
|
130
|
+
.calendar-month-weekdays,
|
|
131
|
+
.calendar-month-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
|
|
132
|
+
.calendar-month-weekdays {
|
|
133
|
+
position: sticky;
|
|
134
|
+
top: 0;
|
|
135
|
+
z-index: 2;
|
|
136
|
+
background: var(--paper);
|
|
137
|
+
border-bottom: 1px solid var(--line);
|
|
138
|
+
}
|
|
139
|
+
.calendar-month-weekdays span {
|
|
140
|
+
padding: 11px 8px;
|
|
141
|
+
color: var(--muted);
|
|
142
|
+
font-size: 12px;
|
|
143
|
+
text-align: center;
|
|
144
|
+
}
|
|
145
|
+
.calendar-month-cell {
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
gap: 2px;
|
|
149
|
+
min-height: 108px;
|
|
150
|
+
min-width: 0;
|
|
151
|
+
padding: 6px;
|
|
152
|
+
border-right: 1px solid var(--line);
|
|
153
|
+
border-bottom: 1px solid var(--line);
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
transition: background-color var(--motion-quick) var(--ease-standard), box-shadow var(--motion-quick) var(--ease-standard);
|
|
156
|
+
}
|
|
157
|
+
.calendar-month-cell.shaded { background: color-mix(in srgb, var(--surface) 55%, var(--paper)); }
|
|
158
|
+
.calendar-month-cell-header {
|
|
159
|
+
display: flex;
|
|
160
|
+
align-items: center;
|
|
161
|
+
justify-content: flex-end;
|
|
162
|
+
gap: 4px;
|
|
163
|
+
margin-bottom: 3px;
|
|
164
|
+
}
|
|
165
|
+
.calendar-month-add {
|
|
166
|
+
display: grid;
|
|
167
|
+
place-items: center;
|
|
168
|
+
width: 22px;
|
|
169
|
+
height: 22px;
|
|
170
|
+
margin-right: auto;
|
|
171
|
+
border-radius: 6px;
|
|
172
|
+
color: var(--muted);
|
|
173
|
+
opacity: 0;
|
|
174
|
+
scale: 0.8;
|
|
175
|
+
transition:
|
|
176
|
+
opacity var(--motion-quick) var(--ease-standard),
|
|
177
|
+
scale var(--motion-spring) var(--ease-spring),
|
|
178
|
+
background-color var(--motion-quick) var(--ease-standard),
|
|
179
|
+
color var(--motion-quick) var(--ease-standard);
|
|
180
|
+
}
|
|
181
|
+
.calendar-month-cell:hover .calendar-month-add,
|
|
182
|
+
.calendar-month-add:focus-visible { opacity: 1; scale: 1; }
|
|
183
|
+
.calendar-month-add:hover { background: var(--hover); color: var(--text); }
|
|
184
|
+
.calendar-month-date {
|
|
185
|
+
display: grid;
|
|
186
|
+
place-items: center;
|
|
187
|
+
width: 26px;
|
|
188
|
+
height: 26px;
|
|
189
|
+
border-radius: 13px;
|
|
190
|
+
font-variant-numeric: tabular-nums;
|
|
191
|
+
margin: 0;
|
|
192
|
+
color: var(--text-secondary);
|
|
193
|
+
font-size: 12px;
|
|
194
|
+
}
|
|
195
|
+
.calendar-month-date.month-start { width: auto; min-width: 26px; padding: 0 8px; color: var(--text); font-weight: 600; }
|
|
196
|
+
.calendar-month-date:hover:not(.today) { background: var(--hover); color: var(--text); }
|
|
197
|
+
.calendar-month-date.today:hover { background: var(--green-fill-hover); color: var(--on-accent, white); }
|
|
198
|
+
.calendar-month-event { width: 100%; }
|
|
199
|
+
.calendar-month-event.is-timed:not(.is-due) { background: transparent; }
|
|
200
|
+
.calendar-month-event.is-timed:not(.is-due):not(:has(.calendar-inline-check))::before {
|
|
201
|
+
content: '';
|
|
202
|
+
flex: none;
|
|
203
|
+
width: 6px;
|
|
204
|
+
height: 6px;
|
|
205
|
+
margin-left: -2px;
|
|
206
|
+
border-radius: 50%;
|
|
207
|
+
background: color-mix(in srgb, var(--tone) 70%, var(--paper));
|
|
208
|
+
}
|
|
209
|
+
.calendar-month-event.is-timed:not(.is-due):hover,
|
|
210
|
+
.calendar-month-event.is-timed:not(.is-due):focus-within { background: color-mix(in srgb, var(--tone) 8%, var(--paper)); }
|
|
211
|
+
.calendar-month-more {
|
|
212
|
+
display: block;
|
|
213
|
+
width: 100%;
|
|
214
|
+
margin-top: 1px;
|
|
215
|
+
padding: 2px 6px;
|
|
216
|
+
border-radius: 5px;
|
|
217
|
+
color: var(--muted);
|
|
218
|
+
font-size: 11px;
|
|
219
|
+
font-weight: 500;
|
|
220
|
+
text-align: left;
|
|
221
|
+
}
|
|
222
|
+
.calendar-month-more:hover,
|
|
223
|
+
.calendar-month-more[aria-expanded='true'] { background: var(--hover); color: var(--text); }
|
|
224
|
+
</style>
|