Commit c6a002da6a7093163fe64bdde3170f1d440f130e
1 parent
59995619
fix(src/packages): 修改3D编辑器,携带id为uuidv4版本
Showing
3 changed files
with
47 additions
and
20 deletions
... | ... | @@ -32,6 +32,35 @@ export const getUUID = (randomLength = 10) => { |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | + * 生成一个UUIDv4版本的 | |
36 | + */ | |
37 | + | |
38 | +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('') | |
61 | +} | |
62 | + | |
63 | +/** | |
35 | 64 | * * render 图标 |
36 | 65 | * @param icon 图标 |
37 | 66 | * @param set 设置项 |
... | ... | @@ -359,24 +388,22 @@ export const setTitle = (title?: string) => { |
359 | 388 | title && (document.title = title) |
360 | 389 | } |
361 | 390 | |
362 | - | |
363 | - | |
364 | -export const getUrlSearch = (name: string) =>{ | |
391 | +export const getUrlSearch = (name: string) => { | |
365 | 392 | // 未传参,返回空 |
366 | - if (!name) return null; | |
393 | + if (!name) return null | |
367 | 394 | // 查询参数:先通过search取值,如果取不到就通过hash来取 |
368 | - let after = window.location.search; | |
369 | - after = after.substr(1) || window.location.hash.split('?')[1]; | |
395 | + let after = window.location.search | |
396 | + after = after.substr(1) || window.location.hash.split('?')[1] | |
370 | 397 | // 地址栏URL没有查询参数,返回空 |
371 | - if (!after) return null; | |
398 | + if (!after) return null | |
372 | 399 | // 如果查询参数中没有"name",返回空 |
373 | - if (after.indexOf(name) === -1) return null; | |
374 | - | |
375 | - const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | |
400 | + if (after.indexOf(name) === -1) return null | |
401 | + | |
402 | + const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') | |
376 | 403 | // 当地址栏参数存在中文时,需要解码,不然会乱码 |
377 | - const r = decodeURI(after).match(reg); | |
404 | + const r = decodeURI(after).match(reg) | |
378 | 405 | // 如果url中"name"没有值,返回空 |
379 | - if (!r) return null; | |
380 | - | |
381 | - return r[2]; | |
382 | -} | |
\ No newline at end of file | ||
406 | + if (!r) return null | |
407 | + | |
408 | + return r[2] | |
409 | +} | ... | ... |
... | ... | @@ -100,7 +100,7 @@ import { useDataListInit } from './hooks/useData.hook' |
100 | 100 | import { ref } from 'vue' |
101 | 101 | import type { FormInst } from 'naive-ui' |
102 | 102 | import { icon } from '@/plugins' |
103 | -import { getUUID } from '@/utils/utils' | |
103 | +import { generateUUIDv4 } from '@/utils/utils' | |
104 | 104 | import { threeJsDeleteApi, putReleaseThreeJsModel } from '@/api/external/contentSave/content' |
105 | 105 | import { ChartType } from '../..' |
106 | 106 | import { DialogEnum } from '@/enums/pluginEnum' |
... | ... | @@ -170,7 +170,7 @@ const releaseGoDialog = (message: string, state: number, messageText: string) => |
170 | 170 | window['$message'].success(window['$t'](messageText)) |
171 | 171 | handleSearchClick() |
172 | 172 | isBulkOperationFlag.value = true |
173 | - selectAllTextFlag.value = false | |
173 | + selectAllTextFlag.value = true | |
174 | 174 | operationKey.value = '' |
175 | 175 | resetSelect(list.value, false) |
176 | 176 | } |
... | ... | @@ -197,7 +197,7 @@ const handleOperationSelect = async (key: string) => { |
197 | 197 | window['$message'].success(window['$t']('common.deleteSuccessText')) |
198 | 198 | handleSearchClick() |
199 | 199 | isBulkOperationFlag.value = true |
200 | - selectAllTextFlag.value = false | |
200 | + selectAllTextFlag.value = true | |
201 | 201 | operationKey.value = '' |
202 | 202 | resetSelect(list.value, false) |
203 | 203 | } |
... | ... | @@ -249,7 +249,7 @@ const handleResetClick = () => { |
249 | 249 | |
250 | 250 | const handleOpenThreeEditor = () => { |
251 | 251 | const { host, protocol, pathname } = location |
252 | - const randomId = getUUID(32) | |
252 | + const randomId = generateUUIDv4() | |
253 | 253 | window.open(`${protocol}//${host}${pathname}editor/?three_file_uuid=${randomId}&action_type=create`) |
254 | 254 | } |
255 | 255 | </script> | ... | ... |