From f26d83f291856bb92d47828958124ecf6a71540f Mon Sep 17 00:00:00 2001 From: akanyan Date: Wed, 23 Apr 2025 14:24:35 +0000 Subject: [PATCH] fix: misc cleanup --- rust/src/cmd.rs | 30 ++++++++++++++++++++--- rust/src/lib.rs | 1 + src/components/App.vue | 18 ++++++-------- src/components/ModList.vue | 9 +++++-- src/components/ModStore.vue | 20 ++++++++-------- src/components/OptionList.vue | 4 ++-- src/components/ProfileList.vue | 2 +- src/components/StartButton.vue | 2 +- src/components/options/Display.vue | 12 ++++++---- src/components/options/Segatools.vue | 14 +++++------ src/stores.ts | 36 +++++++++++++++------------- 11 files changed, 89 insertions(+), 59 deletions(-) diff --git a/rust/src/cmd.rs b/rust/src/cmd.rs index 40ed203..a091bcc 100644 --- a/rust/src/cmd.rs +++ b/rust/src/cmd.rs @@ -190,12 +190,16 @@ pub async fn get_all_packages(state: State<'_, Mutex>) -> Result>, game: Game) -> Result, ()> { - log::debug!("invoke: get_game_packages {game}"); +pub async fn get_game_packages(state: State<'_, Mutex>, game: Option) -> Result, ()> { + log::debug!("invoke: get_game_packages {game:?}"); let appd = state.lock().await; - Ok(appd.pkgs.get_game_list(game)) + if let Some(game) = game { + Ok(appd.pkgs.get_game_list(game)) + } else { + Ok(Vec::new()) + } } #[tauri::command] @@ -437,6 +441,26 @@ pub async fn import_profile(path: PathBuf) -> Result<(), String> { Profile::import(path).map_err(|e| e.to_string()) } +#[tauri::command] +pub async fn clear_cache(state: State<'_, Mutex>) -> Result<(), String> { + log::debug!("invoke: clear_cache"); + + let appd = state.lock().await; + if let Some(p) = &appd.profile { + let dir = p.data_dir().join("mu3-mods-cache"); + let path = dir.join("data_cache.bin"); + if path.exists() { + std::fs::remove_file(path).map_err(|e| e.to_string())?; + } + let path = dir.join("data_fumen_analysis_cache.bin"); + if path.exists() { + std::fs::remove_file(path).map_err(|e| e.to_string())?; + } + } + + Ok(()) +} + #[tauri::command] pub async fn list_platform_capabilities() -> Result, ()> { log::debug!("invoke: list_platform_capabilities"); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 4ce573a..7863a9a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -207,6 +207,7 @@ pub async fn run(_args: Vec) { cmd::create_shortcut, cmd::export_profile, cmd::import_profile, + cmd::clear_cache, cmd::get_global_config, cmd::set_global_config, diff --git a/src/components/App.vue b/src/components/App.vue index a90fc32..3e5733c 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -56,11 +56,6 @@ listen('update-end', (_) => { }); onMounted(async () => { - invoke('list_directories').then((d) => { - general.dirs = d as Dirs; - client.load(); - }); - const fetch_promise = pkg.fetch(true); await Promise.all([prf.reloadList(), prf.reload()]); @@ -231,8 +226,9 @@ listen('download-progress', (event) => { >
@@ -304,19 +300,19 @@ listen('download-progress', (event) => { - + - + - + - + -
+
+ ∅ +
diff --git a/src/components/ModStore.vue b/src/components/ModStore.vue index 68a7e6e..e26b42d 100644 --- a/src/components/ModStore.vue +++ b/src/components/ModStore.vue @@ -23,7 +23,7 @@ const props = defineProps({ const gameSublist: Ref = ref([]); invoke('get_game_packages', { - game: prf.current?.meta.game, + game: prf.current?.meta.game ?? null, }).then((list) => { gameSublist.value = list as string[]; }); @@ -46,10 +46,10 @@ const list = () => { }; const shouldShowRecommended = computed(() => { - if (prf.current!.meta.game === 'ongeki') { + if (prf.current?.meta.game === 'ongeki') { return !pkgs.allLocal.some((p) => pkgKey(p) === 'segatools-mu3hook'); } - if (prf.current!.meta.game === 'chunithm') { + if (prf.current?.meta.game === 'chunithm') { return ( !pkgs.allLocal.some((p) => pkgKey(p) === 'segatools-chusanhook') || !pkgs.allLocal.some((p) => pkgKey(p) === 'mempatcher-mempatcher') @@ -58,21 +58,21 @@ const shouldShowRecommended = computed(() => { return false; }); -const getRecommendedTooltip = () => { - if (prf.current!.meta.game === 'ongeki') { +const recommendedTooltip = computed(() => { + if (prf.current?.meta.game === 'ongeki') { return 'segatools-mu3hook'; } - if (prf.current!.meta.game === 'chunithm') { + if (prf.current?.meta.game === 'chunithm') { return 'segatools-chusanhook + mempatcher'; } return ''; -}; +}); const installRecommended = () => { - if (prf.current!.meta.game === 'ongeki') { + if (prf.current?.meta.game === 'ongeki') { pkgs.installFromKey('segatools-mu3hook'); } - if (prf.current!.meta.game === 'chunithm') { + if (prf.current?.meta.game === 'chunithm') { pkgs.installFromKey('segatools-chusanhook'); pkgs.installFromKey('mempatcher-mempatcher'); } @@ -120,7 +120,7 @@ const installRecommended = () => {