提交 2e7719de authored 作者: 王鹏飞's avatar 王鹏飞

移除node,调整接口

上级 0efd66b8
module.exports = {
demain: 'dev.ezijing.com',
url: 'http://dev.ezijing.com:4006/api',
// apiBaseURL: '//demo-login.ezijing.com/'
url: 'https://wmp-learning2.ezijing.com/api',
apiBaseURL: '/',
others: {
url: '/login/is-login'
},
webpack: {
externals: {
'CKEDITOR': 'window.CKEDITOR',
'VideoJs': 'window.swfobject',
'Base64': 'window.Base64',
'md5': 'window.md5',
'regeneratorRuntime': 'window.regeneratorRuntime',
'$': 'window.$',
'Aliplayer': 'window.Aliplayer',
'AliPlayerComponent': 'window.AliPlayerComponent'
CKEDITOR: 'window.CKEDITOR',
VideoJs: 'window.swfobject',
Base64: 'window.Base64',
md5: 'window.md5',
regeneratorRuntime: 'window.regeneratorRuntime',
$: 'window.$',
Aliplayer: 'window.Aliplayer',
AliPlayerComponent: 'window.AliPlayerComponent'
// 'sentNotify': 'window.sentNotify',
}
},
ProvidePlugin: {
}
ProvidePlugin: {}
}
......@@ -39,6 +39,7 @@ export default class OtherAction extends BaseACTION {
* 当前登录用户,检测是否该系统有权限
*/
getInfo () { return Other.getInfo().then(res => res) }
getUser () { return Other.getUser().then(res => res) }
examAutoLogin (obj) { return Other.examAutoLogin(obj).then(res => res) }
/* 调用退出登录接口 */
......
......@@ -4,11 +4,11 @@ export default class AffairsAPI extends BaseAPI {
/**
* 获取事务类型
*/
getAffairsType = () => this.get('/v2/lobby/affairs')
getAffairsType = () => this.get('/api/lms/v2/lobby/affairs')
/**
* 获取事务类型
*/
getAffairsData = (obj = {}) => this.get('/v2/lobby/processes', obj)
getAffairsData = (obj = {}) => this.get('/api/lms/v2/lobby/processes', obj)
/**
* 提交活动申请
* affair_id 活动名称
......@@ -20,13 +20,13 @@ export default class AffairsAPI extends BaseAPI {
* symposium_lecturer
* 返回 {'flag' : true, 'errors' : []}
*/
submitLearning = (obj = {}) => this.post('/v2/lobby/processes', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
submitLearning = (obj = {}) => this.post('/api/lms/v2/lobby/processes', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/* 删除事务 */
deleteAffairs = (reid) => this.delete(`/v2/lobby/processes/${reid}`, {})
deleteAffairs = (reid) => this.delete(`/api/lms/v2/lobby/processes/${reid}`, {})
/* 获取事务详情 */
getAffairsDetails = (rid) => this.get(`/v2/lobby/processes/${rid}`, {})
getAffairsDetails = (rid) => this.get(`/api/lms/v2/lobby/processes/${rid}`, {})
/* 修改事务 */
updateAffairs = (rid, obj = {}) => this.post(`/v2/lobby/processes/${rid}`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updateAffairs = (rid, obj = {}) => this.post(`/api/lms/v2/lobby/processes/${rid}`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/* 重修图片提交 */
uploadFile = (obj = {}) => this.post('/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) => this.post('/api/lms/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -105,7 +105,7 @@ export default class API {
if (!/account\/get-user-info/gi.test(res.config.url)) {
Message({ type: 'error', message: data.msg })
}
return null
return data
} else if (data.code === 0) {
return data.data
}
......
......@@ -4,31 +4,31 @@ export default class CourseAPI extends BaseAPI {
/**
* 获取学期分类信息
*/
getLearnFind = () => this.get('/v2/education/semesters', {})
getLearnFind = () => this.get('/api/lms/v2/education/semesters', {})
/**
* 获取所有课程列表 - 选课广场 和 我的课程 共用同一个,通过 isMy判断
* @param {[string]} isMy
* @param {[object]} param
*/
getCourseList = (isMy, param) => this.get('/v2/education/courses' + (isMy ? '/my' : ''), param)
getCourseList = (isMy, param) => this.get('/api/lms/v2/education/courses' + (isMy ? '/my' : ''), param)
/**
* 获取某个课程详细信息 - 课程考核 和 课程讨论单独获取
* @param {[string]} id
*/
getCourseDetail = (id, sid) => this.get(`/v2/education/courses/${id}`, {})
getCourseDetail = (id, sid) => this.get(`/api/lms/v2/education/courses/${id}`, {})
/**
* 获取课程考核信息
* @param {[string]} cid
*/
getCourseAssess = (cid, sid) => this.get(`/v2/analytics/courses/${cid}/evaluation`, {})
getCourseAssess = (cid, sid) => this.get(`/api/lms/v2/analytics/courses/${cid}/evaluation`, {})
/**
* 选课
* @param {[string]} cid
*/
selectCourse = (cid, sid) => this.post('/v2/education/courses/major', { course_id: cid })
selectCourse = (cid, sid) => this.post('/api/lms/v2/education/courses/major', { course_id: cid })
/**
* 退课
* @param {[string]} cid
*/
outSelectCourse = (cid, sid) => this.post('/v2/education/courses/drop', { course_id: cid })
outSelectCourse = (cid, sid) => this.post('/api/lms/v2/education/courses/drop', { course_id: cid })
}
......@@ -8,7 +8,7 @@ export default class DiscussAPI extends BaseAPI {
* @param {[string]} path
* @param {[object]} dataJson
*/
getDiscussList = (path, dataJson) => this.get('/v2/qa/questions' + path, dataJson)
getDiscussList = (path, dataJson) => this.get('/api/lms/v2/qa/questions' + path, dataJson)
/**
* 获取讨论题目列表,“课程的问题”信息
* dataJson.limit - 获取数量
......@@ -17,50 +17,50 @@ export default class DiscussAPI extends BaseAPI {
* @param {[string]} cid
* @param {[object]} dataJson
*/
getCourseDiscussList = (cid, sid, dataJson) => this.get(`/v2/qa/questions/course/${cid}`, dataJson)
getCourseDiscussList = (cid, sid, dataJson) => this.get(`/api/lms/v2/qa/questions/course/${cid}`, dataJson)
/**
* 获取问题详情
* @param {[string]} qid
*/
getDiscussDetail = (qid) => this.get(`/v2/qa/questions/${qid}`, {})
getDiscussDetail = (qid) => this.get(`/api/lms/v2/qa/questions/${qid}`, {})
/**
* 删除提问
* @param {[string]} qid
*/
deleteDiscuss = (qid) => this.delete(`/v2/qa/questions/${qid}`, {})
deleteDiscuss = (qid) => this.delete(`/api/lms/v2/qa/questions/${qid}`, {})
/**
* 提出问题
* @param {[object]} param
*/
publishQues = (param) => this.post('/v2/qa/questions', param, { headers: { 'Content-Type': 'multipart/form-data' } })
publishQues = (param) => this.post('/api/lms/v2/qa/questions', param, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 回答问题
* @param {[object]} param
*/
answerQues = (param) => this.post('/v2/qa/answers', param, { headers: { 'Content-Type': 'application/json' } })
answerQues = (param) => this.post('/api/lms/v2/qa/answers', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 删除回答
* @param {[string]} aid
*/
deleteAnswer = (aid) => this.delete(`/v2/qa/answers/${aid}`, {})
deleteAnswer = (aid) => this.delete(`/api/lms/v2/qa/answers/${aid}`, {})
/**
* 回复评论
* @param {[object]} param
*/
callbackComment = (param) => this.post('/v2/qa/comments', param, { headers: { 'Content-Type': 'application/json' } })
callbackComment = (param) => this.post('/api/lms/v2/qa/comments', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 删除评论
* @param {[string]} cid
*/
deleteComment = (cid) => this.delete(`/v2/qa/comments/${cid}`)
deleteComment = (cid) => this.delete(`/api/lms/v2/qa/comments/${cid}`)
/**
* 点赞
* @param {[object]} param
*/
like = (param) => this.post('/v2/qa/tags', param, { headers: { 'Content-Type': 'application/json' } })
like = (param) => this.post('/api/lms/v2/qa/tags', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 取消点赞
* @param {[string]} tagid
*/
unlike = (tagid) => this.delete(`/v2/qa/tags/${tagid}`, {})
unlike = (tagid) => this.delete(`/api/lms/v2/qa/tags/${tagid}`, {})
}
......@@ -4,22 +4,22 @@ export default class FeedbackAPI extends BaseAPI {
/**
* 提交 重修课程
*/
submitRebuild = (obj = {}) => this.post('/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
submitRebuild = (obj = {}) => this.post('/api/lms/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 获取意见列表
* type_id [int]
* page [int]
* pageSize [int]
*/
feedbackList = (obj = {}) => this.get('/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackList = (obj = {}) => this.get('/api/lms/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈回复
* feedback_id [int]
* contents [string]
*/
feedbackReply = (obj = {}) => this.post('/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackReply = (obj = {}) => this.post('/api/lms/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈提交
*/
feedbackCommit = (obj = {}) => this.post('/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackCommit = (obj = {}) => this.post('/api/lms/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -4,26 +4,26 @@ export default class GradeAPI extends BaseAPI {
/**
* 获取我的学分信息
*/
getCredit = () => this.get('/v2/education/credits', {})
getCredit = () => this.get('/api/lms/v2/education/credits', {})
/**
* 提交 重修课程
*/
submitRebuild = (obj = {}) => this.post('/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
submitRebuild = (obj = {}) => this.post('/api/lms/v2/education/retake', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 获取意见列表
* type_id [int]
* page [int]
* pageSize [int]
*/
feedbackList = (obj = {}) => this.get('/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackList = (obj = {}) => this.get('/api/lms/v2/feedback/lists', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈回复
* feedback_id [int]
* contents [string]
*/
feedbackReply = (obj = {}) => this.post('/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackReply = (obj = {}) => this.post('/api/lms/v2/feedback/reply', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 意见反馈提交
*/
feedbackCommit = (obj = {}) => this.post('/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
feedbackCommit = (obj = {}) => this.post('/api/lms/v2/feedback/commit', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -3,42 +3,83 @@ import _ from 'lodash'
export default class OtherAPI extends BaseAPI {
/**
* 当前登录用户,检测是否该系统有权限
*/
getInfo = () => this.post('/user/getinfo', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
* 当前登录用户,检测是否该系统有权限
* /user_center/get_user_info
*/
getInfo = () =>
this.get(
'/api/lms/user/check-access',
{},
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
/**
* 当前登录用户,检测是否该系统有权限
* /user_center/get_user_info
*/
getUser = () =>
this.get(
'/api/passport/account/get-user-info',
{},
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
/**
* 获取我的消息信息
*/
getMyMsg = (obj = {}) => this.get('/v2/education/message/my', obj, {})
getMyMsg = (obj = {}) => this.get('/api/lms/v2/education/message/my', obj, {})
/* 支持三方登录 */
examAutoLogin = (obj) => this.post('/util/kaosx', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
examAutoLogin = (obj) =>
this.post('/api/passport/util/kaosx', obj, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
/**
* 标记已读未读
*/
setMyMsg = (rid) => this.post(`/v2/education/message/${rid}`, {})
getNavMsg = (rid) => this.get(`/v2/education/message/num?v=${new Date().getTime()}`, {})
setMyMsg = (rid) => this.post(`/api/lms/v2/education/message/${rid}`, {})
getNavMsg = (rid) =>
this.get(`/api/lms/v2/education/message/num?v=${new Date().getTime()}`, {})
/**
* wmp标记已读未读
*/
setMsgWmp = (rid) => this.get(`/v2/education/message/read/${rid}`, {})
setMsgWmp = (rid) => this.get(`/api/lms/v2/education/message/read/${rid}`, {})
/**
* 调用退出登录
*/
outLogin = () => this.post('/user_center/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
outLogin = () => this.get('/api/passport/rest/logout')
/**
* 文件提交
* @param {[object]} obj
*/
uploadFile = (obj = {}) => this.post('/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) =>
this.post('/api/sso//util/upload-file', obj, {
headers: { 'Content-Type': 'multipart/form-data' }
})
/**
* 个人信息 - 修改密码
* @param {[string]} obj.old_password 验证码
* @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 这里 一直是定值 h5.ezijing.com
*/
updatePwd = (obj = {}) => this.post('/user_center/change_password', _.assignIn(obj, { service: 'h5.ezijing.com' }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
updatePwd = (obj = {}) =>
this.post(
'/api/usercenter/user/change-pwd-by-cookie',
_.assignIn(obj, { service: 'h5.ezijing.com' }),
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
/**
* 个人信息 - 上传头像
*/
updatePic = (obj = {}) => this.post('/v3/storage/upload/avatar', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updatePic = (obj = {}) =>
this.post('/api/sso/v3/storage/upload/avatar', obj, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
......@@ -6,23 +6,23 @@ export default class PlayerAPI extends BaseAPI {
* @param {[string]} cur_course_id -> cid
* @param {[string]} cur_video_id -> vid
*/
getChapterList = (cid, sid, vid) => this.get(`/v2/education/courses/${cid}`, {})
getChapterList = (cid, sid, vid) => this.get(`/api/lms/v2/education/courses/${cid}`, {})
/**
* 获取对应某个章节的详细信息
* @param {[string]} vid
*/
getCurrentChapterDetail = (vid) => this.post('/v2/education/video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
getCurrentChapterDetail = (vid) => this.post('/api/lms/v2/education/video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取对应某个章节的详细信息
* @param {[string]} vid
*/
getCurrentChapterDetailAliyun = (vid) => this.post('/v2/education/aliyun-video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
getCurrentChapterDetailAliyun = (vid) => this.post('/api/lms/v2/education/aliyun-video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取进度信息
* @param {[string]} vid
* @param {[string]} did
*/
getProgress = (vid, did, sid) => this.get(`/v2/education/video/${vid}/device`, { device_id: did })
getProgress = (vid, did, sid) => this.get(`/api/lms/v2/education/video/${vid}/device`, { device_id: did })
/**
* 提交进度信息
* @param {[object]} obj
......@@ -35,69 +35,69 @@ export default class PlayerAPI extends BaseAPI {
_m: obj.mpt, // 当前播放最大时间
_c: obj.cpt // 当前播放位置
*/
updateProgress = (obj = {}) => this.get('/v2/analytics/upload-video', obj)
updateProgress = (obj = {}) => this.get('/api/lms/v2/analytics/upload-video', obj)
/**
* 获取试题信息
* @param {[string]} eid
*/
getExamDetail = (sid, cid, eid) => this.get(`/v2/education/homeworks/${eid}`, {})
getExamDetail = (sid, cid, eid) => this.get(`/api/lms/v2/education/homeworks/${eid}`, {})
/**
* 提交考试信息
* @param {[object]} param
*/
submitExamDetail = (param) => this.post('/v2/education/homeworks', param, { headers: { 'Content-Type': 'application/json' } })
submitExamDetail = (param) => this.post('/api/lms/v2/education/homeworks', param, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取试题信息 - 课程后考试
* @param {[string]} eid
*/
getExamDetailAfterCourse = (sid, cid, eid) => this.get(`/v2/education/examinations/${cid}/${eid}`, {})
getExamDetailAfterCourse = (sid, cid, eid) => this.get(`/api/lms/v2/education/examinations/${cid}/${eid}`, {})
/**
* 提交考试信息 - 课程后考试
* @param {[object]} param
*/
submitExamDetailAfterCourse = (param) => this.post('/v2/education/examinations', param)
submitExamDetailAfterCourse = (param) => this.post('/api/lms/v2/education/examinations', param)
/**
* 获取对应 作业或问题 回答
* @param {[string]} id resource_id
*/
getHomework = (sid, cid, id) => this.get(`/v2/education/homeworks/${id}`, {})
getHomework = (sid, cid, id) => this.get(`/api/lms/v2/education/homeworks/${id}`, {})
/**
* 文件提交
* @param {[object]} obj
*/
uploadFile = (obj = {}) => this.post('/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) => this.post('/api/sso/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 提交课程 作业或问题
*/
updateHomework = (obj = {}) => this.post('/v2/education/homeworks', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updateHomework = (obj = {}) => this.post('/api/lms/v2/education/homeworks', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 课程作业截止时间
*/
getHomeworkStopTime = (sid, cid, chapterId) => this.get(`/v2/education/homeworks/${sid}/${cid}/${chapterId}/deadline`, {})
getHomeworkStopTime = (sid, cid, chapterId) => this.get(`/api/lms/v2/education/homeworks/${sid}/${cid}/${chapterId}/deadline`, {})
/**
* 获取对应 大作业 回答
* @param {[string]} cid
*/
getCourseHomework = (sid, cid) => this.get(`/v2/education/courses/${cid}/essay`, {})
getCourseHomework = (sid, cid) => this.get(`/api/lms/v2/education/courses/${cid}/essay`, {})
/**
* 提交课程 大作业
* @param {[string]} cid
*/
updateCourseHomework = (sid, cid, obj = {}) => this.post(`/v2/education/courses/${cid}/essay`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
updateCourseHomework = (sid, cid, obj = {}) => this.post(`/api/lms/v2/education/courses/${cid}/essay`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
/**
* 提交 课程考核
* @param {[string]} obj.cid
* @param {[string]} obj.raw (base64)
*/
updateSurveyAnswer = (obj) => this.post('/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } })
updateSurveyAnswer = (obj) => this.post('/api/lms/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 手机端 获取实时最新直播接口
*/
getNewLiveMsg = (obj = {}) => this.get('/v2/education/lives/latest', obj)
getNewLiveMsg = (obj = {}) => this.get('/api/lms/v2/education/lives/latest', obj)
/**
* 手机端 获取列表接口
*/
getLiveList = (obj = {}) => this.get('/v2/education/lives/courses', obj)
getLiveList = (obj = {}) => this.get('/api/lms/v2/education/lives/courses', obj)
/**
* 跨域接口请求 - 直接获取云课堂设置
*/
......
......@@ -4,11 +4,11 @@ export default class ReportAPI extends BaseAPI {
/**
* 获取所有通过报告列表
*/
getReportList = () => this.get('/v2/education/symposium-report-all', {})
getReportList = () => this.get('/api/lms/v2/education/symposium-report-all', {})
/**
* 获取我的学术活动
*/
getReportActiveList = () => this.get('/v2/education/symposium/my', {})
getReportActiveList = () => this.get('/api/lms/v2/education/symposium/my', {})
/**
* 提交活动申请
* symposium_name 活动名称
......@@ -19,53 +19,53 @@ export default class ReportAPI extends BaseAPI {
* symposium_address 活动地点
* 返回 {'flag' : true, 'errors' : []}
*/
submitReportActive = (obj = {}) => this.post('/v2/education/symposium', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
submitReportActive = (obj = {}) => this.post('/api/lms/v2/education/symposium', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 获取学术活动详情
*/
getReportActive = (rid) => this.get(`/v2/education/symposium/${rid}`, {})
getReportActive = (rid) => this.get(`/api/lms/v2/education/symposium/${rid}`, {})
/**
* 修改活动申请
* 参数同上
*/
updateReportActive = (rid, obj = {}) => this.post(`/v2/education/symposium/${rid}`, obj, { headers: { 'Content-Type': 'application/json' } })
updateReportActive = (rid, obj = {}) => this.post(`/api/lms/v2/education/symposium/${rid}`, obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 删除活动申请
* 参数同上
*/
deleteReportActive = rid => this.delete(`/v2/education/symposium/${rid}`, {})
deleteReportActive = rid => this.delete(`/api/lms/v2/education/symposium/${rid}`, {})
/**
* 获取活动相关的学术报告
*/
getReportListAll = (rid) => this.get(`/v2/education/symposium/${rid}/report`, {})
getReportListAll = (rid) => this.get(`/api/lms/v2/education/symposium/${rid}/report`, {})
/**
* 提交学术报告
* report_name 报告名称
* report_description 报告描述
* file_url 文章URL
*/
submitReport = (rid, obj = {}) => this.post(`/v2/education/symposium/${rid}/report`, obj, { headers: { 'Content-Type': 'application/json' } })
submitReport = (rid, obj = {}) => this.post(`/api/lms/v2/education/symposium/${rid}/report`, obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 获取学术报告详情
*/
getSubmitReport = (rid, reid) => this.get(`/v2/education/symposium/report/${reid}`, {})
getSubmitReport = (rid, reid) => this.get(`/api/lms/v2/education/symposium/report/${reid}`, {})
/**
* 更新学术报告
*/
updateSubmitReport = (rid, reid, obj = {}) => this.post(`/v2/education/symposium/${rid}/report/${reid}`, obj)
updateSubmitReport = (rid, reid, obj = {}) => this.post(`/api/lms/v2/education/symposium/${rid}/report/${reid}`, obj)
/**
* 删除学术报告
* 参数同上
*/
deleteSubmitReport = (rid, reid) => this.delete(`/v2/education/symposium/report/${reid}`, {})
deleteSubmitReport = (rid, reid) => this.delete(`/api/lms/v2/education/symposium/report/${reid}`, {})
/**
* 获取事务类型
*/
getAffairsType = () => this.get('/v2/lobby/affairs')
getAffairsType = () => this.get('/api/lms/v2/lobby/affairs')
/**
* 获取事务类型
*/
getAffairsData = (obj = {}) => this.get('/v2/lobby/processes', obj)
getAffairsData = (obj = {}) => this.get('/api/lms/v2/lobby/processes', obj)
/**
* 提交活动申请
* affair_id 活动名称
......@@ -77,13 +77,13 @@ export default class ReportAPI extends BaseAPI {
* symposium_lecturer
* 返回 {'flag' : true, 'errors' : []}
*/
submitLearning = (obj = {}) => this.post('/v2/lobby/processes', obj)
submitLearning = (obj = {}) => this.post('/api/lms/v2/lobby/processes', obj)
/* 删除事务 */
deleteAffairs = (reid) => this.delete(`/v2/lobby/processes/${reid}`, {})
deleteAffairs = (reid) => this.delete(`/api/lms/v2/lobby/processes/${reid}`, {})
/* 获取事务详情 */
getAffairsDetails = (rid) => this.get(`/v2/lobby/processes/${rid}`, {})
getAffairsDetails = (rid) => this.get(`/api/lms/v2/lobby/processes/${rid}`, {})
/* 修改事务 */
updateAffairs = (rid, obj = {}) => this.post(`/v2/lobby/processes/${rid}`, obj)
updateAffairs = (rid, obj = {}) => this.post(`/api/lms/v2/lobby/processes/${rid}`, obj)
/* 重修图片提交 */
uploadFile = (obj = {}) => this.post('/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
uploadFile = (obj = {}) => this.post('/api/lms/v2/lobby/tools/upload', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -3,36 +3,61 @@ import cAction from '@action'
import { Message } from 'element-ui'
export default class Before {
constructor (opt) {
constructor(opt) {
const UA = navigator.userAgent
this.opt = opt || {}
// 免登录列表
this.whiteList = [
'login-normal',
'login-code',
'login-forget',
'studentHelp',
'teacherHelp'
]
this.isMobile = /android|iphone|ipad|ipod/i.test(UA)
}
async update (to, from, next) {
if (to.name === 'studentHelp' || to.name === 'teacherHelp') {
next()
} else if (to.name !== 'login-normal' && to.name !== 'login-code' && to.name !== 'login-forget') { // 所有登录页 不进行登录校验
const isLogin = await this.isLogin()
if (isLogin) {
next()
} else {
next({ path: '/login/index?rd=' + encodeURIComponent(to.fullPath) }) // 需要传参并再传回来
}
} else {
async update(to, from, next) {
// 免登录页面
if (this.whiteList.includes(to.name)) {
next()
return
}
// 检测登录状态
const isLogin = await this.isLogin()
if (!isLogin) {
next({
path: '/login/index',
query: { rd: encodeURIComponent(to.fullPath) }
})
return
}
// 移动端
if (this.isMobile && to.name !== 'mobileIndex') {
next({ path: '/mobile/list' })
return
}
next()
}
/* 获取用户信息 */
isLogin () {
isLogin() {
if (window.G.UserInfo) return true
return cAction.Other.getInfo().then(res => {
window.G.UserInfo = res
return true
}).catch(res => {
if (res.code !== 0) {
Message({ type: 'error', message: res.message })
}
return false
})
return Promise.all([cAction.Other.getInfo(), cAction.Other.getUser()])
.then(([p1, p2]) => {
const res = { student_info: p1, data: p2 }
if (res.data.id) {
window.G.UserInfo = res
return true
} else {
return false
}
})
.catch((res) => {
if (res.code !== 80201) {
Message({ type: 'error', message: res.message })
}
return false
})
}
}
......@@ -7,42 +7,42 @@ export default class LoginAPI extends BaseAPI {
* @param {[string]} obj.password 密码 md5加密
* @param {[string]} obj.service 传当前域名
*/
userLogin = (obj = {}) => this.post('/user_center/login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
userLogin = (obj = {}) => this.post('/api/passport/rest/login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 调用退出登录
*/
outLogin = () => this.get('/user_center/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
outLogin = () => this.get('/api/passport/rest/logout', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 当前登录用户,检测是否该系统有权限
*/
getInfo = () => this.get('/user/getinfo', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
getInfo = () => this.get('/api/passport/account/get-user-info', {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 发送验证码
* @param {[string]} obj.mobile 手机号
* @param {[string]} obj.service 传当前域名
*/
sendCode = (obj = {}) => this.post('/user_center/send_login_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
sendCode = (obj = {}) => this.post('/api/usercenter/user/send-code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 验证码登录
* @param {[string]} obj.mobile 手机号
* @param {[string]} obj.code 验证码
* @param {[string]} obj.service 传当前域名
*/
codeLogin = (obj = {}) => this.post('/user_center/code_login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
codeLogin = (obj = {}) => this.post('/api/passport/user_center/code_login', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 发送重置密码验证码
* @param {[string]} obj.contact 手机号/邮箱
* @param {[string]} obj.source_type 值为 3
* @param {[string]} obj.service 传当前域名
*/
sendResetPwdCode = (obj = {}) => this.post('/user_center/send_reset_password_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
sendResetPwdCode = (obj = {}) => this.post('/api/usercenter/user/send-code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 重置密码验证码确认
* @param {[string]} obj.contact 手机号/邮箱
* @param {[string]} obj.code 验证码
* @param {[string]} obj.service 传当前域名
*/
validateCode = (obj = {}) => this.post('/user_center/validate_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
validateCode = (obj = {}) => this.post('/api/passport/user_center/validate_code', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 重置密码
* @param {[string]} obj.contact 手机号/邮箱
......@@ -50,14 +50,14 @@ export default class LoginAPI extends BaseAPI {
* @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 传当前域名
*/
resetPwd = (obj = {}) => this.post('/user_center/reset_password', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
resetPwd = (obj = {}) => this.post('/api/passport/user_center/reset_password', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 个人信息 - 修改密码
* @param {[string]} obj.old_password 验证码
* @param {[string]} obj.new_password 新的密码
* @param {[string]} obj.service 传当前域名
*/
updatePwd = (obj = {}) => this.post('/user_center/change_password', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
updatePwd = (obj = {}) => this.post('/api/usercenter/user/change-pwd-by-cookie', obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
/**
* 清空所有cookies
*/
......
......@@ -193,11 +193,8 @@ export default {
/* 发送验证码 */
sendCode () {
if (!this.isSendCode) {
Login.sendResetPwdCode({
contact: this.accountSet.account,
source_type: 3
}).then(res => {
if (res.status === 200) {
Login.sendResetPwdCode({ account: this.accountSet.account }).then(res => {
if (res.code === 0) {
/* 发送验证码不管是否成功,都开始倒计时 */
let time = 60
this.isSendCode = true
......
......@@ -66,11 +66,11 @@ export default {
if (valid) {
Login.userLogin({
/* 老版登录 */
login_name: this.setAccount.user,
password: md5('uokoaduw' + this.setAccount.pwd.split('').reverse().join('') + 'auhgniq'),
// login_name: this.setAccount.user,
// password: md5('uokoaduw' + this.setAccount.pwd.split('').reverse().join('') + 'auhgniq'),
/* 新版登录 */
account: this.setAccount.user,
// password: this.setAccount.pwd,
password: this.setAccount.pwd,
type: 1,
RememberMe: this.setAccount.isRemember ? 'true' : 'false',
service: window.location.origin
......
......@@ -68,16 +68,16 @@ export default {
actionName: 'Other',
functionName: 'updatePwd',
data: {
old_password: md5('uokoaduw' + this.accountSetPwd.oldPwd.split('').reverse().join('') + 'auhgniq'),
new_password: this.accountSetPwd.newPwdAgain
// old_password: md5('uokoaduw' + this.accountSetPwd.oldPwd.split('').reverse().join('') + 'auhgniq'),
old_password: this.accountSetPwd.oldPwd,
password: this.accountSetPwd.newPwd,
passwordR: this.accountSetPwd.newPwdAgain
},
thenCallback: data => {
if (data.status === 200) {
if (data.code === 0) {
/* 重置密码 */
this.$refs.setpwdform.resetFields()
this.$message.success('密码修改成功')
} else {
this.$message.error(data.message)
}
},
catchCallback: () => {},
......
......@@ -203,7 +203,7 @@ export default [
},
{
path: 'list',
name: 'list',
name: 'mobileIndex',
component: () => import('@/pages/mobileLive/list.vue'),
props: true
},
......
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"js-cookie": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz",
"integrity": "sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ=="
},
"js-md5": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
"integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
},
"vuex": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.3.tgz",
"integrity": "sha512-k8vZqNMSNMgKelVZAPYw5MNb2xWSmVgCKtYKAptvm9YtZiOXnRXFWu//Y9zQNORTrm3dNj1n/WaZZI26tIX6Mw=="
}
}
}
# 查到当前目录就可以了,不用再往下查找
root = true
# 对所有文件制定规范
[*]
charset = utf-8 # 字符编码
end_of_line = lf # 从左往右写
indent_size = 2 # tab键长度2个空格
indent_style = space
insert_final_newline = true # 保存自动加上一个空行
trim_trailing_whitespace = true # 每行最后空格去掉
{
"extends": "standard",
"plugins": [
"html"
],
"parser": "babel-eslint",
"rules": {
"no-new": "off",
"no-debugger": "off"
},
"globals": {
"window": false,
"$": false,
"webConf": false
}
}
.DS_Store
node_modules
npm-debug.log
server-dist
node-dist
dist
dist.zip
# code protect - prevent submit code below
.vscode
PC-server-1.0.3 / 2019-10-22
==================
* 追加 视频错误信息采集、本地JS报错信息采集。
PC-server-1.0.2 / 2019-10-15
==================
* 修改 目录文件查询,增加文件大小
PC-server-1.0.1 / 2019-10-08
==================
* 追加 服务端 采集 客户端 上报的 视频播放错误。
PC-server-1.0.0 / 2019-08-26
==================
* 拆分 分离 服务端。
# 根据项目框架 - 记录新增模块 与 修改
* adm-zip - npm 模块安装
* form-data - npm 模块安装
* axios - npm 模块安装
* promise.prototype.finally - npm 模块安装
* 修改 package.json 中 端口号
* 修改 package.json 中 项目名
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "nodejs",
"version": "1.0.0",
"description": "enterprise-wmp - 学习系统",
"main": "index.js",
"scripts": {
"lint": "eslint --ext .js server/",
"lint:fix": "eslint --fix --ext .js server/",
"deploy:test": "cross-env NODE_ENV=test SERVER_PORT=3502 pm2 start ./server/distRun.js -i 1 -n elearning-enterprise-wmp -o upload_tmp/pm2_elearning-enterprise-wmp.stdout.log -e upload_tmp/pm2_elearning-enterprise-wmp.stderr.log --log-date-format 'YYYY-MM-DD HH:mm Z'",
"deploy": "cross-env NODE_ENV=production SERVER_PORT=3502 pm2 start ./server/distRun.js -i 2 -n elearning-enterprise-wmp -o /data/logs/pm3/elearning-enterprise-wmp/pm2_elearning-enterprise-wmp.stdout.log -e /data/logs/pm3/elearning-enterprise-wmp/pm2_elearning-enterprise-wmp.stderr.log --log-date-format 'YYYY-MM-DD HH:mm Z'",
"reload": "pm2 reload elearning-enterprise-wmp"
},
"author": "ZYX",
"license": "ISC",
"eslintIgnore": [
"build/"
],
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0"
},
"dependencies": {
"@god/node-com": "^1.1.4",
"adm-zip": "^0.4.13",
"axios": "^0.19.0",
"body-parser": "^1.18.3",
"child_process": "^1.0.2",
"connect-history-api-fallback": "^1.6.0",
"cors": "^2.8.5",
"cross-env": "^5.2.0",
"express": "^4.16.4",
"form-data": "^2.5.0",
"multer": "^1.4.1",
"promise.prototype.finally": "^3.1.1"
}
}
const state = process.env.NODE_ENV
let conf = {}
if (state === 'test') {
conf.agentApiUrl = 'https://api2.ezijing.com/'
conf.apiKey = 'ITol9gsbkEb85gnaxIu7oWfHDOaKgwbH'
conf.host = 'wmp-api2.ezijing.com'
} else if (state === 'production') {
conf.agentApiUrl = 'https://zapi.ezijing.com/'
conf.apiKey = 'ITol9gsbkEb85gnaxIu7oWfHDOaKgwbH'
conf.host = 'wmp-api.ezijing.com'
}
global.app = null
module.exports = conf
const fs = require('fs')
const path = require('path')
const _cpro = require('child_process')
const com = require('@god/node-com')
const md5 = com.Tool.MD5
/**
* 目录结构操作,删除查询
* 0: delete, 删除;
* 1: list, 查询;
* 2: create, 创建;
* 3: readfile, 文件;
* 4: searchinfo, 直接根据姓名,搜索对应目录,并返回该目录下,info.txt文件中 所有内容
* 5: searchlogvideo, 根据姓名,搜索参数(video目录+vid)所有该人员所有观看记录
* 9: get-md5, 获取md5字符串, 鉴权使用;
*/
const dirOperate = (req, res) => {
let operate = req.body.operate || ''
let timestamp = Math.floor(new Date().getTime() / 100000000) + '00000000'
let md5Str = md5('ezijing.com' + timestamp)
if (operate === '9') { res.status(200).json({ 'timestamp': timestamp, 'MD5-auth': md5Str }); return }
let auth = req.headers.auth || ''
if (auth === md5Str) {
_executeOperate(req, res)
} else {
res.status(200).json({ 'msg': '没有权限 访问该接口' })
}
}
/**
* 根据 对应参数,执行
* @param {*} req 请求参数
* @param {*} res 返回参数
*/
const _executeOperate = (req, res) => {
let dir = req.body.dir || ''
let operate = req.body.operate || ''
let json = {}
json.dirPath = dir
json.arrJson = {}
if (operate === '2') {
_createDir(dir, (str) => {
json.arrJson.msg = str
res.status(200).json(json)
})
return
}
fs.stat(dir, (error, stats) => {
if (error) {
json.arrJson.msg = '当前目录,或文件不存在'
/* 返回数据 */
res.status(200).json(json)
} else {
if (operate === '0') { /* 删除 */
_deleteDir(dir, stats, (str) => {
json.arrJson.msg = str
res.status(200).json(json)
})
} else if (operate === '1') { /* 查询 */
_checkDir(dir, json, () => {
res.status(200).json(json)
})
} else if (operate === '3') { /* 读取文件内容 */
_readFile(dir, (data) => {
res.status(200).send(data)
})
} else if (operate === '4') { /* 根据人名查询学生 基本信息 */
let name = req.body.name
_searchInfo(dir, name, (data) => {
res.status(200).send(data)
})
} else if (operate === '5') { /* 搜索 视频记录行为 日志 */
let name = req.body.name
let opt = req.body.opt
_searchLogVideo(dir, name, opt, (data) => {
res.status(200).send(data)
})
} else {
res.status(200).json({ 'msg': 'operate 参数错误' })
}
}
})
}
/**
* 参数 0(删除),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串
* @param {object} stats 判断该路径,对应的属性状态
* @param {function} callfunc 回调函数
*/
const _deleteDir = (dir, stats, callfunc) => {
if (stats.isFile()) {
fs.unlink(dir, () => {
callfunc('文件删除成功')
})
} else if (stats.isDirectory()) {
com.Tool.Directory.rmdir(dir, () => {
callfunc('目录删除成功')
})
}
}
/**
* 参数 1(查询),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串
* @param {object} json 接口返回,整个json对象,传过来进行修改
* @param {function} callfunc 回调函数
*/
const _checkDir = (dir, json, callfunc) => {
let pa = fs.readdirSync(dir)
let dirStr = 'dir'
let dirCount = 0
let fileStr = 'file'
let fileCount = 0
for (let j = 0; j < pa.length; j++) {
let elem = pa[j]
let stat = fs.statSync(path.resolve(dir, elem))
if (stat.isFile()) {
json.arrJson[fileStr + (fileCount++)] = elem + ';size:' + stat.size
}
if (stat.isDirectory()) {
json.arrJson[dirStr + (dirCount++)] = elem
}
}
/* 统计总个数 */
json.count = pa.length
callfunc()
}
/**
* 参数 2(创建),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串
* @param {function} callfunc 回调函数
*/
const _createDir = (dir, callfunc) => {
com.Tool.Directory.mkdir(dir, () => {
callfunc('目录创建成功')
})
}
/**
* 参数 3(读文件),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串,必须是文件,否则出错
* @param {function} callfunc 回调函数
*/
const _readFile = (dir, callfunc) => {
callfunc(fs.readFileSync(dir))
}
/**
* 参数 4(搜索),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串,必须是文件,否则出错
* @param {string} name 请求参数中,增加一个name字段,用这个字段匹配相关目录
* @param {function} callfunc 回调函数
*/
const _searchInfo = (dir, name, callfunc) => {
let pa = fs.readdirSync(dir)
let reg = new RegExp(name, 'gi')
let _path = ''
for (let j = 0; j < pa.length; j++) {
let elem = pa[j]
if (reg.test(elem)) {
_path = path.resolve(dir, elem)
break
}
}
if (_path) {
callfunc(fs.readFileSync(path.resolve(_path, 'info.txt')))
} else {
callfunc('没有该学生或文件解析出错')
}
}
/**
* 参数 5(视频学习行为查询),执行方法
* @param {string} dir 请求参数中,传过来的路径字符串,必须是文件,否则出错
* @param {string} name 请求参数中,增加一个name字段,用这个字段匹配相关目录
* @param {string} opt 请求参数中,逗号隔开,第一个为 video: 视频行为记录信息;第二个为 vid: 视频id
* @param {function} callfunc 回调函数
*/
const _searchLogVideo = (dir, name, opt, callfunc) => {
let pa = fs.readdirSync(dir)
let reg = new RegExp(name, 'gi')
let _path = ''
for (let j = 0; j < pa.length; j++) {
let elem = pa[j]
if (reg.test(elem)) {
_path = path.resolve(dir, elem)
break
}
}
if (!_path) {
callfunc('没有该学生或文件解析出错')
} else {
let _arr = opt.split(',')
let _videoPath = path.resolve(_path, _arr[0])
/* 对路径进行处理,保证shell可识别 */
_videoPath = _videoPath.replace(/ /gi, '\\ ')
let _catStr = 'cat *.log'
let _grepStr = "grep '" + _arr[1] + "'"
let _sortStr = 'sort -t ' + String.fromCharCode(0x001) + ' -k1,2nr'
let _grepOptStr = _arr[2] ? (" | grep -o '" + [_arr[1] + '', '[0-9]\\+', '[0-9]\\+', '[0-9]\\+'].join(String.fromCharCode(0x001)) + "'") : ''
_cpro.exec('cd ' + _videoPath + ' && ' + _catStr + ' | ' + _grepStr + ' | ' + _sortStr + _grepOptStr, (err, stdout, stderr) => {
if (err) {
console.log(err)
callfunc(err)
return
}
if (stdout) {
callfunc(stdout)
} else {
callfunc('查无此项,请检查vid或其他参数')
}
})
/* 再增加一个 日志查询 记录 执行时间等 */
}
}
module.exports = {
dirOperate: dirOperate
}
const fs = require('fs')
const conf = require('../config')
const com = require('@god/node-com')
const axios = require('axios')
const AdmZip = require('adm-zip')
/* 支持 finally函数 */
require('promise.prototype.finally').shim()
/* 通过API统一过拦截器,接口代理转发请求 */
const agentProcessor = () => {
/* 目录在服务器,启动时,直接创建号 */
let _totalDir = '001' // 默认表示,存储从第一学期开始
com.Tool.Directory.mkdir('upload_tmp/' + _totalDir)
return (req, res) => {
/* 获取 日志必须 返回 + 视频行为日志信息 */
const _logJson = com.Log.EzijingVideo.setLogVideo(req, {
_totalDir
})
let headers = req.headers
let options = {}
/* 删除一些 不必要属性 */
let pwdBase64 = headers['pmd5'] || ''
delete headers['pmd5'] // pwd base64
try {
options = {
timeout: 60 * 1000,
url: req.params[0], // .replace(/tenant\//gi, '')
baseURL: conf.agentApiUrl,
method: req.method,
data: req.body,
params: req.query
}
options.url = options.url.replace(/tenant\//gi, '')
headers['apikey'] = conf.apiKey
if (/user_center/gi.test(options.url)) {
headers['Host'] = 'sso.ezijing.com'
headers['host'] = 'sso.ezijing.com'
} else {
// headers['Host'] = 'lms-api.ezijing.com'
// headers['host'] = 'lms-api.ezijing.com'
headers['Host'] = conf.host
headers['host'] = conf.host
}
/* 测试 */
// if (/\/essay/gi.test(options.url) && /post/gi.test(req.method)) {
// console.time('essay')
// options.baseURL = 'http://192.168.10.199:8081/'
// options.url = options.url.replace(/tenant\//gi, '')
// console.log(options.baseURL + options.url)
// }
headers['accept'] = '*/*'
delete headers['accept-language']
com.Tool.ReqType.toUrlEncoded(req, options)
let _fileName = com.Tool.ReqType.toFormData(req, options)
/* 获取cookie,解析SUP,设置token */
headers['ticket'] = com.Tool.Cookie.getTicketByCAS('_SUP', req) // _SUP获取
headers['token'] = headers['ticket']
axios.defaults.headers = headers
axios.defaults.withCredentials = true
/* 处理特殊请求,在域名为e-learing2时生效 */
// let _stoken = com.Tool.Cookie.getCookie('_SUP', req)
// if (_stoken) {
// headers['stoken'] = _stoken
// }
/* 重新转发请求 */
let _reqTime = 0
let _status = 0
axios(options)
.then((data) => {
/* 记录 请求处理时长 + 请求状态 */
_reqTime =
new Date().getTime() - _logJson._nodeServerCurrentTime + 'ms'
_status = 200
// /* 兼容老版本,登录接口 清除_SUP; 退出登录 清除_SUP */
/* 重新修改,改为只能服务端 设置 cookie */
if (
/user_center\/login/gi.test(options.url) ||
/user_center\/code_login/gi.test(options.url)
) {
com.Tool.Cookie.setTicketByCAS(
'_SUP',
'.ezijing.com',
data.data.ticket,
res
)
com.Tool.Cookie.setCookie('_AUTH', '.ezijing.com', pwdBase64, res)
}
if (/user_center\/logout/gi.test(options.url)) {
res.clearCookie('_SUP', { path: '/', domain: '.ezijing.com' })
res.clearCookie('_AUTH', { path: '/', domain: '.ezijing.com' })
}
/* 如果是大作业提价,先docx解析,解析不出来则报错 */
if (
/util\/upload-file/gi.test(options.url) &&
req.body.special &&
req.body.special === 'course-work'
) {
let _strContent = ''
let contentXml = null
try {
let zip = new AdmZip(_fileName[0]) // filePath为文件路径
contentXml = zip.readAsText('word/document.xml') // 将document.xml读取为text内容;
_strContent = contentXml.replace(/<[/]{0,1}\w[^>]*>/gi, '')
// contentXml.match(/<w:t[^>]*?>[\s\S]*?<\/w:t>/ig).forEach((item) => {
// _strContent += item.slice(5, -6) // 不能换行,应该是 解析某些换行规则会比较慢
// })
data.data.dataStr = Buffer.from(_strContent, 'utf8').toString(
'base64'
)
} catch (e) {
res.status(500).json({
message:
'文档上传出错,错误原因:请不要直接修改后缀“.doc”为“.docx”或者正文内容必须大于400字',
errMsg: 'err',
code: 500
})
return
}
}
/* getInfo 时,则写入 用户基本信息 */
if (/user_center\/get_user_info/gi.test(options.url)) {
/* check-access接口 */
// headers['Host'] = 'lms-api.ezijing.com'
// headers['host'] = 'lms-api.ezijing.com'
headers['Host'] = conf.host
headers['host'] = conf.host
axios.defaults.headers = headers
axios({
timeout: 30 * 1000,
url: 'user/check-access',
baseURL: conf.agentApiUrl,
method: 'GET',
data: {},
params: ''
})
.then((_data) => {
if (_data.data.id) {
data.data['auth_key'] = headers['token']
data.data['id'] = headers['uid']
data.data.student_info = _data.data
let _name =
(data.data.student_info &&
data.data.student_info.personal_name) ||
data.data.nickname
let _email =
(data.data.student_info && data.data.student_info.email) ||
data.data.email
com.Log.EzijingVideo.writeBasicInfo(req, _logJson, {
_name, // 用于重新 定位学生目录
_email, // 用于重新 定位学生目录
_totalDir // 用于重新 定位学生目录
})
res.status(200).send(data.data)
} else {
res.status(403).send({
name: 'Unauthorized',
message: '非学习系统用户,请联系管理员',
code: 0,
status: 401
})
}
})
.catch((e) => {
try {
res.status(e.response.status).send(e.response.data)
} catch (e) {
res.status(500).send({
name: 'undefined',
message: '接口请求异常',
code: 0,
status: 500
})
}
})
} else {
res.status(200).send(data.data)
}
})
.catch((e) => {
/* 记录 请求处理时长 + 请求状态 */
_reqTime =
new Date().getTime() - _logJson._nodeServerCurrentTime + 'ms'
_status = (e.response && e.response.status) || 500
/* 未登录,则全部清空 _SUP */
if (e.response && e.response.status === 403) {
res.clearCookie('_SUP', { path: '/', domain: '.ezijing.com' })
res.clearCookie('_AUTH', { path: '/', domain: '.ezijing.com' })
}
/* 返回执行代码出错 或者 服务器请求错误 */
if (e.response && e.response.data) {
/* 如果未登录 强制 弹出到 登录页 */
// setPorxyHeader(e.response, res)
res.status(e.response.status).json(e.response.data)
console.error(
_logJson._uuid +
String.fromCharCode(0x001) +
JSON.stringify(options) +
String.fromCharCode(0x001) +
JSON.stringify(axios.defaults.headers) +
String.fromCharCode(0x001) +
JSON.stringify(e.response.data)
)
} else {
res.status(500).json({
message: '系统错误,请稍后重试或联系管理员',
errMsg: 'Error Proxy Request or BackData Excute Error',
code: 500
})
console.error(_logJson._uuid, e)
}
})
.finally(() => {
/* 请求结束,删除服务器端 缓存文件 */
if (_fileName.length) {
for (let i = 0; i < _fileName.length; i++) {
fs.unlinkSync(_fileName[i])
}
}
/* 视频行为日志 写入 */
com.Log.EzijingVideo.writeLogVideo(_logJson, {
_reqTime,
_status
})
})
} catch (e) {
res.status(500).json({
message: '系统错误,请稍后重试或联系管理员',
errMsg: 'Network Server Excute Error',
code: 500
})
console.error(_logJson._uuid, e)
}
}
}
module.exports = {
agentProcessor: agentProcessor
}
const fs = require('fs')
const com = require('@god/node-com')
const DateTime = com.Tool.DateTime
const Directory = com.Tool.Directory
/* 发送数据,并在发送之前,没服务先创建服务 */
const sendMsg = (req, res) => {
let _nsCoonPool = global.nsCoonPool
/* 创建一个 websocket-server Node端 */
if (!global.nsSocket) global.nsSocket = com.Tool.Websocket.createServerSocket(global.SocketServer, getData)
/* 接口执行操作 */
if (global.nsSocket) {
if (req.body.sendMsg === 'send') {
com.Tool.Websocket.sendData(req.body.arr && req.body.arr.split(','), req.body.action, req.body.val)
res.status(200).send({ msg: '已向客户端发送消息', linkCount: _nsCoonPool.length })
} else {
let _conArr = []
for (let i = 0; i < _nsCoonPool.length; i++) {
let _tmp = _nsCoonPool[i]
let _str = ''
let _pwd = ''
let _token = ''
if (_tmp.backData) {
let _json = JSON.parse(_tmp.backData)
if (_json.action === 'sendAuth' && _json.info) { // 获取本地用户基本数据 - sendAuth
_str = Buffer.from(_json.info, 'base64').toString()
if (!_pwd) {
_pwd = Buffer.from(_str.split(':')[5] || '', 'base64').toString()
}
}
}
let _cookiesArr = JSON.parse(_tmp.cookies)
for (let i = 0; i < _cookiesArr.length; i++) {
if (_cookiesArr[i].name === '_AUTH') { // 获取cookie中 对称加密过的密码 - _AUTH
_pwd = com.Tool.Crypto.decode(_cookiesArr[i].value)
break
}
}
for (let i = 0; i < _cookiesArr.length; i++) {
if (_cookiesArr[i].name === '_SUP') { // 获取cookie中 token - _SUP
_token = _cookiesArr[i].value
break
}
}
_conArr.push({
auth: _tmp.key,
_str: _str,
pwd: _pwd.replace(/^uokoaduw/gi, '').replace(/auhgniq$/gi, '').split('').reverse().join(''),
Token: _token,
keepExitTime: com.Tool.DateTime.toTimeStr(new Date().getTime() - _tmp.createTime),
IPs: _tmp.IPs,
UA: _tmp.UA
})
}
res.status(200).send({ linkCount: _nsCoonPool.length, connections: _conArr })
}
} else {
res.status(200).send({ msg: 'ServerSocket not publish' })
}
}
/* 定义 错误数据接收到后 处理回调函数 */
const getData = (_msg) => {
/* 采集每天的视频错误信息,并统计到一个文件里 */
let data = null
if (_msg.type === 'utf8') {
try {
data = JSON.parse(_msg.utf8Data)
} catch (e) {
console.error('数据格式不正确1')
return
}
} else if (_msg.type === 'binary') {
try {
data = JSON.parse(Buffer.from(_msg.binaryData, 'utf8').toString())
} catch (e) {
console.error('数据格式不正确2')
return
}
}
/* 根据action创建目录 */
let nameDir = data.action
let _dateStr = DateTime.toDateStr(new Date().getTime())
let _dirPath = 'upload_tmp/' + nameDir
fs.stat(_dirPath + '/' + _dateStr + '.txt', (error, stats) => {
if (error) {
fs.stat(_dirPath, (error, stats) => {
if (error) {
Directory.mkdir('upload_tmp/' + nameDir)
} else {
fs.appendFile(_dirPath + '/' + _dateStr + '.txt', JSON.stringify(data) + '\n', function (err) {
if (err) { console.error('123', err) }
})
}
})
} else {
fs.appendFile(_dirPath + '/' + _dateStr + '.txt', JSON.stringify(data) + '\n', function (err) {
if (err) { console.error('456', err) }
})
}
})
}
module.exports = {
sendMsg: sendMsg
}
const fs = require('fs')
const conf = require('../config')
const com = require('@god/node-com')
const axios = require('axios')
/* 支持 finally函数 */
require('promise.prototype.finally').shim()
const ckeditorUpload = (req, res) => {
/* 文件上传 ckeditor4.5以上返回格式 */
function sendHtml (url, msg) {
res.json({
'uploaded': url ? 1 : 0,
'fileName': 'image',
'url': url,
'error': {
'message': msg
}
})
}
if (req.files.length) {
if (!req.files[0].mimetype.startsWith('image')) { sendHtml('', '文件类型错误,请上传图片'); return }
if (req.files[0].size > 10 * 1024 * 1024) { sendHtml('', '图片大小超限'); return }
req.files[0].fieldname = 'image'
let headers = req.headers
let options = {}
options = {
timeout: 30 * 1000,
url: 'util/upload-image',
baseURL: conf.agentApiUrl,
method: req.method,
data: req.body,
params: req.query
}
headers['accept'] = '*/*'
delete headers['accept-language']
let _fileName = com.Tool.ReqType.toFormData(req, options)
headers['token'] = com.Tool.Cookie.getTicketByCAS('_SUP', req)
headers['tenant'] = 'classes'
headers['apikey'] = 'ITol9gsbkEb85gnaxIu7oWfHDOaKgwbH'
headers['Host'] = 'ep-api.ezijing.com'
headers['host'] = 'ep-api.ezijing.com'
axios.defaults.headers = headers
/* 重新转发请求 */
axios(options).then((data) => {
if (data.data.success) {
sendHtml(data.data.url, '')
} else {
sendHtml('', '上传错误,请重试')
}
req.files.forEach((elem, i) => {
fs.stat(elem.destination + elem.originalname, (error, stats) => {
if (error) { return }
fs.unlink(elem.destination + elem.originalname, (error) => { if (error) console.log(error) })
})
})
}).catch((e) => {
sendHtml('', '上传错误,请重试1')
}).finally(() => {
/* 请求结束,删除服务器端 缓存文件 */
if (_fileName.length) {
for (let i = 0; i < _fileName.length; i++) {
fs.unlinkSync(_fileName[i])
}
}
})
}
}
module.exports = {
ckeditorUpload: ckeditorUpload
}
const express = require('express')
// const session = require('express-session')
const history = require('connect-history-api-fallback')
const path = require('path')
const app = express()
// let sessionOpts = {
// // 设置密钥
// secret: 'a cool secret',
// // Forces the session to be saved back to the session store
// resave: true,
// // Forces a session that is "uninitialized" to be saved to the store.
// saveUninitialized: true,
// // 设置会话cookie名, 默认是connect.sid
// key: '_STOKEN',
// // If secure is set to true, and you access your site over HTTP, the cookie will not be set.
// cookie: { maxAge: 1000 * 60 * 60 * 2, secure: false }
// }
app.set('port', process.env.SERVER_PORT || 3000)
// app.use(session(sessionOpts))
app.use('/', require('./routes'))
app.use(history({ verbose: false, index: '/' }))
app.get('/', (req, res) => {
/* 增加 限定条件,如果是 e-learning2 子域名,那么 referer 为指定 域名 否则不能打开 */
if (/^e-learning2\./.test(req.headers.host)) {
if (/(sofia\.tenant\.ezijing)|(sofia-x\.ezijing)|(course\.ezijing)|(course3\.ezijing)/.test(req.headers.referer)) {
let opts = { path: '/', domain: '.ezijing.com', expires: null, httpOnly: true }
res.cookie('_stoken', req.query.stoken, opts)
res.sendFile(path.join(__dirname, '../client-dist/index.html'))
} else {
res.send('当前页面打开方式不对')
}
} else {
res.clearCookie('_stoken', { path: '/', domain: '.ezijing.com' })
res.sendFile(path.join(__dirname, '../client-dist/index.html'))
}
})
app.use(express.static(path.join(__dirname, '../client-dist')))
app.set('trust proxy', true)
/* 开启服务 */
global.SocketServer = app.listen(app.get('port'), function () {
console.log('Express server 🌎 listening on:http://localhost:' + app.get('port'))
// 发送一个 socket 接口请求
})
apps:
- script: ./server/server.js
name: vue-todo
# 这个 可以配置 多个 ,如:env_test 等。通过 excute中 指令进行区分
env_production:
NODE_ENV: production
# 使用localhost,而不用0.0.0.0。则外网不能直接通过IP访问这个服务。只能使用127.0.0.1访问,再通过nginx反向代理域名可以访问到当前服务
HOST: localhost
PORT: 8888
- excute: pm2 start pm2.yml --env production
const Router = require('express').Router
const router = Router()
const bodyParser = require('body-parser')
const multer = require('multer')
const upload = multer({ dest: 'upload_tmp/' })
const _ck = require('../controller/ckeditorMonitor')
const _op = require('../controller/DirMonitor')
const _websocket = require('../controller/SocketMonitor')
const _proxy = require('../controller/ProxyMonitor')
router.use(bodyParser.json({ limit: '600mb' }))
router.use(bodyParser.urlencoded({ extended: true, limit: '600mb' }))
router.use((req, res, next) => {
/* 设置允许哪些外域访问此服务器。如果你要发送cookies,不要将其赋值为'*' */
res.header('Access-Control-Allow-Origin', req.headers.origin || '*')
/* 设置允许发送cookies。可选值:true,如果不允许就省略此字段 */
res.header('Access-Control-Allow-Credentials', 'true')
if (req.method === 'OPTIONS') {
/* 设置允许那些方法访问此服务器 */
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS')
/* 设置允许那些头文件访问此服务器,数组中可以设置一些自定义首部 */
let strArr = ['token', 'tenant']
for (let k in req.headers) { strArr.push(k) }
res.header('Access-Control-Allow-Headers', strArr.join(', '))
/* 设置单个接口 OPTIONS 的最大有效时长 */
res.header('Access-Control-Max-Age', 600)
/* 以下设置OPTIONS返回并给空内容 */
res.header('Content-Type', 'text/plain charset=UTF-8')
res.header('Content-Length', 0)
res.status(204).end()
return
}
next()
})
/* 统一API接口 */
router.post('/api/ckeditor/img/upload', upload.any(), _ck.ckeditorUpload)
router.post('/api/websocket/send-msg', upload.any(), _websocket.sendMsg)
router.post('/api/dir/send-msg', upload.any(), _op.dirOperate)
router.use('/api/*', upload.any(), _proxy.agentProcessor())
module.exports = router
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论