Files
PicHost/app/utils/image-display.ts
O96u 737235acff release: v1.4.0 — 标签系统、操作日志扩展与文档截图更新
- 每用户标签与彩色打标,图库 OR/AND 筛选与批量打标
- 操作日志记录登录、删除、设置与标签操作
- API 标签/打标接口;README 与文档站截图同步
2026-09-09 14:46:52 +08:00

29 lines
840 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export function getFileExtension(filename: string): string {
const base = filename.split(/[/\\]/).pop() ?? filename
const dot = base.lastIndexOf('.')
if (dot <= 0 || dot === base.length - 1) return '—'
return base.slice(dot + 1).toLowerCase()
}
export function getUrlPathname(url: string): string {
try {
return decodeURIComponent(new URL(url).pathname.replace(/^\/+/, ''))
} catch {
return url
}
}
export function getStorageKeyTail(key: string): string {
const prefix = 'images/'
return key.startsWith(prefix) ? key.slice(prefix.length) : key
}
export function formatImageDimensions(width: number | null, height: number | null): string | null {
if (!width || !height) return null
return `${width} × ${height} px`
}
export function buildImageBbcode(url: string): string {
return `[img]${url}[/img]`
}