From cdeebddccd2ee44ba785598849d77befe4300cd3 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 21 Aug 2017 17:15:05 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-2354=20=E5=B0=86=E5=8E=9F=E6=9D=A5?= =?UTF-8?q?=E5=AD=98=E5=9C=A8finereportEnv=E4=B8=AD=E7=9A=84=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E4=BF=A1=E6=81=AF=E7=A7=BB=E5=88=B0config.xml?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/ActiveKeyGenerator.java | 5 +- .../mainframe/InformationCollector.java | 5 +- .../alphafine/component/AlphaFineDialog.java | 3 +- .../design/mainframe/bbs/BBSLoginDialog.java | 8 ++- .../fr/design/mainframe/bbs/ExitLabel.java | 6 +- .../design/mainframe/bbs/UserInfoLabel.java | 26 +++---- .../fr/design/mainframe/bbs/UserInfoPane.java | 12 ++-- .../errorinfo/ErrorInfoLogAppender.java | 3 +- .../src/com/fr/design/DesignerEnvManager.java | 70 +------------------ .../src/com/fr/design/bbs/BBSLoginUtils.java | 31 ++++++++ .../com/fr/design/extra/LoginWebBridge.java | 60 ++++++++-------- .../fr/design/extra/PluginFromStorePane.java | 8 +-- .../fr/design/extra/PluginOperateUtils.java | 7 +- .../com/fr/design/extra/PluginUpdatePane.java | 7 +- .../com/fr/design/extra/PluginWebBridge.java | 20 +++--- .../templateinfo/TemplateInfoCollector.java | 3 +- 16 files changed, 114 insertions(+), 160 deletions(-) create mode 100644 designer_base/src/com/fr/design/bbs/BBSLoginUtils.java diff --git a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java index 3a57b11ec..a941660aa 100644 --- a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java +++ b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe; -import com.fr.base.BaseUtils; +import com.fr.base.ConfigManager; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.stable.StableUtils; @@ -102,7 +101,7 @@ public class ActiveKeyGenerator { HashMap para = new HashMap(); para.put("uuid", envManager.getUUID()); para.put("key", key); - para.put("username", envManager.getBBSName()); + para.put("username", ConfigManager.getProviderInstance().getBbsUsername()); HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("verify.code"), para); if (timeout != -1) { hc.setTimeout(timeout); diff --git a/designer/src/com/fr/design/mainframe/InformationCollector.java b/designer/src/com/fr/design/mainframe/InformationCollector.java index 4bac9a15b..a5912da56 100644 --- a/designer/src/com/fr/design/mainframe/InformationCollector.java +++ b/designer/src/com/fr/design/mainframe/InformationCollector.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.dialect.DialectFactory; @@ -134,7 +135,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { content.put(XML_UUID, envManager.getUUID()); content.put(XML_JAR, GeneralUtils.readBuildNO()); content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); - content.put(XML_USERNAME, envManager.getBBSName()); + content.put(XML_USERNAME, ConfigManager.getProviderInstance().getBbsUsername()); content.put(XML_KEY, envManager.getActivationKey()); content.put(XML_OS, System.getProperty("os.name")); @@ -254,7 +255,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { } DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - content.put("username", envManager.getBBSName()); + content.put("username", ConfigManager.getProviderInstance().getBbsUsername()); content.put("uuid", envManager.getUUID()); content.put("functions", functionArray); diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 83945d324..ed0bc5731 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.alphafine.component; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.UIDialog; @@ -776,7 +777,7 @@ public class AlphaFineDialog extends UIDialog { */ private void sendToServer(String searchKey, AlphaCellModel cellModel) { if (cellModel.isNeedToSendToServer()) { - String username = DesignerEnvManager.getEnvManager().getBBSName(); + String username = ConfigManager.getProviderInstance().getBbsUsername(); String uuid = DesignerEnvManager.getEnvManager().getUUID(); String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java index 3946b73e5..f5401c028 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java @@ -1,6 +1,8 @@ package com.fr.design.mainframe.bbs; -import com.fr.design.DesignerEnvManager; +import com.fr.base.ConfigManager; +import com.fr.base.FRContext; +import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.ActionLabel; @@ -207,8 +209,8 @@ public class BBSLoginDialog extends UIDialog { // 登录成功 private void loginSuccess() { - DesignerEnvManager.getEnvManager().setBBSPassword(String.valueOf(passField.getPassword())); - userInfoLabel.setUserName(nameField.getText()); + String password = String.valueOf(passField.getPassword()); + BBSLoginUtils.bbsLogin(nameField.getText(), password); userInfoLabel.getUserInfoPane().markSignIn(nameField.getText()); BBSLoginDialog.this.setVisible(false); } diff --git a/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java b/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java index c3436755a..a830d3332 100644 --- a/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java @@ -9,14 +9,13 @@ import java.awt.event.MouseEvent; import com.fr.base.BaseUtils; -import com.fr.design.DesignerEnvManager; +import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; -import com.fr.stable.StringUtils; /** * @author neil @@ -61,8 +60,7 @@ public class ExitLabel extends UILabel{ } private void clearLoingInformation(){ - DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY); + BBSLoginUtils.bbsLogout(); } private void updateInfoPane(){ diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 4d58b3db6..b4ba82399 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -3,8 +3,10 @@ */ package com.fr.design.mainframe.bbs; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.extra.*; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; @@ -16,12 +18,7 @@ import com.fr.general.DateUtils; import com.fr.general.Inter; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; -import com.fr.plugin.manage.bbs.BBSPluginLogin; -import com.fr.plugin.manage.bbs.BBSUserInfo; -import com.fr.stable.EncodeConstants; -import com.fr.stable.OperatingSystem; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; +import com.fr.stable.*; import javax.swing.*; import java.awt.*; @@ -77,7 +74,7 @@ public class UserInfoLabel extends UILabel { public UserInfoLabel(UserInfoPane userInfoPane) { this.userInfoPane = userInfoPane; - String userName = DesignerEnvManager.getEnvManager().getBBSName(); + String userName = ConfigManager.getProviderInstance().getBbsUsername(); this.addMouseListener(userInfoAdapter); this.setHorizontalAlignment(SwingConstants.CENTER); this.setText(userName); @@ -117,10 +114,9 @@ public class UserInfoLabel extends UILabel { } private void clearLoginInformation() { - DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setBbsUid(DEFAULT_BBS_UID); + ConfigManager.getProviderInstance().setInShowBBsName(StringUtils.EMPTY); + ConfigManager.getProviderInstance().setBbsUid(DEFAULT_BBS_UID); + BBSLoginUtils.bbsLogout(); } private void updateInfoPane() { @@ -192,8 +188,6 @@ public class UserInfoLabel extends UILabel { return; } - //往designerenvmanger里写一下 - DesignerEnvManager.getEnvManager().setBBSName(userName); this.userName = userName; } @@ -238,8 +232,7 @@ public class UserInfoLabel extends UILabel { @Override public void mouseClicked(MouseEvent e) { - BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo(); - userName = bbsUserInfo == null ? "" : bbsUserInfo.getUserName(); + userName = ConfigManager.getProviderInstance().getBbsUsername(); if (StringUtils.isNotEmpty(userName)) { UIPopupMenu menu = new UIPopupMenu(); menu.setOnlyText(true); @@ -265,10 +258,9 @@ public class UserInfoLabel extends UILabel { UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account")); closeOther.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { - BBSPluginLogin.getInstance().logOut(); + BBSLoginUtils.bbsLogout(); UserLoginContext.fireLoginContextListener(); } - }); menu.add(priviteMessage); menu.add(closeOther); diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java index a638ac3e4..711fd634d 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -11,6 +11,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicPane; @@ -18,8 +19,6 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.general.DateUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.plugin.manage.bbs.BBSPluginLogin; -import com.fr.plugin.manage.bbs.BBSUserInfo; import com.fr.stable.StringUtils; @@ -77,9 +76,8 @@ public class UserInfoPane extends BasicPane{ @Override public void run() { - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); - if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)){ + String username = ConfigManager.getProviderInstance().getBbsUsername(); + if (StringUtils.isEmpty(username)){ markUnSignIn(); } else { markSignIn(username); @@ -133,7 +131,7 @@ public class UserInfoPane extends BasicPane{ FRContext.getLogger().error(e.getMessage()); } - String userName = DesignerEnvManager.getEnvManager().getBBSName(); + String userName = ConfigManager.getProviderInstance().getBbsUsername(); if(StringUtils.isNotEmpty(userName)){ return; } @@ -169,8 +167,6 @@ public class UserInfoPane extends BasicPane{ * */ public void markSignIn(String userName){ - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - BBSPluginLogin.getInstance().login(new BBSUserInfo(userName, password)); this.userInfoLabel.setText(userName); this.userInfoLabel.setUserName(userName); this.userInfoLabel.setOpaque(true); diff --git a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index f01bb669e..26ae4d61f 100644 --- a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.errorinfo; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.base.io.IOFile; import com.fr.base.io.XMLReadHelper; @@ -38,7 +39,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { this.layout = new org.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - this.username = envManager.getBBSName(); + this.username = ConfigManager.getProviderInstance().getBbsUsername(); this.uuid = envManager.getUUID(); this.activekey = envManager.getActivationKey(); } diff --git a/designer_base/src/com/fr/design/DesignerEnvManager.java b/designer_base/src/com/fr/design/DesignerEnvManager.java index d02d41abf..0725f8e83 100644 --- a/designer_base/src/com/fr/design/DesignerEnvManager.java +++ b/designer_base/src/com/fr/design/DesignerEnvManager.java @@ -89,14 +89,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private int westRegionContainerWidth = 240; private String encryptionKey; private String jdkHome; - //当前设计器用户的论坛昵称 - private String bbsName; - //当前设计器用户的论坛密码 - private String bbsPassword; - //当前设计器用户的论坛ID - private int bbsUid; - //当前设计器用户的昵称显示(带消息) - private String inShowBBsName; + //上一次登录弹窗的时间, 为了控制一天只弹一次窗口 private String lastShowBBSTime; //上一次资讯弹窗时间, 为了控制一天只弹一次 @@ -1145,37 +1138,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.jdkHome = home; } - public String getBBSName() { - return bbsName; - } - - public void setBBSName(String bbsName) { - this.bbsName = bbsName; - } - - public String getBBSPassword() { - return bbsPassword; - } - - public void setBBSPassword(String bbsPassword) { - this.bbsPassword = bbsPassword; - } - - public int getBbsUid() { - return bbsUid; - } - - public void setBbsUid(int bbsUid) { - this.bbsUid = bbsUid; - } - - public void setInShowBBsName(String inShowBBsName) { - this.inShowBBsName = inShowBBsName; - } - - public String getInShowBBsName() { - return inShowBBsName; - } public String getLastShowBBSTime() { return lastShowBBSTime; @@ -1256,19 +1218,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } - private void readBBSName(XMLableReader reader){ - String tmpVal; - if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { - this.bbsName = tmpVal; - } - } - private void readBBSPassword(XMLableReader reader){ - String tmpVal; - if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { - this.bbsPassword = CodeUtils.passwordDecode(tmpVal); - } - } private void readLastBBSTime(XMLableReader reader){ String tmpVal; @@ -1325,11 +1275,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readEncrytionKey(reader); } else if ("jdkHome".equals(name)) { this.jdkHome = reader.getElementValue(); - } else if ("bbsName".equals(name)){ - readBBSName(reader); - } else if ("bbsPassword".equals(name)){ - readBBSPassword(reader); - } else if ("lastBBSTime".equals(name)){ + }else if ("lastBBSTime".equals(name)){ readLastBBSTime(reader); } else if ("lastBBSNewsTime".equals(name)){ readLastBBSNewsTime(reader); @@ -1736,18 +1682,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { //写论坛相关的两个属性 private void writeBBSRelated(XMLPrintWriter writer){ - if (StringUtils.isNotBlank(bbsName)) { - writer.startTAG("bbsName"); - writer.textNode(bbsName); - writer.end(); - } - - if (StringUtils.isNotBlank(bbsPassword)){ - writer.startTAG("bbsPassword"); - writer.textNode(CodeUtils.passwordEncode(bbsPassword)); - writer.end(); - } - if (StringUtils.isNotEmpty(this.lastShowBBSTime)){ writer.startTAG("lastBBSTime"); writer.textNode(lastShowBBSTime); diff --git a/designer_base/src/com/fr/design/bbs/BBSLoginUtils.java b/designer_base/src/com/fr/design/bbs/BBSLoginUtils.java new file mode 100644 index 000000000..b76702472 --- /dev/null +++ b/designer_base/src/com/fr/design/bbs/BBSLoginUtils.java @@ -0,0 +1,31 @@ +package com.fr.design.bbs; + +import com.fr.base.ConfigManager; +import com.fr.base.FRContext; +import com.fr.stable.StringUtils; + +/** + * Created by ibm on 2017/8/21. + */ +public class BBSLoginUtils { + + public static void bbsLogin(String username, String password){ + try{ + ConfigManager.getProviderInstance().setBbsUsername(username); + ConfigManager.getProviderInstance().setBbsPassword(password); + FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance()); + }catch (Exception e){ + FRContext.getLogger().error(e.getMessage()); + } + } + + public static void bbsLogout(){ + try{ + ConfigManager.getProviderInstance().setBbsUsername(StringUtils.EMPTY); + ConfigManager.getProviderInstance().setBbsPassword(StringUtils.EMPTY); + FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance()); + }catch (Exception e){ + FRContext.getLogger().error(e.getMessage()); + } + } +} diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index 549cb1763..d7e53c005 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -1,16 +1,15 @@ package com.fr.design.extra; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.ucenter.Client; import com.fr.design.extra.ucenter.XMLHelper; import com.fr.design.gui.ilable.UILabel; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; -import com.fr.json.JSONObject; -import com.fr.plugin.manage.bbs.BBSPluginLogin; -import com.fr.plugin.manage.bbs.BBSUserInfo; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; import javafx.scene.web.WebEngine; @@ -20,7 +19,6 @@ import java.awt.*; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; -import java.util.HashMap; import java.util.LinkedList; public class LoginWebBridge { @@ -59,7 +57,7 @@ public class LoginWebBridge { private String userName; public LoginWebBridge() { - String username = DesignerEnvManager.getEnvManager().getBBSName(); + String username = ConfigManager.getProviderInstance().getBbsUsername(); setUserName(username, uiLabel); } @@ -130,16 +128,16 @@ public class LoginWebBridge { */ public void setMessageCount(int count) { if (count == MIN_MESSAGE_COUNT) { - uiLabel.setText(DesignerEnvManager.getEnvManager().getBBSName()); - DesignerEnvManager.getEnvManager().setInShowBBsName(DesignerEnvManager.getEnvManager().getBBSName()); + uiLabel.setText(ConfigManager.getProviderInstance().getBbsUsername()); + ConfigManager.getProviderInstance().setInShowBBsName(ConfigManager.getProviderInstance().getBbsUsername()); return; } this.messageCount = count; StringBuilder sb = new StringBuilder(); - sb.append(StringUtils.BLANK).append(DesignerEnvManager.getEnvManager().getBBSName()) + sb.append(StringUtils.BLANK).append(ConfigManager.getProviderInstance().getBbsUsername()) .append("(").append(this.messageCount) .append(")").append(StringUtils.BLANK); - DesignerEnvManager.getEnvManager().setInShowBBsName(sb.toString()); + ConfigManager.getProviderInstance().setInShowBBsName(sb.toString()); uiLabel.setText(sb.toString()); } @@ -278,11 +276,9 @@ public class LoginWebBridge { if (list.size() > 0) { 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); - BBSPluginLogin.getInstance().login(new BBSUserInfo(username, password)); + ConfigManager.getProviderInstance().setBbsUid($uid); + ConfigManager.getProviderInstance().setInShowBBsName(username); + BBSLoginUtils.bbsLogin(username, password); return LOGININ;//登录成功,0 } else if ($uid == -1) { return USERNAME_NOT_EXSIT;//用户名不存在,-1 @@ -318,24 +314,28 @@ public class LoginWebBridge { public void getLoginInfo(String userInfo) { org.json.JSONObject jo = new org.json.JSONObject(userInfo); String status = jo.get("status").toString(); - if (status.equals(LOGIN_SUCCESS)) { - String username = jo.get("username").toString(); - int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString()); - closeWindow(); - closeQQWindow(); - pluginuiLabel.setText(username); - DesignerEnvManager.getEnvManager().setBBSName(username); - DesignerEnvManager.getEnvManager().setBbsUid(uid); - DesignerEnvManager.getEnvManager().setInShowBBsName(username); - BBSPluginLogin.getInstance().login(new BBSUserInfo(username, "")); - } else if (status.equals(LOGIN_FAILED)) { - //账号没有QQ授权 - closeQQWindow(); - try { - Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("QQ_binding"))); - } catch (Exception exp) { + try{ + if (status.equals(LOGIN_SUCCESS)) { + String username = jo.get("username").toString(); + int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString()); + closeWindow(); + closeQQWindow(); + pluginuiLabel.setText(username); + ConfigManager.getProviderInstance().setBbsUid(uid); + ConfigManager.getProviderInstance().setInShowBBsName(username); + BBSLoginUtils.bbsLogin(username, ""); + } else if (status.equals(LOGIN_FAILED)) { + //账号没有QQ授权 + closeQQWindow(); + try { + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("QQ_binding"))); + } catch (Exception exp) { + } } + }catch (Exception e){ + FRContext.getLogger().error(e.getMessage()); } + } public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { diff --git a/designer_base/src/com/fr/design/extra/PluginFromStorePane.java b/designer_base/src/com/fr/design/extra/PluginFromStorePane.java index f3e0de799..20001cad3 100644 --- a/designer_base/src/com/fr/design/extra/PluginFromStorePane.java +++ b/designer_base/src/com/fr/design/extra/PluginFromStorePane.java @@ -1,5 +1,6 @@ package com.fr.design.extra; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.gui.frpane.UITabbedPane; @@ -9,11 +10,10 @@ import com.fr.general.Inter; import com.fr.json.JSONObject; import com.fr.plugin.context.PluginMarker; import com.fr.plugin.manage.PluginManager; -import com.fr.plugin.manage.bbs.BBSPluginLogin; import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.manage.control.ProgressCallback; import com.fr.plugin.view.PluginView; - +import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.File; @@ -188,10 +188,10 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane implements Serializable, XM private HashMap getNewConsumingMap(String templateID, long openTime, long timeConsume) { HashMap consumingMap = new HashMap<>(); - String username = DesignerEnvManager.getEnvManager().getBBSName(); + String username = ConfigManager.getProviderInstance().getBbsUsername(); String uuid = DesignerEnvManager.getEnvManager().getUUID(); String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());