|
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
|
import { IonHeader, IonToolbar, IonTitle, IonContent, IonCard, IonCardContent,
|
|
import { IonHeader, IonToolbar, IonTitle, IonContent, IonCard, IonCardContent,
|
|
|
IonButton, IonCardHeader, IonCardTitle, IonCardSubtitle, IonIcon } from '@ionic/angular/standalone';
|
|
IonButton, IonCardHeader, IonCardTitle, IonCardSubtitle, IonIcon } from '@ionic/angular/standalone';
|
|
|
-import { ModalController, AlertController } from '@ionic/angular/standalone';
|
|
|
|
|
|
|
+import { ModalController, AlertController, ToastController } from '@ionic/angular/standalone';
|
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
|
import { openUserLoginModal } from '../../lib/user/modal-user-login/modal-user-login.component';
|
|
import { openUserLoginModal } from '../../lib/user/modal-user-login/modal-user-login.component';
|
|
|
import { CloudUser } from '../../lib/ncloud';
|
|
import { CloudUser } from '../../lib/ncloud';
|
|
@@ -46,7 +46,8 @@ export class Tab4Page implements OnInit {
|
|
|
private modalCtrl: ModalController,
|
|
private modalCtrl: ModalController,
|
|
|
private alertController: AlertController,
|
|
private alertController: AlertController,
|
|
|
private auth: AuthService,
|
|
private auth: AuthService,
|
|
|
- private focusDataService: FocusDataService
|
|
|
|
|
|
|
+ private focusDataService: FocusDataService,
|
|
|
|
|
+ private toastController: ToastController
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
@@ -108,17 +109,28 @@ export class Tab4Page implements OnInit {
|
|
|
|
|
|
|
|
async logout() {
|
|
async logout() {
|
|
|
try {
|
|
try {
|
|
|
- await this.auth.logout();
|
|
|
|
|
- this.currentUser?.logOut();
|
|
|
|
|
- this.currentUser = undefined;
|
|
|
|
|
- } catch (error: any) {
|
|
|
|
|
|
|
+ await Parse.User.logOut();
|
|
|
|
|
+
|
|
|
|
|
+ localStorage.removeItem('currentUser');
|
|
|
|
|
+
|
|
|
|
|
+ this.router.navigate(['/login']);
|
|
|
|
|
+
|
|
|
|
|
+ const toast = await this.toastController.create({
|
|
|
|
|
+ message: '已成功登出',
|
|
|
|
|
+ duration: 2000,
|
|
|
|
|
+ color: 'success',
|
|
|
|
|
+ position: 'top'
|
|
|
|
|
+ });
|
|
|
|
|
+ await toast.present();
|
|
|
|
|
+ } catch (error) {
|
|
|
console.error('Logout error:', error);
|
|
console.error('Logout error:', error);
|
|
|
- const alert = await this.alertController.create({
|
|
|
|
|
- header: '登出失败',
|
|
|
|
|
- message: error.message || '请稍后重试',
|
|
|
|
|
- buttons: ['确定']
|
|
|
|
|
|
|
+ const toast = await this.toastController.create({
|
|
|
|
|
+ message: '登出失败,请重试',
|
|
|
|
|
+ duration: 2000,
|
|
|
|
|
+ color: 'danger',
|
|
|
|
|
+ position: 'top'
|
|
|
});
|
|
});
|
|
|
- await alert.present();
|
|
|
|
|
|
|
+ await toast.present();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|