Aurelia 多页应用程序?

Aurelia Multi-page App?

如果我有 main.ts 这样的文件设置...

Main.ts

import {Aurelia} from 'aurelia-framework'
import environment from './environment';

//Configure Bluebird Promises.
(<any>Promise).config({
  warnings: {
    wForgottenReturn: false
  }
});

export function configure(aurelia: Aurelia) {
  aurelia.use
    .standardConfiguration()
    .feature('resources');

  if (environment.debug) {
    aurelia.use.developmentLogging();
  }

  if (environment.testing) {
    aurelia.use.plugin('aurelia-testing');
  }



  // PLAYING AROUND - Log to Console the Value of ShowLanding Session Storage
  let showLanding = false;
  console.log(showLanding);
  // let showLanding = sessionStorage.getItem("show_landing");

  if (showLanding || showLanding === null) {
    aurelia.start().then(() => aurelia.setRoot('landing'));
  } else {
    aurelia.start().then(() => aurelia.setRoot('blog/blog'));
  }
}

我的应用程序的根目录中有一个 "Landing.html/.ts" 文件,这段代码似乎运行良好。意思是,如果 "showLanding = false" 应用程序将加载到我的 "blog.html" 页面,如果是,它将加载到我的 "Landing.html" 页面。

我想做的是创建一个管理页面。任何时候 URL 被访问“....com/admin” 带我到 "admin.html" 我已经设置的页面。

做前端可以吗?我知道的唯一其他方法是从服务器路由匹配 URL 和静态服务,是吗?

我通过简单地阅读 window.location.pathname 并将我的管理页面设置为应用程序根目录,设法让它工作(我希望它工作的方式)。

so my Main.ts was changed to:

  ...

  if (showLanding || showLanding === null) {
    aurelia.start().then(() => aurelia.setRoot('landing'));
  } else if (window.location.pathname == "/admin") { 
    aurelia.start().then(() => aurelia.setRoot('admin/admin'));
  } else {
    aurelia.start().then(() => aurelia.setRoot('blog/blog'));
  }
}

我确定这可能不是实现此目的的最佳方法,但它目前似乎有效。如果我 运行 遇到任何问题,我会确定并更新此内容。

此外,如果其他人想提出任何其他想法、疑虑、建议或反馈,请尽管如此!谢谢!