diff --git a/src/frontend/devops-manage/src/store/userDetailGroupTable.ts b/src/frontend/devops-manage/src/store/userDetailGroupTable.ts index 9283c2b9245f..468fcb4dd15b 100644 --- a/src/frontend/devops-manage/src/store/userDetailGroupTable.ts +++ b/src/frontend/devops-manage/src/store/userDetailGroupTable.ts @@ -1,6 +1,7 @@ import http from '@/http/api'; import { defineStore } from 'pinia'; import { ref } from 'vue'; +import { deepEqual } from "@/utils/util.js"; import pipelineIcon from '@/components/user-group/svg/color-logo-pipeline.svg'; import codelibIcon from '@/components/user-group/svg/color-logo-codelib.svg'; import codeccIcon from '@/components/user-group/svg/color-logo-codecc.svg'; @@ -145,10 +146,10 @@ export default defineStore('userDetailGroupTable', () => { if (currentRequestId === requestId) { detailSourceList.value.forEach(item => { - if (authorizationData && Array.isArray(authorizationData.records) && item === authorizationItem) { + if (authorizationData && Array.isArray(authorizationData.records) && deepEqual(item, authorizationItem)) { item.tableData = authorizationData.records; item.activeFlag = true; - } else if (userGroupData && Array.isArray(userGroupData.records) && item === userGroupItem) { + } else if (userGroupData && Array.isArray(userGroupData.records) && deepEqual(item, userGroupItem)) { item.tableData = userGroupData.records; item.activeFlag = true; } diff --git a/src/frontend/devops-manage/src/utils/util.js b/src/frontend/devops-manage/src/utils/util.js index ce554a051685..4876c6c4d0c6 100644 --- a/src/frontend/devops-manage/src/utils/util.js +++ b/src/frontend/devops-manage/src/utils/util.js @@ -15,3 +15,25 @@ export function convertTime (ms) { return `${time.getFullYear()}-${prezero(time.getMonth() + 1)}-${prezero(time.getDate())} ${prezero(time.getHours())}:${prezero(time.getMinutes())}:${prezero(time.getSeconds())}` } +export function deepEqual(obj1, obj2) { + if (obj1 === obj2) return true; + + if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 === null || obj2 === null) { + return false; + } + + const keys1 = Object.keys(obj1); + const keys2 = Object.keys(obj2); + + if (keys1.length !== keys2.length) return false; + + const keys2Set = new Set(keys2); + + for (const key of keys1) { + if (!keys2Set.has(key) || !deepEqual(obj1[key], obj2[key])) { + return false; + } + } + + return true; +} \ No newline at end of file diff --git a/src/frontend/devops-permission/src/store/userDetailGroupTable.ts b/src/frontend/devops-permission/src/store/userDetailGroupTable.ts index 608a3a329baf..bfe4682a3b62 100644 --- a/src/frontend/devops-permission/src/store/userDetailGroupTable.ts +++ b/src/frontend/devops-permission/src/store/userDetailGroupTable.ts @@ -1,6 +1,7 @@ import http from '@/http/api'; import { defineStore } from 'pinia'; import { ref } from 'vue'; +import { deepEqual } from "@/utils/util.js"; import pipelineIcon from '@/css/svg/color-logo-pipeline.svg'; import codelibIcon from '@/css/svg/color-logo-codelib.svg'; import codeccIcon from '@/css/svg/color-logo-codecc.svg'; @@ -145,10 +146,10 @@ export default defineStore('userDetailGroupTable', () => { if (currentRequestId === requestId) { detailSourceList.value.forEach(item => { - if (authorizationData && Array.isArray(authorizationData.records) && item === authorizationItem) { + if (authorizationData && Array.isArray(authorizationData.records) && deepEqual(item, authorizationItem)) { item.tableData = authorizationData.records; item.activeFlag = true; - } else if(userGroupData && Array.isArray(userGroupData.records) && item === userGroupItem) { + } else if (userGroupData && Array.isArray(userGroupData.records) && deepEqual(item, userGroupItem)) { item.tableData = userGroupData.records; item.activeFlag = true; } diff --git a/src/frontend/devops-permission/src/utils/util.js b/src/frontend/devops-permission/src/utils/util.js index ce554a051685..4876c6c4d0c6 100644 --- a/src/frontend/devops-permission/src/utils/util.js +++ b/src/frontend/devops-permission/src/utils/util.js @@ -15,3 +15,25 @@ export function convertTime (ms) { return `${time.getFullYear()}-${prezero(time.getMonth() + 1)}-${prezero(time.getDate())} ${prezero(time.getHours())}:${prezero(time.getMinutes())}:${prezero(time.getSeconds())}` } +export function deepEqual(obj1, obj2) { + if (obj1 === obj2) return true; + + if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 === null || obj2 === null) { + return false; + } + + const keys1 = Object.keys(obj1); + const keys2 = Object.keys(obj2); + + if (keys1.length !== keys2.length) return false; + + const keys2Set = new Set(keys2); + + for (const key of keys1) { + if (!keys2Set.has(key) || !deepEqual(obj1[key], obj2[key])) { + return false; + } + } + + return true; +} \ No newline at end of file