onlyxx
4 years ago
commit
1459cf0340
15 changed files with 320 additions and 0 deletions
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project> |
||||
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||
<echo message="加密文件"/> |
||||
<echo message="${projectDir}"/> |
||||
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||
<classpath refid="compile.classpath"/> |
||||
</taskdef> |
||||
<pretreatment baseDir="${projectDir}"/> |
||||
</target> |
||||
<target name="compile_plain_javas" depends="copyFiles"> |
||||
</target> |
||||
</project> |
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.fineui.lean</id> |
||||
<name><![CDATA[学习fineUI]]></name> |
||||
<active>yes</active> |
||||
<version>1.0</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>author</vendor> |
||||
<description><![CDATA[学习fineUI]]></description> |
||||
<change-notes><![CDATA[ |
||||
[2018-08-01]修改一点问题。<br/> |
||||
[2018-07-31]初始化插件。<br/> |
||||
]]></change-notes> |
||||
<extra-decision> |
||||
<HttpHandlerProvider class="com.fr.plugin.LeanHttpProvider" /> |
||||
<URLAliasProvider class="com.fr.plugin.MyURLAliasProvider"/> |
||||
</extra-decision> |
||||
<function-recorder class="com.fr.plugin.MyURLAliasProvider"/> |
||||
</plugin> |
@ -0,0 +1,50 @@
|
||||
package com.fr.plugin; |
||||
|
||||
|
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.Filter; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
|
||||
@FunctionRecorder |
||||
public class LeanFileDef extends Component { |
||||
public static final LeanFileDef KEY = new LeanFileDef(); |
||||
private LeanFileDef(){} |
||||
/** |
||||
* 返回需要引入的JS脚本路径 |
||||
* @param client 请求客户端描述 |
||||
* @return JS脚本路径 |
||||
*/ |
||||
public ScriptPath script( RequestClient client ) { |
||||
//如果不需要就直接返回 ScriptPath.EMPTY
|
||||
return ScriptPath.build("com/fr/plugin/web/lean.js"); |
||||
} |
||||
|
||||
/** |
||||
* 返回需要引入的CSS样式路径 |
||||
* @param client 请求客户端描述 |
||||
* @return CSS样式路径 |
||||
*/ |
||||
public StylePath style( RequestClient client ) { |
||||
//如果不需要就直接返回 StylePath.EMPTY;
|
||||
return StylePath.build("com/fr/plugin/web/lean.css"); |
||||
} |
||||
|
||||
/** |
||||
* 通过给定的资源过滤器控制是否加载这个资源 |
||||
* @return 资源过滤器 |
||||
*/ |
||||
@ExecuteFunctionRecord |
||||
public Filter filter() { |
||||
return new Filter(){ |
||||
@Override |
||||
public boolean accept() { |
||||
//任何情况下我们都在平台组件加载时加载我们的组件
|
||||
return true; |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.decision.fun.HttpHandler; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.web.LoginComponent; |
||||
import com.fr.decision.webservice.utils.WebServiceUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.Browser; |
||||
import com.fr.web.struct.AtomBuilder; |
||||
import com.fr.web.struct.PathGroup; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.HashMap; |
||||
//
|
||||
public class LeanHttpHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
//如果返回null表示 支持任意类型
|
||||
//return RequestMethod.GET
|
||||
//return RequestMethod.POST
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/leanFineUI"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
//这里要和注册短url那儿一致
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
String html = WebServiceUtils.parseWebPageResourceSafe("com/fr/plugin/web/lean.html",new HashMap<>()); |
||||
WebUtils.printAsString(response, html); |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.decision.fun.HttpHandler; |
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
|
||||
public class LeanHttpProvider extends AbstractHttpHandlerProvider { |
||||
@Override |
||||
public HttpHandler[] registerHandlers() { |
||||
return new HttpHandler[]{ |
||||
new LeanHttpHandler() |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fr.plugin; |
||||
|
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.web.struct.Atom; |
||||
|
||||
public class LeanJSCSSBridge extends AbstractWebResourceProvider { |
||||
@Override |
||||
public Atom attach() { |
||||
//在平台主组件加载时添加我们自己的组件
|
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
//我们自己要引入的组件
|
||||
return LeanFileDef.KEY; |
||||
} |
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.fr.plugin; |
||||
|
||||
public class MyFunctionConstants { |
||||
|
||||
public static final String PLUGIN_ID = "com.fr.plugin.fineui.lean"; |
||||
} |
@ -0,0 +1,16 @@
|
||||
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; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
|
||||
@FunctionRecorder |
||||
public class MyURLAliasProvider extends AbstractURLAliasProvider { |
||||
@Override |
||||
public URLAlias[] registerAlias() { |
||||
return new URLAlias[]{ |
||||
URLAliasFactory.createPluginAlias("/leanFineUI123","/leanFineUI",true) |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1 @@
|
||||
Plugin-Test_Function_Abs=Test ABS |
@ -0,0 +1 @@
|
||||
Plugin-Test_Function_Abs=测试ABS函数 |
@ -0,0 +1,138 @@
|
||||
<!doctype html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<meta name="viewport" |
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> |
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> |
||||
<title>学习FINE UI工具页</title> |
||||
<!--引入官方 css文件--> |
||||
|
||||
<link rel="stylesheet" type="text/css" |
||||
href="/webroot/decision/file?path=/com/fr/web/ui/fineui.min.css&type=plain&parser=plain"/> |
||||
<link rel="stylesheet" type="text/css" |
||||
href="https://fanruan.design/markdown/lib/codemirror/codemirror.min.css"/> |
||||
<style> |
||||
.CodeMirror { |
||||
height: 100%; |
||||
} |
||||
|
||||
#lean { |
||||
width: 49%; |
||||
height: 100%; |
||||
border: 1px solid; |
||||
position: absolute; |
||||
left: 0 |
||||
} |
||||
|
||||
#editAre { |
||||
width: 49%; |
||||
height: 100%; |
||||
border: 1px solid; |
||||
position: absolute; |
||||
right: 0 |
||||
} |
||||
|
||||
#editor { |
||||
width: 100%; |
||||
height: 100% |
||||
} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<div id="lean"> |
||||
</div> |
||||
${somea} |
||||
<div id="editAre"> |
||||
<textarea id="editor"> |
||||
BI.createWidget({ |
||||
type: "bi.label", |
||||
text: "测试文本" |
||||
}) |
||||
</textarea> |
||||
</div> |
||||
</body> |
||||
|
||||
<!-- 引入官方的js--> |
||||
<script type="text/javascript" |
||||
src="/webroot/decision/file?path=/com/fr/web/ui/fineui.min.js&type=plain&parser=plain"></script> |
||||
<script type="text/javascript" |
||||
src="https://fanruan.design/markdown/lib/codemirror/codemirror.min.js"></script> |
||||
<script id="markdown-lib-codemirror-modes-min" type="text/javascript" |
||||
src="https://fanruan.design/markdown/lib/codemirror/modes.min.js"></script> |
||||
<script id="markdown-lib-prettify-min" type="text/javascript" |
||||
src="https://fanruan.design/markdown/lib/prettify.min.js"></script> |
||||
|
||||
<!-- 写自己的js--> |
||||
<script> |
||||
var editor = document.getElementById("editor"); |
||||
var lean = document.getElementById("lean"); |
||||
var codeEditor = null; |
||||
init(); |
||||
|
||||
function _runCode(code) { |
||||
code = code.replace(/^BI.createWidget|[^=]\sBI.createWidget/, "return BI.createWidget"); |
||||
code = "function(){" + code + "}()"; |
||||
try { |
||||
var widget = new Function("return " + code)(); // eslint-disable-line |
||||
return widget; |
||||
} catch (e) { |
||||
return false; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
function change() { |
||||
var val = codeEditor.getValue(); |
||||
var widget = _runCode(val); |
||||
if (widget) { |
||||
removeAllChild() |
||||
lean.append(widget.element[0]); |
||||
widget._isRoot = true; |
||||
widget._mount(); |
||||
} |
||||
} |
||||
|
||||
function init() { |
||||
codeEditor = CodeMirror.fromTextArea(editor, { |
||||
mode: "javascript", |
||||
value: editor.value, |
||||
// lineNumbers: true, |
||||
lineWrapping: true, |
||||
tabSize: 4, |
||||
dragDrop: false, |
||||
// autofocus: true, |
||||
autoCloseTags: true, |
||||
readOnly: false, |
||||
indentUnit: 4, |
||||
foldGutter: false, |
||||
// gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], |
||||
matchBrackets: true, |
||||
indentWithTabs: true, |
||||
// styleActiveLine: true, |
||||
// styleSelectedText: true, |
||||
autoCloseBrackets: true |
||||
// showTrailingSpace: true |
||||
// highlightSelectionMatches: { showToken: /\w/ } |
||||
}); |
||||
var timer; |
||||
codeEditor.on("change", function (_cm, changeObj) { |
||||
timer = setTimeout(function () { |
||||
clearTimeout(timer); |
||||
change(); |
||||
timer = null; |
||||
}, 300); |
||||
}); |
||||
change() |
||||
} |
||||
|
||||
function removeAllChild() { |
||||
var div = document.getElementById("lean"); |
||||
while (div.hasChildNodes()) //当div下还存在子节点时 循环继续 |
||||
{ |
||||
div.removeChild(div.firstChild); |
||||
} |
||||
} |
||||
</script> |
||||
</html> |
Loading…
Reference in new issue