Skip to content

Commit 13785ca

Browse files
committed
fix(mod): complete mutual exclusion - AquaMai install removes MuMod, latestVersion respects MuMod channel
1 parent a9ca30f commit 13785ca

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

MaiChartManager/Controllers/Mod/InstallationController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ public void InstallAquaMai()
218218
var src = Path.Combine(StaticSettings.exeDir, "AquaMai.dll");
219219
var dest = Path.Combine(StaticSettings.GamePath, @"Mods\AquaMai.dll");
220220
CopyFile(src, dest);
221+
if (System.IO.File.Exists(ModPaths.MuModDllInstalledPath))
222+
{
223+
System.IO.File.Delete(ModPaths.MuModDllInstalledPath);
224+
}
221225
}
222226

223227
[HttpPost]
@@ -285,6 +289,10 @@ public async Task InstallAquaMaiOnline(InstallAquaMaiOnlineDto req)
285289
var dest = Path.Combine(StaticSettings.GamePath, @"Mods\AquaMai.dll");
286290
Directory.CreateDirectory(Path.GetDirectoryName(dest));
287291
await System.IO.File.WriteAllBytesAsync(dest, data);
292+
if (System.IO.File.Exists(ModPaths.MuModDllInstalledPath))
293+
{
294+
System.IO.File.Delete(ModPaths.MuModDllInstalledPath);
295+
}
288296
return;
289297
}
290298
throw new InvalidOperationException("Failed to download AquaMai from all urls", lastException);

MaiChartManager/Front/src/views/ModManager/shouldShowUpdateController.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@ export function compareVersions(v1: string, v2: string) {
4141

4242
export const selectedChannel = useStorage<'slow' | 'ci'>('aquamai-update-channel', 'slow');
4343

44+
// MuMod 模式:MuMod 已安装且没有冲突(两者都不存在的情况不算 MuMod 模式)
45+
export const isMuModMode = computed(() => {
46+
return !!modInfo.value?.muModInstalled && !modInfo.value?.isBothModsPresent;
47+
});
48+
4449
export const latestVersion = computed(() => {
50+
// MuMod 模式下,使用 muModChannel 对应的 API type 查找最新版本
51+
const effectiveChannel = isMuModMode.value
52+
? (modInfo.value?.muModChannel === 'fast' ? 'ci' : 'slow')
53+
: selectedChannel.value;
4554
const defaultVersionInfo =
46-
modUpdateInfo.value?.find(it => it.type === selectedChannel.value) ||
55+
modUpdateInfo.value?.find(it => it.type === effectiveChannel) ||
4756
modUpdateInfo.value?.find(it => it.default) ||
4857
modUpdateInfo.value?.[0] || { type: 'builtin' };
4958
if (defaultVersionInfo.type === "builtin") {
@@ -52,9 +61,9 @@ export const latestVersion = computed(() => {
5261
type: 'builtin',
5362
};
5463
}
55-
let latestVersion = defaultVersionInfo.version!;
64+
let latestVersionStr = defaultVersionInfo.version!;
5665
let builtinVersion = modInfo.value!.bundledAquaMaiVersion!;
57-
if (compareVersions(latestVersion, builtinVersion) < 0) {
66+
if (compareVersions(latestVersionStr, builtinVersion) < 0) {
5867
return {
5968
version: builtinVersion,
6069
type: 'builtin',
@@ -63,11 +72,6 @@ export const latestVersion = computed(() => {
6372
return defaultVersionInfo;
6473
})
6574

66-
// MuMod 模式:MuMod 已安装且没有冲突(两者都不存在的情况不算 MuMod 模式)
67-
export const isMuModMode = computed(() => {
68-
return !!modInfo.value?.muModInstalled && !modInfo.value?.isBothModsPresent;
69-
});
70-
7175
export const shouldShowUpdate = computed(() => {
7276
if (isMuModMode.value) {
7377
// MuMod 模式下:比较缓存版本和最新版本

0 commit comments

Comments
 (0)