amis2/mock/options/nav.js
liaoxuezhi cede563628
Mapping 修复 boolean 值的映射问题 (#1837)
* 优化 pc 样式

* 样式微调

* Nav 支持 lazyreload

* 修复 mapping boolean值映射问题

* 多提交了文件

* 还原 example
2021-04-21 00:08:16 +08:00

64 lines
1.2 KiB
JavaScript

module.exports = function (req, res) {
let repeat = 2 + Math.round(Math.random() * 5);
let options = [];
if (req.query.parentId) {
while (repeat--) {
const value = Math.round(Math.random() * 1000000);
const label = value + '';
options.push({
label: label,
to: `?cat=${value}`,
value: `${value}`,
defer: Math.random() > 0.7
});
}
} else {
options = [
{
label: 'Nav 1',
to: '?cat=1',
value: '1',
icon: 'fa fa-user'
},
{
label: 'Nav 2',
unfolded: true,
children: [
{
label: 'Nav 2-1',
children: [
{
label: 'Nav 2-1-1',
to: '?cat=2-1',
value: '2-1'
}
]
},
{
label: 'Nav 2-2',
to: '?cat=2-2',
value: '2-2'
}
]
},
{
label: 'Nav 3',
to: '?cat=3',
value: '3',
defer: true
}
];
}
res.json({
status: 0,
msg: '',
data: {
links: options,
value: req.query.parentId ? undefined : '?cat=1'
}
});
};