2017-03-03 6 views
1

私はそう...Aureliaマルチページアプリ?

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')); 
    } 
} 

ようmain.tsファイルを設定している場合は、私は、私のアプリのルートにある "Landing.html/.TS" ファイルを持っていますこのコードはうまくいくようです。意味、 "showLanding = false"の場合、アプリケーションは "blog.html"ページにロードされ、それが本当であれば、私の "Landing.html"ページにロードされます。

私がしようとしているのは、管理ページを作成することです。いつでもURLにアクセスしました ".... com/admin"私は "admin.html"ページに移動しますセットアップがあります。

フロントエンドが可能ですか?私が知っている以外の方法は、サーバールートからURLと静的なサービスを照合することだけでしょうか?

+1

明らかに、あなたは本当に異なる根を持つ必要がありますか?あなたはルータを内蔵で使うことはできませんでしたか? Hubのドキュメントを参照してください。http://aurelia.io/hub.html#/doc/article/aurelia/router/latest/router-configuration/ – kettch

+0

ここでプッシュ状態の詳細に関するセクションを参照してください:http://aurelia.io /hub.html#/doc/article/aurelia/router/latest/router-configuration/1これにより、foo.com/#/adminの代わりにfoo.com/adminを使用できるようになります –

+0

これは私が設定したものですが、そうではありませんワーキング。私は "サーバー側の構成"が必要だと言っているが、詳しい説明はしていないし、そこで何をする必要があるのか​​分からない。 ... /#/ adminか.../adminに行くとプッシュ状態がオン/オフになっているかどうかは、そのページに移動する必要がありますが、私の管理ページはルータビューのどこにでも移動します。管理画面に移動するにはどうすればよいですか? –

答えて

0

私は、単に、window.location.pathnameを読んで、自分の管理ページをapp rootとして設定することで、この作業(私が動作させたかったやり方)を得ることができました。

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')); 
    } 
} 

私はこれはおそらくこれを達成するための最良の方法ではありませんが、それは今のために働いているようだと確信しています。私は実行している問題がある場合は、これを確認して更新します。

また、他の誰かが別の考え、懸念、提案、またはフィードバックでチャイムしたい場合は、してください!ありがとう!