This commit is contained in:
wangxk 2025-04-07 17:09:56 +08:00
parent 5a9feedbec
commit 735156bbbd

View File

@ -70,7 +70,7 @@ function diffFile() {
comparearr.value = comparearr.value.filter(item => { comparearr.value = comparearr.value.filter(item => {
return seen.has(item.id) ? false : seen.add(item.id); return seen.has(item.id) ? false : seen.add(item.id);
}); });
tabs.value = 1 tabs.value = 3
differential.value = true differential.value = true
// getchayi() // getchayi()
diffSure() diffSure()
@ -132,7 +132,7 @@ const loading3 = ref(false)
// }) // })
// } // }
//- //-
const sureSize = ref(10) const sureSize = ref(100)
const sureTotal = ref() const sureTotal = ref()
const sureCurrent = ref(1) const sureCurrent = ref(1)
function diffSure() { function diffSure() {
@ -156,7 +156,7 @@ function diffSure() {
sureSize.value = res.data.size sureSize.value = res.data.size
sureTotal.value = res.data.total sureTotal.value = res.data.total
sureCurrent.value = res.data.current sureCurrent.value = res.data.current
diffColor() // diffColor()
}) })
} }
//- //-
@ -184,11 +184,11 @@ function diffChange() {
ChangeSize.value = res.data.size ChangeSize.value = res.data.size
ChangeTotal.value = res.data.total ChangeTotal.value = res.data.total
ChangeCurrent.value = res.data.current ChangeCurrent.value = res.data.current
diffColor() // diffColor()
}) })
} }
//- //-
const MisseSize = ref(10) const MisseSize = ref(100)
const MissTotal = ref() const MissTotal = ref()
const MissCurrent = ref(1) const MissCurrent = ref(1)
function diffMiss() { function diffMiss() {
@ -212,49 +212,62 @@ function diffMiss() {
MisseSize.value = res.data.size MisseSize.value = res.data.size
MissTotal.value = res.data.total MissTotal.value = res.data.total
MissCurrent.value = res.data.current MissCurrent.value = res.data.current
diffColor() // diffColor()
}) })
} }
// //
// diffColor
function diffColor() { function diffColor() {
if (workdata.value.length > 0 && localOnlyFiles.value.length > 0) { // 1. 使Map
workdata.value = changeColor(workdata.value, localOnlyFiles.value, '1') const createMap = (arr: any[]) => new Map(arr.map(item => [item.id, item]));
}
if (workdata.value.length > 0 && md5MismatchedFiles.value.length > 0) {
workdata.value = changeColor(workdata.value, md5MismatchedFiles.value, '2')
backupsdata.value = changeColor(backupsdata.value, md5MismatchedFiles.value, '2')
}
if (backupsdata.value.length > 0 && minioOnlyFiles.value.length > 0) {
backupsdata.value = changeColor(backupsdata.value, minioOnlyFiles.value, '3')
}
workref.value!.setCheckedKeys([], false)
beifentree.value!.setCheckedKeys([], false)
}
//
function changeColor(data: any, data2: any, type: any) {
data.forEach((item: any) => {
data2.forEach((item2: any) => {
if (item.id == item2.id) {
item.station = type
}
if (item.children.length > 0) {
changeColor(item.children, data2, type)
}
})
})
return data
const localMap = createMap(localOnlyFiles.value);
const md5Map = createMap(md5MismatchedFiles.value);
const minioMap = createMap(minioOnlyFiles.value);
// 2.
const processTree = (tree: any[], location: 'local' | 'minio') => {
const stack = [...tree];
while (stack.length) {
const node = stack.pop();
if (!node) continue;
// 3. 使
let status = 0;
if (location === 'local') {
status |= localMap.has(node.id) ? 1 : 0;
status |= md5Map.has(node.id) ? 2 : 0;
} else {
status |= minioMap.has(node.id) ? 3 : 0;
status |= md5Map.has(node.id) ? 2 : 0;
} }
function gettabletable(){
sureSize.value = 100 // 4. 使
ChangeSize.value = 100 node.station = status.toString(10).split('').sort().reverse()[0];
MisseSize.value = 100
diffSure() // 5.
diffChange() if (node.children?.length) {
diffMiss() stack.push(...node.children);
}
}
};
// 6.
if (workdata.value.length) {
processTree(workdata.value, 'local');
}
if (backupsdata.value.length) {
processTree(backupsdata.value, 'minio');
}
// 7. UI
nextTick(() => {
workref.value?.setCheckedKeys([], false);
beifentree.value?.setCheckedKeys([], false);
});
} }
function diffClose() { function diffClose() {
// gettabletable()
differential.value = false differential.value = false
getlocaltree() getlocaltree()
getminiotree() getminiotree()