Skip to content

Commit 5528457

Browse files
committed
dayjsをthis.$dayjsに置き換え
1 parent 346b464 commit 5528457

File tree

10 files changed

+43
-45
lines changed

10 files changed

+43
-45
lines changed

src/components/EditLessonScreen.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
<script lang="ts">
5454
import Vue from 'vue'
55-
import dayjs from 'dayjs'
5655
import { vxm } from '@/store'
5756
import BaseActionButton from '@/components/BaseActionButton.vue'
5857
import EditLessonScreenInner1 from '@/components/EditLessonScreenInner1.vue'
@@ -255,10 +254,10 @@ export default Vue.extend({
255254
buildLessonData(): classData.Lesson {
256255
const startTimeStr: string =
257256
this.lessonData.date + ' ' + this.lessonData.startTime
258-
const startTimeDate: Date = dayjs(startTimeStr).toDate()
257+
const startTimeDate: Date = this.$dayjs(startTimeStr).toDate()
259258
const endTimeStr: string =
260259
this.lessonData.date + ' ' + this.lessonData.endTime
261-
const endTimeDate: Date = dayjs(endTimeStr).toDate()
260+
const endTimeDate: Date = this.$dayjs(endTimeStr).toDate()
262261
const videoData = []
263262
if (this.lessonData.videoUrl)
264263
videoData.push({

src/components/EditingVisibilityDialog.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555

5656
<script lang="ts">
5757
import Vue from 'vue'
58-
import dayjs from 'dayjs'
5958
import BaseDialog from '@/components/BaseDialog.vue'
6059
import { vxm } from '@/store'
6160
import classData from '@/types/store/classData'
@@ -99,16 +98,18 @@ export default Vue.extend({
9998
},
10099
date(): string {
101100
return this.value.startTime
102-
? dayjs(this.value.startTime).format('MM月DD日(ddd)')
101+
? this.$dayjs(this.value.startTime).format('MM月DD日(ddd)')
103102
: ''
104103
},
105104
time(): string {
106105
return (
107106
(this.value.startTime
108-
? dayjs(this.value.startTime).format('HH:mm')
107+
? this.$dayjs(this.value.startTime).format('HH:mm')
109108
: '') +
110109
' - ' +
111-
(this.value.endTime ? dayjs(this.value.endTime).format('HH:mm') : '')
110+
(this.value.endTime
111+
? this.$dayjs(this.value.endTime).format('HH:mm')
112+
: '')
112113
)
113114
},
114115
subjectName(): string {

src/components/LessonCaption.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
<script lang="ts">
2424
import Vue from 'vue'
25-
import dayjs from 'dayjs'
2625
2726
export default Vue.extend({
2827
name: 'LessonCaption',
@@ -46,7 +45,7 @@ export default Vue.extend({
4645
},
4746
methods: {
4847
format(date: Date): String {
49-
return dayjs(date).format('h:mm')
48+
return this.$dayjs(date).format('h:mm')
5049
},
5150
},
5251
})

src/components/PeriodSection.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@
2626

2727
<script lang="ts">
2828
import Vue from 'vue'
29-
import dayjs from 'dayjs'
30-
import minMax from 'dayjs/plugin/minMax'
3129
import LessonSummaryCard from '@/components/LessonSummaryCard.vue'
3230
import classData from '@/types/store/classData'
33-
dayjs.extend(minMax)
3431
3532
export default Vue.extend({
3633
components: { LessonSummaryCard },
@@ -54,13 +51,16 @@ export default Vue.extend({
5451
},
5552
computed: {
5653
maxEndTime() {
57-
const endTimeArray = this.classData.map((value) => dayjs(value.endTime))
58-
return dayjs.max(...endTimeArray)
54+
const endTimeArray = this.classData.map((value) =>
55+
this.$dayjs(value.endTime)
56+
)
57+
console.log(endTimeArray)
58+
return (this.$dayjs as any).max([...endTimeArray])
5959
},
6060
},
6161
methods: {
6262
formatDate(date: Date): string {
63-
return dayjs(date).format('HH:mm')
63+
return this.$dayjs(date).format('HH:mm')
6464
},
6565
},
6666
})

src/layouts/classes.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393

9494
<script lang="ts">
9595
import Vue from 'vue'
96-
import dayjs from 'dayjs'
9796
import AppLanguageSelector from '@/components/AppLanguageSelector.vue'
9897
import HeaderLogo from '@/assets/svgs/header_logo.svg'
9998
import CalendarBar from '@/components/CalendarBar.vue'
@@ -132,15 +131,15 @@ export default Vue.extend({
132131
computed: {
133132
date: {
134133
get() {
135-
return dayjs(vxm.app.currentDate).format('YYYY-MM-DD')
134+
return this.$dayjs(vxm.app.currentDate).format('YYYY-MM-DD')
136135
},
137136
set(newValue: string) {
138-
vxm.app.setDate(dayjs(newValue).toDate())
137+
vxm.app.setDate(newValue)
139138
},
140139
},
141140
},
142141
mounted(): void {
143-
this.loading = false
142+
;(this as any).loading = false
144143
},
145144
methods: {
146145
async clickLogout() {

src/layouts/protected.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696

9797
<script lang="ts">
9898
import Vue from 'vue'
99-
import dayjs from 'dayjs'
10099
import { vxm } from '@/store'
101100
import AppLanguageSelector from '@/components/AppLanguageSelector.vue'
102101
import HeaderLogo from '@/assets/svgs/header_logo.svg'
@@ -131,18 +130,18 @@ export default Vue.extend({
131130
computed: {
132131
date: {
133132
get() {
134-
return dayjs(vxm.app.currentDate).format('YYYY-MM-DD')
133+
return this.$dayjs(vxm.app.currentDate).format('YYYY-MM-DD')
135134
},
136135
set(newValue: string) {
137-
vxm.app.setDate(dayjs(newValue).toDate())
136+
vxm.app.setDate(newValue)
138137
},
139138
},
140139
classData() {
141140
return vxm.classData
142141
},
143142
},
144143
mounted(): void {
145-
this.loading = false
144+
;(this as any).loading = false
146145
},
147146
methods: {
148147
unloadClassData() {

src/pages/classes/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
<script lang="ts">
2626
import Vue from 'vue'
27-
import dayjs from 'dayjs'
2827
import isToday from 'date-fns/isToday'
2928
import { vxm } from '@/store'
3029
import PeriodSection from '@/components/PeriodSection.vue'
@@ -54,7 +53,7 @@ export default Vue.extend({
5453
return isToday(vxm.app.currentDate)
5554
},
5655
dateTitle() {
57-
return dayjs(vxm.app.currentDate).format('M/D')
56+
return this.$dayjs(vxm.app.currentDate).format('M/D')
5857
},
5958
},
6059
watch: {

src/pages/edit/index.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130

131131
<script lang="ts">
132132
import Vue from 'vue'
133-
import dayjs from 'dayjs'
134133
import isToday from 'date-fns/isToday'
135134
import { vxm } from '@/store'
136135
import PeriodSection from '@/components/PeriodSection.vue'
@@ -215,7 +214,7 @@ export default Vue.extend({
215214
return isToday(vxm.app.currentDate)
216215
},
217216
dateTitle() {
218-
return dayjs(vxm.app.currentDate).format('M/D')
217+
return this.$dayjs(vxm.app.currentDate).format('M/D')
219218
},
220219
},
221220
watch: {
@@ -235,7 +234,7 @@ export default Vue.extend({
235234
const date =
236235
this.editPageValue.date !== ''
237236
? this.editPageValue.date
238-
: dayjs(vxm.app.currentDate).format('YYYY-MM-DD')
237+
: this.$dayjs(vxm.app.currentDate).format('YYYY-MM-DD')
239238
this.editPageValue = Object.assign({}, this.editPageValue, {
240239
date,
241240
})
@@ -268,9 +267,9 @@ export default Vue.extend({
268267
this.editPageValue = {
269268
isHidden: value.isHidden,
270269
lessonId: value.id,
271-
date: dayjs(value.startTime).format('YYYY-MM-DD'),
272-
startTime: dayjs(value.startTime).format('HH:mm'),
273-
endTime: dayjs(value.endTime).format('HH:mm'),
270+
date: this.$dayjs(value.startTime).format('YYYY-MM-DD'),
271+
startTime: this.$dayjs(value.startTime).format('HH:mm'),
272+
endTime: this.$dayjs(value.endTime).format('HH:mm'),
274273
title: value.title,
275274
subjectName: value.subject.name,
276275
subjectColor: value.subject.color,

src/pages/lesson/index.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115

116116
<script lang="ts">
117117
import Vue from 'vue'
118-
import dayjs from 'dayjs'
119118
import 'dayjs/locale/ja'
120119
import add from 'date-fns/add'
121120
import { vxm } from '@/store'
@@ -132,7 +131,7 @@ export default Vue.extend({
132131
components: { SubjectTag },
133132
// filters: {
134133
// dateString: function dateString(lesson: LessonWithId): string {
135-
// return dayjs(lesson.startTime)
134+
// return this.$dayjs(lesson.startTime)
136135
// .locale('ja')
137136
// .format('M月D日(ddd)')
138137
// }
@@ -222,19 +221,21 @@ export default Vue.extend({
222221
},
223222
computed: {
224223
dateString(): string {
225-
return dayjs(this.lesson.startTime).locale('ja').format('M月D日(ddd)')
224+
return this.$dayjs(this.lesson.startTime)
225+
.locale('ja')
226+
.format('M月D日(ddd)')
226227
},
227228
dateTitle(): string {
228-
return dayjs(this.lesson.startTime).format('M/D')
229+
return this.$dayjs(this.lesson.startTime).format('M/D')
229230
},
230231
startTimeString(): string {
231-
return dayjs(this.lesson.startTime).format('H:mm')
232+
return this.$dayjs(this.lesson.startTime).format('H:mm')
232233
},
233234
endTimeString(): string {
234-
return dayjs(this.lesson.startTime).format('YYYY-MM-DD') ===
235-
dayjs(this.lesson.endTime).format('YYYY-MM-DD')
236-
? dayjs(this.lesson.endTime).format('H:mm')
237-
: dayjs(this.lesson.endTime).format('H:mm(M/D)')
235+
return this.$dayjs(this.lesson.startTime).format('YYYY-MM-DD') ===
236+
this.$dayjs(this.lesson.endTime).format('YYYY-MM-DD')
237+
? this.$dayjs(this.lesson.endTime).format('H:mm')
238+
: this.$dayjs(this.lesson.endTime).format('H:mm(M/D)')
238239
},
239240
},
240241
async mounted() {

src/store/modules/app.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createModule, mutation } from 'vuex-class-component'
2-
import dayjs from 'dayjs'
32

43
const VuexModule = createModule({
54
namespaced: 'app',
@@ -18,17 +17,20 @@ export class AppStore extends VuexModule implements App {
1817

1918
@mutation
2019
public goNextDate() {
21-
this.currentDate = dayjs(this.currentDate).add(1, 'd').toDate()
20+
this.currentDate = this.$store.$dayjs(this.currentDate).add(1, 'd').toDate()
2221
}
2322

2423
@mutation
2524
public goPreviousDate() {
26-
this.currentDate = dayjs(this.currentDate).subtract(1, 'd').toDate()
25+
this.currentDate = this.$store
26+
.$dayjs(this.currentDate)
27+
.subtract(1, 'd')
28+
.toDate()
2729
}
2830

2931
@mutation
30-
public setDate(date: Date) {
31-
this.currentDate = date
32+
public setDate(date: string) {
33+
this.currentDate = this.$store.$dayjs(date).toDate()
3234
}
3335

3436
@mutation

0 commit comments

Comments
 (0)