initial commit

This commit is contained in:
zhangshun
2026-05-23 09:11:46 +08:00
commit 5d08480921
42 changed files with 10615 additions and 0 deletions

20
web/src/utils/format.ts Normal file
View File

@@ -0,0 +1,20 @@
export function escapeHtml(value: string) {
return value.replace(/[&<>"']/g, (char) => ({
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#039;"
}[char]!));
}
export function formatBytes(bytes: number) {
if (bytes < 1024) return `${bytes} B`;
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
}
export function modelNameFromFile(fileName: string) {
return fileName.replace(/\.[^/.]+$/, "");
}