Where to put a separate admin interface for a Meteor app?

后端 未结 6 1162
攒了一身酷
攒了一身酷 2021-02-14 09:11

I\'m trying to build a smart package for Meteor app that provides some monitoring capabilities and other tools based on the features of the smart package. For more details read

6条回答
  •  迷失自我
    2021-02-14 09:32

    IronRouter supports multiple layouts.

    https://github.com/EventedMind/iron-router

    Router.configure({
      layout: 'layout',
      notFoundTemplate: 'notFound',
    
      loadingTemplate: 'loading',
    
      renderTemplates: { 
        /* render the templated named footer to the 'footer' yield */
        'footer': { to: 'footer' },
    
        /* render the template named sidebar to the 'sidebar' yield */
        'header': { to: 'header' }
      }
    });
    
    Router.map(function() { 
    
      this.route('admin', {
        layout: 'admin_layout',
        path: '/admin',
        template: 'admin',
        data: function() {
          return { page : 'admin'}
        },
        onBeforeRun: checkLoggedIn,
        renderTemplates: { 
        /* render the template named footer to the 'footer' yield */
        'admin_footer': {to: 'footer'},
    
        /* render the template named sidebar to the 'sidebar' yield */
        'admin_login_header': {to: 'header'}
        }
      });
    
    this.route('home', {
        path: '/',
        template: 'home',
        data: function() {
          return { page : 'home'}
        }
      });
    
    
    
    
    
    

    Could work pretty well if you match it up with Meteor accounts UserID checks and onBeforeRun hooks. I haven't fully tested the security aspect but it looks like it will work.

提交回复
热议问题