From 413f32edcefe0e79ae25ef8e6188f1191ac5e2e9 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Sat, 19 Oct 2019 21:42:14 +0800 Subject: [PATCH] refactor(time-picker): remove momentjs --- package.json | 1 - packages/common/DatePicker/src/main.vue | 2 +- .../DatePicker/src/panel/datetimerange.vue | 2 +- .../DatePicker/src/panel/dualCalendarMixin.js | 2 +- .../DatePicker/src/panel/uniCalendarMixin.js | 2 +- packages/common/Time/src/main.js | 6 +- packages/common/TimePicker/src/main.vue | 56 ++++++++++--------- .../src/utils.js => utils/dateUtils.js} | 0 8 files changed, 36 insertions(+), 35 deletions(-) rename packages/{common/DatePicker/src/utils.js => utils/dateUtils.js} (100%) diff --git a/package.json b/package.json index 1001c540c..45ee14851 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,6 @@ "date-fns": "^2.5.1", "ionicons": "^4.5.8", "masonry-layout": "^4.2.2", - "moment": "^2.24.0", "node-sass": "^4.12.0", "resize-observer-polyfill": "^1.5.1", "sass-loader": "^7.1.0" diff --git a/packages/common/DatePicker/src/main.vue b/packages/common/DatePicker/src/main.vue index cc1aff6a5..201939a9f 100644 --- a/packages/common/DatePicker/src/main.vue +++ b/packages/common/DatePicker/src/main.vue @@ -151,7 +151,7 @@ import NInput from '../../Input' import withapp from '../../../mixins/withapp' import themeable from '../../../mixins/themeable' import { format, getTime, isValid } from 'date-fns' -import { strictParse } from './utils' +import { strictParse } from '../../../utils/dateUtils' import isEqual from 'lodash/isEqual' const DATE_FORMAT = { diff --git a/packages/common/DatePicker/src/panel/datetimerange.vue b/packages/common/DatePicker/src/panel/datetimerange.vue index baf95514d..905b44b06 100644 --- a/packages/common/DatePicker/src/panel/datetimerange.vue +++ b/packages/common/DatePicker/src/panel/datetimerange.vue @@ -236,7 +236,7 @@ import NInput from '../../../Input' import dualCalendarMixin from './dualCalendarMixin' import NBaseIcon from '../../../../base/Icon' import { startOfSecond, format, set, getYear, getMonth, getDate, isValid } from 'date-fns' -import { strictParse } from '../utils' +import { strictParse } from '../../../../utils/dateUtils' const DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss' const DATE_FORMAT = 'yyyy-MM-dd' diff --git a/packages/common/DatePicker/src/panel/dualCalendarMixin.js b/packages/common/DatePicker/src/panel/dualCalendarMixin.js index 254ab008d..66f10ecac 100644 --- a/packages/common/DatePicker/src/panel/dualCalendarMixin.js +++ b/packages/common/DatePicker/src/panel/dualCalendarMixin.js @@ -1,6 +1,6 @@ // import moment from 'moment' import { isValid, getMonth, getYear, getTime, format, addMonths, startOfMonth } from 'date-fns' -import { dateArray } from '../utils' +import { dateArray } from '../../../../utils/dateUtils' import commonCalendarMixin from './commonCalendarMixin' diff --git a/packages/common/DatePicker/src/panel/uniCalendarMixin.js b/packages/common/DatePicker/src/panel/uniCalendarMixin.js index e123ef580..d23af06a2 100644 --- a/packages/common/DatePicker/src/panel/uniCalendarMixin.js +++ b/packages/common/DatePicker/src/panel/uniCalendarMixin.js @@ -1,7 +1,7 @@ // import moment from 'moment' import commonCalendarMixin from './commonCalendarMixin' import { isValid, getDate, getMonth, getYear, getTime, isSameMonth, format, addMonths, addYears, set } from 'date-fns' -import { dateArray, strictParse } from '../utils' +import { dateArray, strictParse } from '../../../../utils/dateUtils' // import { setYMD } from '../utils' diff --git a/packages/common/Time/src/main.js b/packages/common/Time/src/main.js index f3b3c7bd4..7c92cbc7f 100644 --- a/packages/common/Time/src/main.js +++ b/packages/common/Time/src/main.js @@ -1,12 +1,12 @@ -import moment from 'moment' +// import moment from 'moment' export default { name: 'NTime', props: { time: { validator (time) { - if (time === null) return - return moment(time).isValid() + if (time === null) return false + // return moment(time).isValid() }, default: null }, diff --git a/packages/common/TimePicker/src/main.vue b/packages/common/TimePicker/src/main.vue index 7f27af19b..897b2f347 100644 --- a/packages/common/TimePicker/src/main.vue +++ b/packages/common/TimePicker/src/main.vue @@ -43,7 +43,7 @@ 'n-time-picker-selector-time-row__item--active': hour === computedHour }" - @click="setHour(hour)" + @click="setHours(hour)" > {{ hour }} @@ -66,7 +66,7 @@ 'n-time-picker-selector-time-row__item--active': minute === computedMinute }" - @click="setMinute(minute)" + @click="setMinutes(minute)" > {{ minute }} @@ -92,7 +92,7 @@ validator && !validator(computedHour, computedMinute, second) }" - @click="setSecond(second)" + @click="setSeconds(second)" > {{ second }} @@ -132,13 +132,14 @@