cnhis-design-vue 3.2.7-beta.7 → 3.2.7-beta.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -466,9 +466,9 @@ declare const _default: import("vue").DefineComponent<{
466
466
  hide: boolean;
467
467
  }>;
468
468
  draggable: boolean;
469
+ isHighlightRow: boolean;
469
470
  idx: number;
470
471
  isHighlight: boolean;
471
- isHighlightRow: boolean;
472
472
  isFieldSet: boolean;
473
473
  fieldDescribeMode: "column" | "tooltip";
474
474
  }>;
@@ -488,9 +488,9 @@ declare const _default: import("vue").DefineComponent<{
488
488
  hide: boolean;
489
489
  }>;
490
490
  draggable: boolean;
491
+ isHighlightRow: boolean;
491
492
  idx: number;
492
493
  isHighlight: boolean;
493
- isHighlightRow: boolean;
494
494
  isFieldSet: boolean;
495
495
  fieldDescribeMode: "column" | "tooltip";
496
496
  }>;
@@ -612,9 +612,9 @@ declare const _default: import("vue").DefineComponent<{
612
612
  hide: boolean;
613
613
  }>;
614
614
  draggable: boolean;
615
+ isHighlightRow: boolean;
615
616
  idx: number;
616
617
  isHighlight: boolean;
617
- isHighlightRow: boolean;
618
618
  isFieldSet: boolean;
619
619
  fieldDescribeMode: "column" | "tooltip";
620
620
  }>;
@@ -725,8 +725,8 @@ declare const _default: import("vue").DefineComponent<{
725
725
  showSeq: boolean;
726
726
  footerFlag: boolean;
727
727
  fieldDescribeMode: "column" | "tooltip";
728
- showSearch: boolean;
729
728
  customColumns: FieldSetColumnItem[];
729
+ showSearch: boolean;
730
730
  showSortPriority: boolean;
731
731
  showHeadFilter: boolean;
732
732
  }>;
@@ -317,9 +317,9 @@ declare const _default: import("vue").DefineComponent<{
317
317
  hide: boolean;
318
318
  }>;
319
319
  draggable: boolean;
320
+ isHighlightRow: boolean;
320
321
  idx: number;
321
322
  isHighlight: boolean;
322
- isHighlightRow: boolean;
323
323
  isFieldSet: boolean;
324
324
  fieldDescribeMode: "column" | "tooltip";
325
325
  }>;
@@ -1 +1 @@
1
- import{arrayed as e,deepOmit as o}from"../../../../shared/utils/index.js";import{cloneDeep as t,castArray as n,pick as i}from"lodash-es";import"../../index.js";import{parseNumberFromMaybeString as r,formRenderLog as l}from"../utils/index.js";import{useFieldNormalize as s}from"./useFieldNormalize.js";import{fieldKeyEscape as a,createLinebarId as p}from"../utils/schema.js";import{useFormValidator as c}from"./useFormValidator.js";import{transformDateFormat as d}from"../utils/business.js";function m(e,o){Object.assign(e["x-component-props"],{...i(o,["wordbook","autograph"])})}function u(e,o){Object.assign(e["x-component-props"],{...i(o,["urlConfig","wordbook"])})}function f(e){return"1"===e||!0===e}function x(x,_){const{createValidatorSchema:h}=c(),b=e=>{var o;const t={name:e.val_key,type:null!=(o=e.fieldType)?o:"string",title:e.alias||e.name,"x-component":e.html_type,default:e.default_val,"x-component-props":{placeholder:e.placeholder,clearable:"0"===e.is_empty,...e.componentProps||{}},"x-content":e.slots,"x-display":"0"===e.is_show?"hidden":"visible","x-pattern":"0"===e.is_edit?"disabled":"editable","x-compile-omitted":["title","x-component-props","x-decorator-props"]};e.reactions&&(t["x-reactions"]=e.reactions),e.noDecorator||Object.assign(t,{"x-decorator":"FORM_ITEM","x-decorator-props":{fieldItem:e,beforeSetValue:null==_?void 0:_.beforeSetValue,span:2*(e.elem_width||3),showLabel:"1"!==e.hide_title,remark:e.remark,propertyKey:e.val_key,annotation:e.annotation,...e.decoratorProps||{}}});const n=h(e);return n&&(t["x-validator"]=n),"0"===e.is_null&&(t.required=!0),t},v=e=>{var o,t,n,l,s,a,p,c,d,x,_,h,v,g;const y=b(e);e.urlConfig?u(y,e):e.autograph&&m(y,e);const w=!!e.__multiple,C=f(null!=(t=null==(o=e.componentProps)?void 0:o.allowModify)?t:e.allowModify),O=f(null!=(l=null==(n=e.componentProps)?void 0:n.selectAll)?l:e.selectAll),A=f(null!=(a=null==(s=e.componentProps)?void 0:s.shouldSave)?a:e.save_free_entry),E=f(null!=(c=null==(p=e.componentProps)?void 0:p.allowCreate)?c:e.free_entry),j=null!=(x=null==(d=e.componentProps)?void 0:d.showField)?x:e.show_key,k=null!=(h=null==(_=e.componentProps)?void 0:_.options)?h:e.option,N=null!=(g=r(e.multi_select_value))?g:null==(v=e.componentProps)?void 0:v.maxTagCount;return Object.assign(y["x-component-props"],{multiple:w,options:k,allowModify:C,allowCreate:E||C,shouldSave:A,showField:j,maxTagCount:N,selectAll:O,...i(e,["lazyRequest","requestCache"])}),w&&(y.type="array"),y},g=e=>{var o,t;const n=b(e),i=null!=(t=null==(o=e.componentProps)?void 0:o.selectAll)?t:e.selectAll;return Object.assign(n["x-component-props"],{options:e.option,childFieldStrategy:e.childFieldStrategy,childWidthMode:e.childWidthMode,vertical:e.__vertical,selectAll:"1"===i||!0===i}),e.urlConfig?u(n,e):e.autograph&&m(n,e),n},y=e=>{const t=b(e);return Object.assign(t["x-component-props"],{fieldItem:o(e,["reactions"])}),t},w=e=>({name:e.val_key,type:"void",title:e.alias||e.name,"x-component":"LINEBAR","x-display":"visible","x-component-props":{linebarTextDirection:e.linebarTextDirection,linebarDirection:e.linebarDirection,linebarWidth:e.linebarWidth,disabled:"1"===e.is_not_fold,id:p(e.val_key),show:"0"!==e.is_show,remark:e.remark},"x-content":e.slots}),C=new Map([["LINEBAR",w],["LINE_BREAKS",e=>({name:e.val_key,type:"void",title:e.alias||e.name,"x-component":"LINE_BREAKS","x-component-props":{border:e.lineBreaksBorder},"x-display":"0"===e.is_show?"hidden":"visible"})],["INPUT",e=>{const o=b(e);return Object.assign(o["x-component-props"],{...i(e,["prefix","suffix"])}),o}],["TEXTAREA",e=>{const o=b(e);return Object.assign(o["x-component-props"],{rows:e.initialize_high||3}),o}],["INPUT_NUMBER",e=>{const o=b(e),{decimal_length:t,validate:n,allowSlash:i}=e;return!0!==i&&"1"!==i||(o["x-component"]="INPUT_NUMBER_SLASH",o.type="string"),Object.assign(o["x-component-props"],{precision:r(null!=t?t:null==n?void 0:n.decimal_length),whiteList:e.whiteList,prefix:e.prefix,suffix:e.suffix}),o}],["SELECT",v],["REMOTE_SEARCH",v],["DATE",e=>{const o=b(e);return Object.assign(o["x-component-props"],{valueFormat:e.date_format,type:d(e.date_format),validate:e.validate}),o}],["TIME",e=>{const o=b(e);return Object.assign(o["x-component-props"],{format:e.date_format,type:d(e.date_format),validate:e.validate}),o}],["LEVEL_SEARCH_CASCADER",e=>{const o=b(e);return Object.assign(o["x-component-props"],{...i(e,["wordbook","lazyRequest","autograph"])}),"1"===e.is_allow_check_mid&&e.allow_check_mid_level&&(o["x-component-props"].checkAbleLevel=+e.allow_check_mid_level),o}],["SEARCH_CASCADER",e=>{var o;const t=b(e);return Object.assign(t["x-component-props"],{urlConfig:e.urlConfig,depth:null==(o=e.wordbook)?void 0:o.level_num,options:e.option}),t}],["COMBINATION",e=>{const o=b(e);return o.type="array","table"===e.displayMode?o["x-component"]="TABLE_COMBINATION":!1!==e.jsonCombination&&(o["x-component"]="JSON_COMBINATION"),Object.assign(o["x-decorator-props"],{showLabel:!1,showFeedback:!1}),Object.assign(o["x-component-props"],{title:e.alias||e.name,maxGroupNum:e.maxGroupNum,minGroupNum:e.minGroupNum,showLabel:"1"!==e.hide_title,properties:e.children||[],combinationItemDeletable:e.combinationItemDeletable}),o}],["RADIO",g],["CHECKBOX",g],["SWITCH",e=>{const o=b(e);return Object.assign(o["x-component-props"],{openDescription:e.open,closeDescription:e.close,showMode:e.show_mode}),o}],["SLIDER",e=>{const o=b(e);return Object.assign(o["x-component-props"],{step:r(e.step_length),max:r(e.max_length),min:r(e.min_length),option:e.option}),o}],["COMPLEX",e=>{const o=b(e);Array.isArray(e.properties)&&l("COMPLEX控件的properties属性已经废弃, 请使用children作为替代, 在之后的版本中properties属性将不再支持");const t=Array.isArray(e.properties||e.children)?k(e.properties||e.children):{};return o.type=e.fieldType||"void",o.properties=t,Object.assign(o["x-decorator-props"],{showFeedback:!1}),Object.assign(o["x-component-props"],i(e,["wrapperStyle","display"])),o}]]),O=e=>{if(e.suffixConfig)return A(e);return(C.get(e.html_type)||y)(e)},A=o=>{if(!o.suffixConfig&&!o.prefixConfig)return O(o);const t=o.suffixConfig?e(o.suffixConfig):[],n=[...(o.prefixConfig?e(o.prefixConfig):[]).map((e=>({elem_width:o.elem_width,...e,hide_title:"1",is_show:"1"}))),{...o,is_show:"1",hide_title:"1",suffixConfig:void 0,prefixConfig:void 0},...t.map((e=>({elem_width:o.elem_width,...e,hide_title:"1",is_show:"1"})))],i=b(o),r=n.reduce(((e,o)=>e+2*(o.elem_width||3)),0);return Object.assign(i,{type:"void",name:a(n),title:o.alias||o.name,"x-component":"INPUT_GROUP","x-component-props":{span:r},"x-decorator-props":{...i["x-decorator-props"],showFeedback:!1,suffixFields:n.map((e=>e.val_key))},properties:k(n)}),i},{FieldNormalizeWaterfallHook:E,FieldListNormalizeWaterfallHook:j}=s();function k(o,i={column:9999}){let r=null;const l=j.call(t(o),i).reduce(((e,o,n)=>{var l;const a=null==(l=(o=E.call(o,i)).validate)?void 0:l.obj_type;return a&&x&&x.collect(a,t(o)),"LINEBAR"===o.html_type?(e[p(o)]=s(w(o),n),r=e[p(o)].properties={}):r?r[p(o)]=s(O(o),n):(r=null,e[p(o)]=s(O(o),n)),e}),{});return i.linebarAutoHidden&&Object.values(l).forEach((e=>{if("LINEBAR"!==e["x-component"])return;e["x-reactions"]?e["x-reactions"]=n(e["x-reactions"]):e["x-reactions"]=[];const o=Object.keys(e.properties||{}).map((o=>`${e.name}.${o}#selfDisplay`));e["x-reactions"].push({dependencies:o,fulfill:{state:{visible:"{{hasVisible($deps)}}"}}})})),l;function s(e,o){return e["x-index"]=o,e["x-decorator-props"]={_index:o,...e["x-decorator-props"]},e}function p(o){return o.suffixConfig?a([o,...e(o.suffixConfig)]):o.val_key}}return{schemaAdaptor:k}}export{x as useFieldListAdaptor};
1
+ import{arrayed as e,deepOmit as o}from"../../../../shared/utils/index.js";import{cloneDeep as t,castArray as n,pick as i}from"lodash-es";import"../../index.js";import{parseNumberFromMaybeString as r,formRenderLog as l}from"../utils/index.js";import{useFieldNormalize as s}from"./useFieldNormalize.js";import{traverseSchema as a,fieldKeyEscape as p,createLinebarId as c}from"../utils/schema.js";import{useFormValidator as d}from"./useFormValidator.js";import{transformDateFormat as m}from"../utils/business.js";function u(e,o){Object.assign(e["x-component-props"],{...i(o,["wordbook","autograph"])})}function x(e,o){Object.assign(e["x-component-props"],{...i(o,["urlConfig","wordbook"])})}function f(e){return"1"===e||!0===e}function _(n,_){const{createValidatorSchema:b}=d(),v=e=>{var o;const t={name:e.val_key,type:null!=(o=e.fieldType)?o:"string",title:e.alias||e.name,"x-component":e.html_type,default:e.default_val,"x-component-props":{placeholder:e.placeholder,clearable:"0"===e.is_empty,...e.componentProps||{}},"x-content":e.slots,"x-display":"0"===e.is_show?"hidden":"visible","x-pattern":"0"===e.is_edit?"disabled":"editable","x-compile-omitted":["title","x-component-props","x-decorator-props"]};e.reactions&&(t["x-reactions"]=e.reactions),e.noDecorator||Object.assign(t,{"x-decorator":"FORM_ITEM","x-decorator-props":{fieldItem:e,beforeSetValue:null==_?void 0:_.beforeSetValue,span:2*(e.elem_width||3),showLabel:"1"!==e.hide_title,remark:e.remark,propertyKey:e.val_key,annotation:e.annotation,...e.decoratorProps||{}}});const n=b(e);return n&&(t["x-validator"]=n),"0"===e.is_null&&(t.required=!0),t},g=e=>{var o,t,n,l,s,a,p,c,d,m,_,h,b,g;const y=v(e);e.urlConfig?x(y,e):e.autograph&&u(y,e);const w=!!e.__multiple,C=f(null!=(t=null==(o=e.componentProps)?void 0:o.allowModify)?t:e.allowModify),O=f(null!=(l=null==(n=e.componentProps)?void 0:n.selectAll)?l:e.selectAll),A=f(null!=(a=null==(s=e.componentProps)?void 0:s.shouldSave)?a:e.save_free_entry),E=f(null!=(c=null==(p=e.componentProps)?void 0:p.allowCreate)?c:e.free_entry),j=null!=(m=null==(d=e.componentProps)?void 0:d.showField)?m:e.show_key,k=null!=(h=null==(_=e.componentProps)?void 0:_.options)?h:e.option,N=null!=(g=r(e.multi_select_value))?g:null==(b=e.componentProps)?void 0:b.maxTagCount;return Object.assign(y["x-component-props"],{multiple:w,options:k,allowModify:C,allowCreate:E||C,shouldSave:A,showField:j,maxTagCount:N,selectAll:O,...i(e,["lazyRequest","requestCache"])}),w&&(y.type="array"),y},y=e=>{var o,t;const n=v(e),i=null!=(t=null==(o=e.componentProps)?void 0:o.selectAll)?t:e.selectAll;return Object.assign(n["x-component-props"],{options:e.option,childFieldStrategy:e.childFieldStrategy,childWidthMode:e.childWidthMode,vertical:e.__vertical,selectAll:"1"===i||!0===i}),e.urlConfig?x(n,e):e.autograph&&u(n,e),n},w=e=>{const t=v(e);return Object.assign(t["x-component-props"],{fieldItem:o(e,["reactions"])}),t},C=e=>({name:e.val_key,type:"void",title:e.alias||e.name,"x-component":"LINEBAR","x-display":"visible","x-component-props":{linebarTextDirection:e.linebarTextDirection,linebarDirection:e.linebarDirection,linebarWidth:e.linebarWidth,disabled:"1"===e.is_not_fold,id:c(e.val_key),show:"0"!==e.is_show,remark:e.remark},"x-content":e.slots}),O=new Map([["LINEBAR",C],["LINE_BREAKS",e=>({name:e.val_key,type:"void",title:e.alias||e.name,"x-component":"LINE_BREAKS","x-component-props":{border:e.lineBreaksBorder},"x-display":"0"===e.is_show?"hidden":"visible"})],["INPUT",e=>{const o=v(e);return Object.assign(o["x-component-props"],{...i(e,["prefix","suffix"])}),o}],["TEXTAREA",e=>{const o=v(e);return Object.assign(o["x-component-props"],{rows:e.initialize_high||3}),o}],["INPUT_NUMBER",e=>{const o=v(e),{decimal_length:t,validate:n,allowSlash:i}=e;return!0!==i&&"1"!==i||(o["x-component"]="INPUT_NUMBER_SLASH",o.type="string"),Object.assign(o["x-component-props"],{precision:r(null!=t?t:null==n?void 0:n.decimal_length),whiteList:e.whiteList,prefix:e.prefix,suffix:e.suffix}),o}],["SELECT",g],["REMOTE_SEARCH",g],["DATE",e=>{const o=v(e);return Object.assign(o["x-component-props"],{valueFormat:e.date_format,type:m(e.date_format),validate:e.validate}),o}],["TIME",e=>{const o=v(e);return Object.assign(o["x-component-props"],{format:e.date_format,type:m(e.date_format),validate:e.validate}),o}],["LEVEL_SEARCH_CASCADER",e=>{const o=v(e);return Object.assign(o["x-component-props"],{...i(e,["wordbook","lazyRequest","autograph"])}),"1"===e.is_allow_check_mid&&e.allow_check_mid_level&&(o["x-component-props"].checkAbleLevel=+e.allow_check_mid_level),o}],["SEARCH_CASCADER",e=>{var o;const t=v(e);return Object.assign(t["x-component-props"],{urlConfig:e.urlConfig,depth:null==(o=e.wordbook)?void 0:o.level_num,options:e.option}),t}],["COMBINATION",e=>{const o=v(e);return o.type="array","table"===e.displayMode?o["x-component"]="TABLE_COMBINATION":!1!==e.jsonCombination&&(o["x-component"]="JSON_COMBINATION"),Object.assign(o["x-decorator-props"],{showLabel:!1,showFeedback:!1}),Object.assign(o["x-component-props"],{title:e.alias||e.name,maxGroupNum:e.maxGroupNum,minGroupNum:e.minGroupNum,showLabel:"1"!==e.hide_title,properties:e.children||[],combinationItemDeletable:e.combinationItemDeletable}),o}],["RADIO",y],["CHECKBOX",y],["SWITCH",e=>{const o=v(e);return Object.assign(o["x-component-props"],{openDescription:e.open,closeDescription:e.close,showMode:e.show_mode}),o}],["SLIDER",e=>{const o=v(e);return Object.assign(o["x-component-props"],{step:r(e.step_length),max:r(e.max_length),min:r(e.min_length),option:e.option}),o}],["COMPLEX",e=>{const o=v(e);Array.isArray(e.properties)&&l("COMPLEX控件的properties属性已经废弃, 请使用children作为替代, 在之后的版本中properties属性将不再支持");const t=Array.isArray(e.properties||e.children)?N(e.properties||e.children):{};return o.type=e.fieldType||"void",o.properties=t,Object.assign(o["x-decorator-props"],{showFeedback:!1}),Object.assign(o["x-component-props"],i(e,["wrapperStyle","display"])),o}]]),A=e=>{if(e.suffixConfig)return E(e);return(O.get(e.html_type)||w)(e)},E=o=>{if(!o.suffixConfig&&!o.prefixConfig)return A(o);const t=o.suffixConfig?e(o.suffixConfig):[],n=[...(o.prefixConfig?e(o.prefixConfig):[]).map((e=>({elem_width:o.elem_width,...e,hide_title:"1",is_show:"1"}))),{...o,is_show:"1",hide_title:"1",suffixConfig:void 0,prefixConfig:void 0},...t.map((e=>({elem_width:o.elem_width,...e,hide_title:"1",is_show:"1"})))],i=v(o),r=n.reduce(((e,o)=>e+2*(o.elem_width||3)),0);return Object.assign(i,{type:"void",name:p(n),title:o.alias||o.name,"x-component":"INPUT_GROUP","x-component-props":{span:r},"x-decorator-props":{...i["x-decorator-props"],showFeedback:!1,suffixFields:n.map((e=>e.val_key))},properties:N(n)}),i},{FieldNormalizeWaterfallHook:j,FieldListNormalizeWaterfallHook:k}=s();function N(o,i={column:9999}){let r=null;const l=k.call(t(o),i).reduce(((e,o,l)=>{var a;const p=null==(a=(o=j.call(o,i)).validate)?void 0:a.obj_type;return p&&n&&n.collect(p,t(o)),"LINEBAR"===o.html_type?(e[c(o)]=s(C(o),l),r=e[c(o)].properties={}):r?r[c(o)]=s(A(o),l):(r=null,e[c(o)]=s(A(o),l)),e}),{});return i.linebarAutoHidden&&Object.values(l).forEach((e=>{"LINEBAR"===e["x-component"]&&h(e)})),a({properties:l,"x-root":!0},((e,o)=>{"INPUT_GROUP"===e["x-component"]&&h(e,!!o&&!o["x-root"])})),l;function s(e,o){return e["x-index"]=o,e["x-decorator-props"]={_index:o,...e["x-decorator-props"]},e}function c(o){return o.suffixConfig?p([o,...e(o.suffixConfig)]):o.val_key}}return{schemaAdaptor:N}}function h(e,o=!1){e["x-reactions"]?e["x-reactions"]=n(e["x-reactions"]):e["x-reactions"]=[];const t=Object.keys(e.properties||{}).map((t=>`${o?"*.":""}${e.name}.${t}#selfDisplay`));e["x-reactions"].push({dependencies:t,fulfill:{state:{visible:"{{hasVisible($deps)}}"}}})}export{_ as useFieldListAdaptor};
@@ -3,7 +3,7 @@ import { GeneralField } from '@formily/core';
3
3
  import { ISchema } from '@formily/json-schema/esm/types';
4
4
  import { Ref } from 'vue';
5
5
  import { DependKeyType, FieldItem, ObjectDependKey } from '../../../../components/form-render';
6
- export declare function traverseSchema(schema: ISchema, handler: (_s: ISchema) => void): void;
6
+ export declare function traverseSchema(schema: ISchema, handler: (_s: ISchema, parent?: ISchema) => void, parent?: ISchema): void;
7
7
  export declare function fieldKeyEscape(fieldList: FieldItem[]): string;
8
8
  export declare function dotEscape(id: string): string;
9
9
  export declare function createFieldAddressId(id: string): string;
@@ -1 +1 @@
1
- import{isField as e}from"@formily/core";import{isObject as t,isPromise as r}from"@vue/shared";import{isString as n,isArray as o,isFunction as u,noop as a}from"lodash-es";function i(e,r){r(e),t(e.properties)&&Object.values(e.properties).forEach((e=>{i(e,r)}))}function c(e){return l(e.map((e=>e.val_key)).join("-"))}function l(e){return e.replace(/[.]/g,"-")}function f(e){return l(`address-${e}`)}function s(e){return l(`id-${e}`)}function p(e,r){e&&function(){const r=new Map;o(e)?e.forEach((e=>{var n;t(e)?r.set(e.paramName,{key:null!=(n=e.paramValue)?n:e.paramName,dependKey:e}):r.set(e,e)})):t(e)?Object.entries(e).forEach((([e,t])=>{r.set(e,t)})):n(e)&&r.set(e,e);return r}().forEach(((e,t)=>{if(n(e))return r(t,e);r(t,e.key,e.dependKey)}))}function d(e,t){let r=null;for(const o of t){if(o.val_key===e){n(o)&&(r=null);break}n(o)&&(r=o.val_key)}return r;function n(e){return"LINEBAR"===e.html_type}}function v(t,n){const o={...t};return e(n)&&Object.assign(o,{"onUpdate:value"(e){var t;const o=null==(t=n.decoratorProps)?void 0:t.beforeSetValue;if(u(o)){const t=o(n.path.toString(),e,{field:n,oldValue:n.value});return r(t)?t.then((e=>n.setValue(e)),a):n.setValue(t)}n.setValue(e)}}),o}function m(t,r){const n={...t};return e(r)&&(n.key=void 0===n.value?0:1),n}function y(t,r){const n={...t};return e(r)&&(n.onClear=()=>r.visited=!0),n}function h(e){return{type:"object",properties:e}}function k(t,r){return(...n)=>(e(t.value)&&(t.value.visited=!0),u(r)?r(...n):void 0)}export{y as assignClearBindVisited,v as assignUpdateValue,m as assignValueBindKey,f as createFieldAddressId,s as createLinebarId,h as createObjSchema,k as createVisitedSetter,l as dotEscape,c as fieldKeyEscape,d as getParentLinebar,p as traverseDependKey,i as traverseSchema};
1
+ import{isField as e}from"@formily/core";import{isObject as t,isPromise as r}from"@vue/shared";import{isString as n,isArray as o,isFunction as u,noop as a}from"lodash-es";function i(e,r,n){r(e,n),t(e.properties)&&Object.values(e.properties).forEach((t=>{i(t,r,e)}))}function c(e){return l(e.map((e=>e.val_key)).join("-"))}function l(e){return e.replace(/[.]/g,"-")}function f(e){return l(`address-${e}`)}function s(e){return l(`id-${e}`)}function p(e,r){e&&function(){const r=new Map;o(e)?e.forEach((e=>{var n;t(e)?r.set(e.paramName,{key:null!=(n=e.paramValue)?n:e.paramName,dependKey:e}):r.set(e,e)})):t(e)?Object.entries(e).forEach((([e,t])=>{r.set(e,t)})):n(e)&&r.set(e,e);return r}().forEach(((e,t)=>{if(n(e))return r(t,e);r(t,e.key,e.dependKey)}))}function d(e,t){let r=null;for(const o of t){if(o.val_key===e){n(o)&&(r=null);break}n(o)&&(r=o.val_key)}return r;function n(e){return"LINEBAR"===e.html_type}}function v(t,n){const o={...t};return e(n)&&Object.assign(o,{"onUpdate:value"(e){var t;const o=null==(t=n.decoratorProps)?void 0:t.beforeSetValue;if(u(o)){const t=o(n.path.toString(),e,{field:n,oldValue:n.value});return r(t)?t.then((e=>n.setValue(e)),a):n.setValue(t)}n.setValue(e)}}),o}function m(t,r){const n={...t};return e(r)&&(n.key=void 0===n.value?0:1),n}function y(t,r){const n={...t};return e(r)&&(n.onClear=()=>r.visited=!0),n}function h(e){return{type:"object",properties:e}}function k(t,r){return(...n)=>(e(t.value)&&(t.value.visited=!0),u(r)?r(...n):void 0)}export{y as assignClearBindVisited,v as assignUpdateValue,m as assignValueBindKey,f as createFieldAddressId,s as createLinebarId,h as createObjSchema,k as createVisitedSetter,l as dotEscape,c as fieldKeyEscape,d as getParentLinebar,p as traverseDependKey,i as traverseSchema};
@@ -599,7 +599,8 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
599
599
  isGroupChat: import("vue").ComputedRef<boolean>;
600
600
  contextmenuRef: import("vue").Ref<any>;
601
601
  showMenu: import("vue").Ref<boolean>;
602
- contextmenuPosition: any;
602
+ menuPosition: any;
603
+ menuMsgId: import("vue").Ref<any>;
603
604
  pageInfo: {
604
605
  page: number;
605
606
  hasMore: boolean;
@@ -609,19 +610,9 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
609
610
  '--c-tip-top': string;
610
611
  '--c-tip-gap': string;
611
612
  }>;
612
- chatMainBounding: import("vue").ComputedRef<{
613
- height: import("vue").Ref<number>;
614
- bottom: import("vue").Ref<number>;
615
- left: import("vue").Ref<number>;
616
- right: import("vue").Ref<number>;
617
- top: import("vue").Ref<number>;
618
- width: import("vue").Ref<number>;
619
- x: import("vue").Ref<number>;
620
- y: import("vue").Ref<number>;
621
- update: () => void;
622
- }>;
623
613
  getHistoryRecord: () => Promise<void>;
624
- handleContextmenu: (event: MouseEvent) => Promise<void>;
614
+ handleContextmenu: (event: MouseEvent, msgId: string) => Promise<void>;
615
+ setMenuPosition: (event: MouseEvent) => Promise<void>;
625
616
  showMessage: (item: import("../../shared/types").AnyObject) => boolean;
626
617
  showTemplateMsg: (item: import("../../shared/types").AnyObject, type: "template" | "system") => boolean | undefined;
627
618
  isTemplate3: (content: import("../../shared/types").AnyObject) => boolean;
@@ -795,10 +786,10 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
795
786
  position: {
796
787
  type: import("vue").PropType<import("vue").CSSProperties>;
797
788
  };
798
- exclude: {
799
- type: import("vue").PropType<string[]>;
789
+ msgId: {
790
+ type: StringConstructor;
800
791
  };
801
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
792
+ }, () => JSX.Element | null, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
802
793
  show: {
803
794
  type: BooleanConstructor;
804
795
  default: boolean;
@@ -806,8 +797,8 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
806
797
  position: {
807
798
  type: import("vue").PropType<import("vue").CSSProperties>;
808
799
  };
809
- exclude: {
810
- type: import("vue").PropType<string[]>;
800
+ msgId: {
801
+ type: StringConstructor;
811
802
  };
812
803
  }>> & {
813
804
  onSelect?: ((...args: any[]) => any) | undefined;
@@ -821,7 +812,6 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
821
812
  getAVTime: typeof import("./src/utils").getAVTime;
822
813
  MESSAGE_TYPE: typeof import("./src/constants").MESSAGE_TYPE;
823
814
  ChatbubbleEllipsesOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
824
- EllipsisHorizontal: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
825
815
  CallOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
826
816
  VideocamOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
827
817
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
@@ -604,7 +604,8 @@ declare const _default: import("vue").DefineComponent<{
604
604
  isGroupChat: import("vue").ComputedRef<boolean>;
605
605
  contextmenuRef: import("vue").Ref<any>;
606
606
  showMenu: import("vue").Ref<boolean>;
607
- contextmenuPosition: any;
607
+ menuPosition: any;
608
+ menuMsgId: import("vue").Ref<any>;
608
609
  pageInfo: {
609
610
  page: number;
610
611
  hasMore: boolean;
@@ -614,19 +615,9 @@ declare const _default: import("vue").DefineComponent<{
614
615
  '--c-tip-top': string;
615
616
  '--c-tip-gap': string;
616
617
  }>;
617
- chatMainBounding: import("vue").ComputedRef<{
618
- height: import("vue").Ref<number>;
619
- bottom: import("vue").Ref<number>;
620
- left: import("vue").Ref<number>;
621
- right: import("vue").Ref<number>;
622
- top: import("vue").Ref<number>;
623
- width: import("vue").Ref<number>;
624
- x: import("vue").Ref<number>;
625
- y: import("vue").Ref<number>;
626
- update: () => void;
627
- }>;
628
618
  getHistoryRecord: () => Promise<void>;
629
- handleContextmenu: (event: MouseEvent) => Promise<void>;
619
+ handleContextmenu: (event: MouseEvent, msgId: string) => Promise<void>;
620
+ setMenuPosition: (event: MouseEvent) => Promise<void>;
630
621
  showMessage: (item: AnyObject) => boolean;
631
622
  showTemplateMsg: (item: AnyObject, type: "template" | "system") => boolean | undefined;
632
623
  isTemplate3: (content: AnyObject) => boolean;
@@ -800,10 +791,10 @@ declare const _default: import("vue").DefineComponent<{
800
791
  position: {
801
792
  type: PropType<import("vue").CSSProperties>;
802
793
  };
803
- exclude: {
804
- type: PropType<string[]>;
794
+ msgId: {
795
+ type: StringConstructor;
805
796
  };
806
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
797
+ }, () => JSX.Element | null, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
807
798
  show: {
808
799
  type: BooleanConstructor;
809
800
  default: boolean;
@@ -811,8 +802,8 @@ declare const _default: import("vue").DefineComponent<{
811
802
  position: {
812
803
  type: PropType<import("vue").CSSProperties>;
813
804
  };
814
- exclude: {
815
- type: PropType<string[]>;
805
+ msgId: {
806
+ type: StringConstructor;
816
807
  };
817
808
  }>> & {
818
809
  onSelect?: ((...args: any[]) => any) | undefined;
@@ -826,7 +817,6 @@ declare const _default: import("vue").DefineComponent<{
826
817
  getAVTime: typeof import("./utils").getAVTime;
827
818
  MESSAGE_TYPE: typeof import("./constants").MESSAGE_TYPE;
828
819
  ChatbubbleEllipsesOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
829
- EllipsisHorizontal: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
830
820
  CallOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
831
821
  VideocamOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
832
822
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
@@ -10,7 +10,8 @@ declare const _default: import("vue").DefineComponent<{}, {
10
10
  isGroupChat: import("vue").ComputedRef<boolean>;
11
11
  contextmenuRef: import("vue").Ref<any>;
12
12
  showMenu: import("vue").Ref<boolean>;
13
- contextmenuPosition: any;
13
+ menuPosition: any;
14
+ menuMsgId: import("vue").Ref<any>;
14
15
  pageInfo: {
15
16
  page: number;
16
17
  hasMore: boolean;
@@ -20,19 +21,9 @@ declare const _default: import("vue").DefineComponent<{}, {
20
21
  '--c-tip-top': string;
21
22
  '--c-tip-gap': string;
22
23
  }>;
23
- chatMainBounding: import("vue").ComputedRef<{
24
- height: import("vue").Ref<number>;
25
- bottom: import("vue").Ref<number>;
26
- left: import("vue").Ref<number>;
27
- right: import("vue").Ref<number>;
28
- top: import("vue").Ref<number>;
29
- width: import("vue").Ref<number>;
30
- x: import("vue").Ref<number>;
31
- y: import("vue").Ref<number>;
32
- update: () => void;
33
- }>;
34
24
  getHistoryRecord: () => Promise<void>;
35
- handleContextmenu: (event: MouseEvent) => Promise<void>;
25
+ handleContextmenu: (event: MouseEvent, msgId: string) => Promise<void>;
26
+ setMenuPosition: (event: MouseEvent) => Promise<void>;
36
27
  showMessage: (item: AnyObject) => boolean;
37
28
  showTemplateMsg: (item: AnyObject, type: 'system' | 'template') => boolean | undefined;
38
29
  isTemplate3: (content: AnyObject) => boolean;
@@ -206,10 +197,10 @@ declare const _default: import("vue").DefineComponent<{}, {
206
197
  position: {
207
198
  type: import("vue").PropType<CSSProperties>;
208
199
  };
209
- exclude: {
210
- type: import("vue").PropType<string[]>;
200
+ msgId: {
201
+ type: StringConstructor;
211
202
  };
212
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
203
+ }, () => JSX.Element | null, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
213
204
  show: {
214
205
  type: BooleanConstructor;
215
206
  default: boolean;
@@ -217,8 +208,8 @@ declare const _default: import("vue").DefineComponent<{}, {
217
208
  position: {
218
209
  type: import("vue").PropType<CSSProperties>;
219
210
  };
220
- exclude: {
221
- type: import("vue").PropType<string[]>;
211
+ msgId: {
212
+ type: StringConstructor;
222
213
  };
223
214
  }>> & {
224
215
  onSelect?: ((...args: any[]) => any) | undefined;
@@ -232,7 +223,6 @@ declare const _default: import("vue").DefineComponent<{}, {
232
223
  getAVTime: typeof getAVTime;
233
224
  MESSAGE_TYPE: typeof MESSAGE_TYPE;
234
225
  ChatbubbleEllipsesOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
235
- EllipsisHorizontal: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
236
226
  CallOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
237
227
  VideocamOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
238
228
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as a,unref as r,normalizeStyle as l,createVNode as c,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as v,createBlock as f,createElementVNode as g,withModifiers as y,nextTick as h}from"vue";import{NImageGroup as T,NAvatar as M,NImage as _,NIcon as k,NButtonGroup as x,NButton as I}from"naive-ui";import{useElementBounding as S}from"@vueuse/core";import{format as j}from"date-fns";import{getHistoryRecordApi as L,readMessageApi as C}from"../api/index.js";import{useState as E}from"../hooks/useState.js";import{useSession as w}from"../hooks/useSession.js";import{MESSAGE_TYPE as A}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as b,simplifyMessage as H,getAVTime as D,downloadFile as O}from"../utils/index.js";import{first as P,last as z}from"lodash-es";import N from"./PersonProfile.vue.js";import R from"./MessageTemplate.vue.js";import{emojis as U}from"../utils/emoji.js";import q from"./ContextMenu.js";import{useScrollLoading as G}from"../hooks/useScrollLoading.js";import{CallOutline as J,VideocamOutline as K,ChatbubbleEllipsesOutline as X,EllipsisHorizontal as B}from"@vicons/ionicons5";const F={key:0,class:"time"},Y={key:2,class:"message-box"},$={key:0,class:"content-box"},Q={class:"name-box"},V=["data-time"],W=["onContextmenu"],Z={key:0,class:"reference-content"},ee=["innerHTML"],te=["innerHTML"],ne=["src"],se={style:{"margin-left":"8px"}},oe=["href","onClick"],ie=g("i",{class:"chat--iconfont chat--icon-face"},null,-1);var ae=e({__name:"ChatMain",setup(e){const ae=t(),{state:re,setMsgList:le}=E(),{setCurrentSessionItem:ce,isGroupChat:ue}=w(re),me=t(),pe=t(!1),de=t({left:0,top:0}),ve={page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")},fe=n((()=>({"--c-tip-top":ue.value?"1px":"-20px","--c-tip-gap":ue.value?"10px":"0px"}))),ge=n((()=>S(ae.value)));async function ye(){try{if(!ve.hasMore)return;ve.page++;const e=await L({sessionKey:re.currentSessionItem.sessionKey,page:ve.page,lastSendTime:ve.lastSendTime});if(!Array.isArray(e)||0===e.length)return ve.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=P(e).id;ve.lastSendTime=z(e).sendTime,le(ve.page>1?[...e,...re.msgList]:e),1===ve.page&&re.currentSessionItem.unreadNum&&(await C({chatType:re.currentSessionItem.chatType,messageIdSet:[t],receiver:re.userInfo.id,sender:re.currentSessionItem.receiver}),ce({unreadNum:0}))}catch(e){console.log(e)}}async function he(e){var t,n,s,o,i;pe.value=!0,await h();const{clientX:a,clientY:r}=e,{width:l,height:c,left:u,top:m}=ge.value,p=null!=(s=null==(n=null==(t=me.value)?void 0:t.$el)?void 0:n.getBoundingClientRect().height)?s:220,d=null!=(i=null==(o=ae.value)?void 0:o.scrollTop)?i:0,v={};a<=u.value+l.value/2?v.left=a-u.value+5+"px":v.right=u.value+l.value-a-5+"px",r-m.value<p/2?v.top=d+5+"px":m.value+c.value-r<=p/2?v.bottom=Math.abs(d)+5+"px":v.top=d+r-m.value-p/2+"px",de.value=v}function Te(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==A.TEMPLATE||!!n}function Me(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===A.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function _e(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===A.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function ke(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=re.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}return G(ae,(()=>{ye()}),"top",(()=>{pe.value=!1})),s((()=>re.id),(e=>{e&&(Object.assign(ve,{page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")}),ye())}),{immediate:!0}),s((()=>re.isAppendMsg),(e=>{e&&(le([...re.msgList,re.currentMsg]),re.isAppendMsg=!1,async function(){var e,t,n;const s=null!=(t=null==(e=ae.value)?void 0:e.scrollHeight)?t:0;null==(n=ae.value)||n.scrollTo({top:s,behavior:"auto"})}())}),{immediate:!0}),(e,t)=>(o(),i("div",{class:a(["chat-main",{"home-bg":!r(re).id}]),ref_key:"chatMainRef",ref:ae,style:l(r(fe))},[c(r(T),{"show-toolbar-tooltip":""},{default:u((()=>[(o(!0),i(m,null,p(r(re).msgList,((e,t)=>(o(),i(m,{key:e.id},[Te(e)?(o(),i("div",{key:0,class:a(["message-item",{"message-item--mine":e.sender==r(re).userInfo.id}])},[ke(e,t)?(o(),i("p",F,d(e.__sendTime),1)):v("v-if",!0),Me(e,"system")?(o(),f(R,{key:1,data:e},null,8,["data"])):(o(),i("div",Y,[c(N,{"user-id":e.sender},{trigger:u((()=>[c(r(M),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id"]),e.content?(o(),i("div",$,[g("div",Q,[g("span",{class:"name","data-time":e.__time},d(r(ue)?e.senderName:""),9,V)]),g("div",{class:a(["content",{emoji:e.content.chatMessageType===r(A).EMOJI,template:e.content.chatMessageType===r(A).TEMPLATE,"template--3":_e(e.content),"audio-video":r(b)(e.content)}]),onContextmenu:y(he,["prevent"])},[e.content.chatMessageType===r(A).TEXT?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",Z,[g("span",null,d(e.content.referenceContent.senderName)+":",1),g("pre",{innerHTML:r(H)(e.content.referenceContent.content)},null,8,ee)])):v("v-if",!0),g("pre",{innerHTML:e.__content},null,8,te)],64)):v("v-if",!0),e.content.chatMessageType===r(A).EMOJI?(o(),i("img",{key:1,src:r(U).findEmoji(e.__content)},null,8,ne)):v("v-if",!0),Me(e,"template")?(o(),f(R,{key:2,data:e},null,8,["data"])):v("v-if",!0),e.content.chatMessageType===r(A).IMAGE?(o(),f(r(_),{key:3,width:"240",src:e.__content},null,8,["src"])):v("v-if",!0),r(b)(e.content)?(o(),i(m,{key:4},[c(r(k),{class:a({"is-audio":e.content.chatMessageType===r(A).AUDIO}),component:e.content.chatMessageType===r(A).AUDIO?r(J):r(K)},null,8,["class","component"]),g("span",se,d(r(D)(e.__content)),1)],64)):v("v-if",!0),e.content.chatMessageType===r(A).FILE?(o(),i("a",{key:5,href:e.content.fileUrl,onClick:y((()=>r(O)(e.content.fileUrl,e.__content)),["prevent"])},d(e.__content),9,oe)):v("v-if",!0),c(r(x),{class:"quick-menu"},{default:u((()=>[c(r(I),{quaternary:"",size:"tiny"},{icon:u((()=>[ie])),_:1}),c(r(I),{quaternary:"",size:"tiny",onClick:()=>{return t=e,re.currentReferenceMsg=t,void Object.assign(re.currentReferenceMsg,{chatType:re.currentSessionItem.chatType,receiver:re.currentSessionItem.receiver,receiverAvatar:re.currentSessionItem.avatar,receiverName:re.currentSessionItem.name});var t}},{icon:u((()=>[c(r(k),{size:"17",component:r(X)},null,8,["component"])])),_:2},1032,["onClick"]),c(r(I),{quaternary:"",size:"tiny"},{icon:u((()=>[c(r(k),{component:r(B)},null,8,["component"])])),_:1})])),_:2},1024)],42,W)])):v("v-if",!0)]))],2)):v("v-if",!0)],64)))),128))])),_:1}),c(r(q),{ref_key:"contextmenuRef",ref:me,show:pe.value,"onUpdate:show":t[0]||(t[0]=e=>pe.value=e),position:de.value},null,8,["show","position"])],6))}});export{ae as default};
1
+ import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as a,unref as r,normalizeStyle as c,createVNode as l,withCtx as m,Fragment as u,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as v,createElementVNode as y,withModifiers as g}from"vue";import{NImageGroup as T,NAvatar as h,NImage as M,NIcon as k,NButtonGroup as _,NButton as I}from"naive-ui";import{format as S}from"date-fns";import{getHistoryRecordApi as x,readMessageApi as j}from"../api/index.js";import{useState as E}from"../hooks/useState.js";import{useSession as L}from"../hooks/useSession.js";import{MESSAGE_TYPE as A}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as C,simplifyMessage as b,getAVTime as w,downloadFile as H}from"../utils/index.js";import{first as z,last as D}from"lodash-es";import O from"./PersonProfile.vue.js";import P from"./MessageTemplate.vue.js";import{emojis as N}from"../utils/emoji.js";import U from"./ContextMenu.js";import{useScrollLoading as q}from"../hooks/useScrollLoading.js";import{CallOutline as R,VideocamOutline as G,ChatbubbleEllipsesOutline as J}from"@vicons/ionicons5";const K={key:0,class:"time"},F={key:2,class:"message-box"},X={key:0,class:"content-box"},B={class:"name-box"},Q=["data-time"],V=["onContextmenu"],W={key:0,class:"reference-content"},Y=["innerHTML"],Z=["innerHTML"],$=["src"],ee={style:{"margin-left":"8px"}},te=["href","onClick"];var ne=e({__name:"ChatMain",setup(e){const ne=t(),{state:se,setMsgList:oe}=E(),{setCurrentSessionItem:ie,isGroupChat:ae}=L(se),re=t(),ce=t(!1),le=t({left:0,top:0}),me=t(),ue={page:0,hasMore:!0,lastSendTime:S(new Date,"yyyy-MM-dd HH:mm:ss")},pe=n((()=>({"--c-tip-top":ae.value?"1px":"-20px","--c-tip-gap":ae.value?"10px":"0px"})));async function de(){try{if(!ue.hasMore)return;ue.page++;const e=await x({sessionKey:se.currentSessionItem.sessionKey,page:ue.page,lastSendTime:ue.lastSendTime});if(!Array.isArray(e)||0===e.length)return ue.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=z(e).id;ue.lastSendTime=D(e).sendTime,oe(ue.page>1?[...e,...se.msgList]:e),1===ue.page&&se.currentSessionItem.unreadNum&&(await j({chatType:se.currentSessionItem.chatType,messageIdSet:[t],receiver:se.userInfo.id,sender:se.currentSessionItem.receiver}),ie({unreadNum:0}))}catch(e){console.log(e)}}function fe(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==A.TEMPLATE||!!n}function ve(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===A.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function ye(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===A.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function ge(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=se.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}return q(ne,(()=>{de()}),"top",(()=>{ce.value=!1})),s((()=>se.id),(e=>{e&&(Object.assign(ue,{page:0,hasMore:!0,lastSendTime:S(new Date,"yyyy-MM-dd HH:mm:ss")}),de())}),{immediate:!0}),s((()=>se.isAppendMsg),(e=>{e&&(oe([...se.msgList,se.currentMsg]),se.isAppendMsg=!1,async function(){var e,t,n;const s=null!=(t=null==(e=ne.value)?void 0:e.scrollHeight)?t:0;null==(n=ne.value)||n.scrollTo({top:s,behavior:"auto"})}())}),{immediate:!0}),(e,t)=>(o(),i("div",{class:a(["chat-main",{"home-bg":!r(se).id}]),ref_key:"chatMainRef",ref:ne,style:c(r(pe))},[l(r(T),{"show-toolbar-tooltip":""},{default:m((()=>[(o(!0),i(u,null,p(r(se).msgList,((e,t)=>(o(),i(u,{key:e.id},[fe(e)?(o(),i("div",{key:0,class:a(["message-item",{"message-item--mine":e.sender==r(se).userInfo.id}])},[ge(e,t)?(o(),i("p",K,d(e.__sendTime),1)):f("v-if",!0),ve(e,"system")?(o(),v(P,{key:1,data:e},null,8,["data"])):(o(),i("div",F,[l(O,{"user-id":e.sender},{trigger:m((()=>[l(r(h),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id"]),e.content?(o(),i("div",X,[y("div",B,[y("span",{class:"name","data-time":e.__time},d(r(ae)?e.senderName:""),9,Q)]),y("div",{class:a(["content",{emoji:e.content.chatMessageType===r(A).EMOJI,template:e.content.chatMessageType===r(A).TEMPLATE,"template--3":ye(e.content),"audio-video":r(C)(e.content)}]),onContextmenu:g((t=>async function(e,t){}(0,e.id)),["prevent"])},[e.content.chatMessageType===r(A).TEXT?(o(),i(u,{key:0},[e.content.referenceContent?(o(),i("div",W,[y("span",null,d(e.content.referenceContent.senderName)+":",1),y("pre",{innerHTML:r(b)(e.content.referenceContent.content)},null,8,Y)])):f("v-if",!0),y("pre",{innerHTML:e.__content},null,8,Z)],64)):f("v-if",!0),e.content.chatMessageType===r(A).EMOJI?(o(),i("img",{key:1,src:r(N).findEmoji(e.__content)},null,8,$)):f("v-if",!0),ve(e,"template")?(o(),v(P,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===r(A).IMAGE?(o(),v(r(M),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),r(C)(e.content)?(o(),i(u,{key:4},[l(r(k),{class:a({"is-audio":e.content.chatMessageType===r(A).AUDIO}),component:e.content.chatMessageType===r(A).AUDIO?r(R):r(G)},null,8,["class","component"]),y("span",ee,d(r(w)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===r(A).FILE?(o(),i("a",{key:5,href:e.content.fileUrl,onClick:g((()=>r(H)(e.content.fileUrl,e.__content)),["prevent"])},d(e.__content),9,te)):f("v-if",!0),l(r(_),{class:"quick-menu"},{default:m((()=>[f(' <n-button quaternary size="tiny">\n\t\t\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\n\t\t\t\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t\t\t</n-button> '),l(r(I),{quaternary:"",size:"tiny",onClick:()=>{return t=e,se.currentReferenceMsg=t,void Object.assign(se.currentReferenceMsg,{chatType:se.currentSessionItem.chatType,receiver:se.currentSessionItem.receiver,receiverAvatar:se.currentSessionItem.avatar,receiverName:se.currentSessionItem.name});var t}},{icon:m((()=>[l(r(k),{size:"17",component:r(J)},null,8,["component"])])),_:2},1032,["onClick"]),f(' <n-button quaternary size="tiny">\n\t\t\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t\t\t<n-icon :component="EllipsisHorizontal" />\n\t\t\t\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t\t\t</n-button> ')])),_:2},1024)],42,V)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(r(U),{ref_key:"contextmenuRef",ref:re,show:ce.value,"onUpdate:show":t[0]||(t[0]=e=>ce.value=e),position:le.value,"msg-id":me.value},null,8,["show","position","msg-id"])],6))}});export{ne as default};
@@ -7,10 +7,10 @@ declare const _default: import("vue").DefineComponent<{
7
7
  position: {
8
8
  type: PropType<CSSProperties>;
9
9
  };
10
- exclude: {
11
- type: PropType<string[]>;
10
+ msgId: {
11
+ type: StringConstructor;
12
12
  };
13
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
13
+ }, () => JSX.Element | null, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show")[], "select" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
14
14
  show: {
15
15
  type: BooleanConstructor;
16
16
  default: boolean;
@@ -18,8 +18,8 @@ declare const _default: import("vue").DefineComponent<{
18
18
  position: {
19
19
  type: PropType<CSSProperties>;
20
20
  };
21
- exclude: {
22
- type: PropType<string[]>;
21
+ msgId: {
22
+ type: StringConstructor;
23
23
  };
24
24
  }>> & {
25
25
  onSelect?: ((...args: any[]) => any) | undefined;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,computed as o,withDirectives as l,createVNode as r,vShow as n,isVNode as i}from"vue";import{NButtonGroup as a,NButton as c,NIcon as u}from"naive-ui";import{CopyOutline as p,OpenOutline as s,ChatbubbleEllipsesOutline as y,ReorderFourOutline as d,ReturnDownBack as m,DownloadOutline as v}from"@vicons/ionicons5";import{onClickOutside as f}from"@vueuse/core";var b=e({name:"PopupMenu",inheritAttrs:!1,props:{show:{type:Boolean,default:!1},position:{type:Object},exclude:{type:Array}},emits:["update:show","select"],setup(e,{attrs:b,slots:k,emit:w}){const h=[{icon:p,label:"复制",key:"copy"},{icon:s,label:"转发",key:"relay"},{icon:y,label:"回复",key:"reply"},{icon:d,label:"多选",key:"multiSelect"},{icon:m,label:"撤回",key:"withdraw"},{icon:v,label:"下载",key:"download"}],x=t(null),j=o((()=>{var t;return(null==(t=e.exclude)?void 0:t.length)?h.filter((t=>{var o;return!(null==(o=e.exclude)?void 0:o.includes(t.key))})):h}));return f(x,(e=>{w("update:show",!1)})),()=>{let t;return l(r("div",{class:"contextmenu-wrapper",ref:x,style:e.position},[r(a,{vertical:!0},(o=t=j.value.map((e=>{return r(c,{onClick:(t=e.key,void w("select",t)),quaternary:!0},{default:()=>e.label,icon:()=>r(u,{component:e.icon},null)});var t})),"function"==typeof o||"[object Object]"===Object.prototype.toString.call(o)&&!i(o)?t:{default:()=>[t]}))]),[[n,e.show]]);var o}}});export{b as default};
1
+ import{defineComponent as e,ref as t,computed as o,withDirectives as n,createVNode as s,vShow as i,isVNode as l}from"vue";import{NButtonGroup as r,NButton as a,NIcon as p}from"naive-ui";import{CopyOutline as u,OpenOutline as c,ChatbubbleEllipsesOutline as d,ReorderFourOutline as m,ReturnDownBack as y,DownloadOutline as f}from"@vicons/ionicons5";import{onClickOutside as h}from"@vueuse/core";import{useState as v}from"../hooks/useState.js";import{isAudioOrVideoMessage as w}from"../utils/index.js";import"lodash-es";import{MESSAGE_TYPE as b}from"../constants/index.js";import"../api/index.js";import"trtc-sdk-v5";import{isSameMonth as k}from"date-fns";var g=e({name:"PopupMenu",inheritAttrs:!1,props:{show:{type:Boolean,default:!1},position:{type:Object},msgId:{type:String}},emits:["update:show","select"],setup(e,{attrs:g,slots:j,emit:E}){const{state:T,setMsgList:I}=v(),L=[{icon:u,label:"复制",key:"copy"},{icon:c,label:"转发",key:"relay"},{icon:d,label:"回复",key:"reply"},{icon:m,label:"多选",key:"multiSelect"},{icon:y,label:"撤回",key:"withdraw"},{icon:f,label:"下载",key:"download"}],M=t(null),x=o((()=>T.msgList.find((({id:t})=>t===e.msgId)))),O=o((()=>{if(!e.msgId)return[];if(!(null==x?void 0:x.value))return[];const{content:t={},sendTime:o,sender:n}=x.value,{chatMessageType:s}=t,i=[];return(n!==T.userInfo.id&&k(new Date(o),new Date)||s===b.TEMPLATE)&&i.push("withdraw"),[b.TEXT,b.EMOJI,b.BLEND].includes(s)?i.push("download"):w(t)?i.push("copy","relay","download"):s===b.FILE?i.push("copy"):[b.FORWARD,b.TEMPLATE].includes(s)&&i.push("copy","download"),i.length?L.filter((e=>!i.includes(e.key))):L}));return h(M,(e=>{E("update:show",!1)})),()=>{let t;return e.msgId&&O.value?n(s("div",{class:"contextmenu-wrapper",ref:M,style:e.position},[s(r,{vertical:!0},(o=t=O.value.map((e=>s(a,{onClick:()=>{return t=e.key,E("update:show",!1),x.value,void E("select",t);var t},quaternary:!0},{default:()=>e.label,icon:()=>s(p,{component:e.icon},null)}))),"function"==typeof o||"[object Object]"===Object.prototype.toString.call(o)&&!l(o)?t:{default:()=>[t]}))]),[[i,e.show]]):null;var o}}});export{g as default};