Browse Source

Merge pull request #459 in BA/design from ~LEE/design:dev to dev

* commit '402d9e98c808f2cc8362163ccf874514549de6e1':
  1
  1
master
superman 8 years ago
parent
commit
06340ff5c4
  1. 5
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  2. 25
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  3. 13
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  4. 49
      designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java

5
designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java

@ -18,6 +18,7 @@ import com.fr.general.Inter;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -99,7 +100,9 @@ public class UserInfoLabel extends UILabel{
} }
}); });
//PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this); if (StableUtils.getMajorJavaVersion() == 8) {
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
}
QQLoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this); QQLoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this);
UserLoginContext.addLoginContextListener(new LoginContextListener() { UserLoginContext.addLoginContextListener(new LoginContextListener() {

25
designer_base/src/com/fr/design/extra/LoginWebBridge.java

@ -68,11 +68,11 @@ public class LoginWebBridge {
public static com.fr.design.extra.LoginWebBridge getHelper() { public static com.fr.design.extra.LoginWebBridge getHelper() {
if (helper != null) { if (helper != null) {
return helper; return helper;
} }
synchronized (com.fr.design.extra.LoginWebBridge.class) { synchronized (com.fr.design.extra.LoginWebBridge.class) {
if (helper == null) { if (helper == null) {
helper = new com.fr.design.extra.LoginWebBridge(); helper = new com.fr.design.extra.LoginWebBridge();
} }
return helper; return helper;
} }
@ -118,14 +118,13 @@ public class LoginWebBridge {
if(!StringUtils.isEmpty(this.userName)){ if(!StringUtils.isEmpty(this.userName)){
updateMessageCount(); updateMessageCount();
} }
DesignerEnvManager.getEnvManager().setBBSName(userName);
this.userName = userName; this.userName = userName;
} }
/** /**
* 定时取后台论坛消息 * 定时取后台论坛消息
*/ */
private void updateMessageCount(){ public void updateMessageCount(){
//启动获取消息更新的线程 //启动获取消息更新的线程
//登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数. //登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数.
Thread updateMessageThread = new Thread(new Runnable() { Thread updateMessageThread = new Thread(new Runnable() {
@ -171,7 +170,7 @@ public class LoginWebBridge {
} }
this.messageCount = count; this.messageCount = count;
StringBuilder sb = new StringBuilder(); 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(this.messageCount)
.append(")").append(StringUtils.BLANK); .append(")").append(StringUtils.BLANK);
DesignerEnvManager.getEnvManager().setInShowBBsName(sb.toString()); DesignerEnvManager.getEnvManager().setInShowBBsName(sb.toString());
@ -244,7 +243,7 @@ public class LoginWebBridge {
* @param uiLabel 两边的label显示 * @param uiLabel 两边的label显示
* @return 登录信息标志 * @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)) { if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) {
return LOGIN_INFO_EMPTY; return LOGIN_INFO_EMPTY;
} }
@ -253,7 +252,7 @@ public class LoginWebBridge {
} }
String loginResult = login(username, password); String loginResult = login(username, password);
if (loginResult.equals(LOGININ)) { if (loginResult.equals(LOGININ)) {
updateUserInfo(username, password); updateUserInfo(username);
loginSuccess(username, uiLabel); loginSuccess(username, uiLabel);
setUserName(username, uiLabel); setUserName(username, uiLabel);
} }
@ -275,10 +274,7 @@ public class LoginWebBridge {
* @param username 用户名 * @param username 用户名
* @param password 密码 * @param password 密码
*/ */
public void updateUserInfo(String username,String password) { public void updateUserInfo(String username) {
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setBBSPassword(password);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
this.userName = 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 { try {
Client uc = new Client(); Client uc = new Client();
String result = uc.uc_user_login(username, password); String result = uc.uc_user_login(username, password);
@ -319,6 +315,9 @@ public class LoginWebBridge {
int $uid = Integer.parseInt(list.get(0)); int $uid = Integer.parseInt(list.get(0));
if ($uid > 0) { if ($uid > 0) {
DesignerEnvManager.getEnvManager().setBbsUid($uid); DesignerEnvManager.getEnvManager().setBbsUid($uid);
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
DesignerEnvManager.getEnvManager().setBBSPassword(password);
return LOGININ;//登录成功,0 return LOGININ;//登录成功,0
} else if ($uid == -1) { } else if ($uid == -1) {
return USERNAME_NOT_EXSIT;//用户名不存在,-1 return USERNAME_NOT_EXSIT;//用户名不存在,-1
@ -335,4 +334,4 @@ public class LoginWebBridge {
} }
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
} }

13
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -529,6 +529,17 @@ public class PluginWebBridge {
return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel); return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel);
} }
/**
* 插件管理部分的登陆的回调处理
* @param username
* @param password
* @param callback
*/
public void defaultLogin(String username, String password, final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password, uiLabel));
new Thread(task).start();
}
/** /**
* 弹出QQ授权页面 * 弹出QQ授权页面
*/ */
@ -545,4 +556,4 @@ public class PluginWebBridge {
DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY);
uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
} }
} }

49
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<String> process) {
String loginResult = LoginWebBridge.getHelper().login(username, password, uiLabel);
if (Integer.valueOf(loginResult) == 0) {
LoginWebBridge.getHelper().updateMessageCount();
}
result = loginResult;
}
}
};
}
}
Loading…
Cancel
Save