私はイオン2/angular2の状況を抱えています。私はそれをどのように処理するのか本当に分かりません。私のコードのガイド。グローバルに@ ng-idle/coreを使用してログインページを使用せずに
私の画面がアイドル状態の私のとき私は、上記のコードによると以下のように定義されてapp.componentファイル(これは私がするつもりですどこだけで理解するだけのサンプルです)
import { Page1,LoginPage } from '../pages/pages';
import { Component } from '@angular/core';
import {Idle, DEFAULT_INTERRUPTSOURCES} from '@ng-idle/core';
import {Keepalive} from '@ng-idle/keepalive';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
public pages = [
{
title: 'Page 1', // I want when the user is on this page or other pages except Login, to sign the user out on Idle state
icon: 'apps',
count: 0,
component: Page1
}]
rootPage: any = LoginPage;
idleState = 'Not started.';
timedOut = false;
lastPing?: Date = null;
constructor(public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
public _menuController: MenuController,
private idle: Idle,
private keepalive: Keepalive){
this.initializeApp();
idle.setIdle(5);
idle.setTimeout(5);
idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
idle.onIdleEnd.subscribe(() => this.idleState = 'No longer idle.');
idle.onTimeout.subscribe(() => {
this.idleState = 'Timed out!';
this.timedOut = true;
});
idle.onIdleStart.subscribe(() => this.idleState = 'You\'ve gone idle!');
idle.onTimeoutWarning.subscribe((countdown) => this.idleState = 'You will
time out in ' + countdown + ' seconds!');
keepalive.interval(15);
keepalive.onPing.subscribe(() => this.lastPing = new Date());
this.reset();
}
reset() {
this.idle.watch();
this.idleState = 'Started.';
this.timedOut = false;
}
}
を持っていますアイドル状態を示すようにthis.idleStateを設定します。しかし、今私はログインページがあり、10ページ(この例では私は1)があるかもしれません。ユーザーがアイドル状態のときに状況が必要です。ユーザーをroot(ログイン)にポップします。私の質問は、私はすべてのページ上のコンストラクタでコードのブロックを繰り返し、そこから私のユーザーをログオンする必要がありますか、またはヘルパークラスを作成し、すべてのpages.Iに注入することができますアドバイスや回避策が必要です
このプラグインは実際のデバイスで動作しますか?私は発射するイベントを得ることができませんが、それはブラウザで素晴らしい動作します。 –
@Dexterこれはもっと良い解決策を見つけましたか? –