98 lines
2.2 KiB
JavaScript
98 lines
2.2 KiB
JavaScript
const { resolveScene } = require('../../../../utils/static-ux/shared')
|
|
const { ROUTES, openStaticRoute } = require('../../../../utils/static-ux/route-map')
|
|
|
|
const READER_SURFACES = Object.freeze({
|
|
'reader-a': {
|
|
chapterTitle: '上古天真论',
|
|
passages: [
|
|
'上古之人,其知道者,法于阴阳,和于术数。',
|
|
'食饮有节,起居有常,不妄作劳,故能形与神俱。'
|
|
]
|
|
},
|
|
'reader-b': {
|
|
chapterTitle: '太阳病篇',
|
|
passages: [
|
|
'伤寒者,太阳病也。',
|
|
'太阳之为病,脉浮,头项强痛而恶寒。'
|
|
]
|
|
}
|
|
})
|
|
|
|
function createTcmSectionPageData(rawScene) {
|
|
const scene = resolveScene(rawScene, ['reader-a', 'reader-b'], 'reader-a')
|
|
const surface = READER_SURFACES[scene]
|
|
|
|
return {
|
|
title: '典籍阅读',
|
|
scene,
|
|
chapterTitle: surface.chapterTitle,
|
|
passages: [...surface.passages],
|
|
toolbarVisible: false,
|
|
settings: {
|
|
fontScale: 1,
|
|
lineMode: 'normal',
|
|
bgMode: 'default'
|
|
},
|
|
lineModes: [
|
|
{ key: 'compact', label: '紧凑' },
|
|
{ key: 'normal', label: '适中' },
|
|
{ key: 'relaxed', label: '宽松' }
|
|
],
|
|
backgroundModes: [
|
|
{ key: 'default', label: '默认' },
|
|
{ key: 'paper', label: '纸张' },
|
|
{ key: 'care', label: '护眼' }
|
|
],
|
|
catalogItems: [
|
|
{
|
|
key: 'reader-a',
|
|
title: '上古天真论',
|
|
route: `${ROUTES.tcm.section}?scene=reader-a`
|
|
},
|
|
{
|
|
key: 'reader-b',
|
|
title: '太阳病篇',
|
|
route: `${ROUTES.tcm.section}?scene=reader-b`
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
function showNavigate(route) {
|
|
openStaticRoute(route, wx)
|
|
}
|
|
|
|
Page({
|
|
data: createTcmSectionPageData('reader-a'),
|
|
|
|
onLoad(options) {
|
|
this.setData(createTcmSectionPageData(options.scene))
|
|
},
|
|
|
|
handleToolbarToggle() {
|
|
this.setData({
|
|
toolbarVisible: !this.data.toolbarVisible
|
|
})
|
|
},
|
|
|
|
handleLineModeTap(event) {
|
|
this.setData({
|
|
'settings.lineMode': event.currentTarget.dataset.mode
|
|
})
|
|
},
|
|
|
|
handleBackgroundTap(event) {
|
|
this.setData({
|
|
'settings.bgMode': event.currentTarget.dataset.mode
|
|
})
|
|
},
|
|
|
|
handleCatalogTap(event) {
|
|
showNavigate(event.currentTarget.dataset.route)
|
|
}
|
|
})
|
|
|
|
module.exports = {
|
|
createTcmSectionPageData
|
|
}
|