Commit 9d0b72e1 by xinla

优化:统一系统共用文件上传接口,统一为img的src不是绝对地址的src拼接接口地址

1 parent 81c4b476
...@@ -28,11 +28,10 @@ export default { ...@@ -28,11 +28,10 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
action: action: process.env.VUE_APP_BASE_API + '/common/uploadFile2Cos',
process.env.VUE_APP_BASE_API + // (this.type == 0
(this.type == 0 // ? '/wecom/material/uploadimg'
? '/wecom/material/uploadimg' // : '/common/uploadFile2Cos'),
: '/common/uploadFile2Cos'),
headers: window.CONFIG.headers, headers: window.CONFIG.headers,
domain: process.env.VUE_APP_BASE_API, domain: process.env.VUE_APP_BASE_API,
} }
......
...@@ -45,4 +45,21 @@ window.CONFIG = { ...@@ -45,4 +45,21 @@ window.CONFIG = {
return { Authorization: 'Bearer ' + getToken() } return { Authorization: 'Bearer ' + getToken() }
}, },
} }
// 统一为img的src不是绝对地址的拼接接口地址
document.addEventListener(
'error',
function(e) {
let target = e.target
let src = target.attributes.getNamedItem('src').value
if (
target.tagName.toUpperCase() === 'IMG' &&
src &&
!src.includes('http')
) {
target.src = process.env.VUE_APP_BASE_API + src
}
},
true
)
export default window.CONFIG export default window.CONFIG
...@@ -67,20 +67,29 @@ Vue.prototype.msgInfo = function(msg) { ...@@ -67,20 +67,29 @@ Vue.prototype.msgInfo = function(msg) {
import { pickerOptions } from '@/utils/index' import { pickerOptions } from '@/utils/index'
Vue.prototype.pickerOptions = pickerOptions Vue.prototype.pickerOptions = pickerOptions
import VideoPlayer from 'vue-video-player' import VideoPlayer from 'vue-video-player'
Vue.use(VideoPlayer); Vue.use(VideoPlayer)
import AudioPlayer from '@liripeng/vue-audio-player' import AudioPlayer from '@liripeng/vue-audio-player'
import '@liripeng/vue-audio-player/lib/vue-audio-player.css' import '@liripeng/vue-audio-player/lib/vue-audio-player.css'
Vue.use(AudioPlayer) Vue.use(AudioPlayer)
import VueAMap from 'vue-amap'; import VueAMap from 'vue-amap'
Vue.use(VueAMap); Vue.use(VueAMap)
VueAMap.initAMapApiLoader({ VueAMap.initAMapApiLoader({
  key: '32396af00cd726deed804cf5b63ed2d8', key: '32396af00cd726deed804cf5b63ed2d8',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'], plugin: [
  v: '1.4.4' 'AMap.Autocomplete',
}); 'AMap.PlaceSearch',
'AMap.Scale',
'AMap.OverView',
'AMap.ToolBar',
'AMap.MapType',
'AMap.PolyEditor',
'AMap.CircleEditor',
],
v: '1.4.4',
})
// 全局组件挂载 // 全局组件挂载
Vue.component('Pagination', Pagination) Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar) Vue.component('RightToolbar', RightToolbar)
......
...@@ -10,7 +10,7 @@ const service = axios.create({ ...@@ -10,7 +10,7 @@ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分 // axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL: baseURL:
process.env.NODE_ENV === 'development' process.env.NODE_ENV === 'development'
? process.env.VUE_APP_BASE_API ? '/api'
: process.env.VUE_APP_BASE_API, : process.env.VUE_APP_BASE_API,
// 超时 // 超时
timeout: 10000, timeout: 10000,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!