feat: add image management functionality

- Implemented image folder repository with CRUD operations.
- Added image reference repository for managing image references to articles.
- Created image repository for handling image assets, including listing, inserting, updating, and deleting images.
- Introduced image usage repository to track storage usage and quotas for tenants.
- Added SQL queries for image assets, folders, references, and usage.
- Developed image handler for HTTP endpoints to manage images and folders.
- Created database migration scripts for image-related tables and structures.
This commit is contained in:
2026-04-16 20:40:41 +08:00
parent 0a3558fc51
commit 27389164b0
57 changed files with 8063 additions and 153 deletions
+20
View File
@@ -31,6 +31,26 @@ export function formatDateTime(value?: string | null, pattern = "YYYY-MM-DD HH:m
return parsed.isValid() ? parsed.format(pattern) : value;
}
export function formatBytes(bytes: number, decimals = 2): string {
if (bytes === 0) return "0 B";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
}
export function formatPercentage(value?: number | null, decimals = 2): string {
if (typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value)) {
return "--";
}
return value.toFixed(Math.max(0, decimals));
}
export function getGenerateStatusMeta(status?: string | null): { label: string; color: string } {
if (!status) {
return { label: "--", color: "default" };