| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /**
- * 图片映射配置文件
- *
- * @author 系统开发团队
- * @date 2023-05-15
- * @version 1.0.0
- * @description
- * 该配置文件用于定义特定图片URL的映射规则。
- * 可以为特定的远程图片URL指定本地路径,优先级高于通用映射规则。
- * 主要用于处理特殊情况,如需要将某些图片映射到特定的本地路径。
- */
- /**
- * 图片映射配置
- * 可以为特定的远程图片URL指定本地路径
- *
- * @example
- * {
- * 'http://example.com/image1.jpg': '/local-images/special/image1.jpg',
- * 'http://example.com/image2.jpg': '/local-images/special/image2.jpg'
- * }
- */
- export const imageMapping: Record<string, string> = {
- // 远程URL: 本地路径
- // 示例:
- // 'http://localhost:48081/admin-api/infra/file/1/get/example.jpg': '/local-images/custom/special-example.jpg',
- // 可以添加更多映射...
- }
- /**
- * 获取映射的本地路径
- * @param url 远程图片URL
- * @returns 映射的本地路径,如果没有映射则返回null
- *
- * @example
- * // 如果有映射,返回映射的本地路径
- * getMappedImagePath('http://example.com/image1.jpg') // 返回: '/local-images/special/image1.jpg'
- *
- * @example
- * // 如果没有映射,返回null
- * getMappedImagePath('http://example.com/no-mapping.jpg') // 返回: null
- */
- export const getMappedImagePath = (url: string): string | null => {
- return imageMapping[url] || null
- }
|