alter section display
This commit is contained in:
父節點
225cfdbc54
當前提交
656427e444
@ -2,7 +2,7 @@ import {IExercise, ITextbook, IToc} from "./types"
|
||||
|
||||
export function fillIToc(single: any) {
|
||||
return <IToc>{
|
||||
section: single.section,
|
||||
section: single.section.replace(/\//g,'-'),
|
||||
count: single.count,
|
||||
pageBegin: single.pageBegin,
|
||||
pageEnd: single.pageEnd
|
||||
@ -19,7 +19,7 @@ export function fillITextbook(single: any) {
|
||||
export function fillIExercise(single: any) {
|
||||
return <IExercise>{
|
||||
exercise: single.exercise,
|
||||
section: single.section,
|
||||
section: single.section.replace(/\//g,'-'),
|
||||
part: single.part,
|
||||
page: single.page,
|
||||
html: single.html
|
||||
|
@ -24,13 +24,13 @@ textbookRouter.get('/:textbook/:section?/:exercise?',
|
||||
}),
|
||||
query('page').optional().isInt({min: 1}),
|
||||
param('section').optional().notEmpty().bail().custom((input, {req}) => {
|
||||
if (!textbookModel.existSection(req.params!.textbook, input)) {
|
||||
if (!textbookModel.existSection(req.params!.textbook, input.replace(/-/g, '/'))) {
|
||||
throw new Error('section not exist')
|
||||
}
|
||||
return true
|
||||
}),
|
||||
param('exercise').optional().notEmpty().bail().custom((input, {req}) => {
|
||||
if (!textbookModel.existExercise(req.params!.textbook, req.params!.section, input)) {
|
||||
if (!textbookModel.existExercise(req.params!.textbook, req.params!.section.replace(/-/g, '/'), input)) {
|
||||
throw new Error('exercise not exist')
|
||||
}
|
||||
return true
|
||||
@ -40,9 +40,9 @@ textbookRouter.get('/:textbook/:section?/:exercise?',
|
||||
if (req.query.page) {
|
||||
res.json(await textbookService.getPage(req.params.textbook, Number(req.query.page)))
|
||||
} else if (req.params.exercise) {
|
||||
res.json(await textbookService.getExercise(req.params.textbook, req.params.section, req.params.exercise))
|
||||
res.json(await textbookService.getExercise(req.params.textbook, req.params.section.replace(/-/g, '/'), req.params.exercise))
|
||||
} else if (req.params.section) {
|
||||
res.json(await textbookService.getSection(req.params.textbook, req.params.section))
|
||||
res.json(await textbookService.getSection(req.params.textbook, req.params.section.replace(/-/g, '/')))
|
||||
} else {
|
||||
res.json(await textbookService.getTextbook(req.params.textbook))
|
||||
}
|
||||
|
載入中…
x
新增問題並參考
Block a user