mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
feat: supports show connection detail
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const UNITS = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
|
||||
const parseTraffic = (num: number) => {
|
||||
const parseTraffic = (num?: number) => {
|
||||
if (typeof num !== "number") return ["NaN", ""];
|
||||
if (num < 1000) return [`${Math.round(num)}`, "B"];
|
||||
const exp = Math.min(Math.floor(Math.log2(num) / 10), UNITS.length - 1);
|
||||
const dat = num / Math.pow(1024, exp);
|
||||
|
||||
6
src/utils/truncate-str.ts
Normal file
6
src/utils/truncate-str.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const truncateStr = (str?: string, prefixLen = 16, maxLen = 56) => {
|
||||
if (!str || str.length <= maxLen) return str;
|
||||
return (
|
||||
str.slice(0, prefixLen) + " ... " + str.slice(-(maxLen - prefixLen - 5))
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user