diff --git a/src/components/ATable.tsx b/src/components/ATable.tsx index f45475d..432d627 100644 --- a/src/components/ATable.tsx +++ b/src/components/ATable.tsx @@ -11,6 +11,7 @@ type ATableProps = { const ATable: FC = ({ header = [], data = [], loading }) => { + const onDownloadFile = (item: data) => { const host = ` https://ton-gateway.crust.network/gateway/${item.bagId}?filename=${item.fileName}` const link = document.createElement("a"); @@ -34,7 +35,7 @@ const ATable: FC = ({ header = [], data = [], loading }) => { data-tooltip-id="my-tooltip" data-tooltip-content={item.fileName} data-tooltip-delay-hide={100} - data-tooltip-place='top-start' className="w-[230px] pl-2 h-[40px] flex items-center">{truncateMiddle(item.fileName, 5, 5)} + data-tooltip-place='top-start' className="w-[230px] pl-2 h-[40px] flex items-center">{truncateMiddle(item.fileName, 6, 6)}
{truncateMiddle(item.bagId, 5, 5)}
-
+
- - -
diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 7b5d39e..292a1e3 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -8,7 +8,6 @@ export const timestampToDateTime = (timestamp: number) => { const day = ('0' + date.getDate()).slice(-2); const hours = ('0' + date.getHours()).slice(-2); const minutes = ('0' + date.getMinutes()).slice(-2); - // const seconds = ('0' + date.getSeconds()).slice(-2); return `${year}-${month}-${day} ${hours}:${minutes}`; }; @@ -34,16 +33,11 @@ export function calculateTotalFileSize(data: T[], key: strin } export const truncateMiddle = (str: string, frontLen: number, endLen: number) => { - if (!str) return; - if (str.length <= 10) return str; - const [name, ext] = str.split('.'); - - const firstPart = name?.slice(0, frontLen); - const lastPart = name?.slice(-endLen); - - const shortName = `${firstPart}...${lastPart}${ext ? '.' + ext : ''}`; - - return shortName; + if (!str) return ''; + if (str.length <= frontLen + endLen) return str; + const start = str?.substring(0, frontLen) || ''; + const end = str?.substring(str.length - endLen) || ''; + return `${start}...${end}`; }; export function getCurrentUrlParams() { @@ -75,4 +69,5 @@ export const copyTextToClipboard = async (text: string) => { export const scrollToTop = () => { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; + document.getElementsByClassName('overflow')[0]!.scrollLeft = 0; };