Skip to content

Commit 0dc0c99

Browse files
committed
moment -> date-fns
1 parent b0974e7 commit 0dc0c99

19 files changed

+122
-49
lines changed

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
"main": "index.js",
66
"author": "xpionner",
77
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/xpioneer/react-typescript.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/xpioneer/react-typescript/issues"
14+
},
815
"scripts": {
916
"start": "npm run dev",
1017
"dev": "NODE_ENV=development webpack-dev-server --config build/webpack.dev.conf.js",
@@ -14,17 +21,11 @@
1421
"lintcss": "stylelint --syntax scss src/**/*.scss",
1522
"lintcss:fix": "stylelint --syntax scss src/**/*.scss --fix"
1623
},
17-
"repository": {
18-
"type": "git",
19-
"url": "git+https://github.com/xpioneer/react-typescript.git"
20-
},
21-
"bugs": {
22-
"url": "https://github.com/xpioneer/react-typescript/issues"
23-
},
2424
"dependencies": {
2525
"@ant-design/icons": "^4.6.2",
2626
"antd": "^4.16.11",
2727
"axios": "^0.19.0",
28+
"date-fns": "^2.23.0",
2829
"echarts": "^4.2.0-rc.2",
2930
"mobx": "^5.15.0",
3031
"mobx-react": "^6.1.4",
@@ -55,6 +56,8 @@
5556
"eslint-plugin-react": "^7.21.5",
5657
"html-webpack-plugin": "^5.0.0-alpha.17",
5758
"husky": "^4.3.6",
59+
"less": "^4.1.1",
60+
"less-loader": "^10.0.1",
5861
"lint-staged": "^10.5.3",
5962
"mini-css-extract-plugin": "^1.3.3",
6063
"node-sass": "^5.0.0",

src/pages/article/articleList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22
import {inject, observer} from 'mobx-react'
3-
import { Row, Col, Form, Input, Button, DatePicker, Table, Modal, Badge, } from 'antd'
3+
import { Row, Col, Form, Input, Button, Table, Modal, Badge, } from 'antd'
4+
import { DatePicker } from 'components/datePicker'
45
import { ColumnProps } from 'antd/lib/table'
56
import { IArticle } from '@models/article'
67

src/pages/article/articleListStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable, action, autorun, runInAction } from 'mobx'
22
import { serialize } from '@utils/params'
3-
import { Moment } from 'moment'
3+
import { startOfDay, endOfDay } from 'date-fns'
44
import { GRAPHQL_API } from '@constants/index'
55

66
const queryArticles = `
@@ -31,8 +31,8 @@ class articleListStore {
3131
if (type === 'createdAt') {
3232
this.createdAt = value
3333
const range = value
34-
this.value[type] = range.map((d: Moment, index: number) => {
35-
return index > 0 ? d.format('YYYY-MM-DD 23:59:59:999') : d.format('YYYY-MM-DD 00:00:00:000')
34+
this.value[type] = range.map((d: Date, index: number) => {
35+
return index > 0 ? endOfDay(d) : startOfDay(d)
3636
})
3737
} else {
3838
this.value[type] = value.trim()

src/pages/articleType/articleTypeList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22
import {inject, observer} from 'mobx-react'
3-
import { Row, Col, Form, Input, Button, DatePicker, Table, Modal, Badge, } from 'antd'
3+
import { Row, Col, Form, Input, Button, Table, Modal, Badge, } from 'antd'
4+
import { DatePicker } from 'components/datePicker'
45
import { ColumnProps } from 'antd/lib/table'
56
import { IArticleType } from '@models/articleType'
67

src/pages/articleType/articleTypeListStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable, action, autorun, runInAction } from 'mobx'
22
import { serialize } from '@utils/params'
3-
import { Moment } from 'moment'
3+
import { startOfDay, endOfDay } from 'date-fns'
44
import { GRAPHQL_API } from '@constants/index'
55

66
const queryArticleTypes = `
@@ -29,8 +29,8 @@ class articleTypeListStore {
2929
if (type === 'createdAt') {
3030
this.createdAt = value
3131
const range = value
32-
this.value[type] = range.map((d: Moment, index: number) => {
33-
return index > 0 ? d.format('YYYY-MM-DD 23:59:59:999') : d.format('YYYY-MM-DD 00:00:00:000')
32+
this.value[type] = range.map((d: Date, index: number) => {
33+
return index > 0 ? endOfDay(d) : startOfDay(d)
3434
})
3535
} else {
3636
this.value[type] = value.trim()

src/pages/comment/commentList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22
import {inject, observer} from 'mobx-react'
3-
import { Row, Col, Form, Input, Button, DatePicker, Table, Modal, Badge, } from 'antd'
3+
import { Row, Col, Form, Input, Button, Table, Modal, Badge, } from 'antd'
4+
import { DatePicker } from 'components/datePicker'
45
import { ColumnProps } from 'antd/lib/table'
56
import { IComment } from '@models/comment'
67

src/pages/comment/commentListStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable, action, autorun, runInAction } from 'mobx'
22
import { serialize } from '@utils/params'
3-
import { Moment } from 'moment'
3+
import { startOfDay, endOfDay } from 'date-fns'
44
import { GRAPHQL_API } from '@constants/index'
55

66
const queryCommentTypes = `
@@ -29,8 +29,8 @@ class commentListStore {
2929
if (type === 'createdAt') {
3030
this.createdAt = value
3131
const range = value
32-
this.value[type] = range.map((d: Moment, index: number) => {
33-
return index > 0 ? d.format('YYYY-MM-DD 23:59:59:999') : d.format('YYYY-MM-DD 00:00:00:000')
32+
this.value[type] = range.map((d: Date, index: number) => {
33+
return index > 0 ? endOfDay(d) : startOfDay(d)
3434
})
3535
} else {
3636
this.value[type] = value.trim()

src/pages/leaveMsg/leaveMsgList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22
import {inject, observer} from 'mobx-react'
3-
import { Row, Col, Form, Input, Button, DatePicker, Table, Modal, Badge, } from 'antd'
3+
import { Row, Col, Form, Input, Button, Table, Modal, Badge, } from 'antd'
4+
import { DatePicker } from 'components/datePicker'
45
import { ColumnProps } from 'antd/lib/table'
56
import { ILeaveMsg } from '@models/leaveMsg'
67

src/pages/leaveMsg/leaveMsgListStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable, action, autorun, runInAction } from 'mobx'
22
import { serialize } from '@utils/params'
3-
import { Moment } from 'moment'
3+
import { startOfDay, endOfDay } from 'date-fns'
44
import { GRAPHQL_API } from '@constants/index'
55

66
const queryLeaveMsg = `
@@ -29,8 +29,8 @@ class leaveMsgListStore {
2929
if (type === 'createdAt') {
3030
this.createdAt = value
3131
const range = value
32-
this.value[type] = range.map((d: Moment, index: number) => {
33-
return index > 0 ? d.format('YYYY-MM-DD 23:59:59:999') : d.format('YYYY-MM-DD 00:00:00:000')
32+
this.value[type] = range.map((d: Date, index: number) => {
33+
return index > 0 ? endOfDay(d) : startOfDay(d)
3434
})
3535
} else {
3636
this.value[type] = value.trim()

src/pages/logs/errorStore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { observable, action, autorun, runInAction } from 'mobx'
22
import { message } from 'antd'
33
import { serialize } from '@utils/params'
4-
import { Moment } from 'moment'
4+
import { startOfDay, endOfDay } from 'date-fns'
55

66
class errorLogStore {
77
@observable value = {
@@ -20,9 +20,9 @@ class errorLogStore {
2020

2121
@action inputChange = (value: any, type: string) => {
2222
if (type === 'createdAt') {
23-
const range: [Moment, Moment] = value
24-
this.value[type] = range.map((d: Moment, index) => {
25-
return index > 0 ? d.format('YYYY/MM/DD 23:59:59:999') : d.format('YYYY/MM/DD 00:00:00:000')
23+
const range: [Date, Date] = value
24+
this.value[type] = range.map((d, index) => {
25+
return index > 0 ? endOfDay(d) : startOfDay(d)
2626
}).join(',')
2727
} else {
2828
this.value[type] = value.trim()

0 commit comments

Comments
 (0)