You've already forked AstralRinth
36 lines
1.0 KiB
Vue
36 lines
1.0 KiB
Vue
<script setup>
|
|
import { injectNotificationManager } from '@modrinth/ui'
|
|
import { ref } from 'vue'
|
|
|
|
import JavaSelector from '@/components/ui/JavaSelector.vue'
|
|
import { get_java_versions, set_java_version } from '@/helpers/jre'
|
|
|
|
const { handleError } = injectNotificationManager()
|
|
|
|
const javaVersions = ref(await get_java_versions().catch(handleError))
|
|
async function updateJavaVersion(version) {
|
|
if (version?.path === '') {
|
|
version.path = undefined
|
|
}
|
|
|
|
if (version?.path) {
|
|
version.path = version.path.replace('java.exe', 'javaw.exe')
|
|
}
|
|
|
|
await set_java_version(version).catch(handleError)
|
|
}
|
|
</script>
|
|
<template>
|
|
<div v-for="(javaVersion, index) in [25, 21, 17, 8]" :key="`java-${javaVersion}`">
|
|
<h2 class="m-0 text-lg font-extrabold text-contrast" :class="{ 'mt-4': index !== 0 }">
|
|
Java {{ javaVersion }} location
|
|
</h2>
|
|
<JavaSelector
|
|
:id="'java-selector-' + javaVersion"
|
|
v-model="javaVersions[javaVersion]"
|
|
:version="javaVersion"
|
|
@update:model-value="updateJavaVersion"
|
|
/>
|
|
</div>
|
|
</template>
|