2019-10-01 12:19:10 +00:00
|
|
|
const common = require('./common')
|
|
|
|
|
2022-06-21 11:50:03 +00:00
|
|
|
const Tree = window.__nfptree && window.__nfptree.tree || []
|
2022-07-20 00:33:06 +00:00
|
|
|
const TreeMap = new Map()
|
2019-10-01 12:19:10 +00:00
|
|
|
|
|
|
|
exports.Tree = Tree
|
2022-07-20 00:33:06 +00:00
|
|
|
exports.TreeMap = TreeMap
|
2019-10-01 12:19:10 +00:00
|
|
|
|
2022-07-20 00:33:06 +00:00
|
|
|
function parseLeaf(tree) {
|
|
|
|
for (let branch of tree) {
|
|
|
|
TreeMap.set(branch.path, branch)
|
|
|
|
|
|
|
|
if (branch.children && branch.children.length) {
|
|
|
|
parseLeaf(branch.children)
|
|
|
|
}
|
|
|
|
}
|
2019-10-01 12:19:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-20 00:33:06 +00:00
|
|
|
parseLeaf(Tree)
|
|
|
|
|
2022-06-28 08:15:51 +00:00
|
|
|
exports.getPage = function(path, page) {
|
2019-10-01 12:19:10 +00:00
|
|
|
return common.sendRequest({
|
|
|
|
method: 'GET',
|
2022-06-28 08:15:51 +00:00
|
|
|
url: '/api/' + (path ? 'pages/' + path : 'frontpage') + '?page=' + (page || 1),
|
2019-10-01 12:19:10 +00:00
|
|
|
})
|
|
|
|
}
|