Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #41

Merged
merged 3 commits into from
Aug 5, 2019
Merged

Dev #41

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/leetcode-editor-V4.3.zip
Binary file not shown.
11 changes: 10 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>leetcode-editor</id>
<name>leetcode editor</name>
<version>4.2</version>
<version>4.3</version>
<vendor email="[email protected]" url="https://github.com/shuzijun/idea-leetcode-plugin">shuzijun</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -102,6 +102,15 @@

<change-notes><![CDATA[
<ul>
<li>v4.3<br>
1.修复付费用户订阅题目展示<br>
2.修复leetcode-cn.com登陆问题<br>
</li>
<li>v4.3<br>
1.Fix subscription view<br>
2.fix leetcode-cn.com login<br>
</li>

<li>v4.2<br>
1.增加代理<br>
2.修复订阅题目展示<br>
Expand Down
2 changes: 1 addition & 1 deletion src/com/shuzijun/leetcode/plugin/actions/LoginAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class LoginAction extends AbstractAsynAction {
public void perform(AnActionEvent anActionEvent, Config config) {

if (StringUtils.isBlank(HttpClientUtils.getToken())) {
HttpGet httpget = new HttpGet(URLUtils.getLeetcodeUrl());
HttpGet httpget = new HttpGet(URLUtils.getLeetcodeVerify());
CloseableHttpResponse response = HttpClientUtils.executeGet(httpget);
httpget.abort();
if (response == null) {
Expand Down
11 changes: 7 additions & 4 deletions src/com/shuzijun/leetcode/plugin/manager/QuestionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,17 @@ private static List<Question> parseQuestion(String str) {
List<Question> questionList = new ArrayList<Question>();

if (StringUtils.isNotBlank(str)) {

JSONArray jsonArray = JSONObject.parseObject(str).getJSONArray("stat_status_pairs");
JSONObject jsonObject = JSONObject.parseObject(str);
Boolean isPremium = new Integer("1").equals(jsonObject.getInteger("frequency_high")); //Premium users display frequency
JSONArray jsonArray = jsonObject.getJSONArray("stat_status_pairs");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject object = jsonArray.getJSONObject(i);
Question question = new Question(object.getJSONObject("stat").getString("question__title"));
question.setLeaf(Boolean.TRUE);
question.setQuestionId(object.getJSONObject("stat").getString("question_id"));
question.setFrontendQuestionId(object.getJSONObject("stat").getString("frontend_question_id"));
try {
if(object.getBoolean("paid_only")){
if(object.getBoolean("paid_only") && !isPremium){
question.setStatus(object.getBoolean("paid_only") ? "lock" : null);
}else {
question.setStatus(object.get("status") == null ? "" : object.getString("status"));
Expand Down Expand Up @@ -255,7 +256,9 @@ private static void translation(List<Question> questions) {
translationMap.put(object.getJSONObject("question").getString("questionId"), object.getString("title"));
}
for (Question question : questions) {
question.setTitle(translationMap.get(question.getQuestionId()));
if(translationMap.containsKey(question.getQuestionId())){
question.setTitle(translationMap.get(question.getQuestionId()));
}
}
} else {
logger.error("读取翻译内容为空");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public static void resetHttpclient() {
e.printStackTrace();
} finally {
httpclient = null;
context = null;
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/com/shuzijun/leetcode/plugin/utils/URLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/
public class URLUtils {

public static final String leetcode="leetcode.com";
public static final String leetcodecn="leetcode-cn.com";
public static final String leetcode = "leetcode.com";
public static final String leetcodecn = "leetcode-cn.com";

private static String leetcodeUrl = "https://";
private static String leetcodeLogin = "/accounts/login/";
Expand All @@ -21,7 +21,7 @@ public class URLUtils {
private static String leetcodeSubmissions = "/submissions/detail/";
private static String leetcodeTags = "/problems/api/tags/";
private static String leetcodeFavorites = "/problems/api/favorites/";

private static String leetcodeVerify = "/problemset/all/";

public static String getLeetcodeHost() {
String host = PersistentConfig.getInstance().getConfig().getUrl();
Expand Down Expand Up @@ -71,6 +71,10 @@ public static String getLeetcodeFavorites() {
return getLeetcodeUrl() + leetcodeFavorites;
}

public static String getLeetcodeVerify() {
return getLeetcodeUrl() + leetcodeVerify;
}

public static String getDescContent() {
if ("leetcode.com".equals(getLeetcodeHost())) {
return "content";
Expand Down