init-menu.js 637 B

12345678910111213141516171819202122232425
  1. const MenuItem = require('../models/MenuItem');
  2. async function initMenuItems() {
  3. const count = await MenuItem.countDocuments();
  4. if (count === 0) {
  5. await MenuItem.insertMany([
  6. {
  7. text: '首页',
  8. link: '/',
  9. icon: 'fa-home',
  10. order: 1
  11. },
  12. {
  13. text: '文档',
  14. link: '/docs',
  15. icon: 'fa-book',
  16. order: 2
  17. }
  18. // 添加更多默认菜单项...
  19. ]);
  20. console.log('默认菜单项已初始化');
  21. }
  22. }
  23. module.exports = initMenuItems;