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