onlyxx
4 years ago
commit
bfa0246528
13 changed files with 341 additions and 0 deletions
@ -0,0 +1,127 @@
|
||||
|
||||
apply plugin: 'java' |
||||
|
||||
|
||||
ext { |
||||
/** |
||||
* 项目中依赖的jar的路径 |
||||
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||
*/ |
||||
libPath = "$projectDir/../webroot/WEB-INF/lib" |
||||
|
||||
/** |
||||
* 是否对插件的class进行加密保护,防止反编译 |
||||
*/ |
||||
guard = true |
||||
|
||||
def pluginInfo = getPluginInfo() |
||||
pluginPre = "fine-plugin" |
||||
pluginName = pluginInfo.id |
||||
pluginVersion = pluginInfo.version |
||||
|
||||
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" |
||||
} |
||||
|
||||
group = 'com.fr.plugin' |
||||
version = '10.0' |
||||
sourceCompatibility = '8' |
||||
|
||||
sourceSets { |
||||
main { |
||||
java.outputDir = file(outputPath) |
||||
output.resourcesDir = file(outputPath) |
||||
} |
||||
} |
||||
|
||||
ant.importBuild("encrypt.xml") |
||||
//定义ant变量 |
||||
ant.projectDir = projectDir |
||||
ant.references["compile.classpath"] = ant.path { |
||||
fileset(dir: libPath, includes: '**/*.jar') |
||||
fileset(dir: ".",includes:"**/*.jar" ) |
||||
} |
||||
|
||||
classes.dependsOn('clean') |
||||
|
||||
task copyFiles(type: Copy,dependsOn: 'classes'){ |
||||
from outputPath |
||||
into "$projectDir/classes" |
||||
} |
||||
tasks.withType(JavaCompile) { |
||||
options.encoding = "UTF-8" |
||||
} |
||||
|
||||
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){ |
||||
from "$projectDir/classes" |
||||
into "$projectDir/transform-classes" |
||||
include "**/*.*" |
||||
} |
||||
jar.dependsOn("preJar") |
||||
|
||||
task makeJar(type: Jar,dependsOn: preJar){ |
||||
delete file("$projectDir/classes") |
||||
delete file("$projectDir/transform-classes") |
||||
from fileTree(dir: "$projectDir/transform-classes") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
destinationDir = file("$buildDir/libs") |
||||
|
||||
doLast(){ |
||||
delete file("$projectDir/classes") |
||||
delete file("$projectDir/transform-classes") |
||||
} |
||||
} |
||||
|
||||
task copyFile(type: Copy,dependsOn: ["makeJar"]){ |
||||
from "$buildDir/libs" |
||||
from("$projectDir/lib") { |
||||
include "*.jar" |
||||
} |
||||
from "$projectDir/plugin.xml" |
||||
into file("$buildDir/temp/plugin") |
||||
} |
||||
|
||||
task zip(type:Zip,dependsOn:["copyFile"]){ |
||||
from "$buildDir/temp/plugin" |
||||
destinationDir file("$buildDir/install") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
} |
||||
|
||||
//控制build时包含哪些文件,排除哪些文件 |
||||
processResources { |
||||
// exclude everything |
||||
// 用*.css没效果 |
||||
// exclude '**/*.css' |
||||
// except this file |
||||
// include 'xx.xml' |
||||
} |
||||
|
||||
/*读取plugin.xml中的version*/ |
||||
def getPluginInfo(){ |
||||
def xmlFile = file("plugin.xml") |
||||
if (!xmlFile.exists()) { |
||||
return ["id":"none", "version":"1.0.0"] |
||||
} |
||||
def plugin = new XmlParser().parse(xmlFile) |
||||
def version = plugin.version[0].text() |
||||
def id = plugin.id[0].text() |
||||
return ["id":id,"version":version] |
||||
} |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
maven { |
||||
url = uri('http://mvn.finedevelop.com/repository/maven-public/') |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
//使用本地jar |
||||
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||
implementation fileTree(dir: libPath, include: ['**/*.jar']) |
||||
} |
||||
|
@ -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,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.js.css.inject</id> |
||||
<name><![CDATA[JS和CSS注入]]></name> |
||||
<active>yes</active> |
||||
<version>1.0</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>author</vendor> |
||||
<description><![CDATA[注入]]></description> |
||||
<change-notes><![CDATA[ |
||||
[2018-08-01]修改一点问题。<br/> |
||||
[2018-07-31]初始化插件。<br/> |
||||
]]></change-notes> |
||||
<extra-decision> |
||||
<WebResourceProvider class="com.fr.plugin.JSCSSBridge"/> |
||||
</extra-decision> |
||||
<!-- <extra-core>--> |
||||
<!-- <FunctionDefineProvider class="com.fr.plugin.MyAbs" name="MyAbs" description="求绝对值,支持数组。"/>--> |
||||
<!-- <LocaleFinder class="com.fr.plugin.MyLocaleFinder"/>--> |
||||
<!-- </extra-core>--> |
||||
<function-recorder class="com.fr.plugin.FileDef"/> |
||||
</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 FileDef extends Component { |
||||
public static final FileDef KEY = new FileDef(); |
||||
private FileDef(){} |
||||
/** |
||||
* 返回需要引入的JS脚本路径 |
||||
* @param client 请求客户端描述 |
||||
* @return JS脚本路径 |
||||
*/ |
||||
public ScriptPath script( RequestClient client ) { |
||||
//如果不需要就直接返回 ScriptPath.EMPTY
|
||||
return ScriptPath.build("com/fr/plugin/web/my.js"); |
||||
} |
||||
|
||||
/** |
||||
* 返回需要引入的CSS样式路径 |
||||
* @param client 请求客户端描述 |
||||
* @return CSS样式路径 |
||||
*/ |
||||
public StylePath style( RequestClient client ) { |
||||
//如果不需要就直接返回 StylePath.EMPTY;
|
||||
return StylePath.build("com/fr/plugin/web/my.css"); |
||||
} |
||||
|
||||
/** |
||||
* 通过给定的资源过滤器控制是否加载这个资源 |
||||
* @return 资源过滤器 |
||||
*/ |
||||
@ExecuteFunctionRecord |
||||
public Filter filter() { |
||||
return new Filter(){ |
||||
@Override |
||||
public boolean accept() { |
||||
//任何情况下我们都在平台组件加载时加载我们的组件
|
||||
return true; |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -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 JSCSSBridge extends AbstractWebResourceProvider { |
||||
@Override |
||||
public Atom attach() { |
||||
//在平台主组件加载时添加我们自己的组件
|
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
//我们自己要引入的组件
|
||||
return FileDef.KEY; |
||||
} |
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.fr.plugin; |
||||
|
||||
public class MyFunctionConstants { |
||||
|
||||
public static final String PLUGIN_ID = "com.fr.plugin.js.css.inject"; |
||||
} |
@ -0,0 +1 @@
|
||||
Plugin-Test_Function_Abs=Test ABS |
@ -0,0 +1 @@
|
||||
Plugin-Test_Function_Abs=测试ABS函数 |
@ -0,0 +1,98 @@
|
||||
(function() { |
||||
var e = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "", |
||||
items: [] |
||||
}, |
||||
render: function() { |
||||
var e = this.options; |
||||
return this.storeValue = BI.deepClone(e.items), |
||||
{ |
||||
type: "bi.vertical", |
||||
bgap: 10, |
||||
items: this._createItems(e.items) |
||||
} |
||||
}, |
||||
_createItems: function(e) { |
||||
var n = this |
||||
, o = BI.Services.getService("dec.service.data.set") |
||||
, s = [DecCst.Common.Parameter.Type.BOOLEAN, DecCst.Common.Parameter.Type.DATE]; |
||||
return BI.map(e, function(t, e) { |
||||
var i = { |
||||
width: 150, |
||||
cls: BI.contains(s, e.type) ? "" : "bi-border" |
||||
}; |
||||
return { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "dec-font-weight-bold", |
||||
textAlign: "left", |
||||
width: 75, |
||||
text: e.name, |
||||
title: e.name, |
||||
rgap: 5 |
||||
}, BI.extend(i, o.createParameterValueItem(e, function(e) { |
||||
n.storeValue[t].value = e |
||||
}))] |
||||
} |
||||
}) |
||||
}, |
||||
getValue: function() { |
||||
return this.storeValue |
||||
} |
||||
}); |
||||
BI.shortcut("dec.data.set.parameters.popup", e) |
||||
}(), |
||||
function() { |
||||
var e = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "dec-directory-detail-items-add", |
||||
columns: 2, |
||||
rows: 1, |
||||
items: [] |
||||
}, |
||||
render: function() { |
||||
var e = this.options; |
||||
var items=BI.filter(e.items,function (e,t){ |
||||
if(t!=="dec.directory.right.add.template"){ |
||||
return true; |
||||
} |
||||
return false; |
||||
}); |
||||
return { |
||||
type: "bi.vertical", |
||||
vgap: 15, |
||||
hgap: 15, |
||||
items: [{ |
||||
el: { |
||||
type: "bi.grid", |
||||
columns: e.columns, |
||||
rows: 1, |
||||
height: 120, |
||||
items: BI.map(items, function(e, t) { |
||||
|
||||
return { |
||||
column: e, |
||||
row: 0, |
||||
el: { |
||||
type: t |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
}] |
||||
} |
||||
}, |
||||
getValue: function() { |
||||
return {} |
||||
}, |
||||
populate: function(e) {} |
||||
}); |
||||
BI.shortcut("dec.directory.detail_items.add.zzl", e) |
||||
BI.config("dec.directory.detail_items.add", function (options) { |
||||
options.type = "dec.directory.detail_items.add.zzl"; // 将组件的type替换为自定义的组件
|
||||
return options; |
||||
}); |
||||
|
||||
}()); |
Loading…
Reference in new issue