21 changed files with 916 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# open-JSD-8171 |
||||
|
||||
JSD-8171 开源任务材料 |
||||
JSD-8171 开源任务材料\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.ws.cont</id> |
||||
<name><![CDATA[websocket控制报表展示]]></name> |
||||
<active>yes</active> |
||||
<version>1.0.5</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2020-07-31</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[控制报表展示]]></description> |
||||
<change-notes><![CDATA[ |
||||
]]></change-notes> |
||||
<lifecycle-monitor class="com.fr.plugin.WSLifeCycleMonitor"/> |
||||
<extra-decision> |
||||
<HttpHandlerProvider class="com.fr.plugin.WSDataHandlerProvider"/> |
||||
<URLAliasProvider class="com.fr.plugin.WSDataURLAliasBridge"/> |
||||
<EmbedRequestFilterProvider class="com.fr.plugin.InitSocketFilter"/> |
||||
</extra-decision> |
||||
<function-recorder class="com.fr.plugin.WSDataHandlerProvider"/> |
||||
</plugin> |
@ -0,0 +1,154 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractEmbedRequestFilterProvider; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.utils.SocketIOUitls; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.socketio.HandshakeData; |
||||
import com.fr.third.socketio.SocketIOClient; |
||||
import com.fr.third.socketio.SocketIOServer; |
||||
import io.netty.util.internal.PlatformDependent; |
||||
|
||||
import javax.servlet.FilterConfig; |
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.util.*; |
||||
|
||||
public class InitSocketFilter extends AbstractEmbedRequestFilterProvider { |
||||
|
||||
@Override |
||||
public void filter(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException { |
||||
|
||||
} |
||||
|
||||
public static List<SocketIOClient> ALL_CLIENT = Collections.synchronizedList(new ArrayList()); |
||||
public static Map<String, List<SocketIOClient>> ALL_DP_CLIENT = PlatformDependent.newConcurrentHashMap();//用户名和大屏的映射
|
||||
public static Map<String, List<SocketIOClient>> ALL_CONTROL_CLIENT = PlatformDependent.newConcurrentHashMap();//用户名和控制器的映射
|
||||
public static List<SocketIOClient> ALL_CONTROL = Collections.synchronizedList(new ArrayList()); |
||||
|
||||
public List<SocketIOClient> getCanControlDPByUserName(String userName) { |
||||
return ALL_DP_CLIENT.get(userName); |
||||
} |
||||
|
||||
private String getUserName(SocketIOClient client) { |
||||
HandshakeData handshakeData = client.getHandshakeData(); |
||||
Map<String, List<String>> urlParams = handshakeData.getUrlParams(); |
||||
List<String> userName = urlParams.get("userName"); |
||||
if (userName != null) { |
||||
if (!userName.isEmpty()) { |
||||
return userName.get(0); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private String getFrom(SocketIOClient client) { |
||||
HandshakeData handshakeData = client.getHandshakeData(); |
||||
Map<String, List<String>> urlParams = handshakeData.getUrlParams(); |
||||
List<String> from = urlParams.get("from"); |
||||
if (from != null) { |
||||
if (!from.isEmpty()) { |
||||
return from.get(0); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
private String getIp(SocketIOClient client) { |
||||
HandshakeData handshakeData = client.getHandshakeData(); |
||||
return handshakeData.getAddress().getAddress().getHostAddress(); |
||||
} |
||||
|
||||
SocketIOServer socketIOServer; |
||||
|
||||
@Override |
||||
public void init(FilterConfig filterConfig) { |
||||
super.init(filterConfig); |
||||
socketIOServer = SocketIOUitls.getSocketIOServer(); |
||||
if (socketIOServer != null) { |
||||
socketIOServer.getNamespace("/system").addEventListener("joinDP", String.class, (client, data, ackReq) -> { |
||||
ALL_CLIENT.add(client); |
||||
String userName = getUserName(client); |
||||
if (userName != null) { |
||||
List<SocketIOClient> socketIOClients = ALL_DP_CLIENT.get(userName); |
||||
if (socketIOClients != null) { |
||||
socketIOClients.add(client); |
||||
} else { |
||||
List list = Collections.synchronizedList(new ArrayList()); |
||||
list.add(client); |
||||
ALL_DP_CLIENT.put(userName, list); |
||||
} |
||||
} |
||||
String ip = getIp(client); |
||||
FineLoggerFactory.getLogger().info("{} 用户 ip :{} 加入大屏列表 ", userName, ip); |
||||
List<SocketIOClient> socketIOClients = ALL_CONTROL_CLIENT.get(userName); |
||||
if (socketIOClients != null) { |
||||
for (SocketIOClient socketIOClient : socketIOClients) { |
||||
JSONObject entries = new JSONObject(); |
||||
entries.put("ip", ip); |
||||
socketIOClient.sendEvent("dpJoin",entries); |
||||
} |
||||
} |
||||
FineLoggerFactory.getLogger().info("收到用户加入事件:{}", client); |
||||
}); |
||||
socketIOServer.getNamespace("/system").addEventListener("leaveDP", String.class, (client, data, ackReq) -> { |
||||
String userName = getUserName(client); |
||||
String ip = getIp(client); |
||||
ALL_CLIENT.remove(client); |
||||
List<SocketIOClient> socketIOClients = ALL_CONTROL_CLIENT.get(userName); |
||||
for (SocketIOClient socketIOClient : socketIOClients) { |
||||
JSONObject entries = new JSONObject(); |
||||
entries.put("ip", ip); |
||||
socketIOClient.sendEvent("dpLeave",entries); |
||||
} |
||||
FineLoggerFactory.getLogger().info("离开大屏:{}", client); |
||||
}); |
||||
socketIOServer.getNamespace("/system").addEventListener("joinControl", String.class, (client, data, ackReq) -> { |
||||
ALL_CLIENT.remove(client); |
||||
FineLoggerFactory.getLogger().info("收到用户加入事件:{}", client); |
||||
}); |
||||
socketIOServer.getNamespace("/system").addDisconnectListener((client) -> { |
||||
String userName = getUserName(client); |
||||
String ip = getIp(client); |
||||
FineLoggerFactory.getLogger().info("{} 用户 ip :{} 断开连接 ", userName, ip); |
||||
ALL_CLIENT.remove(client); |
||||
String from = getFrom(client); |
||||
if (StringUtils.isNotBlank(from)) { |
||||
//判断是否来自大屏
|
||||
if(StringUtils.equals("dp",from)){ |
||||
List<SocketIOClient> socketIOClients = ALL_DP_CLIENT.get(userName); |
||||
if (socketIOClients != null) { |
||||
socketIOClients.remove(client); |
||||
} |
||||
}else{ |
||||
//从控制端移除控制器
|
||||
ALL_CONTROL.remove(client); |
||||
} |
||||
} |
||||
}); |
||||
socketIOServer.getNamespace("/system").addEventListener("clickMessage", String.class, (client, data, ackReq) -> { |
||||
FineLoggerFactory.getLogger().info("收到点击事件:{}, data:{}", client, data); |
||||
//这里不要用socketIOServer直接getBroadcastOperations 这样没有带namespace 要用下面的
|
||||
String userName = getUserName(client); |
||||
List<SocketIOClient> socketIOClients = ALL_DP_CLIENT.get(userName); |
||||
if (socketIOClients != null) { |
||||
for (SocketIOClient socketIOClient : socketIOClients) { |
||||
socketIOClient.sendEvent("clickMessage", data); |
||||
} |
||||
} |
||||
// SocketIOServerFactory.getBroadcastOperations().sendEvent("clickMessage",data);
|
||||
}); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void destroy() { |
||||
super.destroy(); |
||||
if (socketIOServer != null) { |
||||
socketIOServer.getNamespace("/system").removeAllListeners("clickMessage"); |
||||
socketIOServer.getNamespace("/system").removeAllListeners("joinDP"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.config.*; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
|
||||
@Visualization(category = "Websocket配置") |
||||
public class WSConfig extends DefaultConfiguration { |
||||
|
||||
private static volatile WSConfig config = null; |
||||
|
||||
public static WSConfig getInstance() { |
||||
if (config == null) { |
||||
config = ConfigContext.getConfigInstance(WSConfig.class); |
||||
} |
||||
return config; |
||||
} |
||||
|
||||
@Identifier(value = "linkname", name = "数据链接名", description = "", status = Status.SHOW) |
||||
private Conf<String> linkname = Holders.simple("test"); |
||||
@Identifier(value = "secret", name = "对接接口秘钥", description = "", status = Status.SHOW) |
||||
private Conf<String> secret = Holders.simple("456789"); |
||||
|
||||
public String getLinkname() { |
||||
return linkname.get(); |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return secret.get(); |
||||
} |
||||
|
||||
public void setSecret(String secret) { |
||||
this.secret.set(secret); |
||||
} |
||||
|
||||
public void setLinkname(String linkname) { |
||||
this.linkname.set(linkname); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
WSConfig cloned = (WSConfig) super.clone(); |
||||
cloned.linkname = (Conf<String>) linkname.clone(); |
||||
cloned.secret = (Conf<String>) secret.clone(); |
||||
return cloned; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.decision.fun.HttpHandler; |
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
import com.fr.plugin.api.*; |
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.stable.fun.Authorize; |
||||
|
||||
@FunctionRecorder |
||||
@Authorize(callSignKey = "com.fr.plugin.ws.cont") |
||||
public class WSDataHandlerProvider extends AbstractHttpHandlerProvider { |
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public HttpHandler[] registerHandlers() { |
||||
return new HttpHandler[]{ |
||||
new ControlApi(), |
||||
new AddApi(), |
||||
new GetCatalogApi(), |
||||
new SwitchDataApi() |
||||
}; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractURLAliasProvider; |
||||
import com.fr.decision.webservice.url.alias.URLAlias; |
||||
import com.fr.decision.webservice.url.alias.URLAliasFactory; |
||||
|
||||
public class WSDataURLAliasBridge extends AbstractURLAliasProvider |
||||
{ |
||||
|
||||
@Override |
||||
public URLAlias[] registerAlias() { |
||||
return new URLAlias[]{ |
||||
URLAliasFactory.createPluginAlias("/tk/control", "/control", false), |
||||
URLAliasFactory.createPluginAlias("/tk/control/list", "/entityList", false), |
||||
URLAliasFactory.createPluginAlias("/tk/switch", "/switch", false), |
||||
URLAliasFactory.createPluginAlias("/td/alertdata", "/alertdata", true), |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.plugin.utils.SocketIOUitls; |
||||
import com.fr.third.socketio.SocketIOServer; |
||||
|
||||
public class WSLifeCycleMonitor extends AbstractPluginLifecycleMonitor { |
||||
|
||||
@Override |
||||
public void afterRun(PluginContext pluginContext) { |
||||
//WSConfig.getInstance();
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.plugin.api; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.utils.SocketIOUitls; |
||||
import com.fr.third.socketio.SocketIOClient; |
||||
import com.fr.third.socketio.SocketIOServer; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.socketio.SocketIOServerFactory; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Collection; |
||||
|
||||
public class AddApi extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/addWs"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
SocketIOServerFactory.getBroadcastOperations().sendEvent("clickMessage", "hahahaha"); |
||||
// DecisionStatusService.webSocketService().getAlias(username);
|
||||
|
||||
WebUtils.printAsString(httpServletResponse, "success"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.fr.plugin.api; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.v10.login.TokenResource; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.third.socketio.SocketIOClient; |
||||
import com.fr.third.socketio.protocol.Packet; |
||||
import com.fr.third.socketio.protocol.PacketType; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.socketio.SocketIOServerFactory; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Collection; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class ControlApi extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/control"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
Map<String, String> params = new HashMap<>(); |
||||
|
||||
params.put("fine_auth_token", TokenResource.COOKIE.getToken(httpServletRequest)); |
||||
params.put("fine_user_name", UserService.getInstance().getCurrentUserIdFromCookie(httpServletRequest)); |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
// 做认证通过的事情
|
||||
WebUtils.writeOutTemplate("/com/fr/plugin/control.html",httpServletResponse,params); |
||||
} else { |
||||
// 做认证未通过的事情
|
||||
WebUtils.printAsString(httpServletResponse,"请联系开发获取授权"); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,88 @@
|
||||
package com.fr.plugin.api; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.Response; |
||||
import com.fr.decision.webservice.bean.entry.EntryBean; |
||||
import com.fr.decision.webservice.v10.entry.EntryService; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.plugin.utils.JSONUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.socketio.SocketIOServerFactory; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
public class GetCatalogApi extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/entityList"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
String userId = UserService.getInstance().getCurrentUserIdFromCookie(httpServletRequest); |
||||
List<EntryBean> allEntries = EntryService.getInstance().getAllEntries(userId); |
||||
List<EntryBean> respEntries = new ArrayList<>(); |
||||
EntryBean root = null; |
||||
for (EntryBean allEntry : allEntries) { |
||||
//找到头部目录
|
||||
if (StringUtils.equals("decision-directory-root", allEntry.getpId()) && StringUtils.equals(allEntry.getText(), "大屏") && allEntry.getEntryType() == 3) { |
||||
root = allEntry; |
||||
break; |
||||
} |
||||
} |
||||
if (root != null) { |
||||
dgList(allEntries, respEntries, root); |
||||
} |
||||
EntryBean dhy=null; |
||||
for (EntryBean respEntry : respEntries) { |
||||
if (StringUtils.equals(respEntry.getText(),"导航页")) { |
||||
dhy=respEntry; |
||||
respEntries.remove(respEntry); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
Collections.sort(respEntries, (a, b) -> { |
||||
if (a.getSortIndex() > b.getSortIndex()) { |
||||
return 1; |
||||
} else if (a.getSortIndex() == b.getSortIndex()) { |
||||
return 0; |
||||
} else { |
||||
return -1; |
||||
} |
||||
}); |
||||
if (dhy != null) { |
||||
respEntries.add(0,dhy); |
||||
} |
||||
WebUtils.printAsString(httpServletResponse, JSONUtils.serialize(Response.ok(respEntries))); |
||||
} |
||||
|
||||
private void dgList(List<EntryBean> allEntries, List<EntryBean> respEntries, EntryBean root) { |
||||
for (EntryBean allEntry : allEntries) { |
||||
if (StringUtils.equals(root.getId(), allEntry.getpId())) { |
||||
if (allEntry.getEntryType() == 3) { |
||||
dgList(allEntries, respEntries, allEntry); |
||||
} else { |
||||
respEntries.add(allEntry); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.plugin.api; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.v10.login.TokenResource; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class SwitchDataApi extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/switch"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
Map<String, String> params = new HashMap<>(); |
||||
params.put("fine_auth_token", TokenResource.COOKIE.getToken(httpServletRequest)); |
||||
params.put("fine_user_name", UserService.getInstance().getCurrentUserIdFromCookie(httpServletRequest)); |
||||
if (PluginContexts.currentContext().isAvailable()) { |
||||
WebUtils.writeOutTemplate("/com/fr/plugin/switch.html",httpServletResponse,params); |
||||
// 做认证通过的事情
|
||||
} else { |
||||
WebUtils.printAsString(httpServletResponse,"请联系开发获取授权"); |
||||
// 做认证未通过的事情
|
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.third.fasterxml.jackson.core.JsonGenerationException; |
||||
import com.fr.third.fasterxml.jackson.databind.JsonMappingException; |
||||
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; |
||||
|
||||
import java.io.IOException; |
||||
import java.io.StringWriter; |
||||
import java.io.Writer; |
||||
|
||||
public class JSONUtils { |
||||
private static ObjectMapper objectMapper = new ObjectMapper(); |
||||
|
||||
public static String serialize(Object object) { |
||||
Writer write = new StringWriter(); |
||||
try { |
||||
objectMapper.writeValue(write, object); |
||||
} catch (JsonGenerationException e) { |
||||
} catch (JsonMappingException e) { |
||||
} catch (IOException e) { |
||||
} |
||||
return write.toString(); |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.third.socketio.SocketIOServer; |
||||
import com.fr.web.socketio.SocketIOServerFactory; |
||||
|
||||
import java.lang.reflect.Field; |
||||
|
||||
public class SocketIOUitls { |
||||
public static SocketIOServer getSocketIOServer(){ |
||||
|
||||
try { |
||||
Field server = SocketIOServerFactory.class.getDeclaredField("server"); |
||||
server.setAccessible(true); |
||||
Object o = server.get(SocketIOServerFactory.class); |
||||
return (SocketIOServer) o; |
||||
} catch (NoSuchFieldException | IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>控制页</title> |
||||
<!-- 视图窗口,移动端特属的标签。 --> |
||||
<meta name="viewport" |
||||
content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
||||
<!-- 是否启动webapp功能,会删除默认的苹果工具栏和菜单栏。 --> |
||||
<meta name="apple-mobile-web-app-capable" content="yes"/> |
||||
<!-- 这个主要是根据实际的页面设计的主体色为搭配来进行设置。 --> |
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/> |
||||
<!-- 忽略页面中的数字识别为电话号码,email识别 --> |
||||
<meta name="format-detection" content="telephone=no, email=no"/> |
||||
<!-- 启用360浏览器的极速模式(webkit) --> |
||||
<meta name="renderer" content="webkit"> |
||||
<!-- 避免IE使用兼容模式 --> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 --> |
||||
<meta name="HandheldFriendly" content="true"> |
||||
<!-- 微软的老式浏览器 --> |
||||
<meta name="MobileOptimized" content="320"> |
||||
<!-- uc强制竖屏 --> |
||||
<meta name="screen-orientation" content="portrait"> |
||||
<!-- QQ强制竖屏 --> |
||||
<meta name="x5-orientation" content="portrait"> |
||||
<!-- UC强制全屏 --> |
||||
<meta name="full-screen" content="yes"> |
||||
<!-- QQ强制全屏 --> |
||||
<meta name="x5-fullscreen" content="true"> |
||||
<!-- UC应用模式 --> |
||||
<meta name="browsermode" content="application"> |
||||
<!-- QQ应用模式 --> |
||||
<meta name="x5-page-mode" content="app"> |
||||
<!-- windows phone 点击无高光 --> |
||||
<meta name="msapplication-tap-highlight" content="no"> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/web/socketio/dist/socket.io.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/web/ui/fineui.min.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/web/ui/materials.min.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/plugin/js/control.js&type=plain&parser=dynamic"></script> |
||||
|
||||
<link rel="stylesheet" type="text/css" |
||||
href="${fineServletURL}/file?path=/com/fr/web/ui/fineui.min.css&type=plain&parser=plain"/> |
||||
<style type="text/css"> |
||||
html, body, .corl { |
||||
width: 100%; |
||||
height: 100%; |
||||
} |
||||
|
||||
* { |
||||
padding: 0; |
||||
margin: 0; |
||||
} |
||||
|
||||
.corl { |
||||
background-size: 100% 100%; |
||||
background-repeat: no-repeat; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<div id="app"></div> |
||||
</body> |
||||
<script type="text/javascript"> |
||||
var token = "${fine_auth_token}"; |
||||
var userName = "${fine_user_name}"; |
||||
var baseUrl = "${fineServletURL}/url/"; |
||||
var Lists = []; |
||||
var t = window.location.protocol + "//" + window.location.hostname |
||||
var config = BI.extend({ |
||||
requestUrl: t, |
||||
query: { |
||||
token: token, |
||||
from: "control", |
||||
userName: userName |
||||
} |
||||
}, { |
||||
webSocketContextName: "/socket.io", |
||||
webSocketNameSpace: "/system", |
||||
webSocketPort: [38888, 39888, 38889], |
||||
webSocketProtocol: "plain" |
||||
}); |
||||
|
||||
var socket = window.scocket = BI.initSocket(config, function (e) { |
||||
console.info("连接socket 成功"); |
||||
if (socket) { |
||||
socket.emit("joinControl", "success") |
||||
getCanControlViews(); |
||||
socket.on("connect_error", function () { |
||||
console.info("链接异常终止"); |
||||
window.socket = null; |
||||
}); |
||||
} |
||||
}) |
||||
$(document).ready(function () { |
||||
$("#sendBtn").click(function () { |
||||
var text = $("#textVal").val(); |
||||
if (socket) { |
||||
console.info("发送成功:", text) |
||||
socket.emit('clickMessage', text); |
||||
} |
||||
}) |
||||
|
||||
}) |
||||
|
||||
|
||||
function initDoms(list) { |
||||
BI.createWidget({ |
||||
lists: list, |
||||
type: "dec.app", |
||||
element: "#app" |
||||
}); |
||||
} |
||||
|
||||
// getCanControlViews(); |
||||
|
||||
function getCanControlViews() { |
||||
$.get(baseUrl + "tk/control/list", {}, function (data) { |
||||
Lists = data; |
||||
initDoms(data.data) |
||||
}, "json") |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 54 KiB |
@ -0,0 +1,87 @@
|
||||
; |
||||
(function () { |
||||
var baseUrl = "${fineServletURL}"; |
||||
var e = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "corl", |
||||
css: { |
||||
backgroundImage: "url(" + baseUrl + "/resources?path=com/fr/plugin/img/background.png)", |
||||
}, |
||||
}, |
||||
createItems: function () { |
||||
return BI.map(this.options.lists, function (i, v) { |
||||
return { |
||||
type: "bi.send.item", |
||||
item: v, |
||||
ref: function (e) { |
||||
var item = e; |
||||
$(e.element).click(function () { |
||||
if (window.socket) { |
||||
BI.Msg.toast("切换"+item.options.item.text, { |
||||
level: "success" |
||||
}); |
||||
socket.emit('clickMessage', item.options.item.id); |
||||
} else { |
||||
alert("未连接到大屏请刷新网页") |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
}, |
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.default", |
||||
scrolly:true, |
||||
scrollable:true, |
||||
css: { |
||||
padding: 130 |
||||
}, |
||||
items: [{ |
||||
type: "bi.left", |
||||
|
||||
vgap: 30, |
||||
hgap: 30, |
||||
items: this.createItems() |
||||
}] |
||||
} |
||||
}, |
||||
}); |
||||
BI.shortcut("dec.app", e) |
||||
}()); |
||||
(function () { |
||||
var baseUrl = "${fineServletURL}"; |
||||
var e = BI.inherit(BI.Widget, { |
||||
props: { |
||||
css: { |
||||
width: 300, |
||||
height: 87 |
||||
} |
||||
}, |
||||
watch: {}, |
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.center_adapt", |
||||
css: { |
||||
backgroundSize: "100%", |
||||
backgroundRepeat: "no-repeat", |
||||
backgroundImage: "url(" + baseUrl + "/resources?path=com/fr/plugin/img/item.png)", |
||||
}, |
||||
items: [ |
||||
{ |
||||
type: "bi.label", |
||||
css: { |
||||
fontSize: "1.345rem", |
||||
color: "#fff" |
||||
}, |
||||
text: self.options.item.text |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
}); |
||||
BI.shortcut("bi.send.item", e) |
||||
})(); |
@ -0,0 +1,57 @@
|
||||
; |
||||
var baseUrl = "${fineServletURL}/url/"; |
||||
(function () { |
||||
var e = BI.inherit(BI.Widget, { |
||||
watch: {}, |
||||
render: function () { |
||||
var self = this; |
||||
return { |
||||
type: "bi.absolute", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.tab", |
||||
single: !0, |
||||
cardCreator: BI.bind(this._createCard, this), |
||||
showIndex: 0, |
||||
ref: function (e) { |
||||
window.tab=e; |
||||
self.tab = e |
||||
} |
||||
}, |
||||
left:0, |
||||
right:0, |
||||
top:0, |
||||
bottom:0 |
||||
}] |
||||
} |
||||
}, |
||||
_createCard: function (id) { |
||||
var self = this; |
||||
var item = BI.find(Lists.data, function (i, v) { |
||||
return v.id === id; |
||||
}) |
||||
if(item===undefined){ |
||||
if (Lists.data.length > 0) { |
||||
item=Lists.data[0]; |
||||
} |
||||
} |
||||
if(item){ |
||||
var url=rootUrl + "/v10/entry/access/" + item.id |
||||
if(item.entryType ===5){ |
||||
url=item.path |
||||
} |
||||
return { |
||||
type: "bi.iframe", |
||||
src: url |
||||
} |
||||
}else{ |
||||
return { |
||||
type: "bi.iframe", |
||||
} |
||||
} |
||||
}, |
||||
mounted: function () { |
||||
} |
||||
}); |
||||
BI.shortcut("dec.app", e) |
||||
}()); |
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>切换页</title> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/web/socketio/dist/socket.io.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/web/ui/fineui.min.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/web/ui/materials.min.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="${fineServletURL}/file?path=/com/fr/plugin/js/dp.js&type=plain&parser=plain"></script> |
||||
|
||||
|
||||
</head> |
||||
<body> |
||||
<div id="app"></div> |
||||
</body> |
||||
<script type="text/javascript"> |
||||
var token = "${fine_auth_token}"; |
||||
var userName = "${fine_user_name}"; |
||||
var baseUrl = "${fineServletURL}/url/"; |
||||
var rootUrl = "${fineServletURL}"; |
||||
var Lists = []; |
||||
// var token =BI.UUID(); |
||||
var t = window.location.protocol + "//" + window.location.hostname |
||||
var config = BI.extend({ |
||||
requestUrl: t, |
||||
query: { |
||||
token: token, |
||||
from: "dp", |
||||
userName: userName |
||||
} |
||||
}, { |
||||
webSocketContextName: "/socket.io", |
||||
webSocketNameSpace: "/system", |
||||
webSocketPort: [38888, 39888, 38889], |
||||
webSocketProtocol: "plain" |
||||
}); |
||||
|
||||
var socket = window.scocket = BI.initSocket(config, function (e) { |
||||
console.info("连接socket 成功"); |
||||
if (socket) { |
||||
socket.emit("joinDP", "success") |
||||
getCanControlViews(); |
||||
console.info("发送加入房间 成功"); |
||||
} |
||||
}) |
||||
$(document).ready(function () { |
||||
$("#sendBtn").click(function () { |
||||
var text = $("#textVal").val(); |
||||
if (socket) { |
||||
console.info("发送成功:", text) |
||||
socket.emit('clickMessage', text); |
||||
} |
||||
}) |
||||
}) |
||||
socket.on('clickMessage', function (id) { |
||||
if(window.tab){ |
||||
window.tab.setSelect(id) |
||||
} |
||||
}); |
||||
socket.on("connect_error", function () { |
||||
alert("链接异常终止"); |
||||
}); |
||||
|
||||
function initDom() { |
||||
BI.createWidget({ |
||||
type: "dec.app", |
||||
element: "#app" |
||||
}); |
||||
} |
||||
|
||||
function getCanControlViews() { |
||||
$.get(baseUrl + "tk/control/list", {}, function (data) { |
||||
Lists = data; |
||||
console.info("数据加载成功:", data); |
||||
initDom(); |
||||
},"json") |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue