Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/turbo-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ jobs:
restore-keys: |
pnpm-cache-

- name: Cache Gradle distribution
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.gradle/wrapper/dists
~/.gradle/caches
key: ${{ runner.os }}-${{ runner.arch }}-gradle-${{ hashFiles('packages/app-lib/java/gradle/wrapper/gradle-wrapper.properties') }}

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
with:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion apps/app-frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import { get_user, get_version } from '@/helpers/cache.js'
import { command_listener, notification_listener, warning_listener } from '@/helpers/events.js'
import { cancelLogin, get as getCreds, login, logout } from '@/helpers/mr_auth.ts'
import { create_profile_and_install_from_file } from '@/helpers/pack'
import { list } from '@/helpers/profile.js'
import { list, run } from '@/helpers/profile.js'
import { mergeUrlQuery, parseModrinthLink } from '@/helpers/project-links.ts'
import { get as getSettings, set as setSettings } from '@/helpers/settings.ts'
import { get_opening_command, initialize_state } from '@/helpers/state'
Expand Down Expand Up @@ -862,6 +862,8 @@ async function handleCommand(e) {
source: 'CreationModalFileDrop',
})
}
} else if (e.event === 'LaunchProfile') {
await run(decodeURIComponent(e.path)).catch(handleError)
} else if (e.event === 'InstallServer') {
await router.push(`/project/${e.id}`)
await playServerProject(e.id).catch(handleError)
Expand Down
15 changes: 15 additions & 0 deletions apps/app-frontend/src/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { invoke } from '@tauri-apps/api/core'
import { save } from '@tauri-apps/plugin-dialog'

import { get_full_path, get_mod_full_path } from '@/helpers/profile'

Expand Down Expand Up @@ -47,6 +48,20 @@ export async function showLauncherLogsFolder() {
return await invoke('plugin:utils|show_launcher_logs_folder', {})
}

export async function createProfileShortcut(profileName, profilePath) {
const outputPath = await save({
defaultPath: `Modrinth - ${profileName}`,
})

if (!outputPath) return null

return await invoke('plugin:shortcuts|create_profile_shortcut', {
profileName,
profilePath,
outputPath,
})
}

// Opens a profile's folder in the OS file explorer
export async function showProfileInFolder(path) {
const fullPath = await get_full_path(path)
Expand Down
24 changes: 22 additions & 2 deletions apps/app-frontend/src/pages/instance/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,18 @@
id: 'export-mrpack',
action: () => exportModal?.show(),
},
{
id: 'create-shortcut',
action: () => createShortcut(),
},
]"
>
<MoreVerticalIcon />
<template #share-instance> <UserPlusIcon /> Share instance </template>
<template #host-a-server> <ServerIcon /> Create a server </template>
<template #open-folder> <FolderOpenIcon /> Open folder </template>
<template #export-mrpack> <PackageIcon /> Export modpack </template>
<template #create-shortcut> <ExternalIcon /> Create shortcut </template>
</OverflowMenu>
</ButtonStyled>
</div>
Expand Down Expand Up @@ -324,7 +329,7 @@ import { type InstanceContentData, loadInstanceContentData } from '@/helpers/ins
import { get_by_profile_path } from '@/helpers/process'
import { finish_install, get, get_full_path, kill, run } from '@/helpers/profile'
import type { GameInstance } from '@/helpers/types'
import { showProfileInFolder } from '@/helpers/utils.js'
import { createProfileShortcut, showProfileInFolder } from '@/helpers/utils.js'
import { get_server_status, refreshWorlds } from '@/helpers/worlds'
import { injectServerInstall } from '@/providers/server-install'
import { handleSevereError } from '@/store/error.js'
Expand All @@ -333,7 +338,7 @@ import { useBreadcrumbs, useTheming } from '@/store/state'
dayjs.extend(duration)
dayjs.extend(relativeTime)

const { handleError } = injectNotificationManager()
const { addNotification, handleError } = injectNotificationManager()
const { playServerProject } = injectServerInstall()
const queryClient = useQueryClient()
const route = useRoute()
Expand Down Expand Up @@ -578,6 +583,21 @@ const repairInstance = async () => {
await finish_install(instance.value).catch(handleError)
}

const createShortcut = async () => {
if (!instance.value) return
try {
const shortcutPath = await createProfileShortcut(instance.value.name, instance.value.path)
if (!shortcutPath) return

addNotification({
type: 'success',
title: 'Shortcut created',
})
} catch (error) {
handleError(error)
}
}

const handleRightClick = (event: MouseEvent) => {
const baseOptions = [
{ name: 'add_content' },
Expand Down
8 changes: 8 additions & 0 deletions apps/app/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ fn main() {
DefaultPermissionRule::AllowAllCommands,
),
)
.plugin(
"shortcuts",
InlinedPlugin::new()
.commands(&["create_profile_shortcut"])
.default_permission(
DefaultPermissionRule::AllowAllCommands,
),
)
.plugin(
"utils",
InlinedPlugin::new()
Expand Down
1 change: 1 addition & 0 deletions apps/app/capabilities/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"cache:default",
"files:default",
"settings:default",
"shortcuts:default",
"tags:default",
"utils:default",
"ads:default",
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod process;
pub mod profile;
pub mod profile_create;
pub mod settings;
pub mod shortcuts;
pub mod tags;
pub mod utils;

Expand Down
Loading
Loading