Skip to content

Commit 70d3185

Browse files
committed
feat(mod-ui): add MuMod state management layer\n\nAdd isMuModMode computed to shouldShowUpdateController.ts for detecting\nMuMod-only mode. Update shouldShowUpdate to compare MuMod cache version\nagainst latest when in MuMod mode. Add muModChannel, isBothModsPresent\ncomputed refs and updateMuModChannel async function to refs.ts.
1 parent 2e34717 commit 70d3185

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import api from "@/client/api";
22
import { useAsyncState } from '@vueuse/core';
3-
import { ref } from 'vue';
3+
import { computed, ref } from 'vue';
44
import { ConfigDto } from "@/client/apiGen";
55
import { modInfo } from "@/store/refs";
66
import { compareVersions } from "./shouldShowUpdateController";
@@ -65,3 +65,12 @@ export const updateAquaMaiConfig = async (forceDefault = false, skipSignatureChe
6565
configJustLoaded.value = true;
6666
await executeGetConfig();
6767
};
68+
69+
// MuMod 状态
70+
export const muModChannel = computed(() => modInfo.value?.muModChannel ?? 'slow');
71+
export const isBothModsPresent = computed(() => !!modInfo.value?.isBothModsPresent);
72+
73+
export const updateMuModChannel = async (channel: string) => {
74+
await api.SetMuModChannelAndEnsureCache({ channel });
75+
await updateAquaMaiConfig();
76+
};

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,20 @@ export const latestVersion = computed(() => {
6363
return defaultVersionInfo;
6464
})
6565

66+
// MuMod 模式:MuMod 已安装且没有冲突(两者都不存在的情况不算 MuMod 模式)
67+
export const isMuModMode = computed(() => {
68+
return !!modInfo.value?.muModInstalled && !modInfo.value?.isBothModsPresent;
69+
});
70+
6671
export const shouldShowUpdate = computed(() => {
72+
if (isMuModMode.value) {
73+
// MuMod 模式下:比较缓存版本和最新版本
74+
if (!modInfo.value?.muModCacheVersion) return true;
75+
const muModType = modInfo.value?.muModChannel === 'fast' ? 'ci' : 'slow';
76+
const muModLatest = modUpdateInfo.value?.find(it => it.type === muModType);
77+
if (!muModLatest?.version) return false;
78+
return compareVersions(modInfo.value.muModCacheVersion, muModLatest.version) < 0;
79+
}
6780
if (!modInfo.value?.aquaMaiInstalled) return true;
6881
if (!modInfo.value?.aquaMaiVersion) return true;
6982
let currentVersion = modInfo.value.aquaMaiVersion;

0 commit comments

Comments
 (0)