Commit ec09bbd0bffe769e3e495bc0eb6957819b8ccf27
1 parent
4c8ed34f
perf(src/packages): 优化3D编辑器携带参数为uuid格式
Showing
2 changed files
with
8 additions
and
23 deletions
... | ... | @@ -170,7 +170,6 @@ function MenubarFile(editor) { |
170 | 170 | const paramsStr = window.location.search |
171 | 171 | const params = new URLSearchParams(paramsStr) |
172 | 172 | const file_uuid = params.get('three_file_uuid') |
173 | - console.log(file_json) | |
174 | 173 | await saveOrUpdateThreeJsModel({ |
175 | 174 | id: file_uuid, |
176 | 175 | imageUrl: uploadRes?.fileDownloadUri, | ... | ... |
... | ... | @@ -33,31 +33,17 @@ export const getUUID = (randomLength = 10) => { |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * 生成一个UUIDv4版本的 |
36 | + * GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” | |
36 | 37 | */ |
37 | 38 | |
38 | 39 | export function generateUUIDv4() { |
39 | - const len = 32 //32长度 | |
40 | - let radix = 16 //16进制 | |
41 | - const chars = '0123456789abcdefghijklmnopqrstuvwxyz'.split('') | |
42 | - const uuid = [] | |
43 | - let i | |
44 | - radix = radix || chars.length | |
45 | - if (len) { | |
46 | - for (i = 0; i < len; i++) { | |
47 | - uuid[i] = chars[0 | (Math.random() * radix)] | |
48 | - } | |
49 | - } else { | |
50 | - let r | |
51 | - uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-' | |
52 | - uuid[14] = '4' | |
53 | - for (i = 0; i < 36; i++) { | |
54 | - if (!uuid[i]) { | |
55 | - r = 0 | (Math.random() * 16) | |
56 | - uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r] | |
57 | - } | |
58 | - } | |
59 | - } | |
60 | - return uuid.join('') | |
40 | + let d = new Date().getTime() | |
41 | + const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | |
42 | + const r = (d + Math.random() * 16) % 16 | 0 | |
43 | + d = Math.floor(d / 16) | |
44 | + return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16) | |
45 | + }) | |
46 | + return uuid | |
61 | 47 | } |
62 | 48 | |
63 | 49 | /** | ... | ... |