-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support switch back to legacy view
- Loading branch information
Showing
26 changed files
with
1,709 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { InjectionKey } from 'vue' | ||
import { useInstance, useInstanceVersion } from './instance' | ||
import { useLaunchIssue } from './launchIssue' | ||
import { useLaunchTask } from './launchTask' | ||
|
||
export function useInstanceContext() { | ||
const issue = useLaunchIssue() | ||
const task = useLaunchTask() | ||
const { path, instance, refreshing } = useInstance() | ||
const name = computed(() => instance.value.name) | ||
const version = computed(() => instance.value.runtime) | ||
const { localVersion } = useInstanceVersion() | ||
|
||
return { | ||
issue, | ||
task, | ||
path, | ||
name, | ||
version, | ||
localVersion, | ||
instance, | ||
refreshing, | ||
} | ||
} | ||
|
||
export const kInstanceContext: InjectionKey<ReturnType<typeof useInstanceContext>> = Symbol('InstanceContext') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { AssetIndexIssueKey, AssetsIssueKey, InstallProfileIssueKey, isIssue, LibrariesIssueKey, VersionIssueKey, VersionJarIssueKey, VersionJsonIssueKey } from '@xmcl/runtime-api' | ||
import { useIssues } from './issues' | ||
|
||
export function useLaunchIssue() { | ||
const { issues } = useIssues() | ||
const issue = computed(() => { | ||
for (const i of issues.value) { | ||
if (isIssue(AssetsIssueKey, i)) { | ||
return i | ||
} | ||
if (isIssue(LibrariesIssueKey, i)) { | ||
return i | ||
} | ||
if (isIssue(AssetIndexIssueKey, i)) { | ||
return i | ||
} | ||
if (isIssue(VersionIssueKey, i)) { | ||
return i | ||
} | ||
if (isIssue(VersionJsonIssueKey, i)) { | ||
return i | ||
} | ||
if (isIssue(VersionJarIssueKey, i)) { | ||
return i | ||
} | ||
if (isIssue(InstallProfileIssueKey, i)) { | ||
return i | ||
} | ||
} | ||
return undefined | ||
}) | ||
return issue | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { TaskState } from '@xmcl/task' | ||
import { useInstance, useInstanceVersion } from './instance' | ||
import { useTask } from './task' | ||
|
||
export function useLaunchTask() { | ||
const { path, instance } = useInstance() | ||
const version = computed(() => instance.value.runtime) | ||
const { localVersion } = useInstanceVersion() | ||
return useTask((i) => { | ||
const p = i.param as any | ||
if (i.state === TaskState.Cancelled || i.state === TaskState.Succeed || i.state === TaskState.Failed) { | ||
return false | ||
} | ||
if (i.path === 'installVersion' && p?.id === version.value.minecraft) { | ||
return true | ||
} | ||
if (i.path === 'installVersion.jar' && (p?.id === localVersion.value.id || p?.id === version.value.minecraft)) { | ||
return true | ||
} | ||
if (i.path === 'installLibraries' && (p?.id === localVersion.value.id || p?.id === version.value.minecraft)) { | ||
return true | ||
} | ||
if (i.path === 'installAssets' && (p?.id === localVersion.value.id || p?.id === version.value.minecraft || p?.id === version.value.minecraft.substring(version.value.minecraft.lastIndexOf('.')))) { | ||
return true | ||
} | ||
if (i.path === 'installForge' && (p?.id === version.value.forge || p?.id === localVersion.value.id)) { | ||
return true | ||
} | ||
if (i.path === 'installOptifine' && p?.id === version.value.optifine) { | ||
return true | ||
} | ||
if (i.path === 'installByProfile' && p?.id === localVersion.value.id) { | ||
return true | ||
} | ||
if (i.path === 'installFabric' && p?.id === version.value.minecraft) { | ||
return true | ||
} | ||
if (i.path === 'installInstance' && p.instance === path.value) { | ||
// installing this instance | ||
return true | ||
} | ||
return false | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.