|
|
@@ -1,14 +1,49 @@
|
|
|
import { Component } from '@angular/core';
|
|
|
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
|
|
|
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonInput, IonButton, IonCheckbox } from '@ionic/angular/standalone';
|
|
|
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
+import { FormsModule } from '@angular/forms';
|
|
|
+import { CommonModule } from '@angular/common'; // 导入 CommonModule
|
|
|
+
|
|
|
+interface Task {
|
|
|
+ id: number;
|
|
|
+ title: string;
|
|
|
+ completed: boolean;
|
|
|
+}
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-tab1',
|
|
|
templateUrl: 'tab1.page.html',
|
|
|
styleUrls: ['tab1.page.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
|
|
|
+ imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonInput, IonButton, IonCheckbox, ExploreContainerComponent, FormsModule, CommonModule], // 添加 CommonModule
|
|
|
})
|
|
|
export class Tab1Page {
|
|
|
- constructor() {}
|
|
|
-}
|
|
|
+ tasks: Task[] = [];
|
|
|
+ newTaskTitle: string = '';
|
|
|
+
|
|
|
+ constructor() {
|
|
|
+ // 添加一些初始任务
|
|
|
+ this.tasks.push({ id: 1, title: '示例任务 1', completed: false });
|
|
|
+ this.tasks.push({ id: 2, title: '示例任务 2', completed: false });
|
|
|
+ }
|
|
|
+
|
|
|
+ addTask() {
|
|
|
+ if (this.newTaskTitle.trim()) {
|
|
|
+ const newTask: Task = {
|
|
|
+ id: this.tasks.length + 1,
|
|
|
+ title: this.newTaskTitle,
|
|
|
+ completed: false,
|
|
|
+ };
|
|
|
+ this.tasks.push(newTask);
|
|
|
+ this.newTaskTitle = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ toggleTaskCompletion(task: Task) {
|
|
|
+ task.completed = !task.completed;
|
|
|
+ }
|
|
|
+
|
|
|
+ deleteTask(taskId: number) {
|
|
|
+ this.tasks = this.tasks.filter(task => task.id !== taskId);
|
|
|
+ }
|
|
|
+}
|