|
@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
|
import { IonicModule } from '@ionic/angular';
|
|
import { IonicModule } from '@ionic/angular';
|
|
|
-import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
|
|
|
|
|
+import { addIcons } from 'ionicons';
|
|
|
|
|
+import { addOutline, trash } from 'ionicons/icons';
|
|
|
|
|
|
|
|
interface Task {
|
|
interface Task {
|
|
|
id: number;
|
|
id: number;
|
|
@@ -21,8 +22,7 @@ interface Task {
|
|
|
IonicModule,
|
|
IonicModule,
|
|
|
CommonModule,
|
|
CommonModule,
|
|
|
FormsModule
|
|
FormsModule
|
|
|
- ],
|
|
|
|
|
- schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
|
|
|
|
|
|
+ ]
|
|
|
})
|
|
})
|
|
|
export class Tab1Page implements OnInit {
|
|
export class Tab1Page implements OnInit {
|
|
|
tasks: Task[] = [];
|
|
tasks: Task[] = [];
|
|
@@ -35,7 +35,13 @@ export class Tab1Page implements OnInit {
|
|
|
endTime: new Date().toISOString(),
|
|
endTime: new Date().toISOString(),
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- constructor() {}
|
|
|
|
|
|
|
+ constructor() {
|
|
|
|
|
+ // 注册图标
|
|
|
|
|
+ addIcons({
|
|
|
|
|
+ 'add-outline': addOutline,
|
|
|
|
|
+ 'trash': trash
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
|
const savedTasks = localStorage.getItem('tasks');
|
|
const savedTasks = localStorage.getItem('tasks');
|
|
@@ -109,6 +115,11 @@ export class Tab1Page implements OnInit {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getTaskColor(index: number): string {
|
|
|
|
|
+ const colors = ['#ffebee', '#e3f2fd', '#e8f5e9', '#fff3e0', '#f3e5f5'];
|
|
|
|
|
+ return colors[index % colors.length];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private saveTasks() {
|
|
private saveTasks() {
|
|
|
localStorage.setItem('tasks', JSON.stringify(this.tasks));
|
|
localStorage.setItem('tasks', JSON.stringify(this.tasks));
|
|
|
}
|
|
}
|