cnhis-design-vue 3.2.19-beta.3 → 3.2.19-beta.4

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.
Files changed (41) hide show
  1. package/es/components/ai-chat/index.d.ts +146 -17
  2. package/es/components/ai-chat/src/Index.vue.d.ts +146 -17
  3. package/es/components/ai-chat/src/Index.vue2.js +1 -1
  4. package/es/components/ai-chat/src/api/index.d.ts +6 -0
  5. package/es/components/ai-chat/src/api/index.js +1 -0
  6. package/es/components/ai-chat/src/components/ChatAudio.vue.d.ts +43 -0
  7. package/es/components/ai-chat/src/components/ChatAudio.vue.js +1 -0
  8. package/es/components/ai-chat/src/components/ChatAudio.vue2.js +1 -0
  9. package/es/components/ai-chat/src/components/ChatCard.js +1 -1
  10. package/es/components/ai-chat/src/components/ChatFooter.vue.d.ts +54 -2
  11. package/es/components/ai-chat/src/components/ChatFooter.vue2.js +1 -1
  12. package/es/components/ai-chat/src/components/ChatMain.d.ts +1 -7
  13. package/es/components/ai-chat/src/components/ChatMain.js +1 -1
  14. package/es/components/ai-chat/src/components/ChatMainInner.d.ts +2 -0
  15. package/es/components/ai-chat/src/components/ChatMainInner.js +1 -0
  16. package/es/components/ai-chat/src/components/ChatRight.vue.d.ts +56 -0
  17. package/es/components/ai-chat/src/components/ChatRight.vue.js +1 -0
  18. package/es/components/ai-chat/src/components/ChatRight.vue2.js +1 -0
  19. package/es/components/ai-chat/src/components/card/JsonCard.d.ts +25 -0
  20. package/es/components/ai-chat/src/components/card/JsonCard.js +1 -0
  21. package/es/components/ai-chat/src/components/card/SelectIcon.d.ts +14 -0
  22. package/es/components/ai-chat/src/components/card/SelectIcon.js +1 -0
  23. package/es/components/ai-chat/src/hooks/useProgram.d.ts +6 -0
  24. package/es/components/ai-chat/src/hooks/useProgram.js +1 -0
  25. package/es/components/ai-chat/src/hooks/useWebsocket.d.ts +2 -0
  26. package/es/components/ai-chat/src/hooks/useWebsocket.js +1 -0
  27. package/es/components/ai-chat/src/utils/index.d.ts +1 -0
  28. package/es/components/ai-chat/src/utils/index.js +1 -1
  29. package/es/components/ai-chat/style/index.css +1 -1
  30. package/es/components/audio-sdk/src/audioSDK.d.ts +6 -7
  31. package/es/components/audio-sdk/src/audioSDK.js +1 -1
  32. package/es/components/audio-sdk/src/utils/recordingModal.d.ts +2 -1
  33. package/es/components/audio-sdk/src/utils/recordingModal.js +1 -1
  34. package/es/components/editor/src/Editor.js +1 -1
  35. package/es/components/editor/style/index.css +1 -0
  36. package/es/components/index.css +1 -1
  37. package/es/shared/assets/img/file-emr.png.js +1 -0
  38. package/es/shared/assets/img/file.png.js +1 -0
  39. package/es/shared/assets/img/use.png.js +1 -0
  40. package/es/shared/package.json.js +1 -1
  41. package/package.json +2 -2
@@ -1 +1 @@
1
- import{ref as e}from"vue";import t from"recorder-core";import"recorder-core/src/engine/mp3";import"recorder-core/src/engine/mp3-engine";import{RecordingModal as s}from"./utils/recordingModal.js";const i=class{constructor(){if(this.recordingModal=new s,this.webSocket=null,this.messageHandlerQueue=[],this.recorder=null,this.contentRef=e(""),this.realTimeSendStartTime=0,this.realTimeSendBytesChunks=[],this.realTimeSendClearPrevBufferIdx=0,this.timer=null,this.option={},this.hasEventListener=!1,this.isReady=!1,i.instance)return i.instance;i.instance=this}static create(){return new i}initRecorder(){this.recorder=t({type:"mp3",sampleRate:16e3,bitRate:16,...this.option.realTimeRecognition?{onProcess:this.onProcess.bind(this),takeoffEncodeChunk:this.takeoffEncodeChunk.bind(this)}:{}})}async onProcess(e,t,s,i,r){0===this.realTimeSendStartTime&&(this.realTimeSendStartTime=Date.now(),this.realTimeSendBytesChunks=[],this.realTimeSendClearPrevBufferIdx=0);for(let t=this.realTimeSendClearPrevBufferIdx;t<r;t++)e[t]=null;this.realTimeSendClearPrevBufferIdx=r}async takeoffEncodeChunk(e){var t;e&&this.realTimeSendBytesChunks.push(e);const s=Date.now();if(s-this.realTimeSendStartTime<i.sendInterval)return;this.realTimeSendStartTime=s;let r=0;for(let e=0;e<this.realTimeSendBytesChunks.length;e++)r+=this.realTimeSendBytesChunks[e].length;const n=new Uint8Array(r);for(let e=0,t=0;e<this.realTimeSendBytesChunks.length;e++){const s=this.realTimeSendBytesChunks[e];n.set(s,t),t+=s.length}if(this.realTimeSendBytesChunks=[],n.length>0){const e=new Blob([n],{type:"audio/wav"});null==(t=this.webSocket)||t.send(e)}}run(e,t){this.recorder||this.initRecorder(),this.messageHandlerQueue.push(t),this.option.timed&&(this.timer=setTimeout((()=>{this.stop()}),1e3*this.option.timed)),this.recorder.open((()=>{this.recorder.start(),this.recordingModal.show(e,{contentRef:this.contentRef,onClose:()=>this.stop()})}),((e,t)=>{this.handleError({msg:e,isUserNotAllow:t})}))}start(e,t={}){return Object.assign(this.option,t),new Promise(((t,s)=>{if(this.messageHandlerQueue.length>0)return void s({result:"fail",msg:"当前已存在正在录音的任务"});if(this.hasEventListener||(document.addEventListener("keydown",this.handleKeydown),this.hasEventListener=!0),!this.webSocket)return this.webSocket=new WebSocket("wss://emr-tl.cnhis.com/audio/socket"),this.webSocket.onopen=()=>{this.isReady=!0,this.run(e,{resolve:t,reject:s})},this.webSocket.onmessage=this.handleMessage.bind(this),this.webSocket.onerror=()=>console.log("WebSocket连接失败"),void(this.webSocket.binaryType="blob");const i=this;!async function r(n=0){if(n>5)return s({result:"fail",msg:"WebSocket连接失败"});i.isReady?i.run(e,{resolve:t,reject:s}):setTimeout((()=>{r(++n)}),100)}()}))}stop(){if(this.recordingModal.hide(),this.option.realTimeRecognition){const e=this.messageHandlerQueue.shift();if(!e)return;const{resolve:t,reject:s}=e;t({result:"success",data:{text:this.contentRef.value}}),this.reset()}else this.recorder.stop((async(e,t)=>{var s;null==(s=this.webSocket)||s.send(e)}),(e=>{this.handleError({msg:e})}),!0)}handleError(e){const t=this.messageHandlerQueue.shift();if(!t)return;const{resolve:s,reject:i}=t;i({result:"fail",...e}),this.reset()}handleMessage(e){const{data:t}=e||{};if(!function(e){try{return JSON.parse(e),!0}catch(e){return!1}}(t))return void this.handleError({msg:"接收数据不是一个有效SJON"});const s=JSON.parse(t);if("success"===s.msg)if(this.option.realTimeRecognition)this.contentRef.value+=s.data.text.replace(/[??,。,.\s]/g,"");else{const e=this.messageHandlerQueue.shift();if(!e)return;const{resolve:t,reject:i}=e;t({result:"success",data:s.data.text.replace(/[??,。,.\s]/g,"")}),this.reset()}else this.handleError({msg:s.msg})}handleKeydown(e){var t,s,r,n;if(" "===e.key||"Space"===e.code){if(!(null==(s=null==(t=i.instance)?void 0:t.recordingModal)?void 0:s.rendered)||0===(null==(r=i.instance)?void 0:r.messageHandlerQueue.length))return;e.preventDefault(),null==(n=i.instance)||n.stop()}}reset(){var e;null==(e=this.recorder)||e.close(),this.realTimeSendStartTime=0,this.contentRef.value="",this.timer&&(clearTimeout(this.timer),this.timer=null),this.option={realTimeRecognition:!1,allowPunctuationMark:!0,timed:5},this.messageHandlerQueue=[]}destroy(){this.webSocket&&(this.webSocket.close(),this.webSocket=null,this.isReady=!1),document.removeEventListener("keydown",this.handleKeydown),this.hasEventListener=!1,this.reset(),this.recorder=null}static destroy(){i.instance&&(i.instance.destroy(),i.instance=null)}};let r=i;r.sendInterval=1500;export{r as default};
1
+ import{ref as e}from"vue";import t from"recorder-core";import"recorder-core/src/engine/mp3";import"recorder-core/src/engine/mp3-engine";import{RecordingModal as s}from"./utils/recordingModal.js";const i=class{constructor(){if(this.recordingModal=null,this.webSocket=null,this.messageHandlerQueue=[],this.recorder=null,this.contentRef=e(""),this.realTimeSendStartTime=0,this.realTimeSendBytesChunks=[],this.realTimeSendClearPrevBufferIdx=0,this.timer=null,this.option={},this.hasEventListener=!1,this.isReady=!1,i.instance)return i.instance;i.instance=this}static create(){return new i}initRecorder(){this.recorder=t({type:"mp3",sampleRate:16e3,bitRate:16,...this.option.realTimeRecognition&&this.option.recognizable?{onProcess:this.onProcess.bind(this),takeoffEncodeChunk:this.takeoffEncodeChunk.bind(this)}:{}})}async onProcess(e,t,s,i,r){0===this.realTimeSendStartTime&&(this.realTimeSendStartTime=Date.now(),this.realTimeSendBytesChunks=[],this.realTimeSendClearPrevBufferIdx=0);for(let t=this.realTimeSendClearPrevBufferIdx;t<r;t++)e[t]=null;this.realTimeSendClearPrevBufferIdx=r}async takeoffEncodeChunk(e){var t;e&&this.realTimeSendBytesChunks.push(e);const s=Date.now();if(s-this.realTimeSendStartTime<i.sendInterval)return;this.realTimeSendStartTime=s;let r=0;for(let e=0;e<this.realTimeSendBytesChunks.length;e++)r+=this.realTimeSendBytesChunks[e].length;const n=new Uint8Array(r);for(let e=0,t=0;e<this.realTimeSendBytesChunks.length;e++){const s=this.realTimeSendBytesChunks[e];n.set(s,t),t+=s.length}if(this.realTimeSendBytesChunks=[],n.length>0){const e=new Blob([n],{type:"audio/wav"});null==(t=this.webSocket)||t.send(e)}}run(e,t){this.recorder||this.initRecorder(),this.messageHandlerQueue.push(e),this.option.timed&&(this.timer=setTimeout((()=>{this.stop()}),1e3*this.option.timed)),this.recorder.open((()=>{var e;this.recorder.start(),null==(e=this.recordingModal)||e.show({instance:t,contentRef:this.contentRef,onClose:()=>this.stop()})}),((e,t)=>{this.handleError({msg:e,isUserNotAllow:t})}))}start(e,t){return Object.assign(this.option,{recognizable:!0,showModal:!0},t||{}),this.option.recognizable||(this.option.showModal=!1),new Promise(((t,i)=>{if(this.messageHandlerQueue.length>0)return void i({result:"fail",msg:"当前已存在正在录音的任务"});const{showModal:r}=this.option;if(r&&!this.recordingModal&&(this.recordingModal=new s),r&&!this.hasEventListener&&(document.addEventListener("keydown",this.handleKeydown),this.hasEventListener=!0),this.option.recognizable&&!this.webSocket)return this.webSocket=new WebSocket("wss://emr-tl.cnhis.com/audio/socket"),this.webSocket.onopen=()=>{this.isReady=!0,this.run({resolve:t,reject:i},e)},this.webSocket.onmessage=this.handleMessage.bind(this),this.webSocket.onerror=()=>console.log("WebSocket连接失败"),void(this.webSocket.binaryType="blob");const n=this;!async function s(r=0){if(r>5)return i({result:"fail",msg:"WebSocket连接失败"});n.option.recognizable&&!n.isReady?setTimeout((()=>{s(++r)}),100):n.run({resolve:t,reject:i},e)}()}))}pause(){var e;null==(e=this.recorder)||e.pause()}resume(){var e;null==(e=this.recorder)||e.resume()}stop(){var e,t;if(null==(e=this.recordingModal)||e.hide(),this.option.realTimeRecognition&&this.option.recognizable){const e=this.messageHandlerQueue.shift();if(!e)return;const{resolve:t,reject:s}=e;t({result:"success",data:{text:this.contentRef.value}}),this.reset()}else null==(t=this.recorder)||t.stop((async(e,t)=>{var s;if(this.option.recognizable)null==(s=this.webSocket)||s.send(e);else{const t=this.messageHandlerQueue.shift();if(!t)return;const{resolve:s,reject:i}=t;s({result:"success",data:e}),this.reset()}}),(e=>{this.handleError({msg:e})}),!0)}handleError(e){const t=this.messageHandlerQueue.shift();if(!t)return;const{resolve:s,reject:i}=t;i({result:"fail",...e}),this.reset()}handleMessage(e){const{data:t}=e||{};if(!function(e){try{return JSON.parse(e),!0}catch(e){return!1}}(t))return void this.handleError({msg:"接收数据不是一个有效SJON"});const s=JSON.parse(t);if("success"===s.msg)if(this.option.realTimeRecognition)this.contentRef.value+=s.data.text.replace(/[??,。,.\s]/g,"");else{const e=this.messageHandlerQueue.shift();if(!e)return;const{resolve:t,reject:i}=e;t({result:"success",data:s.data.text.replace(/[??,。,.\s]/g,"")}),this.reset()}else this.handleError({msg:s.msg})}handleKeydown(e){var t,s,r,n;if(" "===e.key||"Space"===e.code){if(!(null==(s=null==(t=i.instance)?void 0:t.recordingModal)?void 0:s.rendered)||0===(null==(r=i.instance)?void 0:r.messageHandlerQueue.length))return;e.preventDefault(),null==(n=i.instance)||n.stop()}}reset(){var e;null==(e=this.recorder)||e.close(),this.realTimeSendStartTime=0,this.contentRef.value="",this.timer&&(clearTimeout(this.timer),this.timer=null),this.option={realTimeRecognition:!1,allowPunctuationMark:!0,timed:5},this.messageHandlerQueue=[]}destroy(){this.webSocket&&(this.webSocket.close(),this.webSocket=null,this.isReady=!1),document.removeEventListener("keydown",this.handleKeydown),this.hasEventListener=!1,this.reset(),this.recorder=null}static destroy(){i.instance&&(i.instance.destroy(),i.instance=null)}};let r=i;r.sendInterval=1500;export{r as default};
@@ -2,9 +2,10 @@ import { ComponentInternalInstance, Ref } from 'vue';
2
2
  export declare class RecordingModal {
3
3
  rendered: boolean;
4
4
  target: HTMLElement | null;
5
- show(instance: ComponentInternalInstance, { contentRef, onClose }: {
5
+ show({ contentRef, onClose, instance }: {
6
6
  contentRef: Ref<string>;
7
7
  onClose: () => void;
8
+ instance?: ComponentInternalInstance;
8
9
  }): void;
9
10
  hide(): void;
10
11
  }
@@ -1 +1 @@
1
- import{ref as e,render as t,createVNode as n,withCtx as r,nextTick as o}from"vue";import{createProviderWrapper as s}from"../../../../shared/utils/index.js";import l from"../components/recording.vue.js";class i{constructor(){this.rendered=!1,this.target=null}show(i,{contentRef:d,onClose:a}){if(this.rendered)return;this.rendered=!0;const u=document.createElement("div"),h=e(!1),c=s(i);t(n(c,null,{default:r((()=>n(l,{to:u,content:d.value,show:h.value,"onUpdate:show":e=>h.value=e,onClose:()=>p(),onAfterLeave:()=>p()},null)),i)}),u);const m=this;var v;function p(){a()}v=u,document.body.appendChild(v),m.target=v,o((()=>h.value=!0))}hide(){var e;(null==(e=this.target)?void 0:e.parentElement)&&(this.rendered=!1,this.target.parentElement.removeChild(this.target),this.target=null)}}export{i as RecordingModal};
1
+ import{ref as e,render as t,createVNode as n,withCtx as r,nextTick as o}from"vue";import{createProviderWrapper as s}from"../../../../shared/utils/index.js";import i from"../components/recording.vue.js";class l{constructor(){this.rendered=!1,this.target=null}show({contentRef:l,onClose:a,instance:d}){if(this.rendered)return;this.rendered=!0;const u=document.createElement("div"),h=e(!1),c=s(d);t(n(c,null,{default:r((()=>n(i,{to:u,content:l.value,show:h.value,"onUpdate:show":e=>h.value=e,onClose:()=>p(),onAfterLeave:()=>p()},null)),d)}),u);const m=this;var v;function p(){a()}v=u,document.body.appendChild(v),m.target=v,o((()=>h.value=!0))}hide(){var e;(null==(e=this.target)?void 0:e.parentElement)&&(this.rendered=!1,this.target.parentElement.removeChild(this.target),this.target=null)}}export{l as RecordingModal};
@@ -1 +1 @@
1
- import{defineComponent as e,shallowRef as o,reactive as t,onBeforeUnmount as r,createVNode as d,mergeProps as l}from"vue";import"@wangeditor/editor/dist/css/style.css";import{Editor as i,Toolbar as s}from"@wangeditor/editor-for-vue";var n=e({name:"Editor",inheritAttrs:!1,components:{Editor:i,Toolbar:s},props:{editorConfig:{type:Object},toolbarConfig:{type:Object},uploadImgUrl:{type:String},isDisabled:{type:Boolean,default:!1}},emits:[],setup(e,{attrs:n,slots:a,emit:u}){const p=o(),f=t({MENU_CONF:{uploadImage:{server:e.uploadImgUrl||""}},...e.editorConfig});r((()=>{const e=p.value;null!=e&&e.destroy()}));const c=o=>{p.value=o,e.isDisabled&&o.disable(),console.log("实例",o)};return{editorRef:p,renderVN:()=>d("div",{style:"border: 1px solid #ccc"},[d(s,{style:"border-bottom: 1px solid #ccc",editor:p.value,defaultConfig:e.toolbarConfig,mode:"default"},null),d(i,l({style:"height: 500px; overflow-y: hidden;"},n,{defaultConfig:f,mode:"default",onOnCreated:c}),null)])}},render(){return this.renderVN()}});export{n as default};
1
+ import{defineComponent as e,shallowRef as t,reactive as o,onBeforeUnmount as r,createVNode as i,mergeProps as l}from"vue";import"@wangeditor/editor/dist/css/style.css";import{Editor as d,Toolbar as s}from"@wangeditor/editor-for-vue";var a=e({name:"Editor",inheritAttrs:!1,components:{Editor:d,Toolbar:s},props:{editorConfig:{type:Object},toolbarConfig:{type:Object},uploadImgUrl:{type:String},isDisabled:{type:Boolean,default:!1}},emits:[],setup(e,{attrs:a,slots:n,emit:u}){const p=t(),c=o({MENU_CONF:{uploadImage:{server:e.uploadImgUrl||""}},...e.editorConfig});r((()=>{const e=p.value;null!=e&&e.destroy()}));const f=t=>{p.value=t,e.isDisabled&&t.disable(),console.log("实例",t)};return{editorRef:p,renderVN:()=>i("div",{class:"c-editor"},[i(s,{style:"border-bottom: 1px solid #ccc",editor:p.value,defaultConfig:e.toolbarConfig,mode:"default"},null),i(d,l({class:"c-editor__main",style:"height: 500px"},a,{defaultConfig:c,mode:"default",onOnCreated:f}),null)])}},render(){return this.renderVN()}});export{a as default};
@@ -0,0 +1 @@
1
+ .c-editor{border:1px solid #ccc}.c-editor__main{height:500px;overflow-y:hidden}