tab1.page.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'app-tab1',
  4. templateUrl: 'tab1.page.html',
  5. styleUrls: ['tab1.page.scss'],
  6. standalone: false,
  7. })
  8. export class Tab1Page {
  9. isDark = false;
  10. currentTime = this.formatTime(new Date());
  11. dynamicStats = [
  12. { value: '12', label: '已探索景点' },
  13. { value: '7.5h', label: '今日游览时长' },
  14. { value: '125km', label: '本周旅行里程' }
  15. ];
  16. smartRecommendation = '根据您的旅行偏好,推荐参观当地历史博物馆';
  17. socialFeed = [
  18. {
  19. user: {
  20. avatar: 'assets/avatars/avatar1.png',
  21. nickname: '旅行达人'
  22. },
  23. content: '发现了一个绝美的小众景点!#旅行日记',
  24. likes: 24,
  25. comments: 8
  26. },
  27. {
  28. user: {
  29. avatar: 'assets/avatars/avatar2.png',
  30. nickname: '背包客'
  31. },
  32. content: '第一次独自旅行完成!',
  33. likes: 15,
  34. comments: 5
  35. }
  36. ];
  37. constructor() {
  38. setInterval(() => {
  39. this.currentTime = this.formatTime(new Date());
  40. }, 1000);
  41. }
  42. private formatTime(date: Date): string {
  43. return `${date.getHours()}:${date.getMinutes().toString().padStart(2, '0')}`;
  44. }
  45. toggleTheme() {
  46. this.isDark = !this.isDark;
  47. document.body.classList.toggle('dark', this.isDark);
  48. }
  49. startSmartPlan() {
  50. alert(`开始${this.smartRecommendation}`);
  51. }
  52. }