diff --git a/build/vitePlugins.ts b/build/vitePlugins.ts index 1e3eb80..e7df655 100644 --- a/build/vitePlugins.ts +++ b/build/vitePlugins.ts @@ -34,6 +34,9 @@ export function createVitePlugins({ isProd }: VitePluginConfig): PluginOption[] { 'uni-mini-router': ['useRouter', 'useRoute'], }, + { + dayjs: [['default', 'dayjs']], + }, { 'alova/client': ['useRequest'], }, diff --git a/package.json b/package.json index 0c76a01..4248253 100644 --- a/package.json +++ b/package.json @@ -62,12 +62,13 @@ "@ontos/material-design-3-theme-builder": "workspace:*", "alova": "^3.0.16", "crypto-js": "^4.2.0", + "dayjs": "^1.11.13", "lodash-es": "^4.17.21", "normalize-path": "^3.0.0", "pinia": "^2.2.2", "pinia-plugin-persistedstate": "^3.2.1", "unplugin-vue-components": "^0.27.0", - "vue": "^3.5.3" + "vue": "^3.5.10" }, "devDependencies": { "@antfu/eslint-config": "^2.27.3", @@ -98,7 +99,7 @@ "lint-staged": "^15.2.9", "picocolors": "^1.0.1", "rollup-plugin-visualizer": "^5.12.0", - "sass": "^1.78.0", + "sass": "^1.79.4", "simple-git-hooks": "^2.11.1", "tsx": "^4.19.0", "typescript": "^5.5.4", diff --git a/src/components/WeekGantView/GantDate.vue b/src/components/WeekGantView/GantDate.vue new file mode 100644 index 0000000..c1fffa4 --- /dev/null +++ b/src/components/WeekGantView/GantDate.vue @@ -0,0 +1,161 @@ + + + + + + + diff --git a/src/components/WeekGantView/GantView.vue b/src/components/WeekGantView/GantView.vue new file mode 100644 index 0000000..e74687c --- /dev/null +++ b/src/components/WeekGantView/GantView.vue @@ -0,0 +1,187 @@ + + + + + + + diff --git a/src/components/WeekGantView/helper.ts b/src/components/WeekGantView/helper.ts new file mode 100644 index 0000000..18db01d --- /dev/null +++ b/src/components/WeekGantView/helper.ts @@ -0,0 +1,58 @@ + + +import dayjs from 'dayjs'; +import type { ThingType } from './type'; +import isoWeek from 'dayjs/plugin/isoWeek'; +import weekday from 'dayjs/plugin/weekday'; + + + +export function getWeekDates(date: string | number | Date | dayjs.Dayjs | null | undefined) { + + + dayjs.extend(isoWeek); + dayjs.extend(weekday); + + const startOfWeek = dayjs(date).weekday(0); + const _weekDates: { date: number; day: string; weekDay: string }[] = []; + for (let i = 0; i < 7; i += 1) { + _weekDates.push({ + date: startOfWeek.add(i, 'day').startOf('day').valueOf(), + day: startOfWeek.add(i, 'day').format('D'), + weekDay: startOfWeek.add(i, 'day').format('周dd') + }); + } + return _weekDates; +} + +export function groupEventsByDay({ + events, + minuteStep +}: { + events: ThingType[]; + minuteStep: number; +}): Map { + const _groupedEvents = new Map(); + + events.forEach(event => { + const { startTime, endTime } = event; + + const startOfDay = dayjs(startTime).startOf('day').valueOf(); + const startDayTime = dayjs(startTime); + + const toTop = startDayTime.diff(startDayTime.startOf('day'), 'minute'); + const duration = dayjs(endTime).diff(startTime, 'minute'); + + if (!_groupedEvents.has(startOfDay)) { + _groupedEvents.set(startOfDay, []); + } + + _groupedEvents.get(startOfDay).push({ + ...event, + toTop: toTop * minuteStep, + height: duration * minuteStep + }); + }); + + return _groupedEvents; +} diff --git a/src/components/WeekGantView/index.vue b/src/components/WeekGantView/index.vue new file mode 100644 index 0000000..03560dc --- /dev/null +++ b/src/components/WeekGantView/index.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/src/components/WeekGantView/type.ts b/src/components/WeekGantView/type.ts new file mode 100644 index 0000000..97f0cac --- /dev/null +++ b/src/components/WeekGantView/type.ts @@ -0,0 +1,12 @@ + + +export interface ThingType { + id: string | number; + name: string; + dec: string; + startTime: number; + endTime: number; + color: string; + toTop?: number; + height?: number; +} diff --git a/src/manifest.json b/src/manifest.json index 02b1b5f..e1810c2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -98,7 +98,7 @@ "base": "./" }, "devServer": { - "https": true + "https": false }, "title": "demo", "unipush": { diff --git a/src/pages/numerology/index.vue b/src/pages/numerology/index.vue index b98e5ca..6dd65bf 100644 --- a/src/pages/numerology/index.vue +++ b/src/pages/numerology/index.vue @@ -1,7 +1,6 @@