diff --git a/App.vue b/App.vue
index 1361438..55be1b2 100644
--- a/App.vue
+++ b/App.vue
@@ -33,5 +33,4 @@
diff --git a/team/article/article.vue b/team/article/article.vue
index ca5336e..6e43435 100644
--- a/team/article/article.vue
+++ b/team/article/article.vue
@@ -17,9 +17,8 @@
-
-
-
+
+
@@ -45,6 +44,9 @@
}
}
},
+ components: {
+ uParse
+ },
onShow() {
const pages = getCurrentPages()
const { options } = pages[pages.length - 1]
@@ -59,8 +61,13 @@
title: '加载中'
})
findById(this.id).then(({ message }) => {
- const imgStr= this.convert(message.mainBody)
- // message.mainBody = this.getVideo(imgStr)
+ const str = message.mainBody
+ const newStyle = 'width: 85% !important; height: auto;';
+ const regex = /(]*?\s+style=")([^"]*)("[^>]*?>)/g;
+ const newStr = str.replace(regex, `$1${newStyle}$3`);
+ const brStr = str.replace(/\r\n/g,"
")
+ const videoStr = this.replaceAllVideoTagStyles(brStr, "width: 95%; height: 450rpx;display: block;margin:0 auto")
+ const imgStr = videoStr.replace(regex, `$1${newStyle}$3`);
message.mainBody = imgStr
this.form = message
uni.hideLoading()
@@ -68,43 +75,34 @@
uni.hideLoading()
})
},
- convert (options) {
- let str = options.replace(/]*>/gi, function (match, capture) {
- return match.replace(/style\s*?=\s*?([‘"])[\s\S]*?\1/ig, 'style="width:90%;margin: 0 auto;height:auto;"') // 替换style
- })
- console.log(str)
- return str
+ getAllVideoTagIndices(str) {
+ const regex = /.*?<\/video>/gs;
+ const indices = [];
+ let match;
+ while ((match = regex.exec(str)) !== null) {
+ indices.push(match.index);
+ }
+ return indices;
+ },
+
+ // 将字符串中指定位置的video标签的style属性替换为新的样式
+ replaceVideoTagStyle(str, index, newStyle) {
+ const startIndex = str.indexOf("') // 把字符串 从视频标签分成数组
- arr.forEach((item, index) => {
- var src = item.match(srcReg);
- console.log(src)
- videoList.push(src[1]) //所要显示的字符串中 所有的video 标签 的路径
- })
- let needArticleList = [];
- articleList.forEach((item, index) => {
- if (item != "" && item != undefined) { // 常见的标签渲染
- needArticleList.push({
- type: 'rich-text',
- value: item + ""
- });
- }
- let articleListLength = articleList.length; // 插入到原有video 标签位置
- if (index < articleListLength && videoList[index] != undefined) {
- needArticleList.push({
- type: 'video',
- value: videoList[index]
- })
- }
- })
- return needArticleList
- },
// 下载附件
download(item) {
this.$util.to(`../send/send?url=${item.filePath}©Writing=${item.fileName}`)
@@ -138,6 +136,7 @@