You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
3 years ago
|
package com.fr.plugin;
|
||
|
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
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.FileType;
|
||
|
import com.fr.web.struct.category.ScriptPath;
|
||
|
import com.fr.web.struct.category.StylePath;
|
||
|
@FunctionRecorder()
|
||
|
public class CustomHeaderHeightComponent extends Component {
|
||
|
public static final CustomHeaderHeightComponent KEY = new CustomHeaderHeightComponent();
|
||
|
/**
|
||
|
* 返回需要引入的JS脚本路径
|
||
|
* @param client 请求客户端描述
|
||
|
* @return JS脚本路径
|
||
|
*/
|
||
|
@ExecuteFunctionRecord
|
||
|
public ScriptPath script( RequestClient client ) {
|
||
|
if (PluginContexts.currentContext().isAvailable()) {
|
||
|
// 做认证通过的事情
|
||
|
return ScriptPath.build("com.fr.plugin.CustomHeaderHeightJS", FileType.CLASS);
|
||
|
|
||
|
} else {
|
||
|
// 做认证未通过的事情
|
||
|
return ScriptPath.build("com/fr/plugin/web/webnuy.js");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 返回需要引入的CSS样式路径
|
||
|
* @param client 请求客户端描述
|
||
|
* @return CSS样式路径
|
||
|
*/
|
||
|
public StylePath style( RequestClient client ) {
|
||
|
//如果不需要就直接返回 StylePath.EMPTY;
|
||
|
return StylePath.EMPTY;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 通过给定的资源过滤器控制是否加载这个资源
|
||
|
* @return 资源过滤器
|
||
|
*/
|
||
|
public Filter filter() {
|
||
|
return new Filter(){
|
||
|
@Override
|
||
|
public boolean accept() {
|
||
|
//任何情况下我们都在平台组件加载时加载我们的组件
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}
|