export const FindFileName = (path: string) => { /* find filename */ const isName = /.*\/.*\/(.*\..*)/; const result = isName.exec(path)?.length ? (isName.exec(path) as Array)[1] : ''; return result.split('.')[0]; }; /** 用于合并静态资源请求数量, 如果目录中的资源文件过多而需要引用的较少时不建议使用 * 可以将数量可观并且公用的抽放到同一层文件夹,可以提升页面渲染速度 */ export const TransAssetsUrl = ( source: Record, key: string, path?: string ): any => { if (key) { let target: string | undefined = ''; target = Object.keys(source).find((pathName) => { const p = path ? `${path}${key}` : key; return p === FindFileName(pathName); }); if (target) { return source[target].default; } else { return ''; } } else { return ''; } };