From 95ef76d6440a5363c0b7981b1333f82f9345322d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 07 Jul 2022 15:15:56 +0800
Subject: [PATCH] fix template upload

---
 src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 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 ce47824..38c8fcc 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,6 +2,7 @@
 
 
 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;
@@ -52,22 +53,6 @@
         this.parserData = parserData;
     }
 
-    public static void main(String[] args) {
-//        String data = "{id=[1,2,3], page=1, limit=5, field=art}";
-//        Articles articles = new AttrNode().parserTag(data, Articles.class);
-
-//        String value = "{id=${col.id}, page=1, limit=5, field=art}";
-//        String pattern = "(?<=\\$\\{)[\\s\\S]*?(?=\\})";
-//        Matcher matcher = Pattern.compile(pattern).matcher(value);
-//        while (matcher.find()) {
-//            String group = matcher.group();
-//            System.out.println(1);
-//        }
-
-
-        System.out.println(1);
-    }
-
     private boolean isNeedEmpty() {
         Elements children = this.element.children();
         if (CollUtil.isNotEmpty(children)) {
@@ -93,6 +78,14 @@
         }
 
         this.element.empty();
+
+        // 设置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);
+            }
+        }
         Attributes attributes = this.element.attributes();
         if (attributes.isEmpty()) {
             return;
@@ -112,6 +105,7 @@
             i++;
 
             try {
+                Template.TAGS.add(tagsEnum.getName());
                 // {id=${col.id}, page=1, limit=5, field=art} ${col.id} 形式需先设置值
                 String tagValue = attributes.get(tagsEnum.getName());
                 tagValue = attrValueFormat(tagValue);
@@ -139,6 +133,10 @@
     public void runDataInject() {
         Attributes attributes = this.element.attributes();
         for (Attribute attribute : attributes) {
+            if (attribute.getKey().startsWith("\\$")) {
+                Template.TAGS.add(attribute.getKey());
+            }
+
             String key = attribute.getKey().replaceAll("\\$", "");
             String value = attribute.getValue();
 
@@ -158,9 +156,7 @@
                 this.element.removeAttr("class");
                 this.element.attr("class", evaluate);
             } else if (value.contains( "${")) {
-
                 String result = attrValueFormat(value);
-                System.out.println(result);
                 if ("text".equals(key)) {
                     this.element.text(result);
                 } else {
@@ -258,4 +254,8 @@
     public void systemData(Map<String, Object> systemData) {
         this.systemData = systemData;
     }
+
+    public Object getSystemDataValue(String key) {
+        return this.systemData.get(key);
+    }
 }

--
Gitblit v1.9.1