- 任务详情上传支持"本批素材无条码"开关,跳过条码必填校验 - SKU卡片/主图网格从4列改5列,图片高度压缩,去掉冗余标签和提示 - 详情图/PSD上传区去掉大占位框,改成紧凑按钮+标签 - 补充历史导入相关脚本和工具文件 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
885 B
TypeScript
27 lines
885 B
TypeScript
import path from 'path'
|
|
|
|
export function buildStoredUploadPath(...segments: string[]) {
|
|
return path.posix.join('uploads', ...segments.map((segment) => String(segment || '').replace(/\\/g, '/')))
|
|
}
|
|
|
|
export function getUploadRootDir(): string {
|
|
const configuredUploadDir = String(process.env.UPLOAD_DIR || '').trim()
|
|
if (!configuredUploadDir) {
|
|
return path.join(process.cwd(), 'uploads')
|
|
}
|
|
|
|
return path.isAbsolute(configuredUploadDir)
|
|
? configuredUploadDir
|
|
: path.resolve(process.cwd(), configuredUploadDir)
|
|
}
|
|
|
|
export function resolveStoredUploadPath(storedPath: string): string {
|
|
const normalizedPath = String(storedPath || '').replace(/\\/g, '/')
|
|
if (path.isAbsolute(normalizedPath)) {
|
|
return normalizedPath
|
|
}
|
|
|
|
const relativeToUploadRoot = normalizedPath.replace(/^\.?\/*uploads\//i, '')
|
|
return path.join(getUploadRootDir(), relativeToUploadRoot)
|
|
}
|