Commit f238fd7a by 前端

Merge branch 'dev_v1.0.0' of http://192.168.3.233:8090/npm/glsx-components into dev_v1.0.0

2 parents 3793ae2f 9d7ff296
{
"name": "glsx-components",
"description": "glsx vue components",
"version": "1.4.8",
"version": "1.5.3",
"author": "limin <17653212@qq.com>",
"license": "MIT",
"main": "dist/glsx-components.common.js",
......
......@@ -168,7 +168,7 @@
<span class="emotion-item" v-if="item.type == 'expression'" @click.stop="selectEmotion">{{ item.name }}</span>
<span v-else>{{ item.name }}</span>
<input v-if="item.type == 'img'" type="file" style="opacity: 0" :id="item.type + 'file'" ref="file" class="welcome-input upload-img" :accept="item.accept || 'image/png, image/jpeg, image/jpg'" @change="e => handleImgChange(e)" />
<input v-else-if="item.type == 'video'" type="file" style="opacity: 0" :id="item.type + 'file'" ref="file" class="welcome-input" :accept="item.accept || 'video/*'" @change="e => handleVideoChange(e)" />
<input v-else-if="item.type == 'video'" type="file" style="opacity: 0" :id="item.type + 'file'" ref="file" class="welcome-input upload-video" :accept="item.accept || 'video/*'" @change="e => handleVideoChange(e)" />
<el-link v-else-if="item.type != 'video' && item.type != 'img' && item.type != 'expression'" style="opacity: 0" @click="handleFun(item)">{{ item.name }}</el-link>
</div>
</div>
......@@ -260,6 +260,7 @@ export default {
},
mounted() {
document.addEventListener('click', e => {
console.log(e.target.className)
if (e.target.className != 'emotion-item') {
this.emotionStatus = false
}
......@@ -390,12 +391,12 @@ export default {
if (res) {
let len = this.previewList.length - 1
this.previewList[len].attContent = res
document.querySelector('.upload-img').value = ''
} else {
this.previewList.pop()
}
this.loading = false
})
document.querySelector('.upload-img').value = ''
}
}
},
......@@ -423,6 +424,7 @@ export default {
})
}
})
document.querySelector('.upload-video').value = ''
}
} catch (err) {
console.log(err)
......@@ -484,28 +486,13 @@ export default {
close(index) {
this.previewList.splice(index, 1)
},
conversion(val, status = 'emo') {
let retult = val.replace(/&nbsp;/g, '')
if (status == 'emo' || status == 'es') {
retult = retult.replace(/\[([\u4E00-\u9FA5]{1,4}|OK|NO|666)\]/g, '')
}
if (status == 'special' || status == 'es') {
retult = retult
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
}
return retult
},
reduction(val) {
return val
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
},
textInput(val) {
val = val.replace(/&nbsp;/g, '')
this.textNum = this.conversion(val, 'es').replace(/(\n|\s)/g, '').length
val = val
.replace(/&nbsp;/g, '')
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
this.textNum = val.replace(/(\n|\s)/g, '').length
if (this.textNum > this.maxNum) {
this.textNum = this.maxNum
this.updateList(this.previewList, 1)
......@@ -514,12 +501,12 @@ export default {
const hasText = this.previewList.some(item => item.attType == this.ATT_TYPE.TEXT)
if (hasText) {
this.$set(this.previewList, 0, {
attContent: this.conversion(val, 'special'),
attContent: val,
attType: this.ATT_TYPE.TEXT
})
} else {
this.previewList.unshift({
attContent: this.conversion(val, 'special'),
attContent: val,
attType: this.ATT_TYPE.TEXT
})
}
......@@ -541,8 +528,22 @@ export default {
})
}
},
//图片验证
imageCheck(src) {
return new Promise((resolve, reject) => {
var img = new Image()
img.src = src
img.onerror = function() {
resolve()
}
img.onload = function() {
resolve(1)
}
})
},
// 素材
handleMaterialConfirm(val) {
async handleMaterialConfirm(val) {
console.log(val)
const { materialContent, objectName } = val
const imgSrc = materialContent.imgSrc
const videoSrc = materialContent.videoSrc
......@@ -560,6 +561,13 @@ export default {
return
}
if (imgSrc && imgSrc.length) {
for (let i = 0; i < imgSrc.length; i++) {
const checkStatus = await this.imageCheck(imgSrc[i])
if (!checkStatus) {
this.$message.error('图片访问失败')
return
}
}
imgSrc.forEach(item => {
this.previewList.push({
attContent: item,
......@@ -581,26 +589,31 @@ export default {
html = html.replace('\n', '').replace(/<br\/>/g, '')
}
html = html
// .replace(/&lt;/g, '<')
// .replace(/&gt;/g, '>')
// .replace(/&amp;/g, '&')
let textLen = this.reduction(this.previewList[idx].attContent) + html
if (this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length > this.maxNum) {
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
let textLen = this.previewList[idx].attContent + html
if (textLen.replace(/(\n|\s)/g, '').length > this.maxNum) {
textLen = this.previewList[idx].attContent
} else {
this.textNum = this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length
this.textNum = textLen.replace(/(\n|\s)/g, '').length
}
this.$set(this.previewList, 0, {
attContent: textLen,
attType: this.ATT_TYPE.TEXT
})
} else {
html = html.replace('\n', '').replace(/<br\/>/g, '')
html = html
.replace('\n', '')
.replace(/<br\/>/g, '')
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
let textLen = html
if (this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length > this.maxNum) {
if (textLen.replace(/(\n|\s)/g, '').length > this.maxNum) {
textLen = ''
} else {
this.textNum = this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length
this.textNum = textLen.replace(/(\n|\s)/g, '').length
}
this.previewList.unshift({
attContent: textLen,
......@@ -635,15 +648,15 @@ export default {
if (obj) {
let attContent
if (status) {
attContent = obj.attContent.replace(/\[(@昵称|#兑换码)\]/g, '<wise id="1" contenteditable="false">$1</wise>')
attContent = obj.attContent.replace(/(@昵称|#兑换码)/g, '<wise id="1" contenteditable="false">$1</wise>')
} else {
this.textNum = obj.attContent
.replace(/(\n|\s)/g, '')
.replace(/\[(@昵称|#兑换码)\]/g, '$1')
.replace(/\[([\u4E00-\u9FA5]{1,4}|OK|NO|666)\]/g, '').length
attContent = this.reduction(obj.attContent).replace(/\[(@昵称|#兑换码)\]/g, '<wise id="1" contenteditable="false">$1</wise>')
.replace(/\[[\u4E00-\u9FA56]{1,4}]/g, '').length
attContent = obj.attContent.replace(/\[(@昵称|#兑换码)\]/g, '<wise id="1" contenteditable="false">$1</wise>')
}
let htm = attContent.replace(/\[([\u4E00-\u9FA5]{1,4}|OK|NO|666)]/gi, function(res) {
let htm = attContent.replace(/\[[\u4E00-\u9FA56]{1,4}]/gi, function(res) {
let word = res.replace(/\[|\]/gi, '')
const list = emoji.flat(Infinity)
let index = parseInt(list.indexOf(word)) + 1
......@@ -660,11 +673,6 @@ export default {
setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML = htm
}, 100)
this.previewList.forEach(item => {
if (item.attType == this.ATT_TYPE.TEXT) {
item.attContent = this.conversion(item.attContent, 'special')
}
})
} else {
this.textValue = ''
}
......@@ -693,8 +701,8 @@ export default {
position: relative;
.video-pane-close {
position: absolute;
right: 0px;
top: 0px;
right: -2px;
top: -3px;
width: 14px;
height: 14px;
cursor: pointer;
......
......@@ -118,7 +118,8 @@ export default {
this.isMaterialVisible = true
},
getBaseData() {
this.materialList.groupListApi({}).then(res => {
const params = this.materialList.params || {}
this.materialList.groupListApi(params).then(res => {
this.baseData.groupList = res
this.getOptionsList('searchFormData')
})
......@@ -136,7 +137,7 @@ export default {
return arr
},
getvideosrc(htmlstr) {
var reg = /<video.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim
var reg = /<video.+?src=('|")?([^'"]+)('|")?(?:\s+|\/?>)/gim
var arr = []
var tem
while ((tem = reg.exec(htmlstr))) {
......@@ -149,7 +150,8 @@ export default {
...this.searchForm,
status: 0,
pageNum: this.pageNum,
pageSize: this.pageSize
pageSize: this.pageSize,
...this.materialList.params
}
this.materialList.materialListApi(params).then(res => {
this.modelList = res.data
......
......@@ -214,7 +214,8 @@ export default {
},
getCreatedList() {
const { getSearchApi } = this.messageList
getSearchApi({}).then(res => {
const { params = {} } = this.messageList || {}
getSearchApi(params).then(res => {
this.createdList = res
this.$nextTick(() => {
this.messageLoading = false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!