From 35a3bccaa12309d337e84db75ae344962e55607a Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期二, 17 六月 2025 18:50:27 +0800
Subject: [PATCH] update 调整商品分类为单列

---
 seller/src/utils/file.js |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/seller/src/utils/file.js b/seller/src/utils/file.js
new file mode 100644
index 0000000..74cfa34
--- /dev/null
+++ b/seller/src/utils/file.js
@@ -0,0 +1,40 @@
+
+/**
+ * 鐢熸垚fileKey
+ *
+ * @param fileName 鏂囦欢鍚�
+ * @returns {*}
+ */
+export function getFileKey (fileName) {
+    const extension = fileName.split('.').pop().toLowerCase();
+        
+	const fileTypes = {
+		image: { name: '鍥剧墖', exts: ["jpg", "png", "jpeg", "gif", "bmp", "webp", "tiff", "svg", "ico", "psd", "raw"] },
+		video: { name: '瑙嗛', exts: ["mp4", "avi", "rmvb", "mov", "wmv", "flv", "mkv", "mpeg", "mpg", "m4v", "3gp", "webm", "vob", "swf"] },
+		radio: { name: '闊抽', exts: ["mp3", "wma", "wav", "mpeg-4", "cd", "m4a", "aac", "flac", "ogg", "aiff", "ape", "midi", "amr", "ra"] },
+		text: { name: '鏂囨湰', exts: ["txt", "xls", "xlsx", "doc", "docx", "pdf", "ppt", "pptx", "csv", "rtf", "odt", "ods", "odp", "epub", "mobi", "pages", "numbers", "key"] },
+		zip: { name: '鍘嬬缉鏂囦欢', exts: ["zip", "rar", "7z", "tar", "gz", "bz2", "xz", "iso", "dmg", "pkg", "cab", "z", "lz", "lzma", "lzo"] }
+	};
+  
+	// 鑾峰彇褰撳墠鏃堕棿骞舵牸寮忓寲涓� yyyyMMddHHmmss
+	const now = new Date();
+	const yyyyMMddHHmmss = [
+		now.getFullYear(),
+		String(now.getMonth() + 1).padStart(2, '0'),
+		String(now.getDate()).padStart(2, '0'),
+		String(now.getHours()).padStart(2, '0'),
+		String(now.getMinutes()).padStart(2, '0'),
+		String(now.getSeconds()).padStart(2, '0')
+	].join('');
+	
+	// 鐢熸垚5浣嶉殢鏈烘暟瀛�
+	const random5Digits = Math.floor(10000 + Math.random() * 90000);
+	
+	// 鏌ユ壘鍖归厤鐨勬枃浠剁被鍨�
+	for (const [type, data] of Object.entries(fileTypes)) {
+		if (data.exts.includes(extension)) {
+			return `${type}/${yyyyMMddHHmmss}${random5Digits}` + '.' + extension;
+		}
+	}
+    return '';
+}

--
Gitblit v1.8.0