From eef7c19891e437ef18e79ced890d6aaf0db6113d Mon Sep 17 00:00:00 2001 From: qx <1084500556@qq.com> Date: 星期三, 11 六月 2025 10:53:28 +0800 Subject: [PATCH] Merge branch 'master' of http://101.42.27.146:5001/r/ltkj_peisweb --- src/views/system/zhiye/file.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/src/views/system/zhiye/file.js b/src/views/system/zhiye/file.js new file mode 100644 index 0000000..a0644fd --- /dev/null +++ b/src/views/system/zhiye/file.js @@ -0,0 +1,49 @@ +// base64杞枃浠� +export const dataURLtoFile = (image, filename) => { + var arr = image.split(","); + var mime = arr[0].match(/:(.*?);/)[1]; + var bstr = atob(arr[1]); + var n = bstr.length; + var u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + let file = new File([u8arr], filename, { type: mime }) + return file; +} + +// 绗竴涓弬鏁颁负浣犳兂鐢熸垚鐨勫浐瀹氱殑鏂囧瓧寮�澶存瘮濡�: 寰俊鐢ㄦ埛xxxxx +// 绗簩涓负浣犳兂鐢熸垚鍑哄浐瀹氬紑澶存枃瀛楀鐨勯殢鏈洪暱搴� +export const random = ( randomLength) =>{ + // 鍏煎鏇翠綆鐗堟湰鐨勯粯璁ゅ�煎啓娉� + // prefix === undefined ? prefix = "" : prefix; + randomLength === undefined ? randomLength = 3 : randomLength; + + // 璁剧疆闅忔満鐢ㄦ埛鍚� + // 鐢ㄦ埛鍚嶉殢鏈鸿瘝鍏告暟缁� + let nameArr = [ + ["涓�","绗�","璐�","鍑�","姝�","鏄�","浠�","鍣�","涔�","绀�","鏅�","淇�","鍙�","涓�","閮�","濂�","鏃�","涔�","閽�","鐜�","蹇�","瀛�","鍗�","鑱�","婢�","绾�","姣�","鎮�","鏄�","鍐�","鐖�","鐞�","鑼�","缇�","甯�","瀹�"], + ["绉�","濞�","鑻�","鍗�","鎱�","宸�","缇�","濞�","闈�","娣�","鎯�","鐝�","缈�","闆�","鑺�","鐜�","钀�","绾�","濞�","鐜�","鑺�","鑺�","鐕�","褰�","鏄�","鑿�","杞�","缈�","鏈�","浼�","瑷�","鑻�","楦�","鏈�","鏂�","姊�","鏍�","缁�"] + ] + // 闅忔満鍚嶅瓧瀛楃涓� + // let name = prefix; + let name = ""; + + // 寰幆閬嶅巻浠庣敤鎴疯瘝鍏镐腑闅忔満鎶藉嚭涓�涓� + for (var i = 0; i < randomLength; i++) { + // 闅忔満鐢熸垚index + let index = Math.floor(Math.random() * 2); + let zm = nameArr[index][Math.floor(Math.random() * nameArr[index].length)]; + // 濡傛灉闅忔満鍑虹殑鏄嫳鏂囧瓧姣� + if (index === 1) { + // 鍒欑櫨鍒嗕箣50鐨勬鐜囧彉涓哄ぇ鍐� + if (Math.floor(Math.random() * 2) === 1) { + zm = zm.toUpperCase(); + } + } + // 鎷兼帴杩涘悕瀛楀彉閲忎腑 + name += zm; + } + // 灏嗛殢鏈虹敓鎴愮殑鍚嶅瓧杩斿洖 + return name; +} -- Gitblit v1.8.0