@dao42/d42paas-front 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/_bundle.tsx +0 -283
- package/src/app.tsx +0 -356
- package/src/assets/code-brackets.svg +0 -1
- package/src/assets/colors.svg +0 -1
- package/src/assets/comments.svg +0 -1
- package/src/assets/direction.svg +0 -1
- package/src/assets/flow.svg +0 -1
- package/src/assets/plugin.svg +0 -1
- package/src/assets/repo.svg +0 -1
- package/src/assets/stackalt.svg +0 -1
- package/src/components/Avatar/index.tsx +0 -27
- package/src/components/CanvasHelper/index.tsx +0 -89
- package/src/components/Console/index.tsx +0 -88
- package/src/components/Editor/index copy.tsx +0 -1010
- package/src/components/Editor/index.tsx +0 -1011
- package/src/components/FileTree/index.tsx +0 -478
- package/src/components/LiveContent/index.tsx +0 -221
- package/src/components/LiveContent/video.tsx +0 -213
- package/src/components/LottieAnim/index.tsx +0 -41
- package/src/components/Message/index.tsx +0 -64
- package/src/components/Model/index.tsx +0 -42
- package/src/components/OutputBrowser/index.tsx +0 -180
- package/src/components/Skeleton/index.tsx +0 -41
- package/src/components/Tabs/index.tsx +0 -23
- package/src/components/Terminal/index.tsx +0 -127
- package/src/components/ToolBar/index.tsx +0 -169
- package/src/components/XTerm/index.tsx +0 -113
- package/src/components/index.tsx +0 -4
- package/src/components/loading/index.tsx +0 -284
- package/src/enum/FExtension.ts +0 -168
- package/src/helpers/collections/IoClient.tsx +0 -314
- package/src/helpers/collections/errorCatcher.tsx +0 -0
- package/src/helpers/collections/idb.tsx +0 -186
- package/src/helpers/collections/localStorage.tsx +0 -13
- package/src/helpers/collections/mock.tsx +0 -30
- package/src/helpers/collections/playgroundInit.tsx +0 -316
- package/src/helpers/collections/replay.tsx +0 -168
- package/src/helpers/collections/socket.tsx +0 -6
- package/src/helpers/collections/toast.tsx +0 -19
- package/src/helpers/collections/userTool.tsx +0 -12
- package/src/helpers/collections/util.tsx +0 -4
- package/src/helpers/index.tsx +0 -6
- package/src/helpers/monaco/monaco-ot-adapter.tsx +0 -476
- package/src/hooks/collections/useOT.tsx +0 -39
- package/src/hooks/index.tsx +0 -1
- package/src/index.html +0 -49
- package/src/pages/index.tsx +0 -452
- package/src/public/dev.html +0 -35
- package/src/public/index.html +0 -50
- package/src/public/sdkserver.html +0 -36
- package/src/stores/index.tsx +0 -1
- package/src/stores/oTStore.tsx +0 -310
- package/src/stories/BrowserWindow.tsx +0 -30
- package/src/stories/Console.tsx +0 -46
- package/src/stories/Editor.tsx +0 -37
- package/src/stories/FileTree.tsx +0 -50
- package/src/stories/Shell.tsx +0 -53
- package/src/stories/introduction.stories.mdx +0 -193
- package/src/stories/page.tsx +0 -71
- package/src/styles/collections/iconfont.scss +0 -1
- package/src/styles/collections/tabs-costumers.scss +0 -20
- package/src/styles/collections/tailwind.scss +0 -3
- package/src/styles/collections/tree-costumers.scss +0 -53
- package/src/styles/collections/utility.scss +0 -10
- package/src/styles/collections/xterm-costumers.scss +0 -47
- package/src/styles/index.css +0 -21
- package/src/types/editor.d.ts +0 -31
- package/src/types/index.d.ts +0 -166
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { D42RTC, ID, Events } from '@dao42/d42paas_rtc';
|
|
3
|
-
import styled from '@emotion/styled';
|
|
4
|
-
import { useOT } from '~/hooks';
|
|
5
|
-
import { pick } from 'lodash';
|
|
6
|
-
import { userStore } from '~/stores/oTStore';
|
|
7
|
-
import { UserMedia } from '~/components/LiveContent/index';
|
|
8
|
-
|
|
9
|
-
interface VideoComponentProps {
|
|
10
|
-
userMedia: UserMedia;
|
|
11
|
-
rtc: D42RTC;
|
|
12
|
-
isRemote?: boolean;
|
|
13
|
-
rtcID?: ID;
|
|
14
|
-
currentId?: string;
|
|
15
|
-
closeVideoWindow?: (uuid: string) => void;
|
|
16
|
-
replaying?: boolean;
|
|
17
|
-
segmentId?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const VideoWrapper = styled.div`
|
|
21
|
-
position: relative;
|
|
22
|
-
min-width: 300px;
|
|
23
|
-
min-height: 225px;
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const ToolMask = styled.span`
|
|
27
|
-
position: absolute;
|
|
28
|
-
bottom: 0;
|
|
29
|
-
width: 100%;
|
|
30
|
-
height: 30px;
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
|
|
34
|
-
i {
|
|
35
|
-
width: 20px;
|
|
36
|
-
height: 20px;
|
|
37
|
-
display: flex;
|
|
38
|
-
justify-content: center;
|
|
39
|
-
align-items: center;
|
|
40
|
-
font-size: 18px;
|
|
41
|
-
color: white;
|
|
42
|
-
margin-left: 8px;
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
border-radius: 50%;
|
|
45
|
-
|
|
46
|
-
&.phone-down {
|
|
47
|
-
color: red;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&:hover {
|
|
51
|
-
background-color: rgba(108, 108, 108, 0.7);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
const MicroPhoneComponent: React.FC<{
|
|
57
|
-
audioOpening: boolean;
|
|
58
|
-
onCloseAudio: () => void;
|
|
59
|
-
onOpenAudio: () => void;
|
|
60
|
-
}> = ({ audioOpening, onCloseAudio, onOpenAudio }) => {
|
|
61
|
-
return audioOpening ? (
|
|
62
|
-
<i className="d42 microphone" onClick={onCloseAudio} />
|
|
63
|
-
) : (
|
|
64
|
-
<i className="d42 microphone-off" onClick={onOpenAudio} />
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const VideoPlayingComponent: React.FC<{
|
|
69
|
-
videoPlaying: boolean;
|
|
70
|
-
onCloseVideo: () => void;
|
|
71
|
-
onOpenVideo: () => void;
|
|
72
|
-
}> = ({ videoPlaying, onCloseVideo, onOpenVideo }) => {
|
|
73
|
-
return videoPlaying ? (
|
|
74
|
-
<i className="d42 video-off" onClick={onCloseVideo} />
|
|
75
|
-
) : (
|
|
76
|
-
<i className="d42 video" onClick={onOpenVideo} />
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const RecordComponent: React.FC<{
|
|
81
|
-
recording: boolean;
|
|
82
|
-
onStopRecord: () => void;
|
|
83
|
-
onStartRecord: () => void;
|
|
84
|
-
}> = ({ recording, onStopRecord, onStartRecord }) => {
|
|
85
|
-
return recording ? (
|
|
86
|
-
<i className="d42 stop text-red-600" onClick={onStopRecord} />
|
|
87
|
-
) : (
|
|
88
|
-
<i className="d42 record text-red-600" onClick={onStartRecord} />
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const VideoComponent: React.FC<VideoComponentProps> = ({
|
|
93
|
-
userMedia,
|
|
94
|
-
rtc,
|
|
95
|
-
isRemote,
|
|
96
|
-
rtcID,
|
|
97
|
-
currentId,
|
|
98
|
-
closeVideoWindow,
|
|
99
|
-
replaying,
|
|
100
|
-
segmentId,
|
|
101
|
-
}) => {
|
|
102
|
-
const io = useOT.getState().socket;
|
|
103
|
-
const [audioOpening, setAudioOpening] = useState<boolean>(false);
|
|
104
|
-
const [videoPlaying, setVideoPlaying] = useState<boolean>(true);
|
|
105
|
-
const [recording, setRecording] = useState<boolean>(false);
|
|
106
|
-
|
|
107
|
-
const onOpenAudio = () => {
|
|
108
|
-
setAudioOpening(true);
|
|
109
|
-
rtc.startAudio();
|
|
110
|
-
};
|
|
111
|
-
const onCloseAudio = () => {
|
|
112
|
-
setAudioOpening(false);
|
|
113
|
-
rtc.closeAudio(rtcID);
|
|
114
|
-
};
|
|
115
|
-
const closeWindow = () => {
|
|
116
|
-
closeVideoWindow(currentId);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const onStartRecord = async () => {
|
|
120
|
-
setRecording(true);
|
|
121
|
-
const segmentId = await rtc.startRecord();
|
|
122
|
-
const crdt: D42_FrontType.CRDT = {
|
|
123
|
-
timestamp: Date.now().toString(),
|
|
124
|
-
userInfo: pick(userStore.getState().userInfo, 'uuid'),
|
|
125
|
-
media: {
|
|
126
|
-
extraInfo: {
|
|
127
|
-
segmentId: segmentId,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
io.emit('mediaRecord', JSON.stringify(crdt));
|
|
132
|
-
};
|
|
133
|
-
const onStopRecord = () => {
|
|
134
|
-
setRecording(false);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const onOpenVideo = async () => {
|
|
138
|
-
setVideoPlaying(true);
|
|
139
|
-
rtc.startVideo();
|
|
140
|
-
};
|
|
141
|
-
const onCloseVideo = () => {
|
|
142
|
-
setVideoPlaying(false);
|
|
143
|
-
rtc.closeVideo(rtcID);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
useEffect(() => {
|
|
147
|
-
if (!rtc) return;
|
|
148
|
-
const video = document.querySelector(
|
|
149
|
-
`#video-${currentId}`,
|
|
150
|
-
) as HTMLVideoElement;
|
|
151
|
-
video.autoplay = true;
|
|
152
|
-
video.muted = true;
|
|
153
|
-
video.srcObject = userMedia.videoStream;
|
|
154
|
-
|
|
155
|
-
const audio = document.querySelector(
|
|
156
|
-
`#audio-${currentId}`,
|
|
157
|
-
) as HTMLVideoElement;
|
|
158
|
-
audio.srcObject = userMedia.audioStream;
|
|
159
|
-
audio.play();
|
|
160
|
-
}, [rtc, userMedia]);
|
|
161
|
-
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
if (!rtc) return;
|
|
164
|
-
if (replaying) {
|
|
165
|
-
if (!segmentId) return;
|
|
166
|
-
const video = document.querySelector(
|
|
167
|
-
`#video-${currentId}`,
|
|
168
|
-
) as HTMLVideoElement;
|
|
169
|
-
video.autoplay = true;
|
|
170
|
-
video.muted = true;
|
|
171
|
-
rtc.playbackSegment(segmentId, video);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
}, [rtc, segmentId]);
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<VideoWrapper>
|
|
178
|
-
<div
|
|
179
|
-
className="absolute text-red-600 top-1 right-3 z-10 cursor-pointer"
|
|
180
|
-
onClick={closeWindow}
|
|
181
|
-
>
|
|
182
|
-
x
|
|
183
|
-
</div>
|
|
184
|
-
<video id={'video-' + currentId} />
|
|
185
|
-
<audio id={'audio-' + currentId} />
|
|
186
|
-
<ToolMask>
|
|
187
|
-
{isRemote ? (
|
|
188
|
-
'音量'
|
|
189
|
-
) : (
|
|
190
|
-
<>
|
|
191
|
-
<MicroPhoneComponent
|
|
192
|
-
audioOpening={audioOpening}
|
|
193
|
-
onOpenAudio={onOpenAudio}
|
|
194
|
-
onCloseAudio={onCloseAudio}
|
|
195
|
-
/>
|
|
196
|
-
<VideoPlayingComponent
|
|
197
|
-
videoPlaying={videoPlaying}
|
|
198
|
-
onOpenVideo={onOpenVideo}
|
|
199
|
-
onCloseVideo={onCloseVideo}
|
|
200
|
-
/>
|
|
201
|
-
<RecordComponent
|
|
202
|
-
recording={recording}
|
|
203
|
-
onStartRecord={onStartRecord}
|
|
204
|
-
onStopRecord={onStopRecord}
|
|
205
|
-
/>
|
|
206
|
-
</>
|
|
207
|
-
)}
|
|
208
|
-
</ToolMask>
|
|
209
|
-
</VideoWrapper>
|
|
210
|
-
);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export default VideoComponent;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import Lottie from 'lottie-web';
|
|
3
|
-
import styled from '@emotion/styled';
|
|
4
|
-
|
|
5
|
-
// https://assets10.lottiefiles.com/packages/lf20_fydpgJ.json
|
|
6
|
-
// https://assets10.lottiefiles.com/packages/lf20_n2b0ZQ.json
|
|
7
|
-
// https://assets10.lottiefiles.com/packages/lf20_2OWTcY.json
|
|
8
|
-
// https://assets10.lottiefiles.com/private_files/lf30_iuxli0di.json
|
|
9
|
-
|
|
10
|
-
const LottieAnimLayout = styled.div`
|
|
11
|
-
width: 100%;
|
|
12
|
-
height: 100%;
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
interface LottieType {
|
|
16
|
-
src?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const LottieAnim: React.FC<LottieType> = ({ src }) => {
|
|
20
|
-
const SkeletonRef = useRef<HTMLDivElement>(null);
|
|
21
|
-
// ;
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
Lottie.loadAnimation({
|
|
24
|
-
container: SkeletonRef.current, // the dom element that will contain the animation
|
|
25
|
-
renderer: 'svg',
|
|
26
|
-
loop: true,
|
|
27
|
-
autoplay: true,
|
|
28
|
-
path: src,
|
|
29
|
-
});
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
// <div ref={SkeletonRef} style={{ width: '100%', height: '100%' }}></div>
|
|
34
|
-
<LottieAnimLayout
|
|
35
|
-
ref={SkeletonRef}
|
|
36
|
-
// style={{ width: '100%', height: '100%' }}
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { LottieAnim };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { Message as MessageComponent, toaster, Notification } from 'rsuite';
|
|
3
|
-
import create from 'zustand';
|
|
4
|
-
|
|
5
|
-
export type MsgType = {
|
|
6
|
-
type: 'info' | 'success' | 'warning' | 'error';
|
|
7
|
-
content?: string | number;
|
|
8
|
-
setMessage?: ({
|
|
9
|
-
type,
|
|
10
|
-
content,
|
|
11
|
-
}: {
|
|
12
|
-
type: MsgType['type'];
|
|
13
|
-
content: MsgType['content'];
|
|
14
|
-
}) => void;
|
|
15
|
-
closable?: boolean;
|
|
16
|
-
setClosable?: (bol: boolean) => void;
|
|
17
|
-
};
|
|
18
|
-
// Omit<MsgType, 'setMessage'>
|
|
19
|
-
export const messageStore = create<MsgType>((set) => ({
|
|
20
|
-
type: 'info',
|
|
21
|
-
content: '',
|
|
22
|
-
setMessage: ({ type, content }) =>
|
|
23
|
-
set(() => ({
|
|
24
|
-
type,
|
|
25
|
-
content,
|
|
26
|
-
})),
|
|
27
|
-
closable: true,
|
|
28
|
-
setClosable: (bol) => set(() => ({ closable: bol })),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
export const Message = ({ type, content }) => {
|
|
32
|
-
// const { type, content, closable, setClosable } = messageStore.getState();
|
|
33
|
-
|
|
34
|
-
// useEffect(() => {
|
|
35
|
-
// setClosable(false);
|
|
36
|
-
// }, [type, content]);
|
|
37
|
-
// useEffect(() => {
|
|
38
|
-
// setTimeout(() => {
|
|
39
|
-
// // setClosable(false);
|
|
40
|
-
// // toaster.push(<MessageComponent>MessageComponent</MessageComponent>);
|
|
41
|
-
// toaster.push(<Notification>message</Notification>, {
|
|
42
|
-
// placement: 'topEnd',
|
|
43
|
-
// });
|
|
44
|
-
// }, 2000);
|
|
45
|
-
// }, []);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
<MessageComponent
|
|
50
|
-
// full
|
|
51
|
-
showIcon
|
|
52
|
-
type={type}
|
|
53
|
-
// closable={closable}
|
|
54
|
-
closable={false}
|
|
55
|
-
// duration={0}
|
|
56
|
-
// onClose={() => {
|
|
57
|
-
// setClosable(true);
|
|
58
|
-
// }}
|
|
59
|
-
>
|
|
60
|
-
{content}
|
|
61
|
-
</MessageComponent>
|
|
62
|
-
</>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button, ButtonToolbar, Modal as ModalContent } from 'rsuite';
|
|
3
|
-
|
|
4
|
-
export const Modal = ({ open, onCancel, text }) => {
|
|
5
|
-
// const [, setOpen] = React.useState(false);
|
|
6
|
-
// const handleOpen = () => setOpen(true);
|
|
7
|
-
// const handleClose = () => setOpen(false);
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<div className="modal-container">
|
|
11
|
-
<ButtonToolbar>
|
|
12
|
-
<Button onClick={onCancel}>Disable</Button>
|
|
13
|
-
</ButtonToolbar>
|
|
14
|
-
|
|
15
|
-
<ModalContent
|
|
16
|
-
backdrop="static"
|
|
17
|
-
role="alertdialog"
|
|
18
|
-
open={open}
|
|
19
|
-
onClose={onCancel}
|
|
20
|
-
size="xs"
|
|
21
|
-
>
|
|
22
|
-
<ModalContent.Body>
|
|
23
|
-
{/* <RemindIcon
|
|
24
|
-
style={{
|
|
25
|
-
color: '#ffb300',
|
|
26
|
-
fontSize: 24,
|
|
27
|
-
}}
|
|
28
|
-
/> */}
|
|
29
|
-
{text}
|
|
30
|
-
</ModalContent.Body>
|
|
31
|
-
<ModalContent.Footer>
|
|
32
|
-
<Button onClick={onCancel} appearance="primary">
|
|
33
|
-
Ok
|
|
34
|
-
</Button>
|
|
35
|
-
<Button onClick={onCancel} appearance="subtle">
|
|
36
|
-
Cancel
|
|
37
|
-
</Button>
|
|
38
|
-
</ModalContent.Footer>
|
|
39
|
-
</ModalContent>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import styled from '@emotion/styled';
|
|
3
|
-
import { oTStore } from '~/stores/oTStore';
|
|
4
|
-
|
|
5
|
-
const PROTOCOL = process.env.NODE_ENV === 'production' ? 'https://' : 'http://';
|
|
6
|
-
|
|
7
|
-
export interface OutputBrowserProp {
|
|
8
|
-
url: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const NavBar = styled.div`
|
|
12
|
-
background-color: white;
|
|
13
|
-
height: 30px;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
|
|
17
|
-
i {
|
|
18
|
-
margin: 0 10px;
|
|
19
|
-
width: 24px;
|
|
20
|
-
height: 24px;
|
|
21
|
-
border-radius: 50%;
|
|
22
|
-
display: flex;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
align-items: center;
|
|
25
|
-
|
|
26
|
-
&.disabled {
|
|
27
|
-
color: #f2fffe;
|
|
28
|
-
&:hover {
|
|
29
|
-
background-color: white;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&:hover {
|
|
34
|
-
background-color: #e0e0e0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
input {
|
|
39
|
-
flex: 1;
|
|
40
|
-
display: inline-block;
|
|
41
|
-
height: 26px;
|
|
42
|
-
line-height: 26px;
|
|
43
|
-
padding: 0 8px;
|
|
44
|
-
border: 1px solid #adacac;
|
|
45
|
-
border-radius: 5px;
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
const StopMask = styled.div`
|
|
50
|
-
width: 100%;
|
|
51
|
-
height: calc(100% - 30px);
|
|
52
|
-
position: absolute;
|
|
53
|
-
display: flex;
|
|
54
|
-
justify-content: center;
|
|
55
|
-
align-items: center;
|
|
56
|
-
font-size: 18px;
|
|
57
|
-
color: #ffffff;
|
|
58
|
-
background-color: #5a5a5a;
|
|
59
|
-
opacity: 0.6;
|
|
60
|
-
`;
|
|
61
|
-
|
|
62
|
-
const OutputBrowser: React.FC<OutputBrowserProp> = ({ url, ...props }) => {
|
|
63
|
-
const pStatus = oTStore((state) => state.playgroundStatus);
|
|
64
|
-
const dStatus = oTStore((state) => state.dockerStatus);
|
|
65
|
-
|
|
66
|
-
const [playgroundStatus, setPlaygroundStatus] = useState('EMPTY');
|
|
67
|
-
const [dockerStatus, setDockerStatus] = useState('STOP');
|
|
68
|
-
|
|
69
|
-
const urlWithProtocol = (url): string => {
|
|
70
|
-
// TODO 解除循环渲染page组件
|
|
71
|
-
if (!url) return `${PROTOCOL}showmebug.com`;
|
|
72
|
-
if (url.indexOf('http://') !== 0 && url.indexOf('https://') !== 0) {
|
|
73
|
-
url = `${PROTOCOL}${url}`;
|
|
74
|
-
}
|
|
75
|
-
return url;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
setPlaygroundStatus(pStatus);
|
|
80
|
-
}, [pStatus]);
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
setDockerStatus(dStatus);
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
onRefresh();
|
|
85
|
-
}, 800);
|
|
86
|
-
}, [dStatus]);
|
|
87
|
-
|
|
88
|
-
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
89
|
-
const [iframeSrc, setIframeSrc] = useState(urlWithProtocol(url));
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
setIframeSrc(urlWithProtocol(url));
|
|
92
|
-
}, [url]);
|
|
93
|
-
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
// iframeRef.current.contentWindow.addEventListener('message', (e) => {
|
|
96
|
-
// // console.log(`post message from parent`, e.data);
|
|
97
|
-
// switch (e.data) {
|
|
98
|
-
// case 'forward':
|
|
99
|
-
// iframeRef.current.contentWindow.history.forward();
|
|
100
|
-
// return;
|
|
101
|
-
// case 'backward':
|
|
102
|
-
// iframeRef.current.contentWindow.history.back();
|
|
103
|
-
// return;
|
|
104
|
-
// case 'refresh':
|
|
105
|
-
// // console.log(`???????`);
|
|
106
|
-
// iframeRef.current.contentWindow.location.reload();
|
|
107
|
-
// return;
|
|
108
|
-
// }
|
|
109
|
-
// });
|
|
110
|
-
}, [iframeRef]);
|
|
111
|
-
|
|
112
|
-
const onEnterKey = (e) => {
|
|
113
|
-
if (e.keyCode !== 13) return;
|
|
114
|
-
const url = urlWithProtocol(e.target.value);
|
|
115
|
-
setIframeSrc(url);
|
|
116
|
-
iframeRef.current.contentWindow.location.replace(url);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const onBackward = () => {
|
|
120
|
-
iframeRef.current.contentWindow.history.back();
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const onForward = () => {
|
|
124
|
-
iframeRef.current.contentWindow.history.back();
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const onRefresh = () => {
|
|
128
|
-
// iframeRef.current.contentWindow.location.reload();
|
|
129
|
-
iframeRef.current.contentWindow.location.replace(iframeSrc);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const onOpenInNewTab = () => {
|
|
133
|
-
window.open(iframeSrc);
|
|
134
|
-
};
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (playgroundStatus === 'EMPTY') return;
|
|
137
|
-
if (playgroundStatus === 'ACTIVE' && dockerStatus === 'RUNNING') {
|
|
138
|
-
if (iframeSrc !== 'http://' && iframeSrc !== 'https://') {
|
|
139
|
-
iframeRef.current.contentWindow.location.replace(iframeSrc);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}, [playgroundStatus, dockerStatus]);
|
|
143
|
-
return (
|
|
144
|
-
<>
|
|
145
|
-
<NavBar>
|
|
146
|
-
{/*<i*/}
|
|
147
|
-
{/* className="d42 text-2xl arrow-left cursor-pointer"*/}
|
|
148
|
-
{/* onClick={onBackward}*/}
|
|
149
|
-
{/*/>*/}
|
|
150
|
-
{/*<i*/}
|
|
151
|
-
{/* className="d42 text-2xl arrow-right cursor-pointer"*/}
|
|
152
|
-
{/* onClick={onForward}*/}
|
|
153
|
-
{/*/>*/}
|
|
154
|
-
<i className="d42 text-xl reload cursor-pointer" onClick={onRefresh} />
|
|
155
|
-
<input
|
|
156
|
-
type="text"
|
|
157
|
-
value={iframeSrc}
|
|
158
|
-
onChange={(e) => setIframeSrc(e.target.value)}
|
|
159
|
-
onKeyDown={onEnterKey}
|
|
160
|
-
/>
|
|
161
|
-
<i
|
|
162
|
-
className="d42 text-xl file-copy cursor-pointer"
|
|
163
|
-
onClick={onOpenInNewTab}
|
|
164
|
-
/>
|
|
165
|
-
</NavBar>
|
|
166
|
-
{dockerStatus === 'STOP' && (
|
|
167
|
-
<StopMask>
|
|
168
|
-
<span>点击“运行”,启动应用</span>
|
|
169
|
-
</StopMask>
|
|
170
|
-
)}
|
|
171
|
-
<iframe
|
|
172
|
-
ref={iframeRef}
|
|
173
|
-
src={iframeSrc}
|
|
174
|
-
style={{ width: '100%', height: 'calc(100% - 30px)' }}
|
|
175
|
-
/>
|
|
176
|
-
</>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default OutputBrowser;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren, useEffect } from 'react';
|
|
2
|
-
// import SkeletonComponent as skeleton from 'react-loading-skeleton';
|
|
3
|
-
import * as SkeletonComponent from 'react-loading-skeleton';
|
|
4
|
-
import 'react-loading-skeleton/dist/skeleton.css';
|
|
5
|
-
|
|
6
|
-
const Skeleton: React.FC<{
|
|
7
|
-
count?: number;
|
|
8
|
-
}> = ({ count }) => {
|
|
9
|
-
// useEffect(() => {}, []);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<SkeletonComponent.SkeletonTheme baseColor="#202020" highlightColor="#444">
|
|
13
|
-
<SkeletonComponent.default
|
|
14
|
-
wrapper={Box}
|
|
15
|
-
height={15}
|
|
16
|
-
count={count ? count : 5}
|
|
17
|
-
/>
|
|
18
|
-
;
|
|
19
|
-
</SkeletonComponent.SkeletonTheme>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
function Box({ children }: PropsWithChildren<unknown>) {
|
|
24
|
-
return (
|
|
25
|
-
<div
|
|
26
|
-
style={{
|
|
27
|
-
// border: '1px solid #ccc',
|
|
28
|
-
display: 'block',
|
|
29
|
-
lineHeight: 1,
|
|
30
|
-
padding: '1rem',
|
|
31
|
-
marginTop: '0.5rem',
|
|
32
|
-
marginBottom: '0.5rem',
|
|
33
|
-
width: '100%',
|
|
34
|
-
}}
|
|
35
|
-
>
|
|
36
|
-
{children}
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default Skeleton;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Nav, NavProps } from 'rsuite';
|
|
3
|
-
|
|
4
|
-
interface TabsProps extends NavProps {
|
|
5
|
-
tabItems?: Array<{
|
|
6
|
-
eventKey: string;
|
|
7
|
-
itemName: string;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const Tabs = ({ activeKey, onSelect, tabItems, ...props }: TabsProps) => {
|
|
12
|
-
return (
|
|
13
|
-
<Nav {...props} activeKey={activeKey} onSelect={onSelect}>
|
|
14
|
-
{tabItems.map((item) => (
|
|
15
|
-
<Nav.Item eventKey={item.eventKey} key={item.eventKey}>
|
|
16
|
-
{item.itemName}
|
|
17
|
-
</Nav.Item>
|
|
18
|
-
))}
|
|
19
|
-
</Nav>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default Tabs;
|