后端webadmin调整显示布局
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const ELLIPSIS_TARGETS =
|
||||
'.ant-table-cell, .ant-descriptions-item-content, .ant-typography';
|
||||
|
||||
const ELLIPSIS_SKIP =
|
||||
'.ant-btn, .ant-input, .ant-select, .ant-picker, .ant-checkbox, .ant-radio, pre, textarea, input, select, button, a.ant-btn';
|
||||
|
||||
function isTruncated(el: HTMLElement): boolean {
|
||||
return el.scrollWidth > el.clientWidth + 1;
|
||||
}
|
||||
|
||||
function resolveEllipsisElement(target: EventTarget | null): HTMLElement | null {
|
||||
if (!(target instanceof HTMLElement)) return null;
|
||||
const cell = target.closest<HTMLElement>(ELLIPSIS_TARGETS);
|
||||
if (!cell) return null;
|
||||
if (cell.closest('.admin-cell-line')) return null;
|
||||
if (cell.closest(ELLIPSIS_SKIP)) return null;
|
||||
if (cell.querySelector(ELLIPSIS_SKIP)) return null;
|
||||
return cell;
|
||||
}
|
||||
|
||||
export function bindAdminEllipsisTitle(root: HTMLElement | Document = document) {
|
||||
const onMouseOver = (event: MouseEvent) => {
|
||||
const el = resolveEllipsisElement(event.target);
|
||||
if (!el) return;
|
||||
if (isTruncated(el)) {
|
||||
const text = el.innerText.replace(/\s+/g, ' ').trim();
|
||||
if (text && el.getAttribute('title') !== text) {
|
||||
el.setAttribute('title', text);
|
||||
}
|
||||
} else {
|
||||
el.removeAttribute('title');
|
||||
}
|
||||
};
|
||||
|
||||
root.addEventListener('mouseover', onMouseOver, true);
|
||||
return () => root.removeEventListener('mouseover', onMouseOver, true);
|
||||
}
|
||||
Reference in New Issue
Block a user