Browse Source

update:tab2 page acl

cainiao-hue 3 months ago
parent
commit
ec443a98e9

+ 13 - 5
soul-app/src/app/tab2/tab2.page.ts

@@ -42,8 +42,8 @@ export class Tab2Page {
         return
       }     
     }
-    if(currentUser?.get("realname")){
-      userPrompt += `当前来访的用户,姓名:${currentUser?.get("realname")}`
+    if(currentUser?.get("username")){
+      userPrompt += `当前来访的用户,姓名:${currentUser?.get("username")}`
     }
     if(currentUser?.get("gender")){
       userPrompt += `,性别:${currentUser?.get("gender")}`
@@ -56,10 +56,18 @@ export class Tab2Page {
     let consult = new CloudObject("ChatRecord")
     let now = new Date();
     let dateStr = `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}`
+    //对象权限的精确制定
+    let ACL:any = {//公开访客 不可读 不可写
+      "*":{read:false,write:false}
+    }
+    if(currentUser?.id){//当前用户 可读 可写
+      ACL[currentUser?.id] = {read:true,write:true}
+    }
     consult.set({
       title:`${chatpartner.get('expertise') || ""}领域聊天记录${dateStr}-${chatpartner.get('name')}`,
       chatpartner:chatpartner.toPointer(),
-      user:currentUser.toPointer()
+      user:currentUser.toPointer(),
+      ACL:ACL
     })
     let options:ChatPanelOptions = {
       roleId:"2DXJkRsjXK",
@@ -73,10 +81,10 @@ export class Tab2Page {
         chat.role.set("prompt", `
         # 角色设定
         您是${chatpartner.get("name")},一位${chatpartner.get("bio")},${chatpartner.get("expertise")},需要为用户提供陪伴和支持等积极情绪。
-        # 对话环节
-        每次回复用户消息都在消息结尾附带[祝你有愉快的一天]
         # 开始话语
         当您准备好了,可以以一个关心用户的朋友的身份,向来访的用户打招呼。
+        # 对话环节
+        每次回复用户消息都在消息结尾附带[祝你有愉快的一天]
         ${userPrompt}
         `);
       },

+ 0 - 4
soul-app/src/app/tab3/tab3.page.html

@@ -7,8 +7,6 @@
 </ion-header>
 
 <ion-content [fullscreen]="true">
-
-
   <!-- 用户登录状态 -->
   <ion-card>
     <!-- 未登录 -->
@@ -27,7 +25,6 @@
             <ion-card-subtitle style="font-size: 16px;">性别: {{currentUser?.get("gender") || "-"}} 年龄: {{currentUser?.get("age") || "-"}}</ion-card-subtitle>
           </div>
         </div>
-
       </ion-card-header>
       }
       <ion-card-content>
@@ -45,7 +42,6 @@
     }
     </ion-card-content>
   </ion-card>
-
   <!-- 功能列表 -->
   <ion-list>
     <!-- 个人信息设置 -->

+ 1 - 1
soul-app/src/lib/ncloud.ts

@@ -16,7 +16,7 @@ export class CloudObject {
 
     set(json: Record<string, any>) {
         Object.keys(json).forEach(key => {
-            if (["objectId", "id", "createdAt", "updatedAt", "ACL"].indexOf(key) > -1) {
+            if (["objectId", "id", "createdAt", "updatedAt"].indexOf(key) > -1) {
                 return;
             }
             this.data[key] = json[key];