mirror of
https://github.com/modrinth/code.git
synced 2026-07-31 13:16:38 +00:00
* refactor: app settings layout * fix: privacy copy got reverted * fix: i18n * fix: modal title * fix: rev comments
50 lines
1.4 KiB
Vue
50 lines
1.4 KiB
Vue
<script setup>
|
|
import { defineMessages, injectNotificationManager, useVIntl } 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 { formatMessage } = useVIntl()
|
|
|
|
const messages = defineMessages({
|
|
javaLocation: {
|
|
id: 'app.settings.java-installations.location.title',
|
|
defaultMessage: 'Java {version, number} location',
|
|
},
|
|
})
|
|
|
|
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 class="flex flex-col gap-6">
|
|
<div
|
|
v-for="(javaVersion, index) in [25, 21, 17, 8]"
|
|
:key="`java-${javaVersion}`"
|
|
class="flex flex-col gap-2.5"
|
|
>
|
|
<h2 class="m-0 text-lg font-semibold text-contrast" :class="{ 'mt-4': index !== 0 }">
|
|
{{ formatMessage(messages.javaLocation, { version: javaVersion }) }}
|
|
</h2>
|
|
<JavaSelector
|
|
:id="'java-selector-' + javaVersion"
|
|
v-model="javaVersions[javaVersion]"
|
|
:version="javaVersion"
|
|
@update:model-value="updateJavaVersion"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|