Skip to content

Commit e17a8d1

Browse files
committed
fix(mod): mod version comp corner case
1 parent dd2785c commit e17a8d1

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/renderer/windows/main/components/ModCard.vue

+27-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<template>
22
<v-tooltip top>
33
<template v-slot:activator="{ on }">
4-
<v-card color="darken-1" flat hover :class="{ incompatible: !compatible }" class="draggable-card mod-card white--text" style="margin-top: 10px; padding: 0 10px;"
4+
<v-card color="darken-1" flat hover :class="{ incompatible: !compatible }"
5+
class="draggable-card mod-card white--text" style="margin-top: 10px; padding: 0 10px;"
56
draggable v-on="on" @dragstart="onDragStart" @dblclick="tryOpen">
67
<v-layout justify-center align-center fill-height>
78
<v-flex v-if="icon" xs4 style="padding: 0 10px 0 0;" fill-height>
@@ -58,22 +59,37 @@ export default {
5859
return this.$repo.getters.selectedProfile.mcversion;
5960
},
6061
acceptedRange() {
61-
return this.data.acceptedMinecraftVersions ? this.data.acceptedMinecraftVersions : `[${this.data.mcversion}]`;
62+
if (this.data.acceptedMinecraftVersions) {
63+
return this.data.acceptedMinecraftVersions;
64+
}
65+
if (/^\[.+\]$/.test(this.data.mcversion)) {
66+
return this.data.mcversion;
67+
}
68+
return `[${this.data.mcversion}]`;
6269
},
6370
compatible() {
64-
return isCompatible(this.acceptedRange, this.mcversion);
71+
try {
72+
return isCompatible(this.acceptedRange, this.mcversion);
73+
} catch (e) {
74+
console.error(this.data.modid);
75+
console.error(e);
76+
return false;
77+
}
6578
},
6679
},
6780
mounted() {
68-
this.$repo.dispatch('readForgeLogo', this.hash).then((icon) => {
69-
if (typeof icon === 'string' && icon !== '') {
70-
this.icon = `data:image/png;base64, ${icon}`;
71-
} else {
72-
this.icon = unknownPack;
73-
}
74-
});
81+
this.readLogo();
7582
},
7683
methods: {
84+
readLogo() {
85+
this.$repo.dispatch('readForgeLogo', this.hash).then((icon) => {
86+
if (typeof icon === 'string' && icon !== '') {
87+
this.icon = `data:image/png;base64, ${icon}`;
88+
} else {
89+
this.icon = unknownPack;
90+
}
91+
});
92+
},
7793
onDragStart(e) {
7894
e.dataTransfer.setData('Index', `${this.isSelected ? 'R' : 'L'}${this.index}`);
7995
},
@@ -91,7 +107,7 @@ export default {
91107
background-color: #e65100;
92108
}
93109
.draggable-card:hover {
94-
background-color: #388E3C;
110+
background-color: #388e3c;
95111
}
96112
97113
.title {

0 commit comments

Comments
 (0)