feat(frontend): update chat composables and vite config
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { computed, onMounted, ref, watch, toRef } from 'vue'
|
||||
import { computed, onMounted, ref, watch, type Ref } from 'vue'
|
||||
import { CornerDownLeft, Database, Sparkles, Sun, ListTodo } from 'lucide-vue-next'
|
||||
import { scheduleCenterApi, type ScheduleCenterDateResponse, type ScheduleCenterDaySummary } from '@/api/scheduleCenter'
|
||||
import type { Conversation } from '@/api/conversation'
|
||||
@@ -18,20 +18,24 @@ export const sidebarCollapsedModules = [
|
||||
{ id: 'review', label: '复盘', icon: CornerDownLeft },
|
||||
]
|
||||
|
||||
function formatDateKey(date: Date) {
|
||||
const year = date.getUTCFullYear()
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getUTCDate()).padStart(2, '0')
|
||||
export function formatDateKey(date: Date) {
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
function formatMonthKey(date: Date) {
|
||||
const year = date.getUTCFullYear()
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0')
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
return `${year}-${month}`
|
||||
}
|
||||
|
||||
export function useSidebarPlan(clientTimeRef: { value: Date }, loadDailyDigestFn: () => void, conversationsRef: Conversation[] = []) {
|
||||
export function useSidebarPlan(
|
||||
clientTimeRef: { value: Date },
|
||||
loadDailyDigestFn: () => void,
|
||||
conversationsRef: Ref<Conversation[]> | Conversation[] = [],
|
||||
) {
|
||||
const todayPlanDetail = ref<ScheduleCenterDateResponse | null>(null)
|
||||
const monthPlanDays = ref<ScheduleCenterDaySummary[]>([])
|
||||
const selectedDate = ref<string | null>(null)
|
||||
@@ -41,9 +45,7 @@ export function useSidebarPlan(clientTimeRef: { value: Date }, loadDailyDigestFn
|
||||
const map = new Map<string, boolean>()
|
||||
const conversations = Array.isArray(conversationsRef) ? conversationsRef : (conversationsRef.value ?? [])
|
||||
conversations.forEach((conv) => {
|
||||
const date = new Date(conv.updated_at)
|
||||
const dateKey = formatDateKey(date)
|
||||
map.set(dateKey, true)
|
||||
map.set(formatDateKey(new Date(conv.updated_at)), true)
|
||||
})
|
||||
return map
|
||||
})
|
||||
@@ -52,22 +54,22 @@ export function useSidebarPlan(clientTimeRef: { value: Date }, loadDailyDigestFn
|
||||
const monthPlanSummaryMap = computed(() => new Map(monthPlanDays.value.map((item) => [item.date, item])))
|
||||
|
||||
const calendarCells = computed(() => {
|
||||
const year = clientTimeRef.value.getUTCFullYear()
|
||||
const month = clientTimeRef.value.getUTCMonth()
|
||||
const daysInMonth = new Date(Date.UTC(year, month + 1, 0)).getUTCDate()
|
||||
const firstDayOffset = (new Date(Date.UTC(year, month, 1)).getUTCDay() + 6) % 7
|
||||
const today = clientTimeRef.value.getUTCDate()
|
||||
const year = clientTimeRef.value.getFullYear()
|
||||
const month = clientTimeRef.value.getMonth()
|
||||
const daysInMonth = new Date(year, month + 1, 0).getDate()
|
||||
const firstDayOffset = (new Date(year, month, 1).getDay() + 6) % 7
|
||||
const todayKey = todayDateKey.value
|
||||
const cells: Array<{ key: string; value: number | null; active: boolean; busy: boolean; selected: boolean; hasConversation: boolean }> = []
|
||||
for (let index = 0; index < firstDayOffset; index += 1) {
|
||||
cells.push({ key: `blank-start-${index}`, value: null, active: false, busy: false, selected: false, hasConversation: false })
|
||||
}
|
||||
for (let day = 1; day <= daysInMonth; day += 1) {
|
||||
const monthDate = new Date(Date.UTC(year, month, day))
|
||||
const monthDate = new Date(year, month, day)
|
||||
const dateKey = formatDateKey(monthDate)
|
||||
const summary = monthPlanSummaryMap.value.get(dateKey)
|
||||
const busy = Boolean(summary && (summary.todo_total + summary.task_due_total + summary.goal_total + summary.reminder_total) > 0)
|
||||
const hasConv = conversationDateMap.value.get(dateKey) || false
|
||||
cells.push({ key: dateKey, value: day, active: day === today, busy, selected: dateKey === selectedDate.value, hasConversation: hasConv })
|
||||
cells.push({ key: dateKey, value: day, active: dateKey === todayKey, busy, selected: dateKey === selectedDate.value, hasConversation: hasConv })
|
||||
}
|
||||
while (cells.length % 7 !== 0) {
|
||||
cells.push({ key: `blank-end-${cells.length}`, value: null, active: false, busy: false, selected: false, hasConversation: false })
|
||||
@@ -75,8 +77,8 @@ export function useSidebarPlan(clientTimeRef: { value: Date }, loadDailyDigestFn
|
||||
return cells
|
||||
})
|
||||
|
||||
const calendarYear = computed(() => clientTimeRef.value.getUTCFullYear())
|
||||
const calendarMonth = computed(() => clientTimeRef.value.getUTCMonth() + 1)
|
||||
const calendarYear = computed(() => clientTimeRef.value.getFullYear())
|
||||
const calendarMonth = computed(() => clientTimeRef.value.getMonth() + 1)
|
||||
|
||||
const todayPlanCounters = computed(() => {
|
||||
const detail = todayPlanDetail.value
|
||||
|
||||
Reference in New Issue
Block a user