|
@@ -1,68 +1,60 @@
|
|
import { Component } from '@angular/core';
|
|
import { Component } from '@angular/core';
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent, IonCard, IonCardContent, IonCardHeader, IonChip, IonButton, IonButtons, IonList, IonItem, IonIcon } from '@ionic/angular/standalone';
|
|
|
|
-
|
|
|
|
-import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
|
|
|
+import { IonicModule } from '@ionic/angular';
|
|
|
|
+import { CommonModule, DatePipe } from '@angular/common';
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
-import { CommonModule } from '@angular/common';
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-tab1',
|
|
selector: 'app-tab1',
|
|
- templateUrl: 'tab1.page.html',
|
|
|
|
- styleUrls: ['tab1.page.scss'],
|
|
|
|
|
|
+ templateUrl: './tab1.page.html',
|
|
|
|
+ styleUrls: ['./tab1.page.scss'],
|
|
standalone: true,
|
|
standalone: true,
|
|
- imports: [
|
|
|
|
- CommonModule,
|
|
|
|
- IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
|
|
|
|
- IonCard,IonCardContent,IonCardHeader,IonChip,
|
|
|
|
- IonButton,IonButtons,IonList,IonItem,IonIcon
|
|
|
|
- ],
|
|
|
|
|
|
+ imports: [IonicModule, CommonModule, DatePipe],
|
|
})
|
|
})
|
|
export class Tab1Page {
|
|
export class Tab1Page {
|
|
- currentDate: Date = new Date();
|
|
|
|
- sleepDuration: string = '7小时30分钟';
|
|
|
|
- sleepTime: string = '22:30';
|
|
|
|
- wakeTime: string = '06:00';
|
|
|
|
- lastDreamDescription: string = '在海边漫步';
|
|
|
|
- emotion: string = '放松';
|
|
|
|
- dreamImages: string[] = [
|
|
|
|
- 'assets/images/dream1.jpg',
|
|
|
|
- 'assets/images/dream2.jpg',
|
|
|
|
- 'assets/images/dream3.jpg',
|
|
|
|
- ];
|
|
|
|
- improvementSuggestion: string = '保持卧室安静和黑暗';
|
|
|
|
- sleepTips: string[] = [
|
|
|
|
- '定时作息,建立良好睡眠习惯',
|
|
|
|
- '避免晚上使用电子设备',
|
|
|
|
- '保持卧室温度适宜',
|
|
|
|
|
|
+ recentDreams = [
|
|
|
|
+ {
|
|
|
|
+ title: '飞翔的城市',
|
|
|
|
+ date: new Date('2023-10-20'),
|
|
|
|
+ emotion: '愉悦',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '迷失的森林',
|
|
|
|
+ date: new Date('2023-10-18'),
|
|
|
|
+ emotion: '恐惧',
|
|
|
|
+ },
|
|
|
|
+ // 更多示例梦境
|
|
];
|
|
];
|
|
|
|
|
|
constructor(private router: Router) {}
|
|
constructor(private router: Router) {}
|
|
|
|
|
|
- getSleepQualityStars(): number[] {
|
|
|
|
- return Array(4).fill(0); // 假设4颗星
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- recordDream() {
|
|
|
|
- // 记录梦境的逻辑
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- analyzeDream() {
|
|
|
|
- // 解梦的逻辑
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- viewAllDreams() {
|
|
|
|
- // 查看所有梦境的逻辑
|
|
|
|
|
|
+ // 导航到指定页面
|
|
|
|
+ navigateTo(page: string) {
|
|
|
|
+ this.router.navigate([`/tabs/${page}`]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 打开设置页面
|
|
openSettings() {
|
|
openSettings() {
|
|
- // 打开设置页面的逻辑
|
|
|
|
|
|
+ this.router.navigate(['/settings']);
|
|
}
|
|
}
|
|
|
|
|
|
- openProfile() {
|
|
|
|
- // 打开个人资料页面的逻辑
|
|
|
|
|
|
+ // 打开梦境详情页
|
|
|
|
+ openDreamDetail(dream: any) {
|
|
|
|
+ this.router.navigate(['/dream-detail'], { state: { dream } });
|
|
}
|
|
}
|
|
|
|
|
|
- navigateTo(page: string) {
|
|
|
|
- this.router.navigate([page]);
|
|
|
|
|
|
+ // 根据情感获取对应的图标名称
|
|
|
|
+ getEmotionIcon(emotion: string): string {
|
|
|
|
+ switch (emotion) {
|
|
|
|
+ case '愉悦':
|
|
|
|
+ return 'happy-outline';
|
|
|
|
+ case '悲伤':
|
|
|
|
+ return 'sad-outline';
|
|
|
|
+ case '恐惧':
|
|
|
|
+ return 'alert-circle-outline';
|
|
|
|
+ case '平静':
|
|
|
|
+ return 'leaf-outline';
|
|
|
|
+ default:
|
|
|
|
+ return 'help-outline';
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|