Skip to content

Commit 4a419f4

Browse files
authored
Merge pull request #41 from shuzijun/dev
Dev
2 parents f7efebe + 698e779 commit 4a419f4

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

doc/leetcode-editor-V4.3.zip

1.8 MB
Binary file not shown.

resources/META-INF/plugin.xml

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin>
22
<id>leetcode-editor</id>
33
<name>leetcode editor</name>
4-
<version>4.2</version>
4+
<version>4.3</version>
55
<vendor email="[email protected]" url="https://github.com/shuzijun/idea-leetcode-plugin">shuzijun</vendor>
66

77
<description><![CDATA[
@@ -102,6 +102,15 @@
102102

103103
<change-notes><![CDATA[
104104
<ul>
105+
<li>v4.3<br>
106+
1.修复付费用户订阅题目展示<br>
107+
2.修复leetcode-cn.com登陆问题<br>
108+
</li>
109+
<li>v4.3<br>
110+
1.Fix subscription view<br>
111+
2.fix leetcode-cn.com login<br>
112+
</li>
113+
105114
<li>v4.2<br>
106115
1.增加代理<br>
107116
2.修复订阅题目展示<br>

src/com/shuzijun/leetcode/plugin/actions/LoginAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class LoginAction extends AbstractAsynAction {
2828
public void perform(AnActionEvent anActionEvent, Config config) {
2929

3030
if (StringUtils.isBlank(HttpClientUtils.getToken())) {
31-
HttpGet httpget = new HttpGet(URLUtils.getLeetcodeUrl());
31+
HttpGet httpget = new HttpGet(URLUtils.getLeetcodeVerify());
3232
CloseableHttpResponse response = HttpClientUtils.executeGet(httpget);
3333
httpget.abort();
3434
if (response == null) {

src/com/shuzijun/leetcode/plugin/manager/QuestionManager.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,17 @@ private static List<Question> parseQuestion(String str) {
192192
List<Question> questionList = new ArrayList<Question>();
193193

194194
if (StringUtils.isNotBlank(str)) {
195-
196-
JSONArray jsonArray = JSONObject.parseObject(str).getJSONArray("stat_status_pairs");
195+
JSONObject jsonObject = JSONObject.parseObject(str);
196+
Boolean isPremium = new Integer("1").equals(jsonObject.getInteger("frequency_high")); //Premium users display frequency
197+
JSONArray jsonArray = jsonObject.getJSONArray("stat_status_pairs");
197198
for (int i = 0; i < jsonArray.size(); i++) {
198199
JSONObject object = jsonArray.getJSONObject(i);
199200
Question question = new Question(object.getJSONObject("stat").getString("question__title"));
200201
question.setLeaf(Boolean.TRUE);
201202
question.setQuestionId(object.getJSONObject("stat").getString("question_id"));
202203
question.setFrontendQuestionId(object.getJSONObject("stat").getString("frontend_question_id"));
203204
try {
204-
if(object.getBoolean("paid_only")){
205+
if(object.getBoolean("paid_only") && !isPremium){
205206
question.setStatus(object.getBoolean("paid_only") ? "lock" : null);
206207
}else {
207208
question.setStatus(object.get("status") == null ? "" : object.getString("status"));
@@ -255,7 +256,9 @@ private static void translation(List<Question> questions) {
255256
translationMap.put(object.getJSONObject("question").getString("questionId"), object.getString("title"));
256257
}
257258
for (Question question : questions) {
258-
question.setTitle(translationMap.get(question.getQuestionId()));
259+
if(translationMap.containsKey(question.getQuestionId())){
260+
question.setTitle(translationMap.get(question.getQuestionId()));
261+
}
259262
}
260263
} else {
261264
logger.error("读取翻译内容为空");

src/com/shuzijun/leetcode/plugin/utils/HttpClientUtils.java

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public static void resetHttpclient() {
176176
e.printStackTrace();
177177
} finally {
178178
httpclient = null;
179+
context = null;
179180
}
180181
}
181182
}

src/com/shuzijun/leetcode/plugin/utils/URLUtils.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99
public class URLUtils {
1010

11-
public static final String leetcode="leetcode.com";
12-
public static final String leetcodecn="leetcode-cn.com";
11+
public static final String leetcode = "leetcode.com";
12+
public static final String leetcodecn = "leetcode-cn.com";
1313

1414
private static String leetcodeUrl = "https://";
1515
private static String leetcodeLogin = "/accounts/login/";
@@ -21,7 +21,7 @@ public class URLUtils {
2121
private static String leetcodeSubmissions = "/submissions/detail/";
2222
private static String leetcodeTags = "/problems/api/tags/";
2323
private static String leetcodeFavorites = "/problems/api/favorites/";
24-
24+
private static String leetcodeVerify = "/problemset/all/";
2525

2626
public static String getLeetcodeHost() {
2727
String host = PersistentConfig.getInstance().getConfig().getUrl();
@@ -71,6 +71,10 @@ public static String getLeetcodeFavorites() {
7171
return getLeetcodeUrl() + leetcodeFavorites;
7272
}
7373

74+
public static String getLeetcodeVerify() {
75+
return getLeetcodeUrl() + leetcodeVerify;
76+
}
77+
7478
public static String getDescContent() {
7579
if ("leetcode.com".equals(getLeetcodeHost())) {
7680
return "content";

0 commit comments

Comments
 (0)