From ad651eb974fcdf649cc3b19e28a5e90411b6ae90 Mon Sep 17 00:00:00 2001 From: hugh Date: Tue, 16 Mar 2021 15:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4demo=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- build.gradle | 124 ++++++++++++++++++ encrypt.xml | 13 ++ plugin.xml | 16 +++ .../com/tptj/demo/hg/web/resource/Demo.java | 47 +++++++ .../com/tptj/demo/hg/web/resource/demo.png | Bin 0 -> 7084 bytes .../com/tptj/demo/hg/web/resource/dynamic.css | 3 + .../com/tptj/demo/hg/web/resource/dynamic.js | 8 ++ 8 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 build.gradle create mode 100644 encrypt.xml create mode 100644 plugin.xml create mode 100644 src/main/java/com/tptj/demo/hg/web/resource/Demo.java create mode 100644 src/main/resources/com/tptj/demo/hg/web/resource/demo.png create mode 100644 src/main/resources/com/tptj/demo/hg/web/resource/dynamic.css create mode 100644 src/main/resources/com/tptj/demo/hg/web/resource/dynamic.js diff --git a/README.md b/README.md index 0c99721..2224a54 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # demo-web-resource-simple -前端资源引入插件入门demo实现 \ No newline at end of file +前端资源引入插件入门demo实现 + +效果:插件生效后,访问决策平台登陆页面 +#####1.浏览器的控制台会输出 /webroot/decision 字符串 +#####2.登录页body的background样式变成图片 \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..3d3e2c4 --- /dev/null +++ b/build.gradle @@ -0,0 +1,124 @@ + +apply plugin: 'java' + +[compileJava,compileTestJava]*.options*.encoding = 'UTF-8' + +ext { + /** + * 项目中依赖的jar的路径 + * 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 + * 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 + */ + libPath = "$projectDir/../webroot/WEB-INF/lib" + + /** + * 是否对插件的class进行加密保护,防止反编译 + */ + guard = false + + 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" +} + +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){ + 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']) +} + + diff --git a/encrypt.xml b/encrypt.xml new file mode 100644 index 0000000..1401cd1 --- /dev/null +++ b/encrypt.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..4a902c4 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,16 @@ + + com.tptj.demo.hg.web.resource.simple.v10 + + yes + 1.0 + 10.0 + tptj + 2019-07-18 + + + com.tptj.demo.hg.web.resource + + + + + \ No newline at end of file diff --git a/src/main/java/com/tptj/demo/hg/web/resource/Demo.java b/src/main/java/com/tptj/demo/hg/web/resource/Demo.java new file mode 100644 index 0000000..b595281 --- /dev/null +++ b/src/main/java/com/tptj/demo/hg/web/resource/Demo.java @@ -0,0 +1,47 @@ +package com.tptj.demo.hg.web.resource; + +import com.fr.decision.fun.impl.AbstractWebResourceProvider; +import com.fr.decision.web.LoginComponent; +import com.fr.intelli.record.Focus; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Component; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ParserType; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; + + +/** + * @author 秃破天际 + * @version 10.0 + * Created by 秃破天际 on 2021-03-16 + **/ +@EnableMetrics +public class Demo extends AbstractWebResourceProvider { + + @Override + public Atom attach() { + return LoginComponent.KEY; + } + + @Focus(id = "com.tptj.demo.hg.web.resource.simple.v10",text = "WEB组件资源[S]") + public Atom[] clients() { + return new Atom[]{ + new Component() { + @Override + public ScriptPath script(RequestClient client) { + return ScriptPath.build( "com/tptj/demo/hg/web/resource/dynamic.js", ParserType.DYNAMIC ); + } + @Override + public StylePath style(RequestClient client) { + return StylePath.build("com/tptj/demo/hg/web/resource/dynamic.css",ParserType.DYNAMIC); + } + } + }; + + } + + + +} diff --git a/src/main/resources/com/tptj/demo/hg/web/resource/demo.png b/src/main/resources/com/tptj/demo/hg/web/resource/demo.png new file mode 100644 index 0000000000000000000000000000000000000000..898666761e82285f1785a1556216adf2fc36466f GIT binary patch literal 7084 zcmeHMXH-*JyN)`HBbGA`BcMRgQ9(NDP!tkIK@^bQrOAi_3WOppK%$~V1w{q{kpV`N8{&`4teTGV$P! zro%v{F)BPCY@)4Y;HSZ95rRO!(D#5o7wrd~%msrUCBQ+T3*Q&M*W)`K{$HtK z@@R7l)F3qm5d+jCwI`m z#y;DFfQ-Zw2z3h+oCXH*F8d82TshSYjXT@-&WWF`u)la)fJle^93f862~p%R(Z9A$ zyT0oDiWn*9Q(c_h07br%NY;%qamN{&!pF;H6nQ))Vy z&|2o`zNnT}0uBQ>t)~TddQ)rw&8v{jqMFQCEicyStP1HP24KxVB57%gyYliV`Ba7Q z=RYI}{JzE@2q|N#?PaGMtH1D_tnhs4en zXUMWaZ-v_NzB~X2e{__dqoTsDOinuqb_7DqFcZNrPc}18{t5i2K3`wyO-DfIXN!MR zCPHJZfYN+0ygE!pChUby5o-Aaq*VSRd_>70xY|1pyj7LtjJSMQ{y^j}gpZO%`@h%# za>_9Y0d0b_&+Cg&rSjk!WC82V&C11#Ho)~~^Zl6VP-N95+I-34bNGVY1+e8?OnS)5bty$bi+8if-1d#qqnsKq1y}7!$rk=t zoBn%k9(t&e{cDlyupWt^eh><6>6l2yHn;K`KdXG)x)Ex+3u464i+VH)s3ej17kBDj z{Ule7-FjEyv~tT{H2L1(<`WBxrK1ubg6(0}0Lt|p{aMJ+b)xdsUAnAZHr8qAk@E9q zFGYua0oYjhPhrBDjM-j+WE*}8ns%rje4ciDU14-$Ejy?MuG`%B202?9ygF!W@@>0~ zI`rD5s*9w~7!!UVP>LE9AlHX{d<#N9wBOc6fMCK)D1ycb1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Qnw#^QQrCcK`J&oq9M;rhatV_Z@;r2yVf9_zw#YTT~ zersXS49`C1w`}#P)zhPWos(P*g=L`@fA!f0{j?{!1Fq=kJ<#~@Nf*T#Lc-X^ipiIF z_6+$n$ZL}cb%n2_PCJ=H9v0PjBrH2msb-Ex#_r?G<&B-uNPO!38kJP-lL5@3Yldtg zMgTod3|1Z|vC(rbYhdBZdx*E)4@#{5Ym@wrnGXR9hA?l!2W1(kC!L6fotCq^5krEz#pS@9KDKh%j{+mZK99 zhyJOAWEg&5uVc|6WZSXup!l8Nq(cb`<31Sl>!+dBoC@;9ZO7&dVJ}AK47GK14pq4J z7~it;fbo1rlx|K>mbE1%`)+eTiyiy)3#&haYAn>z{|H<@^fDtL^w5rAnS3vR$ zS%A2KCp?wOWcD(2GB(1?P*JY5+><#c*wcdanil2;0Sx7Acym0^_tXXE${%}UdzWm0 zOp_T;MVfSS_N_D^Mo{7(-(c1SzY({2#GJeb0uLpsw?t8d7sVwBEI={_~-)o_zoB1P*Py^44^rYu#)HeCdy0p|> z?BK0@;=J!jtc}#@O?7I(y*OR&vUuuP*qyw0;&crYjY62|HiK7u=?U$1`8fBhsWvSn&S#xiuK=Sgyh`^$w{m)OD&;70BBDS9hg z*fky@9Q)XqazyBGN@xOWC7Mj!*Jyq*$&R*nXQyvIf{T=MFxxdDQ?>lcU!_p;Sj@x@ z1%BeFd&J2PV0Qw{m=rvzYbvjGgUuAXDIE|bfitf{Ka~Czx?Z=92U`QY&eQe6v%}YU zzz5pu>2tWi2Q1SLXN==AvD!^XDu${4byYs+Dg<8)bGhbmB!&}oK9DW{ug|(JSdh?G zr3cgu2ZhEYRz}~&UV8Wk1Oz(H0)f0p`#^830ni`D-xt2u<2xO`tKt8$8N3h*c*qx; XblzofkAvtB8_49Eg;Dv{+fV)rj9j}f literal 0 HcmV?d00001 diff --git a/src/main/resources/com/tptj/demo/hg/web/resource/dynamic.css b/src/main/resources/com/tptj/demo/hg/web/resource/dynamic.css new file mode 100644 index 0000000..b6a4b8f --- /dev/null +++ b/src/main/resources/com/tptj/demo/hg/web/resource/dynamic.css @@ -0,0 +1,3 @@ +body{ + background: url('${fineServletURL}/view/report?op=resource&resource=/com/tptj/demo/hg/web/resource/demo.png') +} \ No newline at end of file diff --git a/src/main/resources/com/tptj/demo/hg/web/resource/dynamic.js b/src/main/resources/com/tptj/demo/hg/web/resource/dynamic.js new file mode 100644 index 0000000..f91fd3f --- /dev/null +++ b/src/main/resources/com/tptj/demo/hg/web/resource/dynamic.js @@ -0,0 +1,8 @@ +/** + * @author 秃破天际 + * @version 10.0 + * Created by 秃破天际 on 2021-03-16 + **/ +!(function () { + console.info("${fineServletURL}"); +})(); \ No newline at end of file