-
) {
- // const showLines = ref(3);
- // const exceptionMessageMaxHeight = ref(480);
+ function getRealLength(value: string){
+ if (value == null) {
+ return 0;
+ }
+
+ let strLength = 0; // 记录str的总长度
+ for(let i=0;i< value.length;i++){
+ const charCode = value.charCodeAt(i);// 使用charCodeAt返回单个字符的Unicode编码
+ if(charCode>=0 && charCode<=128){
+ strLength++; // 英文字符加1
+ }else {
+ strLength= strLength+2;// 中文字符加2
+ }
+ }
+ return strLength;
+ }
+
+ function subStrNum(value: string, substringLeng: number) {
+ if (value !== '' && value !== undefined && value !== null) {
+ value = '' + value;
+ const strLen = value.length;
+ let strCut = '';
+ let strLength =0;
+ for(let i=0;i
4){ // 使用encodeURI获取编码长度
+ strLength++;
+ }
+ strCut = strCut.concat(charStr); // 单个字符进行合并
+ if(strLength >= substringLeng){
+ strCut = strCut.concat('...'); // 大于指定长度后合并'...'并返回此字符串
+ return strCut;
+ }
+ }
+ if(strLength {
return !!exception.value && !!exception.value.date;
@@ -19,92 +59,48 @@ export default function (exception: Ref) {
return !!exception.value && !!exception.value.detail;
});
+ const shouldShowExpandHandle = computed(() => {
+ return exception.value? (getRealLength(exception.value.detail) > 160): false;
+ });
+
+
+ const showDetailInfo = ref(false);
+ const toggleDetailText = computed(() => {
+ return showDetailInfo.value ? '收起' : '展开';
+ });
+
+
const safeExceptionMessage = computed(() => {
- const safeMessage = (exception.value && exception.value.detail) || '';
- return '详细信息 : ' + safeMessage;
+ const safeMessage = '详细信息 : ' + (exception.value && exception.value.detail) || '';
+ return showDetailInfo.value? safeMessage: subStrNum(safeMessage, 160);
});
- const exceptionMessageId = 'exp_switch_' + new Date().getTime();
-
- // const exceptionMessageStyle = computed(() => {
- // const maxHeight = `${exceptionMessageMaxHeight.value}px`;
- // const styleObject = {
- // overflow: 'hidden',
- // 'text-overflow': 'ellipsis',
- // display: '-webkit-box',
- // '-webkit-box-orient': 'vertical',
- // '-webkit-line-clamp': showLines.value,
- // 'max-height': maxHeight
- // };
- // return styleObject;
- // });
-
- // const shouldShowExpandHandle = computed(() => {
- // return true;
- // });
-
- // const expandExceptionMessage = ref(false);
- // const expandText = ref('展开');
- // const collapseText = ref('收起');
- // const expandHandleStyle = computed(() => {
- // const styleObject = {
- // display: 'block',
- // color: '#2A87FF'
- // } as Record;
- // styleObject['text-align'] = expandExceptionMessage.value ? '' : 'right';
- // return styleObject;
- // });
-
- // function toggalExceptionMessage(expand: boolean, $event: Event) {
- // expandExceptionMessage.value = !expandExceptionMessage.value;
- // showLines.value = expandExceptionMessage.value ? 20 : 3;
- // }
-
- // function onClickExpand(payload: MouseEvent) {
- // return toggalExceptionMessage(true, payload);
- // }
-
- // function onClickCollapse(payload: MouseEvent) {
- // return toggalExceptionMessage(true, payload);
- // }
+ const toggleDetailButtonStyles = computed(() => {
+ return {
+ position: 'absolute',
+ right: 0,
+ bottom: showDetailInfo.value?0 : '2px',
+ color: '#2A87FF',
+ cursor: 'pointer'
+ };
+ });
+
+ function toggleDetail() {
+ showDetailInfo.value = !showDetailInfo.value;
+ }
return () => {
return (
{shouldShowExceptionDate.value &&
{exceptionDateMessage.value}
}
{shouldShowExceptionMessage.value && (
- /*
*/
-
-
-
+
-
+ {shouldShowExpandHandle.value &&
{toggleDetailText.value}}
-
-
)}
- {/* {shouldShowExpandHandle.value && (
-
- {expandExceptionMessage.value && (
-
- {collapseText.value}
-
- )}
- {!expandExceptionMessage.value && (
-
- {expandText.value}
-
- )}
-
- )} */}
);
};
diff --git a/packages/ui-vue/components/modal/src/composition/modal.service.tsx b/packages/ui-vue/components/modal/src/composition/modal.service.tsx
index 2339bf9910ce67df36eb9467db29119fc6ef0fdd..cd551838aeed98156d4771bbaf00d47fbad23b06 100644
--- a/packages/ui-vue/components/modal/src/composition/modal.service.tsx
+++ b/packages/ui-vue/components/modal/src/composition/modal.service.tsx
@@ -271,7 +271,7 @@ export default class ModalService {
update,
destroy,
modalRef: this.activeModalInstance,
- close: this.close
+ close: () => this.close()
};
}
}
diff --git a/packages/ui-vue/components/tooltip/src/tooltip.directive.tsx b/packages/ui-vue/components/tooltip/src/tooltip.directive.tsx
index 5372be26b708de299fd690852d94ae487d174fb3..a11f0e0d59249d4bf4867f787f1dd70811b16ae6 100644
--- a/packages/ui-vue/components/tooltip/src/tooltip.directive.tsx
+++ b/packages/ui-vue/components/tooltip/src/tooltip.directive.tsx
@@ -134,7 +134,8 @@ function triggerByClick(element: any, binding: Record
) {
farrisTooltipInstances.delete(element);
}
});
- !tooltipClickHandler && document.body.addEventListener('click', tooltipClickHandler = ($event: MouseEvent) => {
+ document.body.removeEventListener('click', tooltipClickHandler, true);
+ document.body.addEventListener('click', tooltipClickHandler = ($event: MouseEvent) => {
const target = $event.target as any;
const tooltipElement = target.closest(`.${tooltipDirectiveClass}`);
if (tooltipElement && farrisTooltipInstances.has(tooltipElement)) {
@@ -156,6 +157,16 @@ function storePropertyToElement(element: any, binding: Record) {
}
}
+function destoryTooltip(element: any, binding: any) {
+ if (binding.value.trigger === 'click') {
+ document.body.removeEventListener('click', tooltipClickHandler, true);
+ } else {
+ // 修复没有来得及执行mouseleave的元素
+ deleteTooltipInstance(element);
+ }
+}
+
+
const tooltipDirective = {
mounted: (element: any, binding: Record, vnode: any) => {
element.classList.add(tooltipDirectiveClass);
@@ -170,15 +181,12 @@ const tooltipDirective = {
triggerByHover(element, binding);
}
}
-
+ },
+ beforeUnmount: (element: any, binding: Record, vnode: any) => {
+ destoryTooltip(element, binding);
},
unmounted: (element: any, binding: Record, vnode: any) => {
- if (binding.value.trigger === 'click') {
- document.body.removeEventListener('click', tooltipClickHandler, true);
- } else {
- // 修复没有来得及执行mouseleave的元素
- deleteTooltipInstance(element);
- }
+ destoryTooltip(element, binding);
},
beforeUpdate: (element: any, binding: Record) => {
storePropertyToElement(element, binding);