From f008442a919661369dca4b6dcfbc61139f839486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B0=91=E5=BA=B7?= Date: Tue, 25 Mar 2025 17:26:43 +0800 Subject: [PATCH] =?UTF-8?q?UUID=E5=8D=87=E7=BA=A7=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Jyh/Version/Detail/SBOM.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/views/Jyh/Version/Detail/SBOM.vue b/src/views/Jyh/Version/Detail/SBOM.vue index 07bb8c3..a9d0096 100644 --- a/src/views/Jyh/Version/Detail/SBOM.vue +++ b/src/views/Jyh/Version/Detail/SBOM.vue @@ -46,6 +46,15 @@ const setSelectRow = (row) => { showDetail.value = true; }; + +function generateUUID() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + const r = Math.random() * 16 | 0; + const v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); +} + const renameComponentsToChildren = (obj) => { // 如果传入的不是对象,直接返回 if (typeof obj !== 'object' || obj === null) { @@ -55,7 +64,7 @@ const renameComponentsToChildren = (obj) => { // 如果对象有 `components` 属性,将其改为 `children` if (obj.hasOwnProperty('component')) { // 生成随机 UUID 并赋值给 id - obj.id = crypto.randomUUID(); // 使用浏览器/Node.js 原生 API + obj.id = generateUUID(); // 使用浏览器/Node.js 原生 API // obj.id = obj.component.id; // 将 components 改为 children obj.libraryName = obj.component.libraryName; // 将 components 改为 children obj.latestVersion = obj.component.latestVersion; // 将 components 改为 children