diff --git a/public/react/src/App.js b/public/react/src/App.js index 942316bde..194d8f22f 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -37,7 +37,7 @@ import {MuiThemeProvider, createMuiTheme} from 'material-ui/styles'; import history from './history'; -import {SnackbarHOC} from 'educoder' +import {SnackbarHOC, configShareForIndex} from 'educoder' import {initAxiosInterceptors} from './AppConfig' @@ -326,22 +326,7 @@ class App extends Component { }); wx.ready(function () { console.log('wx is ready') - var shareData = { - title: 'EduCoder - 首页', - desc: 'Educoder是一个面向计算机类的互联网IT教育和实战平台,提供企业级工程实训,以实现工程化专业教学的自动化和智能化。高校和企业人员可以在此开展计算机实践性教学活动,将传统的知识传授和时兴的工程实战一体化。', - link: currentUrl, - imgUrl: window.__testImageUrl - || (currentUrl.endsWith('/') ? currentUrl : currentUrl + '/') + 'react/build/images/share_logo_icon.jpg' - }; - - wx.onMenuShareAppMessage(shareData);//分享给好友 - wx.onMenuShareTimeline(shareData);//分享到朋友圈 - wx.onMenuShareQQ(shareData);//分享给手机QQ - wx.onMenuShareWeibo(shareData);//分享腾讯微博 - wx.onMenuShareQZone(shareData);//分享到QQ空间 - - - + configShareForIndex() }); wx.error(function (res) { console.log('wx is error') diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 356a2f370..fcd0ba7e4 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -20,7 +20,7 @@ export { markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, ap downloadFile, sortDirections } from './TextUtil' export { handleDateString, getNextHalfHourOfMoment,formatDuring } from './DateUtil' -export { configShareForIndex, configShareForPaths, configShareForShixuns, configShareForCourses, configShareForSinglePath, configShareForSingleShixun } from './util/ShareUtil' +export { configShareForIndex, configShareForPaths, configShareForShixuns, configShareForCourses, configShareForCustom } from './util/ShareUtil' export { isDev as isDev, isMobile } from './Env' diff --git a/public/react/src/common/util/ShareUtil.js b/public/react/src/common/util/ShareUtil.js index 5b78b42e3..845297899 100644 --- a/public/react/src/common/util/ShareUtil.js +++ b/public/react/src/common/util/ShareUtil.js @@ -1,12 +1,17 @@ const host = window.location.host const wx = window.wx function share(shareData) { - wx.onMenuShareAppMessage(shareData);//分享给好友 - wx.onMenuShareTimeline(shareData);//分享到朋友圈 - wx.onMenuShareQQ(shareData);//分享给手机QQ - wx.onMenuShareWeibo(shareData);//分享腾讯微博 - wx.onMenuShareQZone(shareData);//分享到QQ空间 + try { + wx.onMenuShareAppMessage(shareData);//分享给好友 + wx.onMenuShareTimeline(shareData);//分享到朋友圈 + wx.onMenuShareQQ(shareData);//分享给手机QQ + wx.onMenuShareWeibo(shareData);//分享腾讯微博 + wx.onMenuShareQZone(shareData);//分享到QQ空间 + } catch(e) { + console.log(e) + } } + /** 实践课程 平台提供涵盖基础入门、案例实践和创新应用的完整实训项目体系,通过由浅入深的实训路径,帮助学生快速提升实战能力。 实训项目 覆盖不同专业的IT实验和实训,每周更新,无需配置本机实验环境,随时随地开启企业级真实实训。 @@ -15,6 +20,7 @@ function share(shareData) { */ export function configShareForIndex () { + if (!wx) return; var shareData = { title: 'EduCoder - 首页', desc: 'Educoder是一个面向计算机类的互联网IT教育和实战平台,提供企业级工程实训,以实现工程化专业教学的自动化和智能化。高校和企业人员可以在此开展计算机实践性教学活动,将传统的知识传授和时兴的工程实战一体化。', @@ -25,6 +31,7 @@ export function configShareForIndex () { share(shareData) } export function configShareForPaths () { + if (!wx) return; var shareData = { title: 'EduCoder - 实践课程', desc: '平台提供涵盖基础入门、案例实践和创新应用的完整实训项目体系,通过由浅入深的实训路径,帮助学生快速提升实战能力。', @@ -35,6 +42,7 @@ export function configShareForPaths () { share(shareData) } export function configShareForShixuns () { + if (!wx) return; var shareData = { title: 'EduCoder - 实训项目', desc: '覆盖不同专业的IT实验和实训,每周更新,无需配置本机实验环境,随时随地开启企业级真实实训。', @@ -45,6 +53,7 @@ export function configShareForShixuns () { share(shareData) } export function configShareForCourses () { + if (!wx) return; var shareData = { title: 'EduCoder - 翻转课堂', desc: '自动评测实训任务,支持技能统计,提供教学活动分析报告,减轻教师和助教的辅导压力,免去作业发布和批改的困扰,实时了解学生学习情况,全面提升教师施教效率和水平。', @@ -56,7 +65,8 @@ export function configShareForCourses () { } // detail -export function configShareForSinglePath (title, desc, path, imgUrl) { +export function configShareForCustom (title, desc, path, imgUrl) { + if (!wx) return; var shareData = { title: title, desc: desc, @@ -66,14 +76,3 @@ export function configShareForSinglePath (title, desc, path, imgUrl) { }; share(shareData) } - -export function configShareForSingleShixun (title, desc, path, imgUrl) { - var shareData = { - title: title, - desc: desc, - link: `${host}/${path}`, - imgUrl: imgUrl || window.__testImageUrl - || host + '/react/build/images/share_logo_icon.jpg' - }; - share(shareData) -} \ No newline at end of file diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 690baf28b..a60080379 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -12,7 +12,7 @@ import SiderBar from '../tpm/SiderBar'; import UpgradeModals from '../modals/UpgradeModals'; -import { SnackbarHOC , getImageUrl} from 'educoder'; +import { SnackbarHOC , getImageUrl, configShareForIndex} from 'educoder'; import Slider from '@icedesign/base/lib/slider'; @@ -37,6 +37,7 @@ class ShixunsHome extends Component { } } componentDidMount(){ + configShareForIndex() const upsystem=`/users/system_update.json`; axios.get(upsystem).then((response)=>{ let updata=response.data; diff --git a/public/react/src/modules/paths/ShixunPaths.js b/public/react/src/modules/paths/ShixunPaths.js index 3d20c86eb..c2bc0d869 100644 --- a/public/react/src/modules/paths/ShixunPaths.js +++ b/public/react/src/modules/paths/ShixunPaths.js @@ -1,12 +1,16 @@ import React, { Component } from 'react'; import PathSearch from './ShixunPathSearch.js'; - +import { configShareForPaths } from 'educoder' class ShixunPath extends Component{ constructor(props) { super(props) } + componentDidMount() { + configShareForPaths() + } + render(){ return(