Skip to content

Commit 16a7576

Browse files
committed
fix: Try to handle launch failed due to bad version libraries
1 parent 524f4f3 commit 16a7576

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

xmcl-keystone-ui/locales/en.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,10 @@ installForge:
358358
postProcessing: Post Processing
359359
installInstance:
360360
file: Update Instance File {file}
361-
name: Update Instance
362-
unzip: Unzip {count} Files
363361
link: Copy or Link {count} Files
362+
name: Update Instance
364363
resolve: Resolve Instance Config
364+
unzip: Unzip {count} Files
365365
installJre:
366366
decompress: Decompress JRE files to folder
367367
download: Download compressed JRE file
@@ -512,6 +512,9 @@ launch:
512512
launch: Launch
513513
launchBlocked:
514514
ignore: Force Launch
515+
launchBadVersion:
516+
description: The version {version} json is breaking. Maybe re-install this version?
517+
title: Bad Version JSON
515518
launchGeneralException:
516519
description: Some errors cause the launch failed.
517520
title: Launch Failed
@@ -648,8 +651,8 @@ mod:
648651
deletionRestHint: And {rest} more Mods...
649652
dropHint: Drop mod's .jar/.litemod here to import.
650653
enabled: '{count} Mods enabled'
651-
groupInstalled: 'Group Installed Mods'
652654
filter: Filter Mods
655+
groupInstalled: Group Installed Mods
653656
hasUpdate: Mod has a new version!
654657
hideIncompatible: Hide Incompatible Mods
655658
import: Import Mod

xmcl-keystone-ui/locales/zh-CN.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ launch:
526526
launch: 启动
527527
launchBlocked:
528528
ignore: 强行启动
529+
launchBadVersion:
530+
description: 版本 {version} 的 JSON 内有无法解析的库,也许你需要重装这个版本?
531+
title: 版本 JSON 可能损坏
529532
launchGeneralException:
530533
description: 一些未知错误导致启动失败。
531534
title: 无法启动

xmcl-keystone-ui/src/views/AppLaunchBlockedDialog.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ function onException(e: LaunchExceptions) {
105105
description.value = t('launchBlocked.launchNoVersionInstalled.description', { version: e.options?.version })
106106
unexpected.value = true
107107
extraText.value = ''
108+
} else if (e.type === 'launchBadVersion') {
109+
title.value = t('launchBlocked.launchBadVersion.title')
110+
description.value = t('launchBlocked.launchBadVersion.description', { version: e.version })
111+
unexpected.value = true
112+
extraText.value = ''
108113
} else if (e.type === 'launchUserStatusRefreshFailed') {
109114
title.value = t('launchBlocked.launchUserStatusRefreshFailed.title')
110115
description.value = t('launchBlocked.launchUserStatusRefreshFailed.description') + '<br>'

xmcl-runtime-api/src/services/LaunchService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ export type LaunchExceptions = {
166166
*/
167167
type: 'launchUserStatusRefreshFailed'
168168
userException: UserExceptions
169+
} | {
170+
type: 'launchBadVersion'
171+
version: string
169172
}
170173

171174
export class LaunchException extends Exception<LaunchExceptions> { }

xmcl-runtime/launch/LaunchService.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ export class LaunchService extends AbstractService implements ILaunchService {
223223
this.log('Launching with these option...')
224224
this.log(JSON.stringify(launchOptions, (k, v) => (k === 'accessToken' ? '***' : v), 2))
225225

226+
const commonLibs = version.libraries.filter(lib => !lib.isNative)
227+
for (const lib of commonLibs) {
228+
if (!lib.download.path) {
229+
(lib.download as any).path = lib.path
230+
if (!lib.download.path) {
231+
throw new LaunchException({ type: 'launchBadVersion', version: version.id }, JSON.stringify(lib))
232+
}
233+
}
234+
}
235+
226236
// Launch
227237
const process = await launch(launchOptions)
228238
const processData = {

0 commit comments

Comments
 (0)