Skip to content

Commit 4486cfe

Browse files
authored
Merge pull request #45 from shuzijun/dev
Dev
2 parents 4a419f4 + e15039d commit 4486cfe

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

doc/leetcode-editor-V4.3.zip

1.1 KB
Binary file not shown.

doc/leetcode-editor.zip

6.37 KB
Binary file not shown.

resources/META-INF/plugin.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@
105105
<li>v4.3<br>
106106
1.修复付费用户订阅题目展示<br>
107107
2.修复leetcode-cn.com登陆问题<br>
108+
3.增加跳转到题目对应的leetcode官网地址的功能 @zzdcon<br>
108109
</li>
109110
<li>v4.3<br>
110111
1.Fix subscription view<br>
111112
2.fix leetcode-cn.com login<br>
113+
3.add a new feature of browsing certain question on the website of leetcode @zzdcon<br>
112114
</li>
113115
114116
<li>v4.2<br>
@@ -274,6 +276,11 @@
274276
<action id="leetcode.OpenAction" class="com.shuzijun.leetcode.plugin.actions.OpenAction"
275277
text="open question" description="open question" icon="AllIcons.Actions.Annotate">
276278
</action>
279+
280+
<action id="leetcode.OpenInWebAction" class="com.shuzijun.leetcode.plugin.actions.OpenInWebAction"
281+
text="open in web" description="open in web" icon="AllIcons.Actions.MoveTo2">
282+
</action>
283+
277284
<action id="leetcode.SubmitAction" class="com.shuzijun.leetcode.plugin.actions.SubmitAction"
278285
text="Submit" description="Submit" icon="AllIcons.Actions.StepOut">
279286
</action>
@@ -311,6 +318,7 @@
311318

312319
<group id="leetcode.NavigatorActionsMenu">
313320
<reference id="leetcode.OpenAction"/>
321+
<reference id="leetcode.OpenInWebAction"/>
314322
<separator/>
315323
<reference id="leetcode.SubmitAction"/>
316324
<reference id="leetcode.SubmissionsAction"/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.shuzijun.leetcode.plugin.actions;
2+
3+
import com.intellij.ide.BrowserUtil;
4+
import com.intellij.openapi.actionSystem.AnActionEvent;
5+
import com.shuzijun.leetcode.plugin.model.Config;
6+
import com.shuzijun.leetcode.plugin.model.Question;
7+
import com.shuzijun.leetcode.plugin.utils.DataKeys;
8+
import com.shuzijun.leetcode.plugin.utils.URLUtils;
9+
10+
import javax.swing.*;
11+
import javax.swing.tree.DefaultMutableTreeNode;
12+
13+
/**
14+
* @author zzdcon
15+
*/
16+
public class OpenInWebAction extends AbstractAction {
17+
@Override public void actionPerformed(AnActionEvent anActionEvent, Config config) {
18+
JTree tree = anActionEvent.getData(DataKeys.LEETCODE_PROJECTS_TREE);
19+
DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
20+
Question question = (Question) note.getUserObject();
21+
BrowserUtil.browse(URLUtils.getLeetcodeProblems()+question.getTitleSlug());
22+
}
23+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private static List<Question> parseQuestion(String str) {
193193

194194
if (StringUtils.isNotBlank(str)) {
195195
JSONObject jsonObject = JSONObject.parseObject(str);
196-
Boolean isPremium = new Integer("1").equals(jsonObject.getInteger("frequency_high")); //Premium users display frequency
196+
Boolean isPremium = new Integer("0").equals(jsonObject.getInteger("frequency_high")); //Premium users display frequency
197197
JSONArray jsonArray = jsonObject.getJSONArray("stat_status_pairs");
198198
for (int i = 0; i < jsonArray.size(); i++) {
199199
JSONObject object = jsonArray.getJSONObject(i);
@@ -202,7 +202,7 @@ private static List<Question> parseQuestion(String str) {
202202
question.setQuestionId(object.getJSONObject("stat").getString("question_id"));
203203
question.setFrontendQuestionId(object.getJSONObject("stat").getString("frontend_question_id"));
204204
try {
205-
if(object.getBoolean("paid_only") && !isPremium){
205+
if(object.getBoolean("paid_only") && isPremium){
206206
question.setStatus(object.getBoolean("paid_only") ? "lock" : null);
207207
}else {
208208
question.setStatus(object.get("status") == null ? "" : object.getString("status"));

0 commit comments

Comments
 (0)