Skip to content

Commit

Permalink
feat:用户个人视角 权限管理优化 #11138
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 28397
  • Loading branch information
useryuyu committed Jan 3, 2025
1 parent 637d1dc commit f648a23
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/frontend/devops-manage/src/store/userDetailGroupTable.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 22 additions & 0 deletions src/frontend/devops-manage/src/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 22 additions & 0 deletions src/frontend/devops-permission/src/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit f648a23

Please sign in to comment.