Skip to content

Commit a71ac74

Browse files
authored
Merge pull request #49 from Lohoyo/master
fix: 填上最后一个迁移 Day.js 带来的坑
2 parents bf9cafa + b823d48 commit a71ac74

18 files changed

Lines changed: 47 additions & 12 deletions

File tree

src/calendar/docs/customHeader.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
<script>
4444
import dayjs from 'dayjs';
4545
import {Calendar, Grid, Radio, Select} from 'santd';
46+
import localeData from 'dayjs/plugin/localeData';
4647
47-
dayjs.extend(require('dayjs/plugin/localeData'));
48+
dayjs.extend(localeData);
4849
4950
export default {
5051
components: {

src/calendar/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import Select from '../select';
1010
import Calendar from './src/fullCalendar';
1111
import './style/index.less';
1212
import localeReceiver from '../localeprovider/receiver';
13+
import weekOfYear from 'dayjs/plugin/weekOfYear';
14+
import localeData from 'dayjs/plugin/localeData';
15+
16+
dayjs.extend(weekOfYear);
17+
dayjs.extend(localeData);
1318

14-
dayjs.extend(require('dayjs/plugin/weekOfYear'));
15-
dayjs.extend(require('dayjs/plugin/localeData'));
1619
const prefixCls = classCreator('fullcalendar')();
1720

1821
function getMonthsLocale(value) {

src/calendar/src/date/dateInput.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import san, {DataTypes} from 'san';
77
import dayjs from 'dayjs';
88
import {formatDate} from '../util/index';
99
import KeyCode from '../../../core/util/keyCode';
10+
import customParseFormat from 'dayjs/plugin/customParseFormat';
11+
12+
dayjs.extend(customParseFormat);
1013

1114
export default san.defineComponent({
1215
dataTypes: {
@@ -68,7 +71,6 @@ export default san.defineComponent({
6871
}
6972

7073
// 不合法直接退出
71-
dayjs.extend(require('dayjs/plugin/customParseFormat'));
7274
const parsed = dayjs(showDate, format, true);
7375
if (!parsed.isValid()) {
7476
this.data.set('invalid', true);

src/calendar/src/util/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* @author mayihui@baidu.com
44
**/
55
import dayjs from 'dayjs';
6+
import utc from 'dayjs/plugin/utc';
7+
8+
dayjs.extend(utc);
69

710
const defaultDisabledTime = {
811
disabledHours() {
@@ -19,7 +22,6 @@ const defaultDisabledTime = {
1922
export function getTodayTime(value) {
2023
const locale = value.locale();
2124
require(`dayjs/locale/${locale}.js`);
22-
dayjs.extend(require('dayjs/plugin/utc'));
2325
return dayjs().locale(locale).utcOffset(value.utcOffset());
2426
}
2527

src/comment/docs/basic.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
<script>
3737
import dayjs from 'dayjs';
3838
import {Comment, Icon, Avatar, Tooltip} from 'santd';
39+
import relativeTime from 'dayjs/plugin/relativeTime';
3940
40-
dayjs.extend(require('dayjs/plugin/relativeTime'));
41+
dayjs.extend(relativeTime);
4142
4243
export default {
4344
components: {

src/comment/docs/list.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
<script>
2525
import dayjs from 'dayjs';
2626
import {Comment, Avatar, List} from 'santd';
27+
import relativeTime from 'dayjs/plugin/relativeTime';
28+
29+
dayjs.extend(relativeTime);
2730
28-
dayjs.extend(require('dayjs/plugin/relativeTime'));
2931
const data = [{
3032
author: 'Han Solo',
3133
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',

src/comment/docs/nested.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import san from 'san';
1919
import dayjs from 'dayjs';
2020
import {Comment, Icon, Avatar} from 'santd';
21+
import relativeTime from 'dayjs/plugin/relativeTime';
22+
23+
dayjs.extend(relativeTime);
2124
22-
dayjs.extend(require('dayjs/plugin/relativeTime'));
2325
const pComment = san.defineComponent({
2426
template: `
2527
<template>

src/comment/docs/reply.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import san from 'san';
2727
import dayjs from 'dayjs';
2828
import {Comment, Icon, Avatar, Form, Button, Input} from 'santd';
29+
import relativeTime from 'dayjs/plugin/relativeTime';
30+
31+
dayjs.extend(relativeTime);
2932
30-
dayjs.extend(require('dayjs/plugin/relativeTime'));
3133
const pComment = san.defineComponent({
3234
template: `
3335
<template>

src/date-picker/docs/customdisabled.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import dayjs from 'dayjs';
3030
import {DatePicker} from 'santd';
3131
32+
dayjs.extend(require('dayjs/plugin/customParseFormat'));
33+
3234
function range(start, end) {
3335
const result = [];
3436
for (let i = start; i < end; i++) {

src/date-picker/docs/disabled.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import dayjs from 'dayjs';
2020
import {DatePicker} from 'santd';
2121
22+
dayjs.extend(require('dayjs/plugin/customParseFormat'));
23+
2224
const dateFormat = 'YYYY-MM-DD';
2325
2426
export default {

0 commit comments

Comments
 (0)