From 3d73fade2ddd1d5a69298a7042db6e94647aaf43 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 18 May 2016 19:21:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=88=86=E7=B1=BBapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 10 ++++++ .../exe/GetPluginCategoriesExecutor.java | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 25d9c20cf5..5c7c2e8a37 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -243,6 +243,16 @@ public class PluginWebBridge { new Thread(task).start(); } + /** + * 在线获取插件分类 + * + * @param callback 回调函数 + */ + public void getPluginCategories(final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new GetPluginCategoriesExecutor()); + new Thread(task).start(); + } + /** * 展示一个重启的对话框(少用,莫名其妙会有bug) * diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java new file mode 100644 index 0000000000..81bdb8f8c7 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java @@ -0,0 +1,35 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.Process; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; + +/** + * Created by vito on 16/5/16. + */ +public class GetPluginCategoriesExecutor implements Executor { + private String result = "[]"; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.category")); + result = httpClient.getResponseText(); + } + } + }; + } +}