| 
					
				 | 
			
			
				@@ -1,47 +1,106 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { Injectable } from '@angular/core'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { Diary } from '../modals/diary.modal'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { AlertController } from '@ionic/angular'; // 添加这行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// import { Injectable } from '@angular/core'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// import { Diary } from '../modals/diary.modal'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// import { AlertController } from '@ionic/angular'; // 添加这行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-@Injectable({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  providedIn: 'root' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-export class DiaryService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  private storageKey = 'diaries'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    modalCtrl: any; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// @Injectable({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   providedIn: 'root' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// export class DiaryService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   private storageKey = 'diaries'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     modalCtrl: any; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //alertCtrl: any; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //storage: any; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     //alertCtrl: any; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     //storage: any; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  constructor(private alertCtrl: AlertController) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   constructor(private alertCtrl: AlertController) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  async getDiaries(): Promise<Diary[]> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const data = localStorage.getItem(this.storageKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return data ? JSON.parse(data) : []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  async addDiary(diary: Diary): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    diaries.push(diary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    localStorage.setItem(this.storageKey, JSON.stringify(diaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   async getDiaries(): Promise<Diary[]> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     const data = localStorage.getItem(this.storageKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     return data ? JSON.parse(data) : []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  async updateDiary(updatedDiary: Diary): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const index = diaries.findIndex(d => d.id === updatedDiary.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (index !== -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      diaries[index] = updatedDiary; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      localStorage.setItem(this.storageKey, JSON.stringify(diaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   async addDiary(diary: Diary): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     diaries.push(diary); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     localStorage.setItem(this.storageKey, JSON.stringify(diaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   async deleteDiary(id: number): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//   async updateDiary(updatedDiary: Diary): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //     const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     //await this.storage.set('diaries', updatedDiaries); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     const index = diaries.findIndex(d => d.id === updatedDiary.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     if (index !== -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//       diaries[index] = updatedDiary; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//       localStorage.setItem(this.storageKey, JSON.stringify(diaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   async deleteDiary(id: number): Promise<boolean> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   async deleteDiary(id: number): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     //await this.storage.set('diaries', updatedDiaries); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   async deleteDiary(id: number): Promise<boolean> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     return new Promise<boolean>(async (resolve) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       const alert = await this.alertCtrl.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         header: '确认删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         message: '确定要删除这篇日记吗?', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         buttons: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //             text: '取消', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //             role: 'cancel', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //             handler: () => resolve(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //             text: '删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //             handler: async () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //               const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //               const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //               localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //               resolve(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   async deleteDiary(id: number): Promise<boolean> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   const alert = await this.alertCtrl.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     header: '确认删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     message: '确定要删除这篇日记吗?', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     buttons: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         text: '取消', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         role: 'cancel', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         handler: () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         text: '删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         handler: () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           this.confirmDelete(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //           return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// // private async confirmDelete(id: number) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //   localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// async deleteDiary(id: number): Promise<boolean> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //     return new Promise<boolean>(async (resolve) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //       const alert = await this.alertCtrl.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //         header: '确认删除', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -59,6 +118,8 @@ export class DiaryService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //               const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //               localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //               resolve(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//               // 关闭当前页面并返回tab1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//             //this.modalCtrl.dismiss({ deleted: true }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //         ] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -67,72 +128,11 @@ export class DiaryService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //       await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   async deleteDiary(id: number): Promise<boolean> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   const alert = await this.alertCtrl.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     header: '确认删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     message: '确定要删除这篇日记吗?', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     buttons: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//       { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         text: '取消', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         role: 'cancel', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         handler: () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//           return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//       }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//       { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         text: '删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         handler: () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//           this.confirmDelete(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//           return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// private async confirmDelete(id: number) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//   localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async deleteDiary(id: number): Promise<boolean> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return new Promise<boolean>(async (resolve) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      const alert = await this.alertCtrl.create({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        header: '确认删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        message: '确定要删除这篇日记吗?', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        buttons: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            text: '取消', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            role: 'cancel', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            handler: () => resolve(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            text: '删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            handler: async () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              const diaries = await this.getDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              const updatedDiaries = diaries.filter(d => d.id !== id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              localStorage.setItem(this.storageKey, JSON.stringify(updatedDiaries)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              resolve(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              // 关闭当前页面并返回tab1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //this.modalCtrl.dismiss({ deleted: true }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await alert.present(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    async onDelete(id: number) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     const success = await this.diaryService.deleteDiary(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     if (success) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//       // 刷新列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//       this.loadDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //    async onDelete(id: number) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     const success = await this.diaryService.deleteDiary(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     if (success) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       // 刷新列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //       this.loadDiaries(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// //  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// } 
			 |