From 0529d6924a7e819198ff8604d17de2270938fa74 Mon Sep 17 00:00:00 2001 From: lee <854954082@qq.com> Date: Mon, 7 Nov 2016 18:28:18 +0800 Subject: [PATCH] 1 1 --- .../com/fr/design/extra/LoginWebBridge.java | 25 +++++----- .../com/fr/design/extra/PluginWebBridge.java | 13 ++++- .../design/extra/exe/PluginLoginExecutor.java | 49 +++++++++++++++++++ 3 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index b604ae8d8b..41ed99beb9 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -68,11 +68,11 @@ public class LoginWebBridge { public static com.fr.design.extra.LoginWebBridge getHelper() { if (helper != null) { - return helper; + return helper; } synchronized (com.fr.design.extra.LoginWebBridge.class) { if (helper == null) { - helper = new com.fr.design.extra.LoginWebBridge(); + helper = new com.fr.design.extra.LoginWebBridge(); } return helper; } @@ -118,14 +118,13 @@ public class LoginWebBridge { if(!StringUtils.isEmpty(this.userName)){ updateMessageCount(); } - DesignerEnvManager.getEnvManager().setBBSName(userName); this.userName = userName; } /** * 定时取后台论坛消息 */ - private void updateMessageCount(){ + public void updateMessageCount(){ //启动获取消息更新的线程 //登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数. Thread updateMessageThread = new Thread(new Runnable() { @@ -171,7 +170,7 @@ public class LoginWebBridge { } this.messageCount = count; StringBuilder sb = new StringBuilder(); - sb.append(StringUtils.BLANK).append(this.userName) + sb.append(StringUtils.BLANK).append(DesignerEnvManager.getEnvManager().getBBSName()) .append("(").append(this.messageCount) .append(")").append(StringUtils.BLANK); DesignerEnvManager.getEnvManager().setInShowBBsName(sb.toString()); @@ -244,7 +243,7 @@ public class LoginWebBridge { * @param uiLabel 两边的label显示 * @return 登录信息标志 */ - private String login(String username, String password, UILabel uiLabel) { + public String login(String username, String password, UILabel uiLabel) { if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) { return LOGIN_INFO_EMPTY; } @@ -253,7 +252,7 @@ public class LoginWebBridge { } String loginResult = login(username, password); if (loginResult.equals(LOGININ)) { - updateUserInfo(username, password); + updateUserInfo(username); loginSuccess(username, uiLabel); setUserName(username, uiLabel); } @@ -275,10 +274,7 @@ public class LoginWebBridge { * @param username 用户名 * @param password 密码 */ - public void updateUserInfo(String username,String password) { - DesignerEnvManager.getEnvManager().setBBSName(username); - DesignerEnvManager.getEnvManager().setBBSPassword(password); - DesignerEnvManager.getEnvManager().setInShowBBsName(username); + public void updateUserInfo(String username) { this.userName = username; } @@ -309,7 +305,7 @@ public class LoginWebBridge { }); } - public String login(String username, String password) { + private String login(String username, String password) { try { Client uc = new Client(); String result = uc.uc_user_login(username, password); @@ -319,6 +315,9 @@ public class LoginWebBridge { int $uid = Integer.parseInt(list.get(0)); if ($uid > 0) { DesignerEnvManager.getEnvManager().setBbsUid($uid); + DesignerEnvManager.getEnvManager().setBBSName(username); + DesignerEnvManager.getEnvManager().setInShowBBsName(username); + DesignerEnvManager.getEnvManager().setBBSPassword(password); return LOGININ;//登录成功,0 } else if ($uid == -1) { return USERNAME_NOT_EXSIT;//用户名不存在,-1 @@ -335,4 +334,4 @@ public class LoginWebBridge { } return UNKNOWN_ERROR; } -} +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 12c3e85c41..15bd72c09c 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -529,6 +529,17 @@ public class PluginWebBridge { return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel); } + /** + * 插件管理部分的登陆的回调处理 + * @param username + * @param password + * @param callback + */ + public void defaultLogin(String username, String password, final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password, uiLabel)); + new Thread(task).start(); + } + /** * 弹出QQ授权页面 */ @@ -545,4 +556,4 @@ public class PluginWebBridge { DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); } -} +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java b/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java new file mode 100644 index 0000000000..c1101f8005 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java @@ -0,0 +1,49 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.LoginWebBridge; +import com.fr.design.extra.Process; +import com.fr.design.gui.ilable.UILabel; + +/** + * Created by Slpire on 2016/11/7. + */ +public class PluginLoginExecutor implements Executor { + + private String result = "[]"; + + private String username; + private String password; + private UILabel uiLabel; + + public PluginLoginExecutor(String username, String password, UILabel uiLabel) { + this.username = username; + this.password = password; + this.uiLabel = uiLabel; + } + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[] { + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + String loginResult = LoginWebBridge.getHelper().login(username, password, uiLabel); + if (Integer.valueOf(loginResult) == 0) { + LoginWebBridge.getHelper().updateMessageCount(); + } + result = loginResult; + } + } + }; + } +}