Skip to content

Commit

Permalink
4.3.0-beta.6: Fix crash when failing to load image. Fix Chinese (Taiw…
Browse files Browse the repository at this point in the history
…an) localization.

Signed-off-by: 黑嫖233 <[email protected]>
  • Loading branch information
heipiao233 committed Feb 6, 2024
1 parent 816fff8 commit 27c74ed
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 43 deletions.
4 changes: 3 additions & 1 deletion locales/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
},

"content_service": {
"not_found": "No such content service!"
"not_found": "No such content service!",
"image_load_fail_detail": "Failed to load image {{url}}.",
"image_load_fail_title": "Failed to load image!"
},

"version": {
Expand Down
2 changes: 1 addition & 1 deletion locales/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.0-beta.5
4.3.0-beta.6
4 changes: 3 additions & 1 deletion locales/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
},

"content_service": {
"not_found": "无此内容服务!"
"not_found": "无此内容服务!",
"image_load_fail_detail": "图片 {{url}} 加载失败。",
"image_load_fail_title": "图片加载失败!"
},

"version": {
Expand Down
42 changes: 22 additions & 20 deletions locales/zh_tw.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"dmclc": "\"海豚\"我的世界》啟動器(核心)",
"dmclc": "\"海豚\"當個創世神》啟動器(核心)",

"accounts": {
"microsoft": {
"name": "微軟賬號",
"name": "微軟帳號",
"message": "按確認後,請在彈出的瀏覽器窗口操作,要輸入的代碼在剪貼板。",
"no_minecraft_in_account": "該賬戶尚未購買 Minecraft。",
"no_minecraft_in_account": "該帳戶尚未購買 Minecraft。",
"timeout": "登錄超時!",
"canceled": "登錄取消!"
},
"yggdrasil": {
"username": "郵箱",
"username": "信箱",
"password": "密碼",
"profileID": "角色 ID",
"wrong_email_or_password": "錯誤的郵箱或密碼"
"wrong_email_or_password": "錯誤的信箱或密碼"
},
"minecraft_universal_login": {
"name": "Minecraft 統一通行證",
"serverID": "服務器 ID"
"serverID": "伺服器 ID"
},
"authlib_injector": {
"name": "外置登錄",
"apiurl": "認證服務器 URL"
"apiurl": "認證伺服器 URL"
},
"offline": {
"name": "離線登錄",
"username": "用戶名"
"username": "使用者名稱"
}
},

Expand All @@ -41,19 +41,21 @@
},

"content_service": {
"not_found": "無此內容服務!"
"not_found": "無此內容服務!",
"image_load_fail_detail": "圖片 {{url}} 載入失敗。",
"image_load_fail_title": "圖片載入失敗!"
},

"version": {
"loader_not_found": "找不到加載器",
"loader_not_found": "找不到載入器",
"version_not_found": "找不到版本:",
"install_datapack": "不支持自動安裝數據包",
"install_datapack": "不支持自動安裝封包",
"progress": {
"run": "啓動遊戲中...",
"account_login": "登錄賬戶中...",
"account_prepare": "準備賬戶中...",
"run": "啟動遊戲中...",
"account_login": "登入帳戶中...",
"account_prepare": "準備帳戶中...",
"complete": "補齊文件中...",
"extract_native": "解壓動態鏈接庫中...",
"extract_native": "解壓動態連結庫中...",
"argument": "生成運行參數中...",
"done": "完成!"
}
Expand All @@ -79,11 +81,11 @@
"dependency_wrong_missing_unless": "除非安裝:{{unless}},{{source}} 模組需要 {{targetVersion}} 版本的 {{target}} 模組,但尚未安裝。",
"dependency_wrong_missing_reason": "因為 {{reason}},{{source}} 模組需要 {{targetVersion}} 版本的 {{target}} 模組,但尚未安裝。",
"recommends_wrong_missing": "{{source}} 模組推薦使用 {{targetVersion}} 版本的 {{target}} 模組,但尚未安裝。",
"conflicts_exists": "{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組可能沖突",
"breaks_exists": "{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組沖突",
"breaks_exists_reason_unless": "除非安裝:{{unless}},因為 {{reason}},{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組沖突",
"breaks_exists_unless": "除非安裝:{{unless}},{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組沖突",
"breaks_exists_reason": "因為 {{reason}},{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組沖突",
"conflicts_exists": "{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組可能衝突",
"breaks_exists": "{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組衝突",
"breaks_exists_reason_unless": "除非安裝:{{unless}},因為 {{reason}},{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組衝突",
"breaks_exists_unless": "除非安裝:{{unless}},{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組衝突",
"breaks_exists_reason": "因為 {{reason}},{{source}} 模組與 {{targetVersion}} 版本的 {{target}} 模組衝突",
"minecraft_wrong": "{{source}} 模組需要 {{need}} 版本的 Minecraft,但已安裝 {{current}}。",
"error": "錯誤",
"warning": "警告"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dmclc",
"version": "4.3.0-beta.5",
"version": "4.3.0-beta.6",
"description": "Dolphin Minecraft Launcher Core",
"typings": "./lib/index.d.ts",
"module": "./lib/index.js",
Expand Down
40 changes: 23 additions & 17 deletions src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class Launcher {
specialNatives: Record<string, Library>;
};
private realRootPath = "";
static readonly version = "4.3.0-beta.5";
static readonly version = "4.3.0-beta.6";
/**
* Create a new Launcher object.
* @throws {@link FormattedError}
Expand Down Expand Up @@ -286,22 +286,28 @@ export class Launcher {
let self = this;
marked.setOptions({
async walkTokens(token) {
if (token.type == "image"){
let file = os.tmpdir() + "/dmclc-image-" + randomUUID() + ".png";
addExitDelete(file);
await download(token.href, file, self);
token.href = pathToFileURL(file).toString();
} else if (token.type == "html") {
if (!token.raw.includes("<img"))
return;
let m = token.raw.match(/src=\"(.+?)\"/);
if (!m || m.length < 2) return;
let url = m[1];
let file = os.tmpdir() + "/dmclc-image-" + randomUUID() + ".png";
addExitDelete(file);
await download(url, file, self);
token.raw = token.raw.replaceAll(url, pathToFileURL(file).toString());
token.text = token.text.replaceAll(url, pathToFileURL(file).toString());
let url = "";
try {
if (token.type == "image"){
url = token.href;
let file = os.tmpdir() + "/dmclc-image-" + randomUUID() + ".png";
addExitDelete(file);
await download(token.href, file, self);
token.href = pathToFileURL(file).toString();
} else if (token.type == "html") {
if (!token.raw.includes("<img"))
return;
let m = token.raw.match(/src=\"(.+?)\"/);
if (!m || m.length < 2) return;
url = m[1];
let file = os.tmpdir() + "/dmclc-image-" + randomUUID() + ".png";
addExitDelete(file);
await download(url, file, self);
token.raw = token.raw.replaceAll(url, pathToFileURL(file).toString());
token.text = token.text.replaceAll(url, pathToFileURL(file).toString());
}
} catch {
self.launcherInterface.error(`图片 ${url} 加载失败`, "图片加载失败")
}
},
})
Expand Down

0 comments on commit 27c74ed

Please sign in to comment.