From fe87cd1b8168b9ef6f89e80bc5c1d6a5757af3c8 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 08 Jul 2022 11:46:31 +0800 Subject: [PATCH] 20220606 --- src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java index b11eae9..c85e75e 100644 --- a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java +++ b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java @@ -2,10 +2,12 @@ import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.xcong.farmer.cms.core.handler.DataParserHandler; import com.xcong.farmer.cms.core.tag.TagsEnum; import com.xcong.farmer.cms.core.template.Configuration; +import com.xcong.farmer.cms.core.template.TemplateConfiguration; import groovy.lang.Binding; import groovy.lang.GroovyShell; import org.apache.commons.text.StringSubstitutor; @@ -70,7 +72,32 @@ return false; } + public void staticPath() { + // 设置img的链接访问 + if ("img".equals(this.element.tagName())) { + String src = this.element.attr("src"); + if (StrUtil.isNotBlank(STATIC_URL)) { + this.element.attr("src", STATIC_URL + src); + } + } + + if ("link".equals(this.element.tagName())) { + String src = this.element.attr("href"); + if (StrUtil.isNotBlank(STATIC_URL)) { + this.element.attr("href", STATIC_URL + src); + } + } + + if ("script".equals(this.element.tagName())) { + String src = this.element.attr("src"); + if (StrUtil.isNotBlank(STATIC_URL)) { + this.element.attr("src", STATIC_URL + src); + } + } + } + public void parser() { + staticPath(); // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空 if (!isNeedEmpty()) { return; -- Gitblit v1.9.1