小阿七 7 maanden geleden
bovenliggende
commit
0aae39ace4

+ 4 - 28
frontend/src/components/spider/CodeEditor.vue

@@ -1,23 +1,5 @@
-<template>
-<<<<<<< HEAD
-    <el-dialog title="编辑代码" :model-value="props.show" @update:model-value="updateModelValue" :close-on-click-modal="false" width="70%">
-        <el-button-group>
-            <el-tooltip v-for="item,index in TemplateJsCode.InitListPageJsCodes" :key="index" class="box-item" effect="dark" :content="item.tooltip"
-                        placement="top-start">
-              <el-button size="small" type="primary" @click='useInitPageJsCode(index)'>{{item.name}}</el-button>
-            </el-tooltip>
-          </el-button-group>
-        <div style="line-height: 6px;height: 6px;"></div>
-        <div class="textarea-container">
-            <el-input v-model="dialogInfo.text" class="textarea" autofocus :autosize="{ minRows: 12, maxRows: 13 }" type="textarea" placeholder="Please input"></el-input>
-        </div>
-        <div slot="footer" class="dialog-footer" style="text-align:right">
-            <el-button @click="handleSave(false)">取 消</el-button>
-            <el-button type="primary" @click="handleSave(false)">保 存</el-button>
-        </div>
-    </el-dialog>
-=======
-  <el-dialog title="编辑代码" :model-value="props.show" @update:model-value="updateModelValue" :close-on-click-modal="false" width="70%">
+<template> 
+   <el-dialog title="编辑代码" :model-value="props.show" @update:model-value="updateModelValue" :close-on-click-modal="false" width="70%">
     <el-button-group>
       <el-tooltip v-for="item,index in TemplateJsCode.InitListPageJsCodes" :key="index" class="box-item" effect="dark" :content="item.tooltip" placement="top-start">
         <el-button size="small" type="primary" @click='useInitPageJsCode(index)'>{{item.name}}</el-button>
@@ -32,8 +14,7 @@
       <el-button type="primary" @click="handleSave(false)">保 存</el-button>
     </div>
   </el-dialog>
->>>>>>> 3146e627030e181299474dd54a941ed33c8183bb
-</template>
+ </template>
 <script setup>
 import { reactive } from 'vue';
 import { TemplateJsCode } from './jscodetpl.js'
@@ -48,14 +29,9 @@ const props = defineProps({
 
 //使用页面初始化模板
 const useInitPageJsCode=(index)=>{
-<<<<<<< HEAD
-    let code =  TemplateJsCode.InitListPageJsCodes[index].code
-    dialogInfo.text = code
-=======
   let code =  TemplateJsCode.InitListPageJsCodes[index].code
   dialogInfo.text = code
->>>>>>> 3146e627030e181299474dd54a941ed33c8183bb
-}
+ }
 
 const dialogInfo = reactive({
   key: '',

+ 9 - 9
frontend/src/components/spider/EditSpider.vue

@@ -169,16 +169,16 @@
           </el-row>
         </el-form>
       </el-tab-pane>
-      <el-tab-pane label="列表页JS代码" name="list_item_js">
+      <el-tab-pane label="列表页代码" name="list_item_js">
         <template #label><span class="custom-tabs-label">
                         <el-icon>
                             <ElementPlus />
                         </el-icon>
-                        <span>列表页JS代码</span>
+                        <span>列表页代码</span>
                     </span>
         </template>
         <el-divider>
-          手写列表页提取JS代码
+          列表页代码
           <el-button-group>
             <el-tooltip v-for="item,index in TemplateJsCode.ListJsCodes" :key="index" class="box-item" effect="dark" :content="item.tooltip"
                         placement="top-start">
@@ -191,17 +191,17 @@
                     placeholder="Please input" />
         </el-row>
       </el-tab-pane>
-      <el-tab-pane label="列表翻页JS代码" name="list_trunpage_js">
+      <el-tab-pane label="列表翻页代码" name="list_trunpage_js">
 
         <template #label><span class="custom-tabs-label">
                         <el-icon>
                             <ElementPlus />
                         </el-icon>
-                        <span>列表翻页JS代码</span>
+                        <span>列表翻页代码</span>
                     </span>
         </template>
         <el-divider>
-          手写列表翻页JS代码
+          列表翻页代码
           <el-button-group>
             <el-tooltip v-for="item,index in TemplateJsCode.ListTurnPageJsCodes" :key="index" class="box-item" effect="dark" :content="item.tooltip"
                         placement="top-start">
@@ -215,17 +215,17 @@
         </el-row>
       </el-tab-pane>
 
-      <el-tab-pane label="详情页JS代码" name="content_js">
+      <el-tab-pane label="详情页代码" name="content_js">
 
         <template #label><span class="custom-tabs-label">
                         <el-icon>
                             <ElementPlus />
                         </el-icon>
-                        <span>详情页JS代码</span>
+                        <span>详情页代码</span>
                     </span>
         </template>
         <el-divider>
-          手写附件下载/上传JS代码
+          详情页代码
           <el-button-group>
             <el-tooltip v-for="item,index in TemplateJsCode.ContentJsCodes" :key="index" class="box-item" effect="dark" :content="item.tooltip"
                         placement="top-start">

+ 36 - 138
frontend/src/components/spider/jscodetpl.js

@@ -184,8 +184,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
   }
 }
 if("{{.AttachCss}}"!=""){//附件
-	tmp = document.querySelectorAll("{{.AttachCss}} a")
 	let attach=[]
+	//先处理正文附件
+	if("{{.AttachCss}}"!="{{.ContentCss}}"){
+		document.querySelectorAll("{{.ContentCss}} a").forEach(v=>{
+			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
+		})
+	}
+	tmp = document.querySelectorAll("{{.AttachCss}} a")
 	if(tmp){
 		tmp.forEach((v,i)=>{
 			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
@@ -240,8 +246,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
     }
 }
 if("{{.AttachCss}}"!=""){//附件
-	tmp = document.querySelectorAll("{{.AttachCss}} a")  
 	let attach=[]
+	//先处理正文附件
+	if("{{.AttachCss}}"!="{{.ContentCss}}"){
+		document.querySelectorAll("{{.ContentCss}} a").forEach(v=>{
+			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
+		})
+	}
+	tmp = document.querySelectorAll("{{.AttachCss}} a")  
 	if(tmp){
 		tmp.forEach((v,i)=>{
 			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
@@ -301,8 +313,14 @@ ret
         }
     }
     if("{{.AttachCss}}"!=""){//附件
+		let attach=[]
+		//先处理正文附件
+		if("{{.AttachCss}}"!="{{.ContentCss}}"){
+			document.querySelectorAll("{{.ContentCss}} a").forEach(v=>{
+				attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
+			})
+		}
         tmp = document.querySelectorAll("{{.AttachCss}} a")
-        let attach=[]
         if(tmp){
             tmp.forEach((v,i)=>{
                 attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
@@ -370,8 +388,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
   }
 }
 if("{{.AttachCss}}"!=""){//附件
-	tmp = document.querySelectorAll("{{.AttachCss}} a")
 	let attach=[]
+	//先处理正文附件
+	if("{{.AttachCss}}"!="{{.ContentCss}}"){
+		document.querySelectorAll("{{.ContentCss}} a").forEach(v=>{
+			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
+		})
+	}
+	tmp = document.querySelectorAll("{{.AttachCss}} a")
 	if(tmp){
 		tmp.forEach((v,i)=>{
 			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
@@ -431,8 +455,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
     }
 }
 if("{{.AttachCss}}"!=""){//附件
+	let attach=[]
+	//先处理正文附件
+	if("{{.AttachCss}}"!="{{.ContentCss}}"){
+		document.querySelectorAll("{{.ContentCss}} a").forEach(v=>{
+			attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
+		})
+	}
     tmp = document.querySelectorAll("{{.AttachCss}} a")
-    let attach=[]
     if(tmp){
         tmp.forEach((v,i)=>{
             attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
@@ -446,139 +476,7 @@ let chineseCharacters = ret["content"]?ret["content"].match(regex):[];
 let chineseCharactersLen=chineseCharacters ? chineseCharacters.length : 0;
 if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
 ret 
-`}, {
-            "name": "模版6",
-            "tooltip": "基础模板扩展,正文、附件区域,都需要找附件",
-            "code": `
-var ret = {}
-var tmp = null
-
-if ("{{.TitleCss}}" != "") {//标题
-    tmp = document.querySelector("{{.TitleCss}}")
-    if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
-}
-if ("{{.PublishUnitCss}}" != "") {//采购单位
-    tmp = document.querySelector("{{.PublishUnitCss}}")
-    if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
-}
-if ("{{.PublishTimeCss}}" != "") {//发布时间
-    tmp = document.querySelector("{{.PublishTimeCss}}")
-    if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
-}
-if ("{{.ContentCss}}" != "") {//正文内容
-    tmp = document.querySelector("{{.ContentCss}}")
-    if (tmp) {
-        ret["content"] = tmp.innerText
-        ret["contentHtml"] = tmp.innerHTML
-        var patchContent = false
-        //处理详情页中的大图,大图作为附件使用
-        const images = tmp.querySelectorAll("img");
-        images.forEach((img, i) => {
-            if (img.width > 300) {
-                patchContent = true
-                const a = document.createElement("a");
-                a.href = img.src;
-                a.innerText = img.src;
-                tmp.appendChild(a);
-            }
-        })
-    }
-}
-if("{{.AttachCss}}"!=""){//附件
-    //附件区域检查
-    tmp = document.querySelectorAll("{{.AttachCss}} a")
-    let attach=[]
-    if(tmp){
-    tmp.forEach((v,i)=>{
-        attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
-    })
-}
-//正文区域附件检查
-tmp = document.querySelectorAll("{{.ContentCss}} a")
-if(tmp){
-    tmp.forEach((v,i)=>{
-        attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
-    })
-}
-//附件过滤
-attch = attach.filter((item)=>item.href && item.href.startsWith('http'))
-ret["attachLinks"]=attach
-}
-//检查中文字符个数,少于20,修正正文内容
-let regex = /[\\u4e00-\\u9fa5]/g;
-let chineseCharacters = ret["content"]?ret["content"].match(regex):[];
-let chineseCharactersLen=chineseCharacters ? chineseCharacters.length : 0;
-if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
-ret 
-<<<<<<< HEAD
-`}, {
-            "name": "模版6",
-            "tooltip": "基础模板扩展,正文、附件区域,都需要找附件",
-            "code": `
-var ret = {}
-var tmp = null
-
-if ("{{.TitleCss}}" != "") {//标题
-tmp = document.querySelector("{{.TitleCss}}")
-if (tmp) ret["title"] = tmp.getAttribute("title") || tmp.innerText
-}
-if ("{{.PublishUnitCss}}" != "") {//采购单位
-tmp = document.querySelector("{{.PublishUnitCss}}")
-if (tmp) ret["publishUnit"] = tmp.getAttribute("title") || tmp.innerText
-}
-if ("{{.PublishTimeCss}}" != "") {//发布时间
-tmp = document.querySelector("{{.PublishTimeCss}}")
-if (tmp) ret["publishTime"] = tmp.getAttribute("title") || tmp.innerText
-}
-if ("{{.ContentCss}}" != "") {//正文内容
-tmp = document.querySelector("{{.ContentCss}}")
-if (tmp) {
-ret["content"] = tmp.innerText
-ret["contentHtml"] = tmp.innerHTML
-var patchContent = false
-//处理详情页中的大图,大图作为附件使用
-const images = tmp.querySelectorAll("img");
-images.forEach((img, i) => {
-if (img.width > 300) {
-patchContent = true
-const a = document.createElement("a");
-a.href = img.src;
-a.innerText = img.src;
-tmp.appendChild(a);
-}
-})
-}
-}
-if("{{.AttachCss}}"!=""){//附件
-//附件区域检查
-tmp = document.querySelectorAll("{{.AttachCss}} a")
-let attach=[]
-if(tmp){
-tmp.forEach((v,i)=>{
-    attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
-})
-}
-//正文区域附件检查
-tmp = document.querySelectorAll("{{.ContentCss}} a")
-if(tmp){
-tmp.forEach((v,i)=>{
-    attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
-})
-}
-//附件过滤
-attch = attach.filter((item)=>item.href && item.href.startsWith('http'))
-ret["attachLinks"]=attach
-}
-//检查中文字符个数,少于20,修正正文内容
-let regex = /[\\u4e00-\\u9fa5]/g;
-let chineseCharacters = ret["content"]?ret["content"].match(regex):[];
-let chineseCharactersLen=chineseCharacters ? chineseCharacters.length : 0;
-if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
-ret 
-=======
->>>>>>> 3146e627030e181299474dd54a941ed33c8183bb
-`,
-        },
+`},
     ],
 
     AttachJsCode: `