@x-edu/whiteboard
v3.1.1
Published
资源接入sdk
Downloads
19
Keywords
Readme
@x-edu/whiteboard
Demo
2.0.0之后版本示例见羽雀文档
import {
NDRRequest,
CDNEnv
} from '@x-edu/whiteboard'
// 设置环境,test为百度测试环境,product为百度正式环境
NDRRequest.setEnv(CDNEnv.test)
// 开启测试,将使用测试地址
NDRRequest.setIsTest(true)
// 开启测试解析,强制注入加密信息
NDRParser.setIsTest(true)
// 请求教材列表
const teachingmaterials = await NDRRequest.getTeachingMaterialList()
console.log('teachingmaterials', teachingmaterials)
// 请求教材标签树
const tags = await NDRRequest.getTeachingMaterialTags()
console.log('tags', tags)
// 请求教材详情
const teachingMaterialDetail = await NDRRequest.getTeachingMaterialDetail(teachingmaterials[0].id)
console.log('teachingMaterialDetail', teachingMaterialDetail)
// 请求教材章节
const chapters = await NDRRequest.getTeachingMaterialChapters(teachingmaterials[0].id)
console.log('chapters', chapters)
// 请求教材的课程列表
const lessons = await NDRRequest.getTeachingMaterialLessons(teachingmaterials[0].id)
console.log('lessons', lessons)
// 请求教材详情
const lessonDetail = await NDRRequest.getNationalLessonDetail(lessons[0].id)
console.log('lessonDetail', lessonDetail)
// 请求课程关联的精品课列表
const elite = await NDRRequest.getNationalLessonRelateEliteLesson(lessons[0].id)
console.log('elite', elite)
// 请求课程关联的讲师信息
const lecture = await NDRRequest.fetchLectureLessons('d7698529-7723-4672-87c5-2e77fb9da32a')
console.log('lecture', lecture)
// 解析课程资源数据
const lessonResourceData = NDRParser.parseLessonResource(lessonDetail)
console.log('resourceData', lessonResourceData)
// 解析课程视频资源
const videoData = await NDRParser.parseResource(
lessonResourceData.resourceData[0].resources[0]
)
console.log('videoData', videoData)
// 解析课程文档资源
const documentData = await NDRParser.parseResource(
lessonResourceData.resourceData[0].resources[1]
)
console.log('documentData', documentData)
// 地址转换
const tiUrl = await NDRParser.getTiItemUrl(lessonResourceData
.resourceData[0]
.resources[1]
.ti_items[0])
console.log('tiUrl', tiUrl)
const authHeader = await NDRParser.getAuthHeader()
console.log('authHeader', authHeader)