master
lion 3 months ago
parent 713a397716
commit 1ce726412c

@ -584,7 +584,34 @@
start_time: this.form.time[0],
sortnumber: this.form.sortnumber,
end_time: this.form.time[1],
content: replaceAll(this.form.content,'../storage/files',`${process.env.VUE_APP_BASE_API}storage/files`)
content: (() => {
let content = this.form.content || ''
const baseUrl = `${process.env.VUE_APP_BASE_API}storage/files`
// 使 http:// https://
// ../storage/files http:// https://
content = content.replace(/\.\.\/storage\/files/g, (match, offset) => {
// http:// https://
const before = content.substring(Math.max(0, offset - 50), offset)
if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) {
return match
}
return baseUrl
})
// /storage/files http:// https://
content = content.replace(/\/storage\/files/g, (match, offset) => {
// http:// https://
const before = content.substring(Math.max(0, offset - 50), offset)
if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) {
return match
}
// URL
if (before.indexOf(baseUrl) !== -1) {
return match
}
return baseUrl
})
return content
})()
}).then(res => {
Message({
type: 'success',
@ -618,7 +645,34 @@
start_time: this.form.time[0],
sortnumber: this.form.sortnumber,
end_time: this.form.time[1],
content: replaceAll(this.form.content,'../storage/files',`${process.env.VUE_APP_BASE_API}storage/files`)
content: (() => {
let content = this.form.content || ''
const baseUrl = `${process.env.VUE_APP_BASE_API}storage/files`
// 使 http:// https://
// ../storage/files http:// https://
content = content.replace(/\.\.\/storage\/files/g, (match, offset) => {
// http:// https://
const before = content.substring(Math.max(0, offset - 50), offset)
if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) {
return match
}
return baseUrl
})
// /storage/files http:// https://
content = content.replace(/\/storage\/files/g, (match, offset) => {
// http:// https://
const before = content.substring(Math.max(0, offset - 50), offset)
if (before.indexOf('http://') !== -1 || before.indexOf('https://') !== -1) {
return match
}
// URL
if (before.indexOf(baseUrl) !== -1) {
return match
}
return baseUrl
})
return content
})()
}).then(res => {
Message({
type: 'success',

Loading…
Cancel
Save