Files
pj_mini_app_cloud/src/sheep/utils/file.ts
T
dzc 653b4688cd fix:图片访问
fix:权限修改
2026-10-29 14:25:46 +08:00

12 lines
709 B
TypeScript

export { fileUrl as filePath, originalFileUrl, stripFileHtml, downloadFile, previewFiles } from './file-access'
import { fileHtml } from './file-access'
/** Preserve existing responsive article images while signing resource attributes. */
export const parseHtml = (html: string) => fileHtml(html || '').replace(/<img\b[^>]*>/gi, img => {
const required = 'max-width: 100%; height: auto; display: block;'
const style = img.match(/\bstyle\s*=\s*(['"])([\s\S]*?)\1/i)
if (!style) return img.replace(/<img\b/i, `<img style="${required}"`)
if (/(?:max-)?width\s*:/i.test(style[2])) return img
return img.replace(style[0], `style=${style[1]}${style[2].replace(/;?\s*$/, '; ')}${required}${style[1]}`)
})