|
|
@@ -3,6 +3,7 @@ import { Component, Input, OnInit } from '@angular/core';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
import { IonList,IonButton, IonButtons, IonContent, IonHeader, IonInput, IonItem, IonLabel, IonTitle, IonToolbar, ModalController, IonToast, ToastController, IonAvatar } from '@ionic/angular/standalone';
|
|
|
import { CloudComment, CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';
|
|
|
+import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
@@ -22,7 +23,7 @@ export class PostCommentComponent implements OnInit {
|
|
|
avatarUrl: string = 'assets/img/random.png'; // 默认头像路径
|
|
|
usersMap = new Map<string, CloudObject[]>();
|
|
|
|
|
|
- constructor( private toastController: ToastController) {
|
|
|
+ constructor( private toastController: ToastController,private modalCtrl:ModalController) {
|
|
|
this.currentUser = new CloudUser(); // 初始化当前用户
|
|
|
}
|
|
|
|
|
|
@@ -73,6 +74,11 @@ export class PostCommentComponent implements OnInit {
|
|
|
|
|
|
// 发送评论
|
|
|
async sendComment() {
|
|
|
+if(!this.currentUser?.id){
|
|
|
+ await openUserLoginModal(this.modalCtrl);
|
|
|
+ }
|
|
|
+ if(this.currentUser?.id)
|
|
|
+ {
|
|
|
if (!this.commentData['content']) {
|
|
|
console.error('评论内容不能为空');
|
|
|
return; // 如果评论内容为空,直接返回
|
|
|
@@ -96,7 +102,7 @@ export class PostCommentComponent implements OnInit {
|
|
|
}catch (error) {
|
|
|
console.error('评论失败:', error);
|
|
|
|
|
|
- }
|
|
|
+ }}
|
|
|
|
|
|
}
|
|
|
|