You've already forked AstralRinth
forked from didirus/AstralRinth
Implement loading (#104)
* Implement loading * LoadingBar * Run linter * Update App.vue * Loading bar all the things * Update SplashScreen.vue * Update SplashScreen.vue * Update App.vue * initial revert * Update Instance.vue * revert css * Fix instance * More reverting * Run lint * Finalize changes * Revert "Merge branch 'master' into loading" This reverts commit 3014e765fb6fb343f3030fd8a822edd97fb2af41, reversing changes made to b780e859d2b53a203eb3561ba3be88af083d9c15. * Fix loading issues * fix lint * Revert "Revert "Merge branch 'master' into loading"" This reverts commit 971ef8466613579b7f523edbd25b692df62d0f86. --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
@@ -96,6 +96,7 @@ pub async fn profile_create(
|
|||||||
let loader_data = match loader {
|
let loader_data = match loader {
|
||||||
ModLoader::Forge => &metadata.forge,
|
ModLoader::Forge => &metadata.forge,
|
||||||
ModLoader::Fabric => &metadata.fabric,
|
ModLoader::Fabric => &metadata.fabric,
|
||||||
|
ModLoader::Quilt => &metadata.quilt,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(ProfileCreationError::NoManifest(
|
return Err(ProfileCreationError::NoManifest(
|
||||||
loader.to_string(),
|
loader.to_string(),
|
||||||
@@ -199,7 +200,6 @@ pub async fn profile_create(
|
|||||||
State::sync().await?;
|
State::sync().await?;
|
||||||
|
|
||||||
Ok(path)
|
Ok(path)
|
||||||
|
|
||||||
}).await
|
}).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ pub async fn init_loading(
|
|||||||
message: title.to_string(),
|
message: title.to_string(),
|
||||||
total,
|
total,
|
||||||
current: 0.0,
|
current: 0.0,
|
||||||
|
last_sent: 0.0,
|
||||||
bar_type,
|
bar_type,
|
||||||
#[cfg(feature = "cli")]
|
#[cfg(feature = "cli")]
|
||||||
cli_progress_bar: {
|
cli_progress_bar: {
|
||||||
@@ -115,6 +116,7 @@ pub async fn edit_loading(
|
|||||||
bar.total = total;
|
bar.total = total;
|
||||||
bar.message = title.to_string();
|
bar.message = title.to_string();
|
||||||
bar.current = 0.0;
|
bar.current = 0.0;
|
||||||
|
bar.last_sent = 0.0;
|
||||||
#[cfg(feature = "cli")]
|
#[cfg(feature = "cli")]
|
||||||
{
|
{
|
||||||
bar.cli_progress_bar.reset(); // indicatif::ProgressBar::new(CLI_PROGRESS_BAR_TOTAL as u64);
|
bar.cli_progress_bar.reset(); // indicatif::ProgressBar::new(CLI_PROGRESS_BAR_TOTAL as u64);
|
||||||
@@ -150,42 +152,47 @@ pub async fn emit_loading(
|
|||||||
// Tick up loading bar
|
// Tick up loading bar
|
||||||
loading_bar.current += increment_frac;
|
loading_bar.current += increment_frac;
|
||||||
let display_frac = loading_bar.current / loading_bar.total;
|
let display_frac = loading_bar.current / loading_bar.total;
|
||||||
let display_frac = if display_frac >= 1.0 {
|
let opt_display_frac = if display_frac >= 1.0 {
|
||||||
None // by convention, when its done, we submit None
|
None // by convention, when its done, we submit None
|
||||||
// any further updates will be ignored (also sending None)
|
// any further updates will be ignored (also sending None)
|
||||||
} else {
|
} else {
|
||||||
Some(display_frac)
|
Some(display_frac)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Emit event to indicatif progress bar
|
if f64::abs(display_frac - loading_bar.last_sent) > 0.005 {
|
||||||
#[cfg(feature = "cli")]
|
// Emit event to indicatif progress bar
|
||||||
{
|
#[cfg(feature = "cli")]
|
||||||
loading_bar.cli_progress_bar.set_message(
|
{
|
||||||
message
|
loading_bar.cli_progress_bar.set_message(
|
||||||
.map(|x| x.to_string())
|
message
|
||||||
.unwrap_or(loading_bar.message.clone()),
|
.map(|x| x.to_string())
|
||||||
);
|
.unwrap_or(loading_bar.message.clone()),
|
||||||
loading_bar.cli_progress_bar.set_position(
|
);
|
||||||
((loading_bar.current / loading_bar.total)
|
loading_bar.cli_progress_bar.set_position(
|
||||||
* CLI_PROGRESS_BAR_TOTAL as f64)
|
(display_frac * CLI_PROGRESS_BAR_TOTAL as f64).round() as u64,
|
||||||
.round() as u64,
|
);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
// Emit event to tauri
|
||||||
|
#[cfg(feature = "tauri")]
|
||||||
|
event_state
|
||||||
|
.app
|
||||||
|
.emit_all(
|
||||||
|
"loading",
|
||||||
|
LoadingPayload {
|
||||||
|
fraction: opt_display_frac,
|
||||||
|
message: message
|
||||||
|
.unwrap_or(&loading_bar.message)
|
||||||
|
.to_string(),
|
||||||
|
event: loading_bar.bar_type.clone(),
|
||||||
|
loader_uuid: loading_bar.loading_bar_uuid,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.map_err(EventError::from)?;
|
||||||
|
|
||||||
|
loading_bar.last_sent = display_frac;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit event to tauri
|
|
||||||
#[cfg(feature = "tauri")]
|
|
||||||
event_state
|
|
||||||
.app
|
|
||||||
.emit_all(
|
|
||||||
"loading",
|
|
||||||
LoadingPayload {
|
|
||||||
fraction: display_frac,
|
|
||||||
message: message.unwrap_or(&loading_bar.message).to_string(),
|
|
||||||
event: loading_bar.bar_type.clone(),
|
|
||||||
loader_uuid: loading_bar.loading_bar_uuid,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.map_err(EventError::from)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ pub struct LoadingBar {
|
|||||||
pub message: String,
|
pub message: String,
|
||||||
pub total: f64,
|
pub total: f64,
|
||||||
pub current: f64,
|
pub current: f64,
|
||||||
|
#[serde(skip)]
|
||||||
|
pub last_sent: f64,
|
||||||
pub bar_type: LoadingBarType,
|
pub bar_type: LoadingBarType,
|
||||||
#[cfg(feature = "cli")]
|
#[cfg(feature = "cli")]
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
|||||||
@@ -30,11 +30,22 @@ pub async fn download_minecraft(
|
|||||||
let assets_index =
|
let assets_index =
|
||||||
download_assets_index(st, version, Some(loading_bar)).await?;
|
download_assets_index(st, version, Some(loading_bar)).await?;
|
||||||
|
|
||||||
|
let amount = if version
|
||||||
|
.processors
|
||||||
|
.as_ref()
|
||||||
|
.map(|x| !x.is_empty())
|
||||||
|
.unwrap_or(false)
|
||||||
|
{
|
||||||
|
25.0
|
||||||
|
} else {
|
||||||
|
40.0
|
||||||
|
};
|
||||||
|
|
||||||
tokio::try_join! {
|
tokio::try_join! {
|
||||||
// Total loading sums to 80
|
// Total loading sums to 90/60
|
||||||
download_client(st, version, Some(loading_bar)), // 10
|
download_client(st, version, Some(loading_bar)), // 10
|
||||||
download_assets(st, version.assets == "legacy", &assets_index, Some(loading_bar)), // 35
|
download_assets(st, version.assets == "legacy", &assets_index, Some(loading_bar), amount), // 40
|
||||||
download_libraries(st, version.libraries.as_slice(), &version.id, Some(loading_bar)) // 35
|
download_libraries(st, version.libraries.as_slice(), &version.id, Some(loading_bar), amount) // 40
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
tracing::info!("Done downloading Minecraft!");
|
tracing::info!("Done downloading Minecraft!");
|
||||||
@@ -83,21 +94,7 @@ pub async fn download_version_info(
|
|||||||
}?;
|
}?;
|
||||||
|
|
||||||
if let Some(loading_bar) = loading_bar {
|
if let Some(loading_bar) = loading_bar {
|
||||||
emit_loading(
|
emit_loading(loading_bar, 5.0, None).await?;
|
||||||
loading_bar,
|
|
||||||
if res
|
|
||||||
.processors
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| !x.is_empty())
|
|
||||||
.unwrap_or(false)
|
|
||||||
{
|
|
||||||
5.0
|
|
||||||
} else {
|
|
||||||
15.0
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::debug!("Loaded version info for Minecraft {version_id}");
|
tracing::debug!("Loaded version info for Minecraft {version_id}");
|
||||||
@@ -140,7 +137,7 @@ pub async fn download_client(
|
|||||||
tracing::trace!("Fetched client version {version}");
|
tracing::trace!("Fetched client version {version}");
|
||||||
}
|
}
|
||||||
if let Some(loading_bar) = loading_bar {
|
if let Some(loading_bar) = loading_bar {
|
||||||
emit_loading(loading_bar, 10.0, None).await?;
|
emit_loading(loading_bar, 9.0, None).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::debug!("Client loaded for version {version}!");
|
tracing::debug!("Client loaded for version {version}!");
|
||||||
@@ -186,6 +183,7 @@ pub async fn download_assets(
|
|||||||
with_legacy: bool,
|
with_legacy: bool,
|
||||||
index: &AssetsIndex,
|
index: &AssetsIndex,
|
||||||
loading_bar: Option<&LoadingBarId>,
|
loading_bar: Option<&LoadingBarId>,
|
||||||
|
loading_amount: f64,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
tracing::debug!("Loading assets");
|
tracing::debug!("Loading assets");
|
||||||
@@ -196,7 +194,7 @@ pub async fn download_assets(
|
|||||||
loading_try_for_each_concurrent(assets,
|
loading_try_for_each_concurrent(assets,
|
||||||
None,
|
None,
|
||||||
loading_bar,
|
loading_bar,
|
||||||
35.0,
|
loading_amount,
|
||||||
num_futs,
|
num_futs,
|
||||||
None,
|
None,
|
||||||
|(name, asset)| async move {
|
|(name, asset)| async move {
|
||||||
@@ -237,10 +235,8 @@ pub async fn download_assets(
|
|||||||
tracing::trace!("Loaded asset with hash {hash}");
|
tracing::trace!("Loaded asset with hash {hash}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}).await?;
|
}).await?;
|
||||||
|
|
||||||
tracing::debug!("Done loading assets!");
|
tracing::debug!("Done loading assets!");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
}).await
|
}).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +246,7 @@ pub async fn download_libraries(
|
|||||||
libraries: &[Library],
|
libraries: &[Library],
|
||||||
version: &str,
|
version: &str,
|
||||||
loading_bar: Option<&LoadingBarId>,
|
loading_bar: Option<&LoadingBarId>,
|
||||||
|
loading_amount: f64,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
tracing::debug!("Loading libraries");
|
tracing::debug!("Loading libraries");
|
||||||
@@ -261,7 +258,7 @@ pub async fn download_libraries(
|
|||||||
let num_files = libraries.len();
|
let num_files = libraries.len();
|
||||||
loading_try_for_each_concurrent(
|
loading_try_for_each_concurrent(
|
||||||
stream::iter(libraries.iter())
|
stream::iter(libraries.iter())
|
||||||
.map(Ok::<&Library, crate::Error>), None, loading_bar,35.0,num_files, None,|library| async move {
|
.map(Ok::<&Library, crate::Error>), None, loading_bar,loading_amount,num_files, None,|library| async move {
|
||||||
if let Some(rules) = &library.rules {
|
if let Some(rules) = &library.rules {
|
||||||
if !rules.iter().all(super::parse_rule) {
|
if !rules.iter().all(super::parse_rule) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ pub async fn install_minecraft(
|
|||||||
let state = State::get().await?;
|
let state = State::get().await?;
|
||||||
let instance_path = &canonicalize(&profile.path)?;
|
let instance_path = &canonicalize(&profile.path)?;
|
||||||
let metadata = state.metadata.read().await;
|
let metadata = state.metadata.read().await;
|
||||||
|
|
||||||
let version = metadata
|
let version = metadata
|
||||||
.minecraft
|
.minecraft
|
||||||
.versions
|
.versions
|
||||||
@@ -93,7 +92,7 @@ pub async fn install_minecraft(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Download version info
|
// Download version info (5)
|
||||||
let mut version_info = download::download_version_info(
|
let mut version_info = download::download_version_info(
|
||||||
&state,
|
&state,
|
||||||
version,
|
version,
|
||||||
@@ -106,12 +105,12 @@ pub async fn install_minecraft(
|
|||||||
// Download minecraft (5-90)
|
// Download minecraft (5-90)
|
||||||
download::download_minecraft(&state, &version_info, &loading_bar).await?;
|
download::download_minecraft(&state, &version_info, &loading_bar).await?;
|
||||||
|
|
||||||
let client_path = state
|
|
||||||
.directories
|
|
||||||
.version_dir(&version_jar)
|
|
||||||
.join(format!("{version_jar}.jar"));
|
|
||||||
|
|
||||||
if let Some(processors) = &version_info.processors {
|
if let Some(processors) = &version_info.processors {
|
||||||
|
let client_path = state
|
||||||
|
.directories
|
||||||
|
.version_dir(&version_jar)
|
||||||
|
.join(format!("{version_jar}.jar"));
|
||||||
|
|
||||||
if let Some(ref mut data) = version_info.data {
|
if let Some(ref mut data) = version_info.data {
|
||||||
processor_rules! {
|
processor_rules! {
|
||||||
data;
|
data;
|
||||||
@@ -138,16 +137,6 @@ pub async fn install_minecraft(
|
|||||||
|
|
||||||
// Forge processors (90-100)
|
// Forge processors (90-100)
|
||||||
for (index, processor) in processors.iter().enumerate() {
|
for (index, processor) in processors.iter().enumerate() {
|
||||||
emit_loading(
|
|
||||||
&loading_bar,
|
|
||||||
10.0 / total_length as f64,
|
|
||||||
Some(&format!(
|
|
||||||
"Running forge processor {}/{}",
|
|
||||||
index, total_length
|
|
||||||
)),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if let Some(sides) = &processor.sides {
|
if let Some(sides) = &processor.sides {
|
||||||
if !sides.contains(&String::from("client")) {
|
if !sides.contains(&String::from("client")) {
|
||||||
continue;
|
continue;
|
||||||
@@ -198,6 +187,16 @@ pub async fn install_minecraft(
|
|||||||
))
|
))
|
||||||
.as_error());
|
.as_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit_loading(
|
||||||
|
&loading_bar,
|
||||||
|
30.0 / total_length as f64,
|
||||||
|
Some(&format!(
|
||||||
|
"Running forge processor {}/{}",
|
||||||
|
index, total_length
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,9 +208,14 @@ pub async fn install_minecraft(
|
|||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
State::sync().await?;
|
State::sync().await?;
|
||||||
|
emit_loading(
|
||||||
|
&loading_bar,
|
||||||
|
1.0,
|
||||||
|
Some("Finished installing"),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
}).await
|
}).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +368,5 @@ pub async fn launch_minecraft(
|
|||||||
post_exit_hook,
|
post_exit_hook,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
||||||
}).await
|
}).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ pub struct Metadata {
|
|||||||
pub minecraft: MinecraftManifest,
|
pub minecraft: MinecraftManifest,
|
||||||
pub forge: LoaderManifest,
|
pub forge: LoaderManifest,
|
||||||
pub fabric: LoaderManifest,
|
pub fabric: LoaderManifest,
|
||||||
|
pub quilt: LoaderManifest,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metadata {
|
impl Metadata {
|
||||||
@@ -25,7 +26,7 @@ impl Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch() -> crate::Result<Self> {
|
pub async fn fetch() -> crate::Result<Self> {
|
||||||
let (minecraft, forge, fabric) = tokio::try_join! {
|
let (minecraft, forge, fabric, quilt) = tokio::try_join! {
|
||||||
async {
|
async {
|
||||||
let url = Self::get_manifest("minecraft");
|
let url = Self::get_manifest("minecraft");
|
||||||
fetch_version_manifest(Some(&url)).await
|
fetch_version_manifest(Some(&url)).await
|
||||||
@@ -37,6 +38,10 @@ impl Metadata {
|
|||||||
async {
|
async {
|
||||||
let url = Self::get_manifest("fabric");
|
let url = Self::get_manifest("fabric");
|
||||||
fetch_loader_manifest(&url).await
|
fetch_loader_manifest(&url).await
|
||||||
|
},
|
||||||
|
async {
|
||||||
|
let url = Self::get_manifest("quilt");
|
||||||
|
fetch_loader_manifest(&url).await
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
@@ -44,6 +49,7 @@ impl Metadata {
|
|||||||
minecraft,
|
minecraft,
|
||||||
forge,
|
forge,
|
||||||
fabric,
|
fabric,
|
||||||
|
quilt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { RouterView, RouterLink } from 'vue-router'
|
import { RouterView, RouterLink } from 'vue-router'
|
||||||
import { HomeIcon, SearchIcon, LibraryIcon, PlusIcon, SettingsIcon, Button } from 'omorphia'
|
import { HomeIcon, SearchIcon, LibraryIcon, PlusIcon, SettingsIcon, Button } from 'omorphia'
|
||||||
import { useLoading, useTheming } from '@/store/state'
|
import { useLoading, useTheming } from '@/store/state'
|
||||||
@@ -8,21 +8,31 @@ import InstanceCreationModal from '@/components/ui/InstanceCreationModal.vue'
|
|||||||
import { get } from '@/helpers/settings'
|
import { get } from '@/helpers/settings'
|
||||||
import Breadcrumbs from '@/components/ui/Breadcrumbs.vue'
|
import Breadcrumbs from '@/components/ui/Breadcrumbs.vue'
|
||||||
import RunningAppBar from '@/components/ui/RunningAppBar.vue'
|
import RunningAppBar from '@/components/ui/RunningAppBar.vue'
|
||||||
|
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
||||||
import ModrinthLoadingIndicator from '@/components/modrinth-loading-indicator'
|
import ModrinthLoadingIndicator from '@/components/modrinth-loading-indicator'
|
||||||
|
|
||||||
const themeStore = useTheming()
|
const themeStore = useTheming()
|
||||||
|
|
||||||
|
const isLoading = ref(true)
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const { settings, collapsed_navigation } = await get()
|
const { settings, collapsed_navigation } = await get()
|
||||||
themeStore.setThemeState(settings)
|
themeStore.setThemeState(settings)
|
||||||
themeStore.collapsedNavigation = collapsed_navigation
|
themeStore.collapsedNavigation = collapsed_navigation
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
initialize: async () => {
|
||||||
|
isLoading.value = false
|
||||||
|
const { theme } = await get()
|
||||||
|
themeStore.setThemeState(theme)
|
||||||
|
},
|
||||||
|
})
|
||||||
const loading = useLoading()
|
const loading = useLoading()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<SplashScreen v-if="isLoading" app-loading />
|
||||||
|
<div v-else class="container">
|
||||||
<div class="nav-container" :class="{ expanded: !themeStore.collapsedNavigation }">
|
<div class="nav-container" :class="{ expanded: !themeStore.collapsedNavigation }">
|
||||||
<div class="nav-section">
|
<div class="nav-section">
|
||||||
<suspense>
|
<suspense>
|
||||||
@@ -150,7 +160,6 @@ const loading = useLoading()
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 0 0 0 1rem;
|
padding: 0 0 0 1rem;
|
||||||
height: 3.25rem;
|
height: 3.25rem;
|
||||||
z-index: 11;
|
|
||||||
|
|
||||||
.navigation-controls {
|
.navigation-controls {
|
||||||
display: inherit;
|
display: inherit;
|
||||||
@@ -222,7 +231,6 @@ const loading = useLoading()
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
z-index: 10;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
box-shadow: var(--shadow-inset-sm), var(--shadow-floating);
|
box-shadow: var(--shadow-inset-sm), var(--shadow-floating);
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ const handleRightPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.row-instance {
|
.row-instance {
|
||||||
min-width: 12rem;
|
min-width: 10.5rem;
|
||||||
max-width: 12rem;
|
max-width: 10.5rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ onBeforeUnmount(() => {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
left: 5.5rem;
|
left: 5.5rem;
|
||||||
z-index: 100;
|
z-index: 9;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border: 1px solid var(--color-button-bg);
|
border: 1px solid var(--color-button-bg);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { shallowRef, ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { ofetch } from 'ofetch'
|
import { ofetch } from 'ofetch'
|
||||||
import { Card, SaveIcon, XIcon, Avatar, AnimatedLogo } from 'omorphia'
|
import { Card, SaveIcon, XIcon, Avatar, AnimatedLogo } from 'omorphia'
|
||||||
@@ -59,34 +59,28 @@ const checkProcess = async () => {
|
|||||||
const install = async (e) => {
|
const install = async (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
modLoading.value = true
|
modLoading.value = true
|
||||||
const [data, versions] = await Promise.all([
|
const versions = await ofetch(
|
||||||
ofetch(
|
`https://api.modrinth.com/v2/project/${props.instance.project_id}/version`
|
||||||
`https://api.modrinth.com/v2/project/${
|
)
|
||||||
props.instance.metadata
|
|
||||||
? props.instance.metadata?.linked_data?.project_id
|
|
||||||
: props.instance.project_id
|
|
||||||
}`
|
|
||||||
).then(shallowRef),
|
|
||||||
ofetch(
|
|
||||||
`https://api.modrinth.com/v2/project/${
|
|
||||||
props.instance.metadata
|
|
||||||
? props.instance.metadata?.linked_dadta?.project_id
|
|
||||||
: props.instance.project_id
|
|
||||||
}/version`
|
|
||||||
).then(shallowRef),
|
|
||||||
])
|
|
||||||
|
|
||||||
if (data.value.project_type === 'modpack') {
|
if (props.instance.project_type === 'modpack') {
|
||||||
const packs = Object.values(await list())
|
const packs = Object.values(await list())
|
||||||
|
|
||||||
if (
|
if (
|
||||||
packs.length === 0 ||
|
packs.length === 0 ||
|
||||||
!packs
|
!packs
|
||||||
.map((value) => value.metadata)
|
.map((value) => value.metadata)
|
||||||
.find((pack) => pack.linked_data?.project_id === data.value.id)
|
.find((pack) => pack.linked_data?.project_id === props.instance.project_id)
|
||||||
) {
|
) {
|
||||||
await pack_install(versions.value[0].id)
|
try {
|
||||||
} else confirmModal.value.show(versions.value[0].id)
|
modLoading.value = true
|
||||||
|
await pack_install(versions[0].id, props.instance.title)
|
||||||
|
modLoading.value = false
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
modLoading.value = false
|
||||||
|
}
|
||||||
|
} else confirmModal.value.show(versions[0].id)
|
||||||
}
|
}
|
||||||
|
|
||||||
modLoading.value = false
|
modLoading.value = false
|
||||||
@@ -125,7 +119,7 @@ const stop = async (e) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await process_listener((e) => {
|
await process_listener((e) => {
|
||||||
if (e.event === 'Finished' && e.uuid == uuid.value) playing.value = false
|
if (e.event === 'Finished' && e.uuid === uuid.value) playing.value = false
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -213,6 +207,10 @@ await process_listener((e) => {
|
|||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cta {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.instance {
|
.instance {
|
||||||
@@ -281,7 +279,7 @@ await process_listener((e) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
z-index: 41;
|
z-index: 1;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
right: 1rem;
|
right: 1rem;
|
||||||
|
|||||||
33
theseus_gui/src/components/ui/ProgressBar.vue
Normal file
33
theseus_gui/src/components/ui/ProgressBar.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<div class="progress-bar">
|
||||||
|
<div class="progress-bar__fill" :style="{ width: `${progress}%` }"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
progress: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
validator(value) {
|
||||||
|
return value >= 0 && value <= 100
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.progress-bar {
|
||||||
|
width: 100%;
|
||||||
|
height: 0.5rem;
|
||||||
|
background-color: var(--color-button-bg);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar__fill {
|
||||||
|
height: 100%;
|
||||||
|
background-color: var(--color-brand);
|
||||||
|
transition: width 0.3s;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -10,30 +10,65 @@
|
|||||||
<Button icon-only class="icon-button" @click="goToTerminal()">
|
<Button icon-only class="icon-button" @click="goToTerminal()">
|
||||||
<TerminalIcon />
|
<TerminalIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
v-if="currentLoadingBars.length > 0"
|
||||||
|
ref="infoButton"
|
||||||
|
icon-only
|
||||||
|
class="icon-button show-card-icon"
|
||||||
|
@click="toggleCard()"
|
||||||
|
>
|
||||||
|
<DownloadIcon />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="status">
|
<div v-else class="status">
|
||||||
<span class="circle stopped" />
|
<span class="circle stopped" />
|
||||||
<span class="running-text"> No running profiles </span>
|
<span class="running-text"> No running profiles </span>
|
||||||
|
<Button
|
||||||
|
v-if="currentLoadingBars.length > 0"
|
||||||
|
ref="infoButton"
|
||||||
|
icon-only
|
||||||
|
class="icon-button show-card-icon"
|
||||||
|
@click="toggleCard()"
|
||||||
|
>
|
||||||
|
<DownloadIcon />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<transition name="download">
|
||||||
|
<Card v-if="showCard === true" ref="card" class="info-card">
|
||||||
|
<div v-for="loadingBar in currentLoadingBars" :key="loadingBar.id" class="info-text">
|
||||||
|
<h3 class="info-title">
|
||||||
|
{{ loadingBar.bar_type.pack_name ?? 'Installing Modpack' }}
|
||||||
|
</h3>
|
||||||
|
<ProgressBar :progress="Math.floor(loadingBar.current)" />
|
||||||
|
<div class="row">{{ Math.floor(loadingBar.current) }}% {{ loadingBar.message }}</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Button } from 'omorphia'
|
import { Button, DownloadIcon, Card } from 'omorphia'
|
||||||
import { StopIcon, TerminalIcon } from '@/assets/icons'
|
import { StopIcon, TerminalIcon } from '@/assets/icons'
|
||||||
import { ref } from 'vue'
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import {
|
import {
|
||||||
get_all_running_profiles as getRunningProfiles,
|
get_all_running_profiles as getRunningProfiles,
|
||||||
kill_by_uuid as killProfile,
|
kill_by_uuid as killProfile,
|
||||||
get_uuids_by_profile_path as getProfileProcesses,
|
get_uuids_by_profile_path as getProfileProcesses,
|
||||||
} from '@/helpers/process'
|
} from '@/helpers/process'
|
||||||
import { process_listener } from '@/helpers/events'
|
import { loading_listener, process_listener } from '@/helpers/events'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import { progress_bars_list } from '@/helpers/state.js'
|
||||||
|
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const card = ref(null)
|
||||||
|
const infoButton = ref(null)
|
||||||
|
const showCard = ref(false)
|
||||||
|
|
||||||
const currentProcesses = ref(await getRunningProfiles())
|
const currentProcesses = ref(await getRunningProfiles())
|
||||||
|
|
||||||
await process_listener(async () => {
|
await process_listener(async (event) => {
|
||||||
|
console.log(event)
|
||||||
await refresh()
|
await refresh()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -48,13 +83,54 @@ const stop = async () => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
await refresh()
|
await refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
const goToTerminal = () => {
|
const goToTerminal = () => {
|
||||||
router.push(`/instance/${encodeURIComponent(currentProcesses.value[0].path)}/logs`)
|
router.push(`/instance/${encodeURIComponent(currentProcesses.value[0].path)}/logs`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentLoadingBars = ref(Object.values(await progress_bars_list()))
|
||||||
|
|
||||||
|
await loading_listener(async () => {
|
||||||
|
await refreshInfo()
|
||||||
|
})
|
||||||
|
|
||||||
|
const refreshInfo = async () => {
|
||||||
|
const currentLoadingBarCount = currentLoadingBars.value.length
|
||||||
|
currentLoadingBars.value = Object.values(await progress_bars_list())
|
||||||
|
if (currentLoadingBars.value.length === 0) {
|
||||||
|
showCard.value = false
|
||||||
|
} else if (currentLoadingBarCount < currentLoadingBars.value.length) {
|
||||||
|
showCard.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClickOutside = (event) => {
|
||||||
|
console.log('clicked outside from appbar')
|
||||||
|
if (
|
||||||
|
card.value &&
|
||||||
|
infoButton.value.$el !== event.target &&
|
||||||
|
card.value.$el !== event.target &&
|
||||||
|
!document.elementsFromPoint(event.clientX, event.clientY).includes(card.value.$el) &&
|
||||||
|
!document.elementsFromPoint(event.clientX, event.clientY).includes(infoButton.value.$el)
|
||||||
|
) {
|
||||||
|
showCard.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleCard = async () => {
|
||||||
|
showCard.value = !showCard.value
|
||||||
|
await refreshInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener('click', handleClickOutside)
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('click', handleClickOutside)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -100,4 +176,94 @@ const goToTerminal = () => {
|
|||||||
--text-color: var(--color-red) !important;
|
--text-color: var(--color-red) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-card {
|
||||||
|
position: absolute;
|
||||||
|
top: 3.5rem;
|
||||||
|
right: 0.5rem;
|
||||||
|
z-index: 9;
|
||||||
|
width: 20rem;
|
||||||
|
background-color: var(--color-raised-bg);
|
||||||
|
box-shadow: var(--shadow-raised);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
overflow: auto;
|
||||||
|
transition: all 0.2s ease-in-out;
|
||||||
|
border: 1px solid var(--color-button-bg);
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-option {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: var(--color-raised-bg-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-icon {
|
||||||
|
width: 2.25rem;
|
||||||
|
height: 2.25rem;
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
:deep(svg) {
|
||||||
|
left: 1rem;
|
||||||
|
width: 2.25rem;
|
||||||
|
height: 2.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-card-icon {
|
||||||
|
color: var(--color-brand);
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-enter-active,
|
||||||
|
.download-leave-active {
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-enter-from,
|
||||||
|
.download-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-title {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
40
theseus_gui/src/components/ui/SplashScreen.vue
Normal file
40
theseus_gui/src/components/ui/SplashScreen.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-loading" :class="{ 'app-loading': appLoading }">
|
||||||
|
<AnimatedLogo class="initializing-icon" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { AnimatedLogo } from 'omorphia'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
appLoading: Boolean,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.page-loading {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
&.app-loading {
|
||||||
|
background-color: #16181c;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.initializing-icon {
|
||||||
|
width: 12rem;
|
||||||
|
height: 12rem;
|
||||||
|
|
||||||
|
:deep(svg),
|
||||||
|
svg {
|
||||||
|
width: 12rem;
|
||||||
|
height: 12rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -16,8 +16,10 @@ app.use(pinia)
|
|||||||
app.use(FloatingVue)
|
app.use(FloatingVue)
|
||||||
app.mixin(loadCssMixin)
|
app.mixin(loadCssMixin)
|
||||||
|
|
||||||
|
const mountedApp = app.mount('#app')
|
||||||
|
|
||||||
initialize_state()
|
initialize_state()
|
||||||
.then(() => app.mount('#app'))
|
.then(() => mountedApp.initialize())
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
ClientIcon,
|
ClientIcon,
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
AnimatedLogo,
|
|
||||||
NavRow,
|
NavRow,
|
||||||
formatCategoryHeader,
|
formatCategoryHeader,
|
||||||
} from 'omorphia'
|
} from 'omorphia'
|
||||||
@@ -23,6 +22,7 @@ import { useBreadcrumbs } from '@/store/breadcrumbs'
|
|||||||
import { get_categories, get_loaders, get_game_versions } from '@/helpers/tags'
|
import { get_categories, get_loaders, get_game_versions } from '@/helpers/tags'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import Instance from '@/components/ui/Instance.vue'
|
import Instance from '@/components/ui/Instance.vue'
|
||||||
|
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
@@ -36,25 +36,28 @@ const breadcrumbs = useBreadcrumbs()
|
|||||||
const showSnapshots = ref(false)
|
const showSnapshots = ref(false)
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
|
|
||||||
const [categories, loaders, availableGameVersions] = await Promise.all([
|
const categories = ref([])
|
||||||
get_categories(),
|
const loaders = ref([])
|
||||||
get_loaders(),
|
const availableGameVersions = ref([])
|
||||||
get_game_versions(),
|
|
||||||
])
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
|
;[categories.value, loaders.value, availableGameVersions.value] = await Promise.all([
|
||||||
|
get_categories(),
|
||||||
|
get_loaders(),
|
||||||
|
get_game_versions(),
|
||||||
|
])
|
||||||
breadcrumbs.setContext({ name: 'Browse', link: route.path })
|
breadcrumbs.setContext({ name: 'Browse', link: route.path })
|
||||||
if (searchStore.projectType === 'modpack') {
|
if (searchStore.projectType === 'modpack') {
|
||||||
searchStore.instanceContext = null
|
searchStore.instanceContext = null
|
||||||
}
|
}
|
||||||
searchStore.searchInput = ''
|
searchStore.searchInput = ''
|
||||||
handleReset()
|
await handleReset()
|
||||||
switchPage(1)
|
loading.value = false
|
||||||
})
|
})
|
||||||
|
|
||||||
const sortedCategories = computed(() => {
|
const sortedCategories = computed(() => {
|
||||||
const values = new Map()
|
const values = new Map()
|
||||||
for (const category of categories.filter(
|
for (const category of categories.value.filter(
|
||||||
(cat) =>
|
(cat) =>
|
||||||
cat.project_type ===
|
cat.project_type ===
|
||||||
(searchStore.projectType === 'datapack' ? 'mod' : searchStore.projectType)
|
(searchStore.projectType === 'datapack' ? 'mod' : searchStore.projectType)
|
||||||
@@ -67,7 +70,7 @@ const sortedCategories = computed(() => {
|
|||||||
return values
|
return values
|
||||||
})
|
})
|
||||||
|
|
||||||
const getSearchResults = async (shouldLoad = false) => {
|
const getSearchResults = async () => {
|
||||||
const queryString = searchStore.getQueryString()
|
const queryString = searchStore.getQueryString()
|
||||||
if (searchStore.instanceContext) {
|
if (searchStore.instanceContext) {
|
||||||
showVersions.value = false
|
showVersions.value = false
|
||||||
@@ -75,16 +78,10 @@ const getSearchResults = async (shouldLoad = false) => {
|
|||||||
searchStore.projectType === 'mod' || searchStore.projectType === 'resourcepack'
|
searchStore.projectType === 'mod' || searchStore.projectType === 'resourcepack'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (shouldLoad === true) {
|
|
||||||
loading.value = true
|
|
||||||
}
|
|
||||||
const response = await ofetch(`https://api.modrinth.com/v2/search${queryString}`)
|
const response = await ofetch(`https://api.modrinth.com/v2/search${queryString}`)
|
||||||
loading.value = false
|
|
||||||
searchStore.setSearchResults(response)
|
searchStore.setSearchResults(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
getSearchResults(true)
|
|
||||||
|
|
||||||
const handleReset = async () => {
|
const handleReset = async () => {
|
||||||
searchStore.currentPage = 1
|
searchStore.currentPage = 1
|
||||||
searchStore.offset = 0
|
searchStore.offset = 0
|
||||||
@@ -309,7 +306,7 @@ watch(
|
|||||||
:count="searchStore.pageCount"
|
:count="searchStore.pageCount"
|
||||||
@switch-page="switchPage"
|
@switch-page="switchPage"
|
||||||
/>
|
/>
|
||||||
<AnimatedLogo v-if="loading" class="loading" />
|
<SplashScreen v-if="loading" />
|
||||||
<section v-else class="project-list display-mode--list instance-results" role="list">
|
<section v-else class="project-list display-mode--list instance-results" role="list">
|
||||||
<ProjectCard
|
<ProjectCard
|
||||||
v-for="result in searchStore.searchResults"
|
v-for="result in searchStore.searchResults"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, shallowRef, onUnmounted } from 'vue'
|
import { ref, onUnmounted, shallowRef } from 'vue'
|
||||||
import { ofetch } from 'ofetch'
|
import { ofetch } from 'ofetch'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import RowDisplay from '@/components/RowDisplay.vue'
|
import RowDisplay from '@/components/RowDisplay.vue'
|
||||||
@@ -16,7 +16,7 @@ const breadcrumbs = useBreadcrumbs()
|
|||||||
|
|
||||||
breadcrumbs.setRootContext({ name: 'Home', link: route.path })
|
breadcrumbs.setRootContext({ name: 'Home', link: route.path })
|
||||||
|
|
||||||
const recentInstances = shallowRef()
|
const recentInstances = shallowRef(Object.values(await list()))
|
||||||
|
|
||||||
const getInstances = async () => {
|
const getInstances = async () => {
|
||||||
filter.value = ''
|
filter.value = ''
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import GridDisplay from '@/components/GridDisplay.vue'
|
|||||||
import { list } from '@/helpers/profile.js'
|
import { list } from '@/helpers/profile.js'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
import { useBreadcrumbs } from '@/store/breadcrumbs'
|
||||||
|
import { loading_listener } from '@/helpers/events.js'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const breadcrumbs = useBreadcrumbs()
|
const breadcrumbs = useBreadcrumbs()
|
||||||
@@ -17,12 +18,21 @@ const instances = shallowRef(
|
|||||||
const modpacks = shallowRef(
|
const modpacks = shallowRef(
|
||||||
Object.values(profiles).filter((prof) => prof.metadata.linked_project_id)
|
Object.values(profiles).filter((prof) => prof.metadata.linked_project_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
loading_listener(async (profile) => {
|
||||||
|
console.log(profile)
|
||||||
|
if (profile.event === 'loaded') {
|
||||||
|
const profiles = await list()
|
||||||
|
instances.value = Object.values(profiles).filter((prof) => !prof.metadata.linked_project_id)
|
||||||
|
modpacks.value = Object.values(profiles).filter((prof) => prof.metadata.linked_project_id)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<GridDisplay label="Instances" :instances="instances" />
|
<GridDisplay v-if="instances.length > 0" label="Instances" :instances="instances" />
|
||||||
<GridDisplay label="Modpacks" :instances="modpacks" />
|
<GridDisplay v-if="modpacks.length > 0" label="Modpacks" :instances="modpacks" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ if (!fetchSettings.java_globals?.JAVA_8)
|
|||||||
fetchSettings.java_globals.JAVA_8 = { path: '', version: '' }
|
fetchSettings.java_globals.JAVA_8 = { path: '', version: '' }
|
||||||
if (!fetchSettings.java_globals?.JAVA_17)
|
if (!fetchSettings.java_globals?.JAVA_17)
|
||||||
fetchSettings.java_globals.JAVA_17 = { path: '', version: '' }
|
fetchSettings.java_globals.JAVA_17 = { path: '', version: '' }
|
||||||
|
|
||||||
const settings = ref(fetchSettings)
|
const settings = ref(fetchSettings)
|
||||||
|
|
||||||
const chosenInstallOptions = ref([])
|
const chosenInstallOptions = ref([])
|
||||||
const browsingInstall = ref(0)
|
const browsingInstall = ref(0)
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ import {
|
|||||||
get_uuids_by_profile_path,
|
get_uuids_by_profile_path,
|
||||||
kill_by_uuid,
|
kill_by_uuid,
|
||||||
} from '@/helpers/process'
|
} from '@/helpers/process'
|
||||||
import { process_listener } from '@/helpers/events'
|
import { process_listener, profile_listener } from '@/helpers/events'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { shallowRef, ref, onUnmounted } from 'vue'
|
import { ref, onUnmounted } from 'vue'
|
||||||
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||||
import { open } from '@tauri-apps/api/dialog'
|
import { open } from '@tauri-apps/api/dialog'
|
||||||
import { useBreadcrumbs, useSearch } from '@/store/state'
|
import { useBreadcrumbs, useSearch } from '@/store/state'
|
||||||
@@ -79,15 +79,21 @@ const route = useRoute()
|
|||||||
const searchStore = useSearch()
|
const searchStore = useSearch()
|
||||||
const breadcrumbs = useBreadcrumbs()
|
const breadcrumbs = useBreadcrumbs()
|
||||||
|
|
||||||
const instance = shallowRef(await get(route.params.id))
|
const instance = ref(await get(route.params.id))
|
||||||
searchStore.instanceContext = instance.value
|
|
||||||
|
|
||||||
|
searchStore.instanceContext = instance.value
|
||||||
breadcrumbs.setName('Instance', instance.value.metadata.name)
|
breadcrumbs.setName('Instance', instance.value.metadata.name)
|
||||||
breadcrumbs.setContext({
|
breadcrumbs.setContext({
|
||||||
name: instance.value.metadata.name,
|
name: instance.value.metadata.name,
|
||||||
link: route.path,
|
link: route.path,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
profile_listener(async (event) => {
|
||||||
|
if (event.profile_path === route.params.id) {
|
||||||
|
instance.value = await get(route.params.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const uuid = ref(null)
|
const uuid = ref(null)
|
||||||
const playing = ref(false)
|
const playing = ref(false)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ const expandImage = (item, index) => {
|
|||||||
|
|
||||||
.expanded-image-modal {
|
.expanded-image-modal {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 20;
|
z-index: 10;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ async function install(version) {
|
|||||||
.map((value) => value.metadata)
|
.map((value) => value.metadata)
|
||||||
.find((pack) => pack.linked_data?.project_id === data.value.id)
|
.find((pack) => pack.linked_data?.project_id === data.value.id)
|
||||||
) {
|
) {
|
||||||
let id = await packInstall(queuedVersionData.id)
|
let id = await packInstall(queuedVersionData.id, data.value.title)
|
||||||
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
|
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
|
||||||
} else {
|
} else {
|
||||||
confirmModal.value.show(queuedVersionData.id)
|
confirmModal.value.show(queuedVersionData.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user