Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
f4d7f1c7
Commit
f4d7f1c7
authored
May 28, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ml小程序
parent
ccd68731
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
31 deletions
+76
-31
src/components/interactive-tutorial/index.js
+59
-25
src/components/interactive-tutorial/program/index.js
+2
-1
src/components/interactive-tutorial/terminal/index.js
+15
-5
No files found.
src/components/interactive-tutorial/index.js
View file @
f4d7f1c7
...
...
@@ -39,6 +39,7 @@ class InteractiveStudy extends Component {
page
,
videoId
:
data
.
current_video_id
,
})
document
.
title
=
data
.
current_video_name
this
.
getPageContent
(
data
.
current_video_id
,
()
=>
{
this
.
updatePosition
()
this
.
getPageContent
(
data
.
current_video_id
)
...
...
@@ -72,6 +73,10 @@ class InteractiveStudy extends Component {
}
getPageContent
=
(
videoId
,
cb
)
=>
{
const
{
page
,
schedule
}
=
this
.
state
if
(
page
>
schedule
.
page_info
.
total_pages
)
{
return
}
http
.
post
(
`
${
API
.
home
}
/m/it/study/syllabus?page=
${
this
.
state
.
isFirst
?
1
:
this
.
state
.
page
}
`
,
{
course_id
:
getParam
(
'id'
),
video_id
:
videoId
,
...
...
@@ -80,17 +85,21 @@ class InteractiveStudy extends Component {
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
this
.
setState
(
state
=>
{
const
totalPage
=
state
.
schedule
.
page_info
.
total_pages
const
page
=
state
.
page
<
totalPage
?
state
.
isFirst
?
state
.
page
:
state
.
page
+
1
:
totalPage
const
list
=
data
.
syllabus_list
const
progress
=
state
.
processContent
.
length
?
data
.
syllabus_
list
.
findIndex
(
item
=>
item
.
syllabus_id
===
state
.
processContent
[
state
.
processContent
.
length
-
1
].
syllabus_id
)
+
1
?
list
.
findIndex
(
item
=>
item
.
syllabus_id
===
state
.
processContent
[
state
.
processContent
.
length
-
1
].
syllabus_id
)
+
1
:
0
if
(
state
.
isFirst
)
{
return
{
processContent
:
state
.
isFirst
?
(
state
.
processContent
.
concat
(
data
.
syllabus_list
))
:
state
.
processContent
,
processContent
:
state
.
processContent
.
concat
(
list
)
,
isFirst
:
false
,
page
,
}
}
return
{
cachedList
:
state
.
cachedList
.
reverse
().
concat
(
list
.
slice
(
progress
)).
reverse
(),
page
:
state
.
page
+
1
,
pageData
:
data
,
progress
:
state
.
isFirst
?
state
.
progress
:
progress
,
progress
:
progress
,
}
},
()
=>
{
cb
&&
cb
()
...
...
@@ -102,10 +111,11 @@ class InteractiveStudy extends Component {
}
saveSchedule
=
(
syllabusId
,
unitInfoId
)
=>
{
http
.
post
(
`/m/it/user/saveSchedule`
,
{
syllabus_id
:
syllabusId
,
unit_info_id
:
unitInfoId
,
}).
then
(
res
=>
{
let
data
=
{
syllabus_id
:
syllabusId
}
if
(
unitInfoId
)
{
data
.
unit_info_id
=
unitInfoId
}
http
.
post
(
`/m/it/user/saveSchedule`
,
data
).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
...
...
@@ -115,26 +125,50 @@ class InteractiveStudy extends Component {
})
}
savePractice
=
({
syllabusId
,
type
,
answer
,
result
,
lines
})
=>
{
let
data
=
{
syllabus_id
:
syllabusId
,
type
,
answer
,
result
,
}
if
(
type
===
2
&&
lines
)
{
data
.
lines
=
lines
}
http
.
post
(
`
${
API
.
home
}
/m/it/user/savePractice`
,
data
).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
}
else
{
Toast
.
fail
(
msg
,
2
)
}
})
}
process
=
()
=>
{
const
{
processStatus
}
=
this
.
state
if
(
processStatus
===
status
.
practicingProgram
||
processStatus
===
status
.
practicingSingle
)
{
this
.
showToast
(
'有其他正在进行的练习'
)
return
}
if
(
processStatus
===
status
.
nextSection
)
{
console
.
log
(
'下一关'
)
return
}
this
.
setState
(
state
=>
{
let
nextQuestion
,
progress
,
cachedList
=
state
.
cachedList
if
(
state
.
cachedList
.
length
)
{
let
nextQuestion
,
cachedList
=
state
.
cachedList
,
pageData
=
state
.
pageData
const
length
=
cachedList
.
length
if
(
length
)
{
nextQuestion
=
[
cachedList
.
pop
()]
progress
=
0
}
else
{
nextQuestion
=
state
.
pageData
.
syllabus_list
.
slice
(
state
.
progress
,
state
.
progress
+
1
)
progress
=
state
.
progress
+
1
}
if
(
!
cachedList
.
length
&&
state
.
progress
===
state
.
pageData
.
syllabus_list
.
length
-
6
)
{
cachedList
=
state
.
pageData
.
syllabus_list
.
slice
(
state
.
progress
+
1
).
reverse
()
console
.
log
(
state
.
page
)
if
(
length
<
6
)
{
this
.
getPageContent
(
state
.
videoId
)
}
}
if
(
!
cachedList
.
length
)
{
return
{
processStatus
:
status
.
nextSection
,
}
}
let
processStatus
=
nextQuestion
[
0
].
type
===
questionType
.
singleAnswer
?
status
.
practicingSingle
:
nextQuestion
[
0
].
type
===
questionType
.
program
...
...
@@ -142,14 +176,12 @@ class InteractiveStudy extends Component {
:
status
.
resumePractice
return
{
processContent
:
state
.
processContent
.
concat
(
nextQuestion
),
progress
,
processStatus
,
isProgramShowed
:
processStatus
===
status
.
practicingProgram
&&
(
state
.
isProgramShowed
+
1
),
cachedList
,
pageData
,
}
},
()
=>
{
// console.log(this.state.processContent)
// console.log(this.state.cachedList)
this
.
updatePosition
()
})
}
...
...
@@ -185,10 +217,12 @@ class InteractiveStudy extends Component {
}
})
}
{
/*<Project user={this.singleIcon}/>*/
}
{
processStatus
===
status
.
nextSection
&&
<
Project
user
=
{
avatar
}
/
>
}
<
div
className
=
"status-bar"
onClick
=
{
this
.
process
}
>
{
processStatus
&&
<
span
className
=
{
'status'
}
>
{
processStatus
}
<
/span>
}
{
/*<span className={'complete'}>已学完全部课时</span>*/
}
<
span
className
=
{
'status'
}
>
{
processStatus
}
<
/span
>
{
/*<div className="free-trial-end">*/
}
{
/* <span>试学体验结束,389.1元学习全部课时</span>*/
}
{
/* <button className={'purchase'}>立即购买</button>*/
}
...
...
src/components/interactive-tutorial/program/index.js
View file @
f4d7f1c7
...
...
@@ -137,7 +137,7 @@ function ToolBar({isProgramShowed, userAnswer, isSuccessful, execute}) {
}
return
<
Finished
/>
}
return
isProgramShowed
?
<
Normal
/>
:
<
First
execute
=
{
execute
}
/
>
return
isProgramShowed
>
1
?
<
Normal
/>
:
<
First
execute
=
{
execute
}
/
>
}
export
default
Program
;
\ No newline at end of file
src/components/interactive-tutorial/terminal/index.js
View file @
f4d7f1c7
...
...
@@ -44,7 +44,12 @@ class TerminalInterface extends Component {
}
getAuthenticationData
=
()
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/ws/auth`
).
then
(
res
=>
{
http
.
post
(
`http://47.93.119.175:8888/auth`
,
{
username
:
'3guh394h3fhj0f4'
,
password
:
'okqdw029j038hrv3890cv'
,
},
{
withCredentials
:
false
}).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
this
.
getLinkId
(
data
.
token
)
...
...
@@ -55,7 +60,11 @@ class TerminalInterface extends Component {
}
getLinkId
=
token
=>
{
http
.
get
(
`
${
API
.
home
}
/sys/ws/connection/
${
token
}
`
).
then
(
res
=>
{
http
.
post
(
`http://47.93.119.175:8888`
,
{},
{
headers
:
{
Token
:
token
,
},
}).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
this
.
connectServer
(
data
.
id
)
...
...
@@ -77,11 +86,12 @@ class TerminalInterface extends Component {
console
.
log
(
event
.
message
)
this
.
terminal
.
write
(
event
.
data
)
}
this
.
socket
.
onerror
=
()
=>
{
console
.
log
(
'error'
)
this
.
socket
.
onerror
=
(
event
)
=>
{
console
.
log
(
event
)
}
this
.
socket
.
onclose
=
()
=>
{
this
.
socket
.
onclose
=
(
event
)
=>
{
console
.
log
(
'closed'
)
console
.
log
(
event
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment