You've already forked AstralRinth
forked from didirus/AstralRinth
New features (#477)
* Linking/Unlinking, Dir changing, CDN * Fixes #435 * Progress bar * Create splashscreen.html * Run lint * add rust part * remove splashscreen code --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
@@ -1,13 +1,26 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { Card, Slider, DropdownSelect, Toggle, Modal, LogOutIcon, LogInIcon } from 'omorphia'
|
||||
import {
|
||||
Card,
|
||||
Slider,
|
||||
DropdownSelect,
|
||||
Toggle,
|
||||
Modal,
|
||||
LogOutIcon,
|
||||
LogInIcon,
|
||||
Button,
|
||||
BoxIcon,
|
||||
FolderSearchIcon,
|
||||
UpdatedIcon,
|
||||
} from 'omorphia'
|
||||
import { handleError, useTheming } from '@/store/state'
|
||||
import { get, set } from '@/helpers/settings'
|
||||
import { change_config_dir, get, set } from '@/helpers/settings'
|
||||
import { get_max_memory } from '@/helpers/jre'
|
||||
import { get as getCreds, logout } from '@/helpers/mr_auth.js'
|
||||
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
||||
import ModrinthLoginScreen from '@/components/ui/tutorial/ModrinthLoginScreen.vue'
|
||||
import { mixpanel_opt_out_tracking, mixpanel_opt_in_tracking } from '@/helpers/mixpanel'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
|
||||
const pageOptions = ['Home', 'Library']
|
||||
|
||||
@@ -24,6 +37,7 @@ fetchSettings.javaArgs = fetchSettings.custom_java_args.join(' ')
|
||||
fetchSettings.envArgs = fetchSettings.custom_env_args.map((x) => x.join('=')).join(' ')
|
||||
|
||||
const settings = ref(fetchSettings)
|
||||
const settingsDir = ref(settings.value.loaded_config_dir)
|
||||
const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
|
||||
|
||||
watch(
|
||||
@@ -91,6 +105,19 @@ async function signInAfter() {
|
||||
loginScreenModal.value.hide()
|
||||
credentials.value = await getCreds().catch(handleError)
|
||||
}
|
||||
|
||||
async function findLauncherDir() {
|
||||
const newDir = await open({ multiple: false, directory: true })
|
||||
|
||||
if (newDir) {
|
||||
settingsDir.value = newDir
|
||||
await refreshDir()
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDir() {
|
||||
await change_config_dir(settingsDir.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -98,7 +125,7 @@ async function signInAfter() {
|
||||
<Card>
|
||||
<div class="label">
|
||||
<h3>
|
||||
<span class="label__title size-card-header">Account</span>
|
||||
<span class="label__title size-card-header">General settings</span>
|
||||
</h3>
|
||||
</div>
|
||||
<Modal
|
||||
@@ -125,6 +152,25 @@ async function signInAfter() {
|
||||
<LogInIcon /> Sign in
|
||||
</button>
|
||||
</div>
|
||||
<label for="theme">
|
||||
<span class="label__title">App directory</span>
|
||||
<span class="label__description">
|
||||
The directory where the launcher stores all of its files.
|
||||
</span>
|
||||
</label>
|
||||
<div class="app-directory">
|
||||
<div class="iconified-input">
|
||||
<BoxIcon />
|
||||
<input id="appDir" v-model="settingsDir" type="text" class="input" />
|
||||
<Button @click="findLauncherDir">
|
||||
<FolderSearchIcon />
|
||||
</Button>
|
||||
</div>
|
||||
<Button large @click="refreshDir">
|
||||
<UpdatedIcon />
|
||||
Refresh
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
<Card>
|
||||
<div class="label">
|
||||
@@ -455,4 +501,19 @@ async function signInAfter() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.app-directory {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: var(--gap-sm);
|
||||
|
||||
.iconified-input {
|
||||
flex-grow: 1;
|
||||
|
||||
input {
|
||||
flex-basis: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
<template>
|
||||
<Card v-if="projects.length > 0" class="mod-card">
|
||||
<Card
|
||||
v-if="projects.length > 0"
|
||||
class="mod-card"
|
||||
:class="{ static: instance.metadata.linked_data }"
|
||||
>
|
||||
<div class="second-row">
|
||||
<Chips
|
||||
v-if="Object.keys(selectableProjectTypes).length > 1"
|
||||
v-model="selectedProjectType"
|
||||
:items="Object.keys(selectableProjectTypes)"
|
||||
/>
|
||||
<Button v-if="canUpdatePack" color="secondary" @click="updateModpack">
|
||||
<UpdatedIcon />
|
||||
Update modpack
|
||||
</Button>
|
||||
</div>
|
||||
<div class="card-row">
|
||||
<div class="iconified-input">
|
||||
@@ -46,7 +54,7 @@
|
||||
<div>
|
||||
<div class="table">
|
||||
<div class="table-row table-head" :class="{ 'show-options': selected.length > 0 }">
|
||||
<div class="table-cell table-text">
|
||||
<div v-if="!instance.metadata.linked_data" class="table-cell table-text">
|
||||
<Checkbox v-model="selectAll" class="select-checkbox" />
|
||||
</div>
|
||||
<div v-if="selected.length === 0" class="table-cell table-text name-cell actions-cell">
|
||||
@@ -55,19 +63,23 @@
|
||||
<DropdownIcon v-if="sortColumn === 'Name'" :class="{ down: ascending }" />
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="selected.length === 0" class="table-cell table-text">
|
||||
<div v-if="selected.length === 0" class="table-cell table-text version">
|
||||
<Button class="transparent" @click="sortProjects('Version')">
|
||||
Version
|
||||
<DropdownIcon v-if="sortColumn === 'Version'" :class="{ down: ascending }" />
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="selected.length === 0" class="table-cell table-text actions-cell">
|
||||
<Button class="transparent" @click="sortProjects('Enabled')">
|
||||
<Button
|
||||
v-if="!instance.metadata.linked_data"
|
||||
class="transparent"
|
||||
@click="sortProjects('Enabled')"
|
||||
>
|
||||
Actions
|
||||
<DropdownIcon v-if="sortColumn === 'Enabled'" :class="{ down: ascending }" />
|
||||
</Button>
|
||||
</div>
|
||||
<div v-else class="options table-cell name-cell">
|
||||
<div v-else-if="!instance.metadata.linked_data" class="options table-cell name-cell">
|
||||
<Button
|
||||
class="transparent share"
|
||||
@click="() => (showingOptions = !showingOptions)"
|
||||
@@ -110,7 +122,10 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showingOptions && selected.length > 0" class="more-box">
|
||||
<div
|
||||
v-if="showingOptions && selected.length > 0 && !instance.metadata.linked_data"
|
||||
class="more-box"
|
||||
>
|
||||
<section v-if="selectedOption === 'Share'" class="options">
|
||||
<Button class="transparent" @click="shareNames()">
|
||||
<TextInputIcon />
|
||||
@@ -171,7 +186,7 @@
|
||||
class="table-row"
|
||||
@contextmenu.prevent.stop="(c) => handleRightClick(c, mod)"
|
||||
>
|
||||
<div class="table-cell table-text">
|
||||
<div v-if="!instance.metadata.linked_data" class="table-cell table-text checkbox">
|
||||
<Checkbox
|
||||
:model-value="selectionMap.get(mod.path)"
|
||||
class="select-checkbox"
|
||||
@@ -196,19 +211,24 @@
|
||||
<span v-tooltip="`${mod.name}`" class="title">{{ mod.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-cell table-text">
|
||||
<div class="table-cell table-text version">
|
||||
<span v-tooltip="`${mod.version}`">{{ mod.version }}</span>
|
||||
</div>
|
||||
<div class="table-cell table-text manage">
|
||||
<Button v-tooltip="'Remove project'" icon-only @click="removeMod(mod)">
|
||||
<Button
|
||||
v-if="!instance.metadata.linked_data"
|
||||
v-tooltip="'Remove project'"
|
||||
icon-only
|
||||
@click="removeMod(mod)"
|
||||
>
|
||||
<TrashIcon />
|
||||
</Button>
|
||||
<AnimatedLogo
|
||||
v-if="mod.updating"
|
||||
v-if="mod.updating && !instance.metadata.linked_data"
|
||||
class="btn icon-only updating-indicator"
|
||||
></AnimatedLogo>
|
||||
<Button
|
||||
v-else
|
||||
v-else-if="!instance.metadata.linked_data"
|
||||
v-tooltip="'Update project'"
|
||||
:disabled="!mod.outdated || offline"
|
||||
icon-only
|
||||
@@ -218,6 +238,7 @@
|
||||
<CheckIcon v-else />
|
||||
</Button>
|
||||
<input
|
||||
v-if="!instance.metadata.linked_data"
|
||||
id="switch-1"
|
||||
autocomplete="off"
|
||||
type="checkbox"
|
||||
@@ -341,9 +362,11 @@ import { useRouter } from 'vue-router'
|
||||
import {
|
||||
add_project_from_path,
|
||||
get,
|
||||
is_managed_modrinth,
|
||||
remove_project,
|
||||
toggle_disable_project,
|
||||
update_all,
|
||||
update_managed_modrinth,
|
||||
update_project,
|
||||
} from '@/helpers/profile.js'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
@@ -380,6 +403,7 @@ const props = defineProps({
|
||||
const projects = ref([])
|
||||
const selectionMap = ref(new Map())
|
||||
const showingOptions = ref(false)
|
||||
const canUpdatePack = ref(await is_managed_modrinth(props.instance.path))
|
||||
|
||||
const initProjects = (initInstance) => {
|
||||
projects.value = []
|
||||
@@ -776,6 +800,10 @@ const handleContentOptionClick = async (args) => {
|
||||
}
|
||||
}
|
||||
|
||||
const updateModpack = async () => {
|
||||
await update_managed_modrinth(props.instance.path).catch(handleError)
|
||||
}
|
||||
|
||||
watch(selectAll, () => {
|
||||
for (const [key, value] of Array.from(selectionMap.value)) {
|
||||
if (value !== selectAll.value) {
|
||||
@@ -791,6 +819,7 @@ const unlisten = await listen('tauri://file-drop', async (event) => {
|
||||
}
|
||||
initProjects(await get(props.instance.path).catch(handleError))
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
unlisten()
|
||||
})
|
||||
@@ -827,6 +856,26 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.static {
|
||||
.table-row {
|
||||
grid-template-areas: 'manage name version';
|
||||
grid-template-columns: 4.25rem 1fr 1fr;
|
||||
}
|
||||
|
||||
.name-cell {
|
||||
grid-area: name;
|
||||
}
|
||||
|
||||
.version {
|
||||
grid-area: version;
|
||||
}
|
||||
|
||||
.manage {
|
||||
justify-content: center;
|
||||
grid-area: manage;
|
||||
}
|
||||
}
|
||||
|
||||
.table-cell {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,14 @@
|
||||
<label for="project-name">
|
||||
<span class="label__title">Name</span>
|
||||
</label>
|
||||
<input id="profile-name" v-model="title" autocomplete="off" maxlength="80" type="text" />
|
||||
<input
|
||||
id="profile-name"
|
||||
v-model="title"
|
||||
autocomplete="off"
|
||||
maxlength="80"
|
||||
type="text"
|
||||
:disabled="instance.metadata.linked_data"
|
||||
/>
|
||||
|
||||
<div class="adjacent-input">
|
||||
<label for="edit-versions">
|
||||
@@ -289,6 +296,17 @@
|
||||
<span class="label__title size-card-header">Instance management</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div v-if="instance.metadata.linked_data" class="adjacent-input">
|
||||
<label for="repair-profile">
|
||||
<span class="label__title">Unpair instance</span>
|
||||
<span class="label__description">
|
||||
Removes the link to an external modpack on the instance. This allows you to edit modpacks
|
||||
you download through the browse page but you will not be able to update the instance from
|
||||
a new version of a modpack if you do this.
|
||||
</span>
|
||||
</label>
|
||||
<Button id="repair-profile" @click="unpairProfile"> <XIcon /> Unpair </Button>
|
||||
</div>
|
||||
<div class="adjacent-input">
|
||||
<label for="repair-profile">
|
||||
<span class="label__title">Repair instance</span>
|
||||
@@ -297,14 +315,14 @@
|
||||
launching due to launcher-related errors.
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
<Button
|
||||
id="repair-profile"
|
||||
class="btn btn-highlight"
|
||||
color="highlight"
|
||||
:disabled="repairing || offline"
|
||||
@click="repairProfile"
|
||||
>
|
||||
<HammerIcon /> Repair
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="props.instance.modrinth_update_version" class="adjacent-input">
|
||||
<label for="repair-profile">
|
||||
@@ -314,16 +332,15 @@
|
||||
launching due to your instance diverging from the Modrinth modpack.
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
<Button
|
||||
id="repair-profile"
|
||||
class="btn btn-highlight"
|
||||
color="highlight"
|
||||
:disabled="repairing || offline"
|
||||
@click="repairModpack"
|
||||
>
|
||||
<DownloadIcon /> Reinstall
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="adjacent-input">
|
||||
<label for="delete-profile">
|
||||
<span class="label__title">Delete instance</span>
|
||||
@@ -332,14 +349,14 @@
|
||||
no way to recover it.
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
<Button
|
||||
id="delete-profile"
|
||||
class="btn btn-danger"
|
||||
color="danger"
|
||||
:disabled="removing"
|
||||
@click="$refs.modal_confirm.show()"
|
||||
>
|
||||
<TrashIcon /> Delete
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -361,6 +378,7 @@ import {
|
||||
HammerIcon,
|
||||
DownloadIcon,
|
||||
ModalConfirm,
|
||||
Button,
|
||||
} from 'omorphia'
|
||||
import { Multiselect } from 'vue-multiselect'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -465,6 +483,8 @@ const hooks = ref(props.instance.hooks ?? globalSettings.hooks)
|
||||
|
||||
const fullscreenSetting = ref(!!props.instance.fullscreen)
|
||||
|
||||
const unlinkModpack = ref(false)
|
||||
|
||||
watch(
|
||||
[
|
||||
title,
|
||||
@@ -483,6 +503,7 @@ watch(
|
||||
fullscreenSetting,
|
||||
overrideHooks,
|
||||
hooks,
|
||||
unlinkModpack,
|
||||
],
|
||||
async () => {
|
||||
const editProfile = {
|
||||
@@ -537,6 +558,10 @@ watch(
|
||||
editProfile.hooks = hooks.value
|
||||
}
|
||||
|
||||
if (unlinkModpack.value) {
|
||||
editProfile.metadata.linked_data = null
|
||||
}
|
||||
|
||||
await edit(props.instance.path, editProfile)
|
||||
},
|
||||
{ deep: true }
|
||||
@@ -544,6 +569,10 @@ watch(
|
||||
|
||||
const repairing = ref(false)
|
||||
|
||||
async function unpairProfile() {
|
||||
unlinkModpack.value = true
|
||||
}
|
||||
|
||||
async function repairProfile() {
|
||||
repairing.value = true
|
||||
await install(props.instance.path).catch(handleError)
|
||||
|
||||
Reference in New Issue
Block a user