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