diff options
-rw-r--r-- | src-tauri/src/main.rs | 34 | ||||
-rw-r--r-- | src-vue/src/App.vue | 6 | ||||
-rw-r--r-- | src-vue/src/main.ts | 4 | ||||
-rw-r--r-- | src-vue/src/utils/Tabs.ts | 3 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 39 | ||||
-rw-r--r-- | src-vue/src/views/RepairView.vue | 60 |
6 files changed, 116 insertions, 30 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c7451763..50e439c8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -37,7 +37,7 @@ use northstar::get_northstar_version_number; mod thunderstore; use thunderstore::query_thunderstore_packages_api; -use tauri::Manager; +use tauri::{Manager, Runtime}; use tauri_plugin_store::PluginBuilder; use tokio::time::sleep; @@ -115,10 +115,12 @@ fn main() { delete_northstar_mod, get_server_player_count, delete_thunderstore_mod, + open_repair_window, query_thunderstore_packages_api, get_pull_requests_wrapper, apply_launcher_pr, apply_mods_pr, + close_application, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -355,3 +357,33 @@ async fn get_server_player_count() -> Result<(i32, usize), String> { Ok((total_player_count, server_count)) } + +#[tauri::command] +/// Spawns repair window +async fn open_repair_window(handle: tauri::AppHandle) -> Result<(), String> { + // Spawn new window + let repair_window = match tauri::WindowBuilder::new( + &handle, + "RepairWindow", + tauri::WindowUrl::App("/#/repair".into()), + ) + .build() + { + Ok(res) => res, + Err(err) => return Err(err.to_string()), + }; + + // Set window title + match repair_window.set_title("FlightCore Repair Window") { + Ok(()) => (), + Err(err) => return Err(err.to_string()), + }; + Ok(()) +} + +/// Closes all windows and exits application +#[tauri::command] +async fn close_application<R: Runtime>(app: tauri::AppHandle<R>) -> Result<(), String> { + app.exit(0); // Close application + Ok(()) +} diff --git a/src-vue/src/App.vue b/src-vue/src/App.vue index c28919e1..f740bd2f 100644 --- a/src-vue/src/App.vue +++ b/src-vue/src/App.vue @@ -6,7 +6,7 @@ import ModsView from './views/ModsView.vue'; import SettingsView from './views/SettingsView.vue'; import { appWindow } from '@tauri-apps/api/window'; import { store } from './plugins/store'; -import { window as tauriWindow } from "@tauri-apps/api"; +import { invoke, window as tauriWindow } from "@tauri-apps/api"; export default { components: { @@ -30,7 +30,7 @@ export default { appWindow.minimize() }, close() { - appWindow.close() + invoke("close_application"); } }, computed: { @@ -47,7 +47,7 @@ export default { <div class="app-inner"> <div id="fc_bg__container" :style="bgStyle"/> - <nav id="fc_menu-bar"> + <nav id="fc_menu-bar" v-if="$route.path !== '/repair'"><!-- Hide menu bar in repair view --> <!-- Navigation items --> <el-menu :default-active="$route.path" diff --git a/src-vue/src/main.ts b/src-vue/src/main.ts index 95bea7af..57d41865 100644 --- a/src-vue/src/main.ts +++ b/src-vue/src/main.ts @@ -8,6 +8,7 @@ import ChangelogView from "./views/ChangelogView.vue"; import ModsView from "./views/ModsView.vue"; import SettingsView from "./views/SettingsView.vue"; import DeveloperView from "./views/DeveloperView.vue"; +import RepairView from "./views/RepairView.vue"; import {createRouter, createWebHashHistory} from "vue-router"; @@ -35,7 +36,8 @@ const routes = [ { path: '/changelog', name: 'Changelog', component: async () => ChangelogView}, { path: '/mods', name: 'Mods', component: async () => ModsView}, { path: '/settings', name: 'Settings', component: async () => SettingsView}, - { path: '/dev', name: 'Dev', component: async () => DeveloperView} + { path: '/dev', name: 'Dev', component: async () => DeveloperView}, + { path: '/repair', name: 'Repair', component: async () => RepairView}, ]; export const router = createRouter({ history: createWebHashHistory(), diff --git a/src-vue/src/utils/Tabs.ts b/src-vue/src/utils/Tabs.ts index 027f9f0a..5d31379c 100644 --- a/src-vue/src/utils/Tabs.ts +++ b/src-vue/src/utils/Tabs.ts @@ -3,5 +3,6 @@ export enum Tabs { CHANGELOG = '/changelog', SETTINGS = '/settings', DEV = '/dev', - MODS = '/mods' + MODS = '/mods', + REPAIR = '/repair', } diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index 11cb4f5d..665e2e55 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -4,6 +4,7 @@ <el-alert title="Warning" type="warning" :closable="false" show-icon> This page is designed for developers. Some of the buttons here can break your Northstar install if you do not know what you're doing! </el-alert> + <h3>Basic:</h3> <el-button type="primary" @click="disableDevMode"> @@ -36,8 +37,8 @@ <h3>Repair:</h3> - <el-button type="primary" @click="disableAllModsButCore"> - Disable all but core mods + <el-button type="primary" @click="createNewWindow"> + Open Repair window </el-button> <el-button type="primary" @click="forceInstallNorthstar"> @@ -118,28 +119,6 @@ export default defineComponent({ async launchGameWithoutChecks() { this.$store.commit('launchGame', true); }, - async disableAllModsButCore() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - await invoke("disable_all_but_core", { gameInstall: game_install }).then((message) => { - ElNotification({ - title: 'Success', - message: "Disabled all mods but core", - type: 'success', - position: 'bottom-right' - }); - }) - .catch((error) => { - ElNotification({ - title: 'Error', - message: error, - type: 'error', - position: 'bottom-right' - }); - }); - }, async getInstalledMods() { let game_install = { game_path: this.$store.state.game_path, @@ -261,6 +240,18 @@ export default defineComponent({ notification.close(); }); }, + async createNewWindow() { + await invoke("open_repair_window") + .then((message) => { }) + .catch((error) => { + ElNotification({ + title: 'Error', + message: error, + type: 'error', + position: 'bottom-right' + }); + }); + }, } }); </script> diff --git a/src-vue/src/views/RepairView.vue b/src-vue/src/views/RepairView.vue new file mode 100644 index 00000000..cf19e3e6 --- /dev/null +++ b/src-vue/src/views/RepairView.vue @@ -0,0 +1,60 @@ +<template> + <div class="fc-container"> + <el-scrollbar> + <el-alert title="Info" type="info" :closable="false" show-icon> + This window contains various functionality to repair common issues with Northstar and FlightCore. + </el-alert> + + <h1>Repair</h1> + + <h2>Northstar</h2> + + <el-button type="primary" @click="disableAllModsButCore"> + Disable all but core mods + </el-button> + + </el-scrollbar> + </div> +</template> + +<script lang="ts"> +import { defineComponent } from "vue"; +import { ElNotification } from "element-plus"; +import { GameInstall } from "../utils/GameInstall"; +import { invoke } from "@tauri-apps/api"; + +export default defineComponent({ + name: "RepairView", + methods: { + async disableAllModsButCore() { + let game_install = { + game_path: this.$store.state.game_path, + install_type: this.$store.state.install_type + } as GameInstall; + await invoke("disable_all_but_core", { gameInstall: game_install }) + .then((message) => { + ElNotification({ + title: 'Success', + message: "Disabled all mods but core", + type: 'success', + position: 'bottom-right' + }); + }) + .catch((error) => { + ElNotification({ + title: 'Error', + message: error, + type: 'error', + position: 'bottom-right' + }); + }); + }, + } +}); +</script> + +<style scoped> +.fc-container { + padding-top: 0px; +} +</style> |