You've already forked AstralRinth
forked from didirus/AstralRinth
* Performance improvements * run fmt * optimize creation modal * remove print, fix mod loader editing * Fix library update * update extract loading bar * Update theseus_gui/src-tauri/src/api/metadata.rs Co-authored-by: triphora <emma@modrinth.com> * fix cli --------- Co-authored-by: triphora <emma@modrinth.com>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
import { add_project_from_version as installMod, check_installed } from '@/helpers/profile'
|
|
import { ofetch } from 'ofetch'
|
|
|
|
export const releaseColor = (releaseType) => {
|
|
switch (releaseType) {
|
|
case 'release':
|
|
return 'green'
|
|
case 'beta':
|
|
return 'orange'
|
|
case 'alpha':
|
|
return 'red'
|
|
default:
|
|
return ''
|
|
}
|
|
}
|
|
|
|
export const installVersionDependencies = async (profile, version) => {
|
|
for (const dep of version.dependencies) {
|
|
if (dep.version_id) {
|
|
if (await check_installed(profile.path, dep.project_id)) continue
|
|
await installMod(profile.path, dep.version_id)
|
|
} else {
|
|
if (await check_installed(profile.path, dep.project_id)) continue
|
|
const depVersions = await ofetch(
|
|
`https://api.modrinth.com/v2/project/${dep.project_id}/version`
|
|
)
|
|
const latest = depVersions.find(
|
|
(v) =>
|
|
v.game_versions.includes(profile.metadata.game_version) &&
|
|
v.loaders.includes(profile.metadata.loader)
|
|
)
|
|
await installMod(profile.path, latest.id)
|
|
}
|
|
}
|
|
}
|