mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 11:36:05 +00:00
* feat: base of instances v2 * feat: use old profiles with compat layer * prototype: instances v2 * fix: install_from using profile * fix: skins migration fix * fix: frontend still using profile path * fix: add update proj multiselect guard * fix: cargo fmt * fix: content missing fields * feat: break up app-lib/api/instance.rs * fix: check_content_updates mismatch * fix: updater modal cleanup w/new structure * feat: better update all handling * fix: remove preview_update_all * fix: feedback on bulk update + lint * fix: rem transitions * fix: change to jsonb * feat: app db backup after update * fix: lint * fix: sqlx prepare + use sqlx macros * fix: lint * fix: bugs * feat: defuck the installing process up * fix: bug of hell * fix: shear * fix: fmt * fix: install progress spacing + change mc/content/overrides to bytes * fix: lint * fix: prepr * fix: navtabs anim not working in app * fix: worlds.vue improvements + browse page fixes * feat: optimise queries + adapter fns * fix: lint * fix: lint * feat: shared modrinth-content-management crate (#6469) * feat: disable warnings setting * feat: add instances shortcuts (#6329) * Add modrinth://launch deep link to start a profile Support external profile launching via modrinth://launch/{profile_path} for integrations such as Stream Deck. * Change route to /launch/profile/{id} for future extensibility * fix: ensure profile path is url decoded * fix: URL-decode profile path from deep link * fix: use urlencoding crate for URL decoding * feat: implement app instance shortcuts * feat: change windows shortcut creation to use windows api instead * feat: implement creating a shortcut launching world/server * format * fmt * fix multiline inline tables * pnpm prepr * feat: move create shortcut to last item * refactor: split up shortcuts.rs for individual platforms * refactor: turn profile launch url into url type * use string literal and add safety comment * pt2 * refactor: rename anything that's profile into instance * update mac shortcut --------- Co-authored-by: DJCheesusReal <134006619+DJCheesusReal@users.noreply.github.com> --------- Co-authored-by: Truman Gao <106889354+tdgao@users.noreply.github.com> Co-authored-by: DJCheesusReal <134006619+DJCheesusReal@users.noreply.github.com>
202 lines
5.3 KiB
Vue
202 lines
5.3 KiB
Vue
<script setup lang="ts">
|
|
import type { Labrinth } from '@modrinth/api-client'
|
|
import {
|
|
ChevronRightIcon,
|
|
CodeIcon,
|
|
CoffeeIcon,
|
|
InfoIcon,
|
|
MonitorIcon,
|
|
WrenchIcon,
|
|
} from '@modrinth/assets'
|
|
import {
|
|
Avatar,
|
|
commonMessages,
|
|
defineMessage,
|
|
TabbedModal,
|
|
type TabbedModalTab,
|
|
useVIntl,
|
|
} from '@modrinth/ui'
|
|
import type { PlatformTag } from '@modrinth/utils'
|
|
import { useQuery, useQueryClient } from '@tanstack/vue-query'
|
|
import { convertFileSrc } from '@tauri-apps/api/core'
|
|
import { computed, nextTick, ref, watch } from 'vue'
|
|
|
|
import GeneralSettings from '@/components/ui/instance_settings/GeneralSettings.vue'
|
|
import HooksSettings from '@/components/ui/instance_settings/HooksSettings.vue'
|
|
import InstallationSettings from '@/components/ui/instance_settings/InstallationSettings.vue'
|
|
import JavaSettings from '@/components/ui/instance_settings/JavaSettings.vue'
|
|
import WindowSettings from '@/components/ui/instance_settings/WindowSettings.vue'
|
|
import { get_project_v3 } from '@/helpers/cache'
|
|
import { get_linked_modpack_info } from '@/helpers/instance'
|
|
import { get_loader_versions } from '@/helpers/metadata'
|
|
import { get_game_versions, get_loaders } from '@/helpers/tags'
|
|
import { provideInstanceSettings } from '@/providers/instance-settings'
|
|
|
|
import type { GameInstance } from '../../../helpers/types'
|
|
|
|
const { formatMessage } = useVIntl()
|
|
const queryClient = useQueryClient()
|
|
|
|
const props = defineProps<{
|
|
instance: GameInstance
|
|
offline?: boolean
|
|
}>()
|
|
const emit = defineEmits<{
|
|
unlinked: []
|
|
}>()
|
|
|
|
const isMinecraftServer = ref(false)
|
|
const handleUnlinked = () => emit('unlinked')
|
|
|
|
const instanceRef = computed(() => props.instance)
|
|
const tabbedModal = ref<InstanceType<typeof TabbedModal> | null>(null)
|
|
|
|
function hide() {
|
|
tabbedModal.value?.hide()
|
|
}
|
|
|
|
provideInstanceSettings({
|
|
instance: instanceRef,
|
|
offline: props.offline,
|
|
isMinecraftServer,
|
|
onUnlinked: handleUnlinked,
|
|
closeModal: hide,
|
|
})
|
|
|
|
watch(
|
|
() => props.instance,
|
|
(instance) => {
|
|
isMinecraftServer.value = false
|
|
if (instance.link?.project_id) {
|
|
get_project_v3(instance.link.project_id, 'must_revalidate')
|
|
.then((project: Labrinth.Projects.v3.Project | undefined) => {
|
|
if (project?.minecraft_server != null) {
|
|
isMinecraftServer.value = true
|
|
}
|
|
})
|
|
.catch(() => {})
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
)
|
|
|
|
const tabs = computed<TabbedModalTab[]>(() => [
|
|
{
|
|
name: defineMessage({
|
|
id: 'instance.settings.tabs.general',
|
|
defaultMessage: 'General',
|
|
}),
|
|
icon: InfoIcon,
|
|
content: GeneralSettings,
|
|
},
|
|
{
|
|
name: defineMessage({
|
|
id: 'instance.settings.tabs.installation',
|
|
defaultMessage: 'Installation',
|
|
}),
|
|
icon: WrenchIcon,
|
|
content: InstallationSettings,
|
|
},
|
|
{
|
|
name: defineMessage({
|
|
id: 'instance.settings.tabs.window',
|
|
defaultMessage: 'Window',
|
|
}),
|
|
icon: MonitorIcon,
|
|
content: WindowSettings,
|
|
},
|
|
{
|
|
name: defineMessage({
|
|
id: 'instance.settings.tabs.java',
|
|
defaultMessage: 'Java and memory',
|
|
}),
|
|
icon: CoffeeIcon,
|
|
content: JavaSettings,
|
|
},
|
|
{
|
|
name: defineMessage({
|
|
id: 'instance.settings.tabs.hooks',
|
|
defaultMessage: 'Launch hooks',
|
|
}),
|
|
icon: CodeIcon,
|
|
content: HooksSettings,
|
|
},
|
|
])
|
|
|
|
function getSupportedModpackLoaders() {
|
|
return get_loaders().then((value: PlatformTag[]) =>
|
|
value
|
|
.filter((item) => item.supported_project_types.includes('modpack') || item.name === 'vanilla')
|
|
.sort((a, b) => (a.name === 'vanilla' ? -1 : b.name === 'vanilla' ? 1 : 0)),
|
|
)
|
|
}
|
|
|
|
// Preload
|
|
useQuery({
|
|
queryKey: ['instance-settings', 'loader-versions', 'fabric'],
|
|
queryFn: () => get_loader_versions('fabric'),
|
|
})
|
|
useQuery({
|
|
queryKey: ['instance-settings', 'loader-versions', 'forge'],
|
|
queryFn: () => get_loader_versions('forge'),
|
|
})
|
|
useQuery({
|
|
queryKey: ['instance-settings', 'loader-versions', 'quilt'],
|
|
queryFn: () => get_loader_versions('quilt'),
|
|
})
|
|
useQuery({
|
|
queryKey: ['instance-settings', 'loader-versions', 'neo'],
|
|
queryFn: () => get_loader_versions('neo'),
|
|
})
|
|
useQuery({
|
|
queryKey: ['instance-settings', 'game-versions'],
|
|
queryFn: get_game_versions,
|
|
})
|
|
useQuery({
|
|
queryKey: ['instance-settings', 'loaders', 'modpack'],
|
|
queryFn: getSupportedModpackLoaders,
|
|
})
|
|
useQuery({
|
|
queryKey: computed(() => ['linkedModpackInfo', props.instance.id]),
|
|
queryFn: () => get_linked_modpack_info(props.instance.id, 'stale_while_revalidate'),
|
|
enabled: computed(() => !!props.instance.link?.project_id && !props.offline),
|
|
})
|
|
|
|
function show(tabIndex?: number) {
|
|
if (props.instance.link?.project_id) {
|
|
queryClient.prefetchQuery({
|
|
queryKey: ['linkedModpackInfo', props.instance.id],
|
|
queryFn: () => get_linked_modpack_info(props.instance.id, 'stale_while_revalidate'),
|
|
})
|
|
}
|
|
tabbedModal.value?.show()
|
|
if (tabIndex !== undefined) {
|
|
nextTick(() => tabbedModal.value?.setTab(tabIndex))
|
|
}
|
|
}
|
|
|
|
defineExpose({ show, hide })
|
|
</script>
|
|
<template>
|
|
<TabbedModal
|
|
ref="tabbedModal"
|
|
:tabs="tabs"
|
|
:max-width="'min(928px, calc(95vw - 10rem))'"
|
|
:width="'min(928px, calc(95vw - 10rem))'"
|
|
>
|
|
<template #title>
|
|
<span class="flex items-center gap-2 text-lg font-semibold text-primary">
|
|
<Avatar
|
|
:src="instance.icon_path ? convertFileSrc(instance.icon_path) : undefined"
|
|
size="24px"
|
|
:tint-by="props.instance.id"
|
|
/>
|
|
{{ instance.name }} <ChevronRightIcon />
|
|
<span class="font-extrabold text-contrast">{{
|
|
formatMessage(commonMessages.settingsLabel)
|
|
}}</span>
|
|
</span>
|
|
</template>
|
|
</TabbedModal>
|
|
</template>
|