From ec37b32eaa230bcb3166a9f8a43607619c598ea4 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Sat, 23 Oct 2021 23:28:19 +0800 Subject: [PATCH] feat(microsoft): copy device code instead of verification uri. --- .../org/jackhuang/hmcl/ui/account/CreateAccountPane.java | 5 +++-- .../jackhuang/hmcl/ui/account/OAuthAccountLoginDialog.java | 5 +++-- HMCL/src/main/resources/assets/lang/I18N.properties | 2 +- HMCL/src/main/resources/assets/lang/I18N_zh.properties | 2 +- HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java index 119b9e851..bc75a8fd5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java @@ -270,14 +270,15 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware { HintPane hintPane = new HintPane(MessageDialogPane.MessageType.INFO); FXUtils.onChangeAndOperate(deviceCode, deviceCode -> { if (deviceCode != null) { - hintPane.setSegment(i18n("account.methods.microsoft.manual", deviceCode.getUserCode())); + FXUtils.copyText(deviceCode.getUserCode()); + hintPane.setSegment(i18n("account.methods.microsoft.manual", deviceCode.getUserCode(), deviceCode.getVerificationUri())); } else { hintPane.setSegment(i18n("account.methods.microsoft.hint")); } }); hintPane.setOnMouseClicked(e -> { if (deviceCode.get() != null) { - FXUtils.copyText(deviceCode.get().getVerificationUri()); + FXUtils.copyText(deviceCode.get().getUserCode()); } }); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OAuthAccountLoginDialog.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OAuthAccountLoginDialog.java index 033c86250..28542226e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OAuthAccountLoginDialog.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OAuthAccountLoginDialog.java @@ -47,14 +47,15 @@ public class OAuthAccountLoginDialog extends DialogPane { HintPane hintPane = new HintPane(MessageDialogPane.MessageType.INFO); FXUtils.onChangeAndOperate(deviceCode, deviceCode -> { if (deviceCode != null) { - hintPane.setSegment(i18n("account.methods.microsoft.manual", deviceCode.getUserCode())); + FXUtils.copyText(deviceCode.getUserCode()); + hintPane.setSegment(i18n("account.methods.microsoft.manual", deviceCode.getUserCode(), deviceCode.getVerificationUri())); } else { hintPane.setSegment(i18n("account.methods.microsoft.hint")); } }); hintPane.setOnMouseClicked(e -> { if (deviceCode.get() != null) { - FXUtils.copyText(deviceCode.get().getVerificationUri()); + FXUtils.copyText(deviceCode.get().getUserCode()); } }); diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 5ac17eacc..c34c5d183 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -97,7 +97,7 @@ account.methods.microsoft.error.no_character=Account is missing a Minecraft Java account.methods.microsoft.error.unknown=Failed to log in. Microsoft respond with error code %d. account.methods.microsoft.logging_in=Logging in... account.methods.microsoft.hint=You should click "login" button, paste the device code shown here later and continue login process in newly opened browser window. -account.methods.microsoft.manual=Your device code is %s. After clicking "login" button, you should finish authorization in the newly opened browser window. If the browser window failed to show, you can click here to copy the URL, and manually open it in your browser. +account.methods.microsoft.manual=Your device code is %1$s, click here to copy. After clicking "login" button, you should finish authorization in the newly opened browser window. If the browser window failed to show, you can open %2$s manually. account.methods.microsoft.profile=Account Profile... account.methods.microsoft.snapshot=HMCL Snapshot version does not support Microsoft login. account.methods.microsoft.waiting_browser=Waiting for authorization in opened browser window... diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index ea717f427..ae2f50474 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -97,7 +97,7 @@ account.methods.microsoft.error.no_character=該帳號沒有包含 Minecraft Jav account.methods.microsoft.error.unknown=登入失敗,錯誤碼:%d account.methods.microsoft.logging_in=登入中... account.methods.microsoft.hint=您需要點擊登錄按鈕,並在新打開的瀏覽器窗口中完成登錄,並輸入待會在此處顯示的設備代碼。 -account.methods.microsoft.manual=設備代碼為:%s。若登錄頁面未能打開,您可以點擊此處複製連結,並手動在瀏覽器中打開網頁。 +account.methods.microsoft.manual=設備代碼為:%1$s,已經幫你拷貝到剪切板中,如果未能黏貼,你可以點擊此處再複製一次。你需要在新打開的瀏覽器窗口中完成登錄,若登錄頁面未能打開,您手動在瀏覽器中打開網頁:%2$s。 account.methods.microsoft.profile=帳戶設置頁 account.methods.microsoft.snapshot=HMCL 快照版不支持微软登录 account.methods.microsoft.waiting_browser=等待在新打開的瀏覽器窗口中完成登入... diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index 798a03c70..35f942fb3 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -97,7 +97,7 @@ account.methods.microsoft.error.no_character=该帐户没有包含 Minecraft Jav account.methods.microsoft.error.unknown=登录失败,错误码:%d account.methods.microsoft.logging_in=登录中... account.methods.microsoft.hint=您需要点击登录按钮,并在新打开的浏览器窗口中完成登录,并输入待会在此处显示的设备代码。 -account.methods.microsoft.manual=设备代码为:%s。若登录页面未能打开,您可以点击此处复制链接,并手动在浏览器中打开网页。 +account.methods.microsoft.manual=设备代码为:%1$s,已经帮你拷贝到剪切板中,如果未能粘贴,你可以点击此处再复制一次。你需要在新打开的浏览器窗口中完成登录,若登录页面未能打开,您手动在浏览器中打开网页:%2$s。 account.methods.microsoft.profile=帐户设置页 account.methods.microsoft.snapshot=HMCL 快照版不支持微软登录 account.methods.microsoft.waiting_browser=等待在新打开的浏览器窗口中完成登录...