Skip to content

Commit 5f58616

Browse files
committed
fix(deps): use dayjs instead of date-fns
1 parent 04336e5 commit 5f58616

File tree

8 files changed

+14
-233
lines changed

8 files changed

+14
-233
lines changed

components/custom/CAS/Record/NewActivityRecord.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup lang="ts">
2-
import { format } from 'date-fns'
32
import { useForm } from 'vee-validate'
43
import { toTypedSchema } from '@vee-validate/zod'
54
import * as z from 'zod'
@@ -127,7 +126,7 @@ const onSubmit = handleSubmit(async (values) => {
127126
)" variant="outline"
128127
:disabled="isLoading"
129128
>
130-
<span>{{ value ? format(value, "PPP") : "选择日期..." }}</span>
129+
<span>{{ value ? $dayjs(value).format("LL") : "选择日期..." }}</span>
131130
<Icon class="ms-auto opacity-50" name="material-symbols:calendar-today-outline" />
132131
</Button>
133132
</FormControl>

nuxt.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default defineNuxtConfig({
2323
'nuxt-svgo',
2424
'@sentry/nuxt/module',
2525
'@nuxt/image',
26+
'dayjs-nuxt',
2627
],
2728

2829
build: {
@@ -57,7 +58,7 @@ export default defineNuxtConfig({
5758

5859
dayjs: {
5960
locales: ['en', 'zh-cn'],
60-
plugins: ['relativeTime', 'utc', 'timezone'],
61+
plugins: ['relativeTime', 'utc', 'timezone', 'localizedFormat'],
6162
defaultLocale: 'zh-cn',
6263
defaultTimezone: 'Asia/Shanghai',
6364
},

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
"@vueuse/core": "^10.11.1",
2929
"class-variance-authority": "^0.7.0",
3030
"clsx": "^2.1.1",
31-
"date-fns": "^3.6.0",
32-
"date-fns-tz": "^3.1.3",
3331
"h3": "^1.12.0",
3432
"h3-clerk": "^0.4.11",
3533
"iron-webcrypto": "^1.2.1",
@@ -59,7 +57,7 @@
5957
"@types/node-fetch": "^2.6.11",
6058
"@types/uuid": "^9.0.8",
6159
"@types/ws": "^8.5.12",
62-
"dayjs-nuxt": "^2.1.9",
60+
"dayjs-nuxt": "^2.1.11",
6361
"eslint": "^9.9.0",
6462
"nuxt": "^3.12.4",
6563
"nuxt-icon": "^0.6.10",

pages/admin/reservation.vue

Lines changed: 0 additions & 193 deletions
This file was deleted.

pages/manage/manage.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<script setup lang="ts">
2-
import { format, formatDistanceToNow, parse } from 'date-fns'
3-
import { zhCN } from 'date-fns/locale'
42
import { LoaderCircle } from 'lucide-vue-next'
5-
import { VueElement, onMounted } from 'vue'
3+
import { onMounted } from 'vue'
64
import { enums } from '~/components/custom/enum2str'
75
import { useToast } from '@/components/ui/toast/use-toast'
86
import Toaster from '@/components/ui/toast/Toaster.vue'
@@ -133,7 +131,7 @@ onMounted(async () => {
133131
<TableCell class="text-muted-foreground">
134132
#{{ record.id }}
135133
</TableCell>
136-
<TableCell>{{ formatDistanceToNow(new Date(record.creationTimestamp), { locale: zhCN, addSuffix: true }) }}</TableCell>
134+
<TableCell>{{ $dayjs(record.creationTimestamp).fromNow() }}</TableCell>
137135
<TableCell>{{ record.user.name }}</TableCell>
138136
<TableCell>{{ record.club.name.zh }}</TableCell>
139137
<TableCell>{{ enums.days.map[record.day] }}</TableCell>

pages/manage/reservation.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script setup lang="ts">
2-
import { format } from 'date-fns'
3-
import { Calendar as CalendarIcon, Clock as ClockIcon, Loader, LoaderCircle } from 'lucide-vue-next'
4-
import { record, string } from 'zod'
2+
import { LoaderCircle } from 'lucide-vue-next'
53
import { Button } from '@/components/ui/button'
64
import { useToast } from '@/components/ui/toast/use-toast'
75
import Toaster from '@/components/ui/toast/Toaster.vue'

pages/manage/statuses.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup lang="ts">
2-
import { format, utcToZonedTime, zonedTimeToUtc } from 'date-fns-tz'
3-
import { Card } from '@/components/ui/card'
42
import { enums, time2period } from '~/components/custom/enum2str'
53
import { useToast } from '@/components/ui/toast/use-toast'
64
import Toaster from '@/components/ui/toast/Toaster.vue'
@@ -15,10 +13,12 @@ useHead({
1513
1614
const { toast } = useToast()
1715
18-
const utc8Time = utcToZonedTime((new Date()).toISOString(), 'Asia/Shanghai')
16+
const dayjs = useDayjs()
1917
20-
const selectedDay = ref(enums.days.values[utc8Time.getDay()])
21-
const selectedPeriod = ref(time2period(utc8Time.getHours() * 100 + utc8Time.getMinutes(), selectedDay.value))
18+
const utc8Time = dayjs().tz('Asia/Shanghai')
19+
20+
const selectedDay = ref(enums.days.values[utc8Time.day()])
21+
const selectedPeriod = ref(time2period(utc8Time.hour() * 100 + utc8Time.minute(), selectedDay.value))
2222
2323
let dataLoaded = false
2424
let data: any
@@ -29,7 +29,7 @@ try {
2929
data = rawData.sort((a: any, b: any) => a.name < b.name ? -1 : 1)
3030
dataLoaded = true
3131
}
32-
catch (error) {
32+
catch {
3333
toast({
3434
title: '错误',
3535
description: '获取教室信息出错',

pnpm-lock.yaml

Lines changed: 1 addition & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)