fmode-ng 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2020/lib/aigc/service-fmai/service-chat/chat-class.mjs
7
7
  */
8
- import{bufferTime,concatMap,Observable,delay,finalize}from"rxjs";import Parse from"parse";const API_BASE="https://server.fmode.cn/api/apig/aigc/gpt";export function getMessageContentText(e){let t="";return"string"==typeof e&&(t=e),"object"==typeof e&&(t=e?.find((e=>e?.text))?.text||""),t}export function getMessageImageUrl(e){return"object"==typeof e?e?.find((e=>e?.image_url))?.image_url?.url||"":null}export class FmodeChat{constructor(e,t,s,i){this.ChatSession=Parse.Object.extend("ChatSession"),this.messageList=[{role:"system",content:"系统提示:AI仅供参考"}],this.userInput="",this.userImage="",this.chatServ=i,this.role=t,this.sessionId=e,s?.id&&(this.chatSession=s,this.messageList=this.chatSession.get("messageList"),this.sessionId=s?.id)}addRolePrompt(){let e=this.role?.get("prompt"),t={role:"user",content:e,hidden:!0};if(!e)return;let s=this.messageList?.map((e=>e?.content)).join();if(s.indexOf(e)>-1)return;let i=this.messageList?.findIndex((e=>"system"==e?.role)),n=i+1;this.messageList.splice(n,0,t),console.log(this.messageList)}sendMessage(e="FmodeAiTest测试问题",t){this.addRolePrompt(),t?this.messageList.push({role:"user",content:[{type:"image_url",image_url:{url:t}},{type:"text",text:e}],complete:!0,createdAt:new Date}):this.messageList.push({role:"user",content:e,complete:!0,createdAt:new Date});let s=new FmodeChatCompletion(this.fixMessageList(this.messageList),{model:this.chatServ?.currentModel?.get("code")||"fmode-3.5-4k"});console.log(this.chatServ?.currentModel?.toJSON());let i=s.sendCompletion().pipe(finalize((()=>{this.messageList[s.indexOfList].complete=!0}))).subscribe((e=>{this.messageList[s.indexOfList]=e;let t=this.chatSession?.get("messageList")?.length;this.messageList?.length>t&&(console.log("cycle新会话"),this.saveChatSession()),e?.complete&&(this.saveChatSession(),i.unsubscribe())}))}async saveChatSession(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",this.role?.toPointer()),this.chatSession.set("messageList",this.messageList),this.chatSession.set("user",Parse.User.current()?.toPointer()),this.chatSession=await this.chatSession.save(),this.sessionId=this.chatSession?.id,this.sessionId){let e=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;e=this.getInviteUrl(e),window.history.replaceState(null,null,e);let t={sid:this.chatSession?.id,rid:this.role?.id,name:this.role?.get("name"),message:this.chatSession?.get("messageList")?.[this.chatSession?.get("messageList")?.length-1]?.content?.slice(0,20),latest:this.chatSession?.createdAt};this.chatServ?.chatList?.length||(this.chatServ.chatList=[]);let s=this.chatServ?.chatList?.find((e=>e?.sid==t?.sid));s>-1?this.chatServ.chatList[s]=t:this.chatServ?.chatList.unshift(t)}}getInviteUrl(e){let t="?";t=e?.indexOf("?")>-1?"&":"?";let s=Parse.User?.current()?.id;if(-1==e?.indexOf("invite="+s)){if(!s)return e;e+=t+"invite="+s}return e}genTitle(){if(this.title)return this.title;let e=this.messageList.find((e=>"user"==e.role))?.content;return"string"==typeof e&&(this.title=e?.slice(0,15)||""),"object"==typeof e&&(this.title=e?.find((e=>e?.text))?.text||""),this.title}fixMessageList(e){return e.map((e=>({role:e.role,content:e.content})))}nowStr(){let e=new Date;return`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`}}export class FmodeChatCompletion{constructor(e,t){this.content="",this.contentBuffer=[],this.isCompleted=!1,this.indexOfList=Number(e.length),this.messages=e,this.model=t?.model||"fmode-3.5-4k"}sendCompletion(e={}){e.intTime=e?.intTime||50,e.isDirect=e?.isDirect||!1,e?.isDirect&&(e.intTime=1);let t={messages:this.messages,stream:!0,model:this.model,temperature:.5,presence_penalty:0,frequency_penalty:0};return console.log(t),new Observable((s=>{let i=RequestFmodeChatApi("/v1/chat/completions",t).subscribe((t=>{let n=String(t);if(n.indexOf("data: {")>-1){let t=chunkToJson(n),o=t?.choices?.[0]?.delta?.content||"";this.contentBuffer.push(o),this.contentPusher||(this.contentPusher=setInterval((()=>{this.isCompleted&&0==this.contentBuffer?.length&&(s.next({role:"assistant",cid:t?.id,content:this.content,complete:!0,createdAt:new Date}),i.unsubscribe(),clearInterval(this.contentPusher),s.complete()),this.contentBuffer?.length>=0&&(this.contentBuffer?.length>0&&(this.content+=this.contentBuffer.shift()),s.next({role:"assistant",cid:t?.id,content:this.content,createdAt:new Date}))}),e?.intTime))}"data: [DONE]"===n&&(this.isCompleted=!0)}))})).pipe(bufferTime(100),concatMap((e=>e)),delay(200))}}function chunkToJson(e){let t;try{t=JSON.parse(e.replaceAll("data: ",""))}catch(e){console.error(e)}return t||{}}function RequestFmodeChatApi(e,t,s="POST"){return new Observable((i=>{let n=API_BASE+e,o=`Bearer ${Parse.User.current()?.getSessionToken()||localStorage.getItem("FMODE_AI_TOKEN")}`;return t.token=o,t&&(t=JSON.stringify(t)),fetch(n,{headers:{"Content-Type":"text/plain","Cache-Control":"no-cache"},body:t||null,method:s,credentials:"omit",mode:"cors"}).then((e=>{let t="";{let s=e.body?.getReader();const n=new TextDecoder;let o=new ReadableStream({start(e){!function read(){s.read().then((({done:t,value:s})=>{if(t)return e.close(),void i.complete();e.enqueue(s),read()}))}()}}).getReader();o.read().then((function processStream({done:e,value:s}){if(e)return;!function processData(e){let s=(t+e).split("\n");if(s?.length>1){for(let e=0;e<s.length-1;e++){let t=s[e];i.next(t)}t=s[s.length-1]}}(n.decode(s)),o.read().then(processStream)}))}})).catch((e=>i.error(e))),()=>{}}))}function JsonToFormData(e){const t=new FormData;return function appendFormData(e,s=""){Array.isArray(e)?e.forEach(((e,t)=>{appendFormData(e,`${s}[${t}]`)})):"object"==typeof e&&null!==e?Object.keys(e).forEach((t=>{const i=s?`${s}.${t}`:t;appendFormData(e[t],i)})):t.append(s,e)}(e),t}
8
+ import{bufferTime,concatMap,Observable,delay,finalize}from"rxjs";import Parse from"parse";const API_BASE="https://server.fmode.cn/api/apig/aigc/gpt";export function getMessageContentText(e){let t="";return"string"==typeof e&&(t=e),"object"==typeof e&&(t=e?.find((e=>e?.text))?.text||""),t}export function getMessageImageUrl(e){return"object"==typeof e?e?.find((e=>e?.image_url))?.image_url?.url||"":null}export class FmodeChat{constructor(e,t,s,i){this.ChatSession=Parse.Object.extend("ChatSession"),this.messageList=[{role:"system",content:"系统提示:AI仅供参考"}],this.userInput="",this.userImage="",this.chatServ=i,this.role=t,this.sessionId=e,s?.id&&(this.chatSession=s,this.messageList=this.chatSession.get("messageList"),this.sessionId=s?.id)}addRolePrompt(){let e=this.role?.get("prompt"),t={role:"user",content:e,hidden:!0};if(!e)return;let s=this.messageList?.map((e=>e?.content)).join();if(s.indexOf(e)>-1)return;let i=this.messageList?.findIndex((e=>"system"==e?.role)),n=i+1;this.messageList.splice(n,0,t),console.log(this.messageList)}sendMessage(e="FmodeAiTest测试问题",t){this.addRolePrompt(),t?this.messageList.push({role:"user",content:[{type:"image_url",image_url:{url:t}},{type:"text",text:e}],complete:!0,createdAt:new Date}):this.messageList.push({role:"user",content:e,complete:!0,createdAt:new Date});let s=new FmodeChatCompletion(this.fixMessageList(this.messageList),{model:this.chatServ?.currentModel?.get("code")||"fmode-3.6-16k"});console.log(this.chatServ?.currentModel?.toJSON());let i=s.sendCompletion().pipe(finalize((()=>{this.messageList[s.indexOfList].complete=!0}))).subscribe((e=>{this.messageList[s.indexOfList]=e;let t=this.chatSession?.get("messageList")?.length;this.messageList?.length>t&&(console.log("cycle新会话"),this.saveChatSession()),e?.complete&&(this.saveChatSession(),i.unsubscribe())}))}async saveChatSession(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",this.role?.toPointer()),this.chatSession.set("messageList",this.messageList),this.chatSession.set("user",Parse.User.current()?.toPointer()),this.chatSession=await this.chatSession.save(),this.sessionId=this.chatSession?.id,this.sessionId){let e=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;e=this.getInviteUrl(e),window.history.replaceState(null,null,e);let t={sid:this.chatSession?.id,rid:this.role?.id,name:this.role?.get("name"),message:this.chatSession?.get("messageList")?.[this.chatSession?.get("messageList")?.length-1]?.content?.slice(0,20),latest:this.chatSession?.createdAt};this.chatServ?.chatList?.length||(this.chatServ.chatList=[]);let s=this.chatServ?.chatList?.find((e=>e?.sid==t?.sid));s>-1?this.chatServ.chatList[s]=t:this.chatServ?.chatList.unshift(t)}}getInviteUrl(e){let t="?";t=e?.indexOf("?")>-1?"&":"?";let s=Parse.User?.current()?.id;if(-1==e?.indexOf("invite="+s)){if(!s)return e;e+=t+"invite="+s}return e}genTitle(){if(this.title)return this.title;let e=this.messageList.find((e=>"user"==e.role))?.content;return"string"==typeof e&&(this.title=e?.slice(0,15)||""),"object"==typeof e&&(this.title=e?.find((e=>e?.text))?.text||""),this.title}fixMessageList(e){return e.map((e=>({role:e.role,content:e.content})))}nowStr(){let e=new Date;return`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`}}export class FmodeChatCompletion{constructor(e,t){this.content="",this.contentBuffer=[],this.isCompleted=!1,this.indexOfList=Number(e.length),this.messages=e,this.model=t?.model||"fmode-3.6-16k"}sendCompletion(e={}){e.intTime=e?.intTime||50,e.isDirect=e?.isDirect||!1,e?.isDirect&&(e.intTime=1);let t={messages:this.messages,stream:!0,model:this.model,temperature:.5,presence_penalty:0,frequency_penalty:0};return console.log(t),new Observable((s=>{let i=RequestFmodeChatApi("/v1/chat/completions",t).subscribe((t=>{let n=String(t);if(n.indexOf("data: {")>-1){let t=chunkToJson(n),o=t?.choices?.[0]?.delta?.content||"";this.contentBuffer.push(o),this.contentPusher||(this.contentPusher=setInterval((()=>{this.isCompleted&&0==this.contentBuffer?.length&&(s.next({role:"assistant",cid:t?.id,content:this.content,complete:!0,createdAt:new Date}),i.unsubscribe(),clearInterval(this.contentPusher),s.complete()),this.contentBuffer?.length>=0&&(this.contentBuffer?.length>0&&(this.content+=this.contentBuffer.shift()),s.next({role:"assistant",cid:t?.id,content:this.content,createdAt:new Date}))}),e?.intTime))}"data: [DONE]"===n&&(this.isCompleted=!0)}))})).pipe(bufferTime(100),concatMap((e=>e)),delay(200))}}function chunkToJson(e){let t;try{t=JSON.parse(e.replaceAll("data: ",""))}catch(e){console.error(e)}return t||{}}function RequestFmodeChatApi(e,t,s="POST"){return new Observable((i=>{let n=API_BASE+e,o=`Bearer ${Parse.User.current()?.getSessionToken()||localStorage.getItem("FMODE_AI_TOKEN")}`;return t.token=o,t&&(t=JSON.stringify(t)),fetch(n,{headers:{"Content-Type":"text/plain","Cache-Control":"no-cache"},body:t||null,method:s,credentials:"omit",mode:"cors"}).then((e=>{let t="";{let s=e.body?.getReader();const n=new TextDecoder;let o=new ReadableStream({start(e){!function read(){s.read().then((({done:t,value:s})=>{if(t)return e.close(),void i.complete();e.enqueue(s),read()}))}()}}).getReader();o.read().then((function processStream({done:e,value:s}){if(e)return;!function processData(e){let s=(t+e).split("\n");if(s?.length>1){for(let e=0;e<s.length-1;e++){let t=s[e];i.next(t)}t=s[s.length-1]}}(n.decode(s)),o.read().then(processStream)}))}})).catch((e=>i.error(e))),()=>{}}))}function JsonToFormData(e){const t=new FormData;return function appendFormData(e,s=""){Array.isArray(e)?e.forEach(((e,t)=>{appendFormData(e,`${s}[${t}]`)})):"object"==typeof e&&null!==e?Object.keys(e).forEach((t=>{const i=s?`${s}.${t}`:t;appendFormData(e[t],i)})):t.append(s,e)}(e),t}
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIwL2xpYi9haWdjL3NlcnZpY2UtZm1haS9zZXJ2aWNlLWNoYXQvY2hhdC1jbGFzcy5tanM=`
10
10
 
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2020/lib/aigc/service-fmai/service-chat/chat.service.mjs
7
7
  */
8
- import{Injectable}from"@angular/core";import{Router}from"@angular/router";import{FmodeChat}from"./chat-class";import Parse from"parse";import{NovaCloudService}from"../../../nova-cloud";import{AlertController,NavController,Platform}from"@ionic/angular";import{CrossService}from"../../../platform";import*as i0 from"@angular/core";import*as i1 from"@angular/router";import*as i2 from"../../../nova-cloud";import*as i3 from"@ionic/angular";import*as i4 from"../../../platform";export class ChatService{constructor(e,t,a,r,i,o){this.router=e,this.ncloud=t,this.platform=a,this.alertCtrl=r,this.navCtrl=i,this.cross=o,this.chatMap={},this.isCapacitor=!1,this.platformMap={pc:"电脑端",mobile:"移动端"},this.isCapacitor=this.platform.is("capacitor")}async loadModelList(e){let t=new Parse.Query("ChatModel");t.notEqualTo("isDeleted",!0),t.equalTo("isEnabled",!0),t.addAscending("index"),this.modelList=await t.find(),this.currentModel=e||this.modelList?.find((e=>"fmode-3.5-4k"==e.get("code")))}async doButtonAction(e){let t=this.cross.navMenuType,a=e?.platform?.map((e=>this.platformMap[e])).join("、");if(e?.platform?.length>0&&-1==e?.platform?.indexOf(t)){(await this.alertCtrl.create({header:"注意",subHeader:"终端不符",message:`请您使用${a}开启本功能。`,buttons:[{role:"ok",text:"知道了"}]})).present()}else e?.path&&this.navCtrl.navigateRoot(e?.path)}async initChatMap(e){if(this.chatMap[e])return this.chatMap[e];let t=new Parse.Query("ChatSession");t.include("role","role.model");let a=await t.get(e),r=new FmodeChat(a?.id,a?.get("role"),a,this);return this.chatMap[e]=r,this.chatMap[e]}async getChatSession(){if(!Parse?.User?.current()?.id)return;let e=new Parse.Query("ChatSession");e.include("role","role.model"),e.addDescending("updatedAt"),e.equalTo("user",Parse.User.current().toPointer()),e.notEqualTo("isDeleted",!0),e.limit(10);let t=await e.find();this.chatList=t.map((e=>(this.chatMap[e?.id]=new FmodeChat(e?.id,e?.get("role"),e),{session:e,sid:e?.id,isHidden:!1,rid:e?.get("role")?.id,name:e?.get("role")?.get("name"),thumb:e?.get("role")?.get("thumb"),title:e?.get("title")||e?.get("role")?.get("name"),message:e?.get("messageList")?.[e?.get("messageList")?.length-1]?.content?.slice(0,20),latest:e?.createdAt})))}async getChatSessionDistinct(){let e=await this.ncloud.novaql('SELECT t1."objectId" as sid , "AvatarRole"."objectId" as rid, * FROM (\n SELECT *,ROW_NUMBER() OVER (PARTITION BY "user", "role" ORDER BY "createdAt" DESC) AS rn\n FROM "ChatSession" WHERE "user"=$1\n ) as t1\n LEFT JOIN "AvatarRole" ON "AvatarRole"."objectId" = t1."role"\n WHERE t1.rn=1\n LIMIT $2\n ;',[Parse.User.current()?.id,10]),t=e?.map((e=>({sid:e?.sid,rid:e?.rid,name:e?.name,message:e?.messageList?.[e?.messageList?.length-1]?.content?.slice(0,20),latest:e?.createdAt})));return this.chatList=t,this.chatList}createChatPanel(e,t){let a=t?.id||"new";t=new FmodeChat(a,e,t,this),this.chatMap[a]=t,this.router.navigate(["/chat/pro/chat/"+a])}async createNewRoleChat(e){let t=new Parse.Query("AvatarRole");t.include("model");let a=await t.get(e);return new FmodeChat("new",a,null,this)}async restoreChatPanel(e){let t=new Parse.Query("AvatarRole"),a=new Parse.Query("ChatSession"),r=await t.get(e?.rid),i=await a.get(e?.sid),o=new FmodeChat(e?.sid,r,i);this.chatMap[e?.sid]=o,this.router.navigate(["/chat/pro/chat/"+e?.sid])}async callRole(e){if(this.isCapacitor)document.body.classList.add("dark"),this.router.navigate([`/avatar/role/${e.id}`,{type:"phone"}]);else{(await this.alertCtrl.create({header:"注意",subHeader:"语音对话,限手机APP端可用",message:"请联系客服获取内测资格哦!",buttons:[{role:"ok",text:"知道了"}]})).present()}}}ChatService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,deps:[{token:i1.Router},{token:i2.NovaCloudService},{token:i3.Platform},{token:i3.AlertController},{token:i3.NavController},{token:i4.CrossService}],target:i0.ɵɵFactoryTarget.Injectable}),ChatService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.Router},{type:i2.NovaCloudService},{type:i3.Platform},{type:i3.AlertController},{type:i3.NavController},{type:i4.CrossService}]}});
8
+ import{Injectable}from"@angular/core";import{Router}from"@angular/router";import{FmodeChat}from"./chat-class";import Parse from"parse";import{NovaCloudService}from"../../../nova-cloud";import{AlertController,NavController,Platform}from"@ionic/angular";import{CrossService}from"../../../platform";import*as i0 from"@angular/core";import*as i1 from"@angular/router";import*as i2 from"../../../nova-cloud";import*as i3 from"@ionic/angular";import*as i4 from"../../../platform";export class ChatService{constructor(e,t,a,r,i,o){this.router=e,this.ncloud=t,this.platform=a,this.alertCtrl=r,this.navCtrl=i,this.cross=o,this.chatMap={},this.isCapacitor=!1,this.platformMap={pc:"电脑端",mobile:"移动端"},this.isCapacitor=this.platform.is("capacitor")}async loadModelList(e){let t=new Parse.Query("ChatModel");t.notEqualTo("isDeleted",!0),t.equalTo("isEnabled",!0),t.addAscending("index"),this.modelList=await t.find(),this.currentModel=e||this.modelList?.find((e=>"fmode-3.6-16k"==e.get("code")))}async doButtonAction(e){let t=this.cross.navMenuType,a=e?.platform?.map((e=>this.platformMap[e])).join("、");if(e?.platform?.length>0&&-1==e?.platform?.indexOf(t)){(await this.alertCtrl.create({header:"注意",subHeader:"终端不符",message:`请您使用${a}开启本功能。`,buttons:[{role:"ok",text:"知道了"}]})).present()}else e?.path&&this.navCtrl.navigateRoot(e?.path)}async initChatMap(e){if(this.chatMap[e])return this.chatMap[e];let t=new Parse.Query("ChatSession");t.include("role","role.model");let a=await t.get(e),r=new FmodeChat(a?.id,a?.get("role"),a,this);return this.chatMap[e]=r,this.chatMap[e]}async getChatSession(){if(!Parse?.User?.current()?.id)return;let e=new Parse.Query("ChatSession");e.include("role","role.model"),e.addDescending("updatedAt"),e.equalTo("user",Parse.User.current().toPointer()),e.notEqualTo("isDeleted",!0),e.limit(10);let t=await e.find();this.chatList=t.map((e=>(this.chatMap[e?.id]=new FmodeChat(e?.id,e?.get("role"),e),{session:e,sid:e?.id,isHidden:!1,rid:e?.get("role")?.id,name:e?.get("role")?.get("name"),thumb:e?.get("role")?.get("thumb"),title:e?.get("title")||e?.get("role")?.get("name"),message:e?.get("messageList")?.[e?.get("messageList")?.length-1]?.content?.slice(0,20),latest:e?.createdAt})))}async getChatSessionDistinct(){let e=await this.ncloud.novaql('SELECT t1."objectId" as sid , "AvatarRole"."objectId" as rid, * FROM (\n SELECT *,ROW_NUMBER() OVER (PARTITION BY "user", "role" ORDER BY "createdAt" DESC) AS rn\n FROM "ChatSession" WHERE "user"=$1\n ) as t1\n LEFT JOIN "AvatarRole" ON "AvatarRole"."objectId" = t1."role"\n WHERE t1.rn=1\n LIMIT $2\n ;',[Parse.User.current()?.id,10]),t=e?.map((e=>({sid:e?.sid,rid:e?.rid,name:e?.name,message:e?.messageList?.[e?.messageList?.length-1]?.content?.slice(0,20),latest:e?.createdAt})));return this.chatList=t,this.chatList}createChatPanel(e,t){let a=t?.id||"new";t=new FmodeChat(a,e,t,this),this.chatMap[a]=t,this.router.navigate(["/chat/pro/chat/"+a])}async createNewRoleChat(e){let t=new Parse.Query("AvatarRole");t.include("model");let a=await t.get(e);return new FmodeChat("new",a,null,this)}async restoreChatPanel(e){let t=new Parse.Query("AvatarRole"),a=new Parse.Query("ChatSession"),r=await t.get(e?.rid),i=await a.get(e?.sid),o=new FmodeChat(e?.sid,r,i);this.chatMap[e?.sid]=o,this.router.navigate(["/chat/pro/chat/"+e?.sid])}async callRole(e){if(this.isCapacitor)document.body.classList.add("dark"),this.router.navigate([`/avatar/role/${e.id}`,{type:"phone"}]);else{(await this.alertCtrl.create({header:"注意",subHeader:"语音对话,限手机APP端可用",message:"请联系客服获取内测资格哦!",buttons:[{role:"ok",text:"知道了"}]})).present()}}}ChatService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,deps:[{token:i1.Router},{token:i2.NovaCloudService},{token:i3.Platform},{token:i3.AlertController},{token:i3.NavController},{token:i4.CrossService}],target:i0.ɵɵFactoryTarget.Injectable}),ChatService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.Router},{type:i2.NovaCloudService},{type:i3.Platform},{type:i3.AlertController},{type:i3.NavController},{type:i4.CrossService}]}});
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIwL2xpYi9haWdjL3NlcnZpY2UtZm1haS9zZXJ2aWNlLWNoYXQvY2hhdC5zZXJ2aWNlLm1qcw==`
10
10
 
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2020/lib/platform/cross.service.mjs
7
7
  */
8
- import{Injectable}from"@angular/core";import{ModalController,NavController,Platform}from"@ionic/angular";import*as i0 from"@angular/core";import*as i1 from"@ionic/angular";export class CrossService{constructor(t,e,i){this.platform=t,this.modalCtrl=e,this.navCtrl=i,this.mobileWidth=915,this.clientWidth=document.body.clientWidth,this.clientWidth=document.body.clientWidth,this.updateWidth(),this.onResizeScreen()}async dismisModalTop(t){let e=await this.modalCtrl.getTop();e&&(t?.preventDefault&&t?.preventDefault(),e.dismiss(),e.isOpen=!1)}updateWidth(){this.fixInterval=setInterval((()=>{if(this.clientWidth)return clearInterval(this.fixInterval),void delete this.fixInterval;console.log(document.body.clientWidth),this.clientWidth=document.body.clientWidth}),200)}onResizeScreen(t){this.clientWidth=document.body.clientWidth,this.clientWidth>=this.mobileWidth?(this.leftMenuMode="horizontal",this.navMenuType="pc"):(this.leftMenuMode="inline",this.navMenuType="mobile")}}CrossService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,deps:[{token:i1.Platform},{token:i1.ModalController},{token:i1.NavController}],target:i0.ɵɵFactoryTarget.Injectable}),CrossService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.Platform},{type:i1.ModalController},{type:i1.NavController}]}});
8
+ import{Injectable}from"@angular/core";import{ModalController,NavController,Platform}from"@ionic/angular";import*as i0 from"@angular/core";import*as i1 from"@ionic/angular";export class CrossService{getMenuType(){return this.clientWidth=document.body.clientWidth,this.onResizeScreen(),this.navMenuType}constructor(e,t,i){this.platform=e,this.modalCtrl=t,this.navCtrl=i,this.mobileWidth=915,this.clientWidth=document.body.clientWidth,this.clientWidth=document.body.clientWidth,this.updateWidth(),this.onResizeScreen()}async dismisModalTop(e){let t=await this.modalCtrl.getTop();t&&(e?.preventDefault&&e?.preventDefault(),t.dismiss(),t.isOpen=!1)}updateWidth(){this.fixInterval=setInterval((()=>{if(this.clientWidth)return clearInterval(this.fixInterval),void delete this.fixInterval;console.log(document.body.clientWidth),this.clientWidth=document.body.clientWidth}),200)}onResizeScreen(e){this.clientWidth=document.body.clientWidth,this.clientWidth>=this.mobileWidth?(this.leftMenuMode="horizontal",this.navMenuType="pc"):(this.leftMenuMode="inline",this.navMenuType="mobile")}}CrossService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,deps:[{token:i1.Platform},{token:i1.ModalController},{token:i1.NavController}],target:i0.ɵɵFactoryTarget.Injectable}),CrossService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.Platform},{type:i1.ModalController},{type:i1.NavController}]}});
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIwL2xpYi9wbGF0Zm9ybS9jcm9zcy5zZXJ2aWNlLm1qcw==`
10
10