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
e4490b83
Commit
e4490b83
authored
Dec 26, 2019
by
FE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
share in wechat
parent
f24b7235
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
13 deletions
+31
-13
src/components/pythonShare/index.js
+31
-13
No files found.
src/components/pythonShare/index.js
View file @
e4490b83
...
...
@@ -4,7 +4,7 @@ import {CopyToClipboard} from 'react-copy-to-clipboard';
import
AceEditor
from
'react-ace'
;
import
{
Toast
}
from
"antd-mobile"
import
{
HeaderBar
}
from
'@/common'
;
import
{
browser
,
http
,
getParam
}
from
'@/utils'
;
import
{
browser
,
http
,
getParam
,
wxShare
}
from
'@/utils'
;
import
'./index.scss'
;
import
'ace-builds/src-noconflict/mode-python'
;
import
'ace-builds/src-noconflict/theme-dracula'
;
...
...
@@ -80,13 +80,38 @@ class PythonClass extends Component {
})
}
handleToSend
=
()
=>
{
handleToSend
=
(
params
)
=>
{
const
{
history
}
=
this
.
props
;
const
{
isShare
,
entryMode
}
=
this
.
state
;
if
(
browser
.
isWeixin
)
{
this
.
setState
({
entryMode
:
1
});
history
.
push
(
`/pythonShare?id=
${
getParam
(
'id'
)}
&type=
${
getParam
(
'type'
)}
&ques=
${
getParam
(
'ques'
)}
&from=python`
);
history
.
replace
(
`/pythonShare?id=
${
getParam
(
'id'
)}
&type=
${
getParam
(
'type'
)}
&ques=
${
getParam
(
'ques'
)}
&from=python`
);
let
title
=
''
;
let
labelName
=
this
.
formatTitle
(
params
);
if
(
entryMode
!==
0
&&
!
isShare
)
{
title
=
`我在
${
params
.
course_name
}
的
${
labelName
}
遇到了困难`
;
}
if
(
entryMode
!==
0
&&
isShare
)
{
title
=
`我已在【
${
params
.
course_name
}
】上运行了行代码了
${
params
.
code_lines
}
`
}
wxShare
({
title
,
desc
:
labelName
,
link
:
encodeURI
(
location
.
href
),
imgUrl
:
params
.
course_img
,
});
}
}
formatTitle
=
(
params
)
=>
{
const
{
type
}
=
this
.
state
;
if
(
type
===
'1'
)
{
return
`练习-
${
params
.
ques_name
}
`
;
}
if
(
type
===
'2'
)
{
return
`课堂-
${
params
.
video_name
}
`
;
}
}
...
...
@@ -110,7 +135,7 @@ class PythonClass extends Component {
}
render
()
{
const
{
isWechat
,
isShare
,
isExecute
,
type
,
entryMode
,
command
,
isCopy
,
data
}
=
this
.
state
;
const
{
isWechat
,
isShare
,
isExecute
,
entryMode
,
command
,
isCopy
,
data
}
=
this
.
state
;
return
(
<>
<
HeaderBar
...
...
@@ -121,12 +146,12 @@ class PythonClass extends Component {
<
PythonContent
isWechat
=
{
isWechat
}
isShare
=
{
isShare
}
type
=
{
type
}
isExecute
=
{
isExecute
}
entryMode
=
{
entryMode
}
isCopy
=
{
isCopy
}
command
=
{
command
}
data
=
{
data
}
labelName
=
{
this
.
formatTitle
(
data
)}
handleToExecute
=
{
this
.
handleToExecute
}
handleToSend
=
{
this
.
handleToSend
}
copyToSuccess
=
{
this
.
copyToSuccess
}
...
...
@@ -158,23 +183,16 @@ function PythonContent(props) {
isWechat
,
isShare
,
isExecute
,
type
,
entryMode
,
isCopy
,
command
,
labelName
,
data
:
{
head_img
,
nickname
,
code_lines
,
code
,
result
,
ques_name
,
course_name
,
course_id
,
video_name
},
handleToSend
,
copyToSuccess
,
handleToExecute
,
handleToHide
}
=
props
;
let
labelName
=
''
;
if
(
type
===
'1'
)
{
labelName
=
`练习-
${
ques_name
}
`
;
}
if
(
type
===
'2'
)
{
labelName
=
`课堂-
${
video_name
}
`
;
}
return
(
<
div
className
=
"python-container"
>
...
...
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