Skip to content

Commit

Permalink
show changed images
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Scheuerle (Plagiatus) committed Feb 19, 2021
1 parent a99852c commit 57d150a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/renderer/components/Comparison.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ export default Vue.extend({
if (hash1 !== hash2) {
// console.log("png", filename);
changedFiles.push(filename);
this.files[filename] = {
status: 0,
newContent: await zip2.file(filename).async(textfile ? "string" : "base64"),
oldContent: await zip1.file(filename).async(textfile ? "string" : "base64"),
};
}
} else if (filename.endsWith(".nbt")) {
// no idea how to properly compare nbt files, so i'm going to ignore them
Expand All @@ -194,15 +199,17 @@ export default Vue.extend({
removedFiles.push(filename);
this.files[filename] = {
status: -1,
removed: await zip1
oldContent: await zip1
.file(filename)
.async(textfile ? "string" : "base64"),
};
} else {
addedFiles.push(filename);
this.files[filename] = {
status: 1,
added: await zip2.file(filename).async(textfile ? "string" : "base64"),
newContent: await zip2
.file(filename)
.async(textfile ? "string" : "base64"),
};
}
}
Expand All @@ -218,6 +225,7 @@ export default Vue.extend({
return true;
},
displayFile(file) {
console.log("displayFile", file);
this.shownFile = file;
},
},
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/components/Comparison/FileDisplay.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<template>
<div>
<span class="top"> {{ file.name }} {{ old ? "(old)" : "(new)" }}</span>
<div class="file-display-content">
<div v-if="imageFile">
<img v-if="(old ? file.oldContent : file.newContent)" :src="'data:image/png;base64,' + (old ? file.oldContent : file.newContent)">
</div>
<div class="file-display-content" v-else>
<span
v-for="(diff, index) in diffContent"
:key="index"
Expand Down Expand Up @@ -45,6 +48,9 @@ export default Vue.extend({
}
return diffs;
},
imageFile() {
return this.file && this.file.name && this.file.name.endsWith(".png")
}
},
});
</script>
Expand All @@ -59,9 +65,9 @@ span.top {
text-align: center;
}
div.file-display-content span {
/* div.file-display-content span {
display: block;
}
} */
.changed {
color: orange;
Expand Down

0 comments on commit 57d150a

Please sign in to comment.