Skip to content

Commit 356677f

Browse files
committed
feat: react gantt
1 parent ee3478f commit 356677f

File tree

8 files changed

+94
-2
lines changed

8 files changed

+94
-2
lines changed

.cspell/custom-dictionary-workspace.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ENOENT
2020
EPSG
2121
fengian
2222
fengxian
23+
gantt
24+
Gantt
2325
hookspath
2426
Huksy
2527
iclient

package-lock.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@
312312
"use-debounce": "^10.0.3",
313313
"use-deep-compare-effect": "^1.8.1",
314314
"use-react-router-breadcrumbs": "^4.0.1",
315-
"user-agents": "^1.1.325"
315+
"user-agents": "^1.1.325",
316+
"wx-react-gantt": "^1.3.0"
316317
},
317318
"engines": {
318319
"node": ">= 14.17.1",

src/pages/layout/proSecNav/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const ProSecNav = () => {
7171
{ label: 'PrismRender', key: '/prism', icon: <FireOutlined /> },
7272
{ label: 'ReactTilt', key: '/tilt', icon: <QrcodeOutlined /> },
7373
{ label: 'Music', key: '/music', icon: <FireOutlined /> },
74+
{ label: 'Gantt', key: '/gantt', icon: <QrcodeOutlined /> },
7475
{ label: 'Crypto', key: '/crypto', icon: <QrcodeOutlined /> },
7576
{ label: 'Video', key: '/video', icon: <FireOutlined /> },
7677
{ label: 'Three', key: '/three', icon: <QrcodeOutlined /> },

src/pages/reactGantt/index.jsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React, { useRef, useEffect } from 'react'
2+
import { Gantt, Willow } from 'wx-react-gantt'
3+
import 'wx-react-gantt/dist/gantt.css'
4+
const ReactGantt = () => {
5+
const tasks = [
6+
{
7+
id: 20,
8+
text: 'New Task',
9+
start: new Date(2024, 5, 11),
10+
end: new Date(2024, 6, 12),
11+
duration: 1,
12+
progress: 2,
13+
type: 'task',
14+
lazy: false,
15+
},
16+
{
17+
id: 47,
18+
text: '[1] Master project',
19+
start: new Date(2024, 5, 12),
20+
end: new Date(2024, 7, 12),
21+
duration: 8,
22+
progress: 0,
23+
parent: 0,
24+
type: 'summary',
25+
},
26+
{
27+
id: 22,
28+
text: 'Task',
29+
start: new Date(2024, 7, 11),
30+
end: new Date(2024, 8, 12),
31+
duration: 8,
32+
progress: 0,
33+
parent: 47,
34+
type: 'task',
35+
},
36+
{
37+
id: 21,
38+
text: 'New Task 2',
39+
start: new Date(2024, 7, 10),
40+
end: new Date(2024, 8, 12),
41+
duration: 3,
42+
progress: 0,
43+
type: 'task',
44+
lazy: false,
45+
},
46+
]
47+
48+
const links = [{ id: 1, source: 20, target: 21, type: 'e2e' }]
49+
50+
const scales = [
51+
{ unit: 'month', step: 1, format: 'MMMM yyy' },
52+
{ unit: 'day', step: 1, format: 'd' },
53+
]
54+
55+
return (
56+
<Willow>
57+
<Gantt tasks={tasks} links={links} scales={scales} />
58+
</Willow>
59+
)
60+
}
61+
62+
export default ReactGantt

src/routers/index.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const ReactPdf = lazy(() => import('@pages/reactPdf'))
4747
const MyIframe = lazy(() => import('@pages/postmessage/myIframe'))
4848
const Exception403 = lazy(() => import('@stateless/Exception/exception403'))
4949
const NoMatch = lazy(() => import('@stateless/NoMatch'))
50+
const ReactGantt = lazy(() => import('@pages/reactGantt'))
5051

5152
const rootRouter = [
5253
{
@@ -82,6 +83,14 @@ const rootRouter = [
8283
auth: true,
8384
element: lazyLoad(ParallaxVert),
8485
},
86+
{
87+
index: false,
88+
path: 'gantt',
89+
name: 'gantt',
90+
key: '/gantt',
91+
auth: false,
92+
element: lazyLoad(ReactGantt),
93+
},
8594
{
8695
index: false,
8796
path: 'qrcode',

src/styles/reset.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ select:-webkit-autofill:active {
135135
display: flex;
136136
justify-content: center;
137137
align-items: center;
138+
overflow: auto;
138139
}
139140

140141
@keyframes rotate {

src/utils/publicFn/index.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,9 @@ export const jsonToMap = (json) => new Map(Object.entries(JSON.parse(json)))
167167
export const snakeToCamelCase = (snake) => snake.toLowerCase().replace(/(_\w)/g, (word) => word.toUpperCase().substr(1))
168168

169169
export const mathRound = (num) => Math.round(num * 100) / 100
170+
171+
export const openInNewTab = (url) => {
172+
const win = window.open(url, '_blank')
173+
win.focus()
174+
return win
175+
}

0 commit comments

Comments
 (0)