diff --git a/doc/leetcode-editor-V4.3.zip b/doc/leetcode-editor-V4.3.zip index 5d2dfdf3..bc3267f1 100644 Binary files a/doc/leetcode-editor-V4.3.zip and b/doc/leetcode-editor-V4.3.zip differ diff --git a/doc/leetcode-editor.zip b/doc/leetcode-editor.zip index ec96b6f3..bc3267f1 100644 Binary files a/doc/leetcode-editor.zip and b/doc/leetcode-editor.zip differ diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 1e5464b9..831a8996 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -105,10 +105,12 @@ <li>v4.3<br> 1.修复付费用户订阅题目展示<br> 2.修复leetcode-cn.com登陆问题<br> + 3.增加跳转到题目对应的leetcode官网地址的功能 @zzdcon<br> </li> <li>v4.3<br> 1.Fix subscription view<br> 2.fix leetcode-cn.com login<br> + 3.add a new feature of browsing certain question on the website of leetcode @zzdcon<br> </li> <li>v4.2<br> @@ -274,6 +276,11 @@ <action id="leetcode.OpenAction" class="com.shuzijun.leetcode.plugin.actions.OpenAction" text="open question" description="open question" icon="AllIcons.Actions.Annotate"> </action> + + <action id="leetcode.OpenInWebAction" class="com.shuzijun.leetcode.plugin.actions.OpenInWebAction" + text="open in web" description="open in web" icon="AllIcons.Actions.MoveTo2"> + </action> + <action id="leetcode.SubmitAction" class="com.shuzijun.leetcode.plugin.actions.SubmitAction" text="Submit" description="Submit" icon="AllIcons.Actions.StepOut"> </action> @@ -311,6 +318,7 @@ <group id="leetcode.NavigatorActionsMenu"> <reference id="leetcode.OpenAction"/> + <reference id="leetcode.OpenInWebAction"/> <separator/> <reference id="leetcode.SubmitAction"/> <reference id="leetcode.SubmissionsAction"/> diff --git a/src/com/shuzijun/leetcode/plugin/actions/OpenInWebAction.java b/src/com/shuzijun/leetcode/plugin/actions/OpenInWebAction.java new file mode 100644 index 00000000..f6fd3bed --- /dev/null +++ b/src/com/shuzijun/leetcode/plugin/actions/OpenInWebAction.java @@ -0,0 +1,23 @@ +package com.shuzijun.leetcode.plugin.actions; + +import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.shuzijun.leetcode.plugin.model.Config; +import com.shuzijun.leetcode.plugin.model.Question; +import com.shuzijun.leetcode.plugin.utils.DataKeys; +import com.shuzijun.leetcode.plugin.utils.URLUtils; + +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; + +/** + * @author zzdcon + */ +public class OpenInWebAction extends AbstractAction { + @Override public void actionPerformed(AnActionEvent anActionEvent, Config config) { + JTree tree = anActionEvent.getData(DataKeys.LEETCODE_PROJECTS_TREE); + DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + Question question = (Question) note.getUserObject(); + BrowserUtil.browse(URLUtils.getLeetcodeProblems()+question.getTitleSlug()); + } +} diff --git a/src/com/shuzijun/leetcode/plugin/manager/QuestionManager.java b/src/com/shuzijun/leetcode/plugin/manager/QuestionManager.java index 85a37fa4..9d0a6628 100644 --- a/src/com/shuzijun/leetcode/plugin/manager/QuestionManager.java +++ b/src/com/shuzijun/leetcode/plugin/manager/QuestionManager.java @@ -193,7 +193,7 @@ private static List<Question> parseQuestion(String str) { if (StringUtils.isNotBlank(str)) { JSONObject jsonObject = JSONObject.parseObject(str); - Boolean isPremium = new Integer("1").equals(jsonObject.getInteger("frequency_high")); //Premium users display frequency + Boolean isPremium = new Integer("0").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); @@ -202,7 +202,7 @@ private static List<Question> parseQuestion(String str) { question.setQuestionId(object.getJSONObject("stat").getString("question_id")); question.setFrontendQuestionId(object.getJSONObject("stat").getString("frontend_question_id")); try { - if(object.getBoolean("paid_only") && !isPremium){ + if(object.getBoolean("paid_only") && isPremium){ question.setStatus(object.getBoolean("paid_only") ? "lock" : null); }else { question.setStatus(object.get("status") == null ? "" : object.getString("status"));