jackcoder 3 月之前
父節點
當前提交
78fde6e5bd
共有 34 個文件被更改,包括 78 次插入23 次删除
  1. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/0.pack
  2. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/1.pack
  3. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/11.pack
  4. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/12.pack
  5. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/14.pack
  6. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/15.pack
  7. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/16.pack
  8. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/2.pack
  9. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/3.pack
  10. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/6.pack
  11. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/8.pack
  12. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/index.pack
  13. 二進制
      huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/index.pack.old
  14. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/08f8a0e649c8042c0972947f565d7fd4c4c41e1af721fdd9c7cff6aec0599bb8.json
  15. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/122cbde9923e64535974c282c9b9e5474b5cc70ca8a5e84da756b1f219b40ea8.json
  16. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/20d21e315600c9f19f8af1d53163d3c6fa62654f33350af12ce0dd9ccd3c9573.json
  17. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/39ce3b600db6d17657d0e1e0fc80ff99e4c6761d28e76a8e0c07e0685bd6e0e1.json
  18. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/425271ca1eaf9640f1f9636fe6efcabd4687690994b04c38589cf7caa2e7694a.json
  19. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/4bc4bf03a2373c9757769346e7e07eef736473c60c3187a21b8ecd75ac1e6528.json
  20. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/4cf003c82fe02932a465b5ad3a1926f76e57c6834068d2e714063c0e06a6b563.json
  21. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/5abd9ec3d57df0e26397e8770f093e1f0c9dea93cd375507f49fe6a758038f4f.json
  22. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/6126a875e0eee0985df77bf183230dff102b680f0d79978b22ce4657e81e5871.json
  23. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/7f389c6aa79217cb1c479985bd599cf1bcaf7319661b8211db229f4531d5e6c7.json
  24. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/8744d32f5240038c57a821894e9f36e3bb0697f3c0c69ead21039610290ba860.json
  25. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/b1e27f6e24583c8f2511e2a36ebfc2114456c7a40d6de096ed31f6ae0bb08146.json
  26. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/b2b836f752804bfeab0e655b5722238e8ebca9384a7e96626e2632ff74d84885.json
  27. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/be8b7949faac55a5bfc4241b060185e9224042ed19524936262c768cbdc885d2.json
  28. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/c2e2fbcfcd55d42d9cb3391a7ad0cc61011f5272f53f81337893379c2c0f1589.json
  29. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/d5568dfed8fcb5f2782571f0eb052b2822c4557919163613ea8583b8b03116f5.json
  30. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/d5f174ac84d6e45a9ab6b4f28fcfdfc4e1c097c16b9775cf0395dd8405e9e93c.json
  31. 0 0
      huinongbao-app/.angular/cache/18.2.12/babel-webpack/d9d505896c50bf8118fce29e9ce91dafcc6b373d6caef63097efeb2ec361e54a.json
  32. 1 1
      huinongbao-app/src/app/post-modal/post-modal.component.ts
  33. 11 0
      huinongbao-app/src/lib/ncloud.ts
  34. 66 22
      huinongbao-app/src/lib/user/modal-user-edit/modal-user-edit.component.ts

二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/0.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/1.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/11.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/12.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/14.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/15.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/16.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/2.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/3.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/6.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/8.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/index.pack


二進制
huinongbao-app/.angular/cache/18.2.12/angular-webpack/c4ab2ce52b528454c655a8210a90c7f3dac2606c/index.pack.old


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/08f8a0e649c8042c0972947f565d7fd4c4c41e1af721fdd9c7cff6aec0599bb8.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/122cbde9923e64535974c282c9b9e5474b5cc70ca8a5e84da756b1f219b40ea8.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/20d21e315600c9f19f8af1d53163d3c6fa62654f33350af12ce0dd9ccd3c9573.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/39ce3b600db6d17657d0e1e0fc80ff99e4c6761d28e76a8e0c07e0685bd6e0e1.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/425271ca1eaf9640f1f9636fe6efcabd4687690994b04c38589cf7caa2e7694a.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/4bc4bf03a2373c9757769346e7e07eef736473c60c3187a21b8ecd75ac1e6528.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/4cf003c82fe02932a465b5ad3a1926f76e57c6834068d2e714063c0e06a6b563.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/5abd9ec3d57df0e26397e8770f093e1f0c9dea93cd375507f49fe6a758038f4f.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/6126a875e0eee0985df77bf183230dff102b680f0d79978b22ce4657e81e5871.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/7f389c6aa79217cb1c479985bd599cf1bcaf7319661b8211db229f4531d5e6c7.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/8744d32f5240038c57a821894e9f36e3bb0697f3c0c69ead21039610290ba860.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/b1e27f6e24583c8f2511e2a36ebfc2114456c7a40d6de096ed31f6ae0bb08146.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/b2b836f752804bfeab0e655b5722238e8ebca9384a7e96626e2632ff74d84885.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/be8b7949faac55a5bfc4241b060185e9224042ed19524936262c768cbdc885d2.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/c2e2fbcfcd55d42d9cb3391a7ad0cc61011f5272f53f81337893379c2c0f1589.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/d5568dfed8fcb5f2782571f0eb052b2822c4557919163613ea8583b8b03116f5.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/d5f174ac84d6e45a9ab6b4f28fcfdfc4e1c097c16b9775cf0395dd8405e9e93c.json


File diff suppressed because it is too large
+ 0 - 0
huinongbao-app/.angular/cache/18.2.12/babel-webpack/d9d505896c50bf8118fce29e9ce91dafcc6b373d6caef63097efeb2ec361e54a.json


+ 1 - 1
huinongbao-app/src/app/post-modal/post-modal.component.ts

@@ -48,7 +48,7 @@ export class PostModalComponent {
 
     // 获取 HnbUser2 表中最近创建用户的 username
     const username = await this.getLatestUsername();
-
+    console.log(username)
     if (!username) {
       await loading.dismiss(); // 关闭加载动画
       this.showToast('用户信息获取失败,请重试。'); // 显示错误提示

+ 11 - 0
huinongbao-app/src/lib/ncloud.ts

@@ -15,6 +15,14 @@ export class CloudObject {
         return { "__type": "Pointer", "className": this.className, "objectId": this.id };
     }
 
+    // set(json: Record<string, any>) {
+    //     Object.keys(json).forEach(key => {
+    //         if (["objectId", "id", "createdAt", "updatedAt"].indexOf(key) > -1) {
+    //             return;
+    //         }
+    //         this.data[key] = json[key];
+    //     });
+    // }
     set(json: Record<string, any>) {
         Object.keys(json).forEach(key => {
             if (["objectId", "id", "createdAt", "updatedAt"].indexOf(key) > -1) {
@@ -82,6 +90,9 @@ export class CloudObject {
 
 // CloudQuery.ts
 export class CloudQuery {
+    limit(arg0: number) {
+      throw new Error('Method not implemented.');
+    }
     save(post: any) {
       throw new Error('Method not implemented.');
     }

+ 66 - 22
huinongbao-app/src/lib/user/modal-user-edit/modal-user-edit.component.ts

@@ -2,7 +2,7 @@ import { Input, OnInit } from '@angular/core';
 import { Component } from '@angular/core';
 import { ModalController } from '@ionic/angular';
 import { IonHeader, IonToolbar, IonTitle, IonContent, IonCard, IonCardContent, IonButton, IonCardHeader, IonCardTitle, IonCardSubtitle, IonInput, IonItem, IonLabel, IonList } from '@ionic/angular/standalone';
-import { CloudUser } from 'src/lib/ncloud';
+import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';
 import { CommonModule } from '@angular/common'; // 导入 CommonModule
 
 @Component({
@@ -14,7 +14,7 @@ import { CommonModule } from '@angular/common'; // 导入 CommonModule
     IonHeader,
     IonToolbar,
     IonTitle,
-    IonContent, 
+    IonContent,
     IonCard,
     IonCardContent,
     IonButton,
@@ -25,37 +25,82 @@ import { CommonModule } from '@angular/common'; // 导入 CommonModule
     IonItem,
     IonLabel,
     IonList,
-    IonCard,
     CommonModule // 添加 CommonModule
   ],
 })
-export class ModalUserEditComponent  implements OnInit {
-
-  currentUser:CloudUser|undefined
-  userData:any = {}
-  userDataChange(key:string,ev:any){
-    let value = ev?.detail?.value
-    if(value){
-      this.userData[key] = value
-    }
-  }
-  constructor(private modalCtrl:ModalController) { 
+export class ModalUserEditComponent implements OnInit {
+  currentUser: CloudUser | undefined;
+  userData: any = {};
+
+  constructor(private modalCtrl: ModalController) {
     this.currentUser = new CloudUser();
     this.userData = this.currentUser.data;
   }
 
   ngOnInit() {}
 
+  userDataChange(key: string, ev: any) {
+    let value = ev?.detail?.value;
+    if (value) {
+      this.userData[key] = value;
+    }
+  }
+
   async save() {
+    // 将年龄转换为数字
     Object.keys(this.userData).forEach(key => {
         if (key === "age") {
             this.userData[key] = Number(this.userData[key]);
         }
     });
 
+    // 查询 HnbUser2 表以获取最近更新的 username
+    const user2Query = new CloudQuery("HnbUser2");
+
+    try {
+        // 手动构建查询 URL,按 updatedAt 字段降序排列
+        const url = `http://dev.fmode.cn:1337/parse/classes/HnbUser2?order=-updatedAt&limit=1`;
+        const response = await fetch(url, {
+            headers: {
+                "x-parse-application-id": "dev",
+                "Content-Type": "application/json"
+            },
+            method: "GET"
+        });
+
+        const latestUser2Data = await response.json();
+        if (latestUser2Data.results.length > 0) {
+            const latestUser2 = new CloudObject("HnbUser2");
+            latestUser2.set(latestUser2Data.results[0]); // 设置最新用户数据
+
+            const latestUsername = latestUser2.get("username"); // 获取最近更新的用户名
+            console.log("最近更新的用户名:", latestUsername); // 调试信息
+
+            // 查询 HnbUser 表以获取对应的用户记录
+            const userQuery = new CloudQuery("HnbUser");
+            userQuery.equalTo("username", latestUsername); // 根据 username 进行查询
+
+            const userResult = await userQuery.first(); // 获取查询结果
+            if (userResult) {
+                // 更新 avatar 字段
+                userResult.set({ avatar: this.userData["avatar"] }); // 将输入的 avatar 保存到对应记录
+
+                await userResult.save(); // 保存更新后的记录
+                console.log("用户信息已更新,avatar 已保存到 HnbUser 表中");
+            } else {
+                console.error("未找到对应的用户信息,username:", latestUsername); // 调试信息
+            }
+        } else {
+            console.error("未找到最近更新的用户信息");
+        }
+    } catch (error) {
+        console.error("保存失败:", error);
+    }
+
+    // 更新当前用户信息
     this.currentUser?.set(this.userData);
     
-    // 这里使用 PUT 方法更新用户信息
+    // 使用 PUT 方法更新用户信息
     const updatedUser = await this.currentUser?.save();
     
     if (updatedUser) {
@@ -64,17 +109,16 @@ export class ModalUserEditComponent  implements OnInit {
         console.error("Failed to save user data");
     }
 }
-  cancel(){
-    this.modalCtrl.dismiss(null,"cancel")
-
+  cancel() {
+    this.modalCtrl.dismiss(null, "cancel");
   }
 }
 
-export async function openUserEditModal(modalCtrl:ModalController):Promise<CloudUser|null>{
+export async function openUserEditModal(modalCtrl: ModalController): Promise<CloudUser | null> {
   const modal = await modalCtrl.create({
     component: ModalUserEditComponent,
-    breakpoints:[0.7,1.0],
-    initialBreakpoint:0.7
+    breakpoints: [0.7, 1.0],
+    initialBreakpoint: 0.7
   });
   modal.present();
 
@@ -83,5 +127,5 @@ export async function openUserEditModal(modalCtrl:ModalController):Promise<Cloud
   if (role === 'confirm') {
     return data;
   }
-  return null
+  return null;
 }

Some files were not shown because too many files changed in this diff