From b7d06e0d47e6dd8f2d8ea3f558ae972f231325d0 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期六, 20 七月 2019 17:33:34 +0800
Subject: [PATCH] 加入 服务绑定功能

---
 WebService/src/main/java/com/java110/web/core/VcCreateProcessor.java |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/WebService/src/main/java/com/java110/web/core/VcCreateProcessor.java b/WebService/src/main/java/com/java110/web/core/VcCreateProcessor.java
index da57636..6f50bc7 100644
--- a/WebService/src/main/java/com/java110/web/core/VcCreateProcessor.java
+++ b/WebService/src/main/java/com/java110/web/core/VcCreateProcessor.java
@@ -58,7 +58,7 @@
         //灏嗙粍寤哄悕绉板啓鍏ョ粍寤篐TML 绗竴涓爣绛句腑
         addDataComponent(elements, componentName);
 
-       htmlModel.addModel(modelFactory.parse(context.getTemplateData(), doc.body().children().toString()));
+        htmlModel.addModel(modelFactory.parse(context.getTemplateData(), doc.body().children().toString()));
 
         String css = VueComponentTemplate.findTemplateByComponentCode(componentName + "." + VueComponentTemplate.COMPONENT_CSS);
         if (css != null) {
@@ -86,7 +86,7 @@
     /**
      * 鍔犲叆缁勪欢鍚嶇О鍒� HTML涓� 鏂逛究瀹氫綅闂
      *
-     * @param elements        椤甸潰鑺傜偣
+     * @param elements      椤甸潰鑺傜偣
      * @param componentCode 缁勪欢缂栫爜
      */
     private void addDataComponent(Elements elements, String componentCode) {
@@ -99,7 +99,7 @@
      * 澶勭悊js
      *
      * @param tag 椤甸潰鍏冪礌
-     * @param js      js鏂囦欢鍐呭
+     * @param js  js鏂囦欢鍐呭
      * @return js 鏂囦欢鍐呭
      */
     private String dealJs(String js, IProcessableElementTag tag) {
@@ -117,14 +117,20 @@
             return js;
         }
 
-        String[] tmpType = tmpProTypes.split(",");
+        String[] tmpType = tmpProTypes.contains("\r\n")
+                        ? tmpProTypes.split("\r\n")
+                        : tmpProTypes.split(",");
         StringBuffer propsJs = new StringBuffer("\nvar $props = {};\n");
         for (String type : tmpType) {
             if (StringUtils.isEmpty(type) || !type.contains(":")) {
                 continue;
             }
             String[] types = type.split(":");
-            String attrKey = types[0].replace(" ", "")
+            String attrKey = "";
+            if (types[0].contains("//")) {
+                attrKey = types[0].substring(0, types[0].indexOf("//"));
+            }
+            attrKey = types[0].replace(" ", "")
                     .replace("\n", "")
                     .replace("\r", "");
             if (!tag.hasAttribute(attrKey)) {
@@ -133,7 +139,7 @@
                 throw new TemplateProcessingException("缁勪欢[" + componentName + "]鏈厤缃粍浠跺睘鎬�" + attrKey);
             }
             String vcType = tag.getAttributeValue(attrKey);
-            if (types[1].equals("vc.propTypes.string")) {
+            if (types[1].contains("vc.propTypes.string")) {
                 vcType = "'" + vcType + "'";
             }
             propsJs.append("$props." + attrKey + "=" + vcType + ";\n");
@@ -154,10 +160,10 @@
      * 澶勭悊js 鍙橀噺鍜� 鏂规硶閮藉姞鍏� 缁勪欢缂栫爜
      *
      * @param tag 椤甸潰鍏冪礌
-     * @param js      js鏂囦欢鍐呭
+     * @param js  js鏂囦欢鍐呭
      * @return js 鏂囦欢鍐呭
      */
-    private String dealJsAddComponentCode(String js,IProcessableElementTag tag) {
+    private String dealJsAddComponentCode(String js, IProcessableElementTag tag) {
 
         if (!tag.hasAttribute("code")) {
             return js;

--
Gitblit v1.8.0