|
@@ -184,8 +184,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
- tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
|
let attach=[]
|
|
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){
|
|
if(tmp){
|
|
tmp.forEach((v,i)=>{
|
|
tmp.forEach((v,i)=>{
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
@@ -240,8 +246,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
- tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
|
let attach=[]
|
|
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){
|
|
if(tmp){
|
|
tmp.forEach((v,i)=>{
|
|
tmp.forEach((v,i)=>{
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
@@ -301,8 +313,14 @@ ret
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
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")
|
|
tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
- let attach=[]
|
|
|
|
if(tmp){
|
|
if(tmp){
|
|
tmp.forEach((v,i)=>{
|
|
tmp.forEach((v,i)=>{
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
@@ -370,8 +388,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
- tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
|
|
let attach=[]
|
|
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){
|
|
if(tmp){
|
|
tmp.forEach((v,i)=>{
|
|
tmp.forEach((v,i)=>{
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
@@ -431,8 +455,14 @@ if ("{{.ContentCss}}" != "") {//正文内容
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if("{{.AttachCss}}"!=""){//附件
|
|
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")
|
|
tmp = document.querySelectorAll("{{.AttachCss}} a")
|
|
- let attach=[]
|
|
|
|
if(tmp){
|
|
if(tmp){
|
|
tmp.forEach((v,i)=>{
|
|
tmp.forEach((v,i)=>{
|
|
attach.push({title:v.getAttribute("title")||v.innerText,href:v.href})
|
|
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;
|
|
let chineseCharactersLen=chineseCharacters ? chineseCharacters.length : 0;
|
|
if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
|
|
if (chineseCharactersLen < 20 && ret["attachLinks"] && ret["attachLinks"].length>0) ret["content"] = '详情请访问原网页!'
|
|
ret
|
|
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: `
|
|
AttachJsCode: `
|