From c64cdafff6b1394a9909f5c592d6471088f024f7 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期日, 01 十二月 2019 02:16:04 +0800
Subject: [PATCH] 优化namespace 最终版

---
 java110-front/src/main/java/com/java110/front/core/VcCreateProcessor.java |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/java110-front/src/main/java/com/java110/front/core/VcCreateProcessor.java b/java110-front/src/main/java/com/java110/front/core/VcCreateProcessor.java
index d53f0a8..8d46af3 100644
--- a/java110-front/src/main/java/com/java110/front/core/VcCreateProcessor.java
+++ b/java110-front/src/main/java/com/java110/front/core/VcCreateProcessor.java
@@ -90,7 +90,9 @@
 
         String namespace = tag.getAttributeValue("namespace");
 
-        return html.replace("this.", namespace + "_");
+        return html.replace("this.", namespace + "_")
+                .replaceAll("(id)+( )*+=+( )*+'", "id='" + namespace + "_")
+                .replaceAll("(id)+( )*+=+( )*+\"", "id=\"" + namespace + "_");
     }
 
     private String dealHtmlJs(IProcessableElementTag tag, String js) {
@@ -101,7 +103,9 @@
 
         String namespace = tag.getAttributeValue("namespace");
 
-        return js.replace("this.", "vc.component."+namespace + "_");
+        return js.replace("this.", "vc.component." + namespace + "_")
+                .replaceAll("(\\$)+( )*+(\\()+( )*+\'+#", "\\$('#" + namespace + "_")
+                .replaceAll("(\\$)+( )*+(\\()+( )*+\"+#", "\\$(\"#" + namespace + "_");
     }
 
 
@@ -246,15 +250,10 @@
     }
 
     public static void main(String[] args) {
-        String js = "(function (vc, vm) {vc.extends({a:'123'})})";
-        int extPos = js.indexOf("vc.extends");
-        String tmpProTypes = js.substring(extPos);
-        int pos = tmpProTypes.indexOf("{") + 1;
-        js = js.substring(0, extPos) + tmpProTypes.substring(0, pos).trim() + "\nnamespace:" + DEFAULT_NAMESPACE + ",\n" + tmpProTypes.substring(pos, tmpProTypes.length());
-        int position = js.indexOf("{");
-        String propsJs = "\n$namespace=" + DEFAULT_NAMESPACE + ";\n";
-        js = new StringBuffer(js).insert(position + 1, propsJs).toString();
+        String js = "123$ ( '#av').val()";
+        js = js.replaceAll("(\\$)+( )*+(\\()+( )*+\'+#", "\\$('#abg_");
 
         System.out.println(js);
+
     }
 }

--
Gitblit v1.8.0