tab3.page.ts 946 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Component } from '@angular/core';
  2. import { NavController, ToastController } from '@ionic/angular';
  3. import * as Parse from "parse";
  4. @Component({
  5. selector: 'app-tab3',
  6. templateUrl: './tab3.page.html',
  7. styleUrls: ['./tab3.page.scss']
  8. })
  9. export class Tab3Page {
  10. constructor(private navCtrl: NavController, private toastController: ToastController) {}
  11. async onItemClick(item: string) {
  12. const toast = await this.toastController.create({
  13. message: `Clicked on ${item}`,
  14. duration: 2000,
  15. });
  16. toast.present();
  17. }
  18. async logout() {
  19. try {
  20. await Parse.User.logOut();
  21. this.navCtrl.navigateRoot('/tabs/calendar'); // 登出后跳转到登录界面
  22. } catch (error: any) {
  23. console.error("Logout failed:", error);
  24. const toast = await this.toastController.create({
  25. message: `登出失败: ${error.message}`,
  26. duration: 2000,
  27. });
  28. toast.present();
  29. }
  30. }
  31. }