上传图片和附件路径调整为相对路径

This commit is contained in:
Vinjor 2024-09-14 18:41:05 +08:00
parent 9ec6e7a515
commit f7bdee8d14
5 changed files with 11 additions and 4 deletions

View File

@ -6,6 +6,8 @@ VUE_APP_TITLE = "车联通"后台管理系统
# 芋道管理系统/开发环境 # 芋道管理系统/开发环境
VUE_APP_BASE_API = 'http://localhost:48080' VUE_APP_BASE_API = 'http://localhost:48080'
# 附件请求地址前缀
VUE_APP_FILE_API = 'http://122.51.230.86:9000/'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@ -9,6 +9,8 @@ VUE_APP_BASE_API = '/prod-api'
# 根据服务器或域名修改 # 根据服务器或域名修改
PUBLIC_PATH = 'http://my-pi.com:8888/yudao-admin/' PUBLIC_PATH = 'http://my-pi.com:8888/yudao-admin/'
# 附件请求地址前缀
VUE_APP_FILE_API = 'http://122.51.230.86:9000/'
# 二级部署路径 # 二级部署路径
VUE_APP_APP_NAME ='yudao-admin' VUE_APP_APP_NAME ='yudao-admin'

View File

@ -72,6 +72,7 @@ export default {
return { return {
number: 0, number: 0,
uploadList: [], uploadList: [],
viewFileUrl: process.env.VUE_APP_FILE_API,
baseUrl: process.env.VUE_APP_BASE_API, baseUrl: process.env.VUE_APP_BASE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", //
headers: { Authorization: "Bearer " + getAccessToken() }, // headers: { Authorization: "Bearer " + getAccessToken() }, //
@ -88,7 +89,7 @@ export default {
// //
this.fileList = list.map(item => { this.fileList = list.map(item => {
if (typeof item === "string") { if (typeof item === "string") {
item = { name: item, url: item }; item = { name: item, url: this.viewFileUrl+item };
} }
item.uid = item.uid || new Date().getTime() + temp++; item.uid = item.uid || new Date().getTime() + temp++;
return item; return item;

View File

@ -88,6 +88,7 @@ export default {
number: 0, number: 0,
uploadList: [], uploadList: [],
baseUrl: "", baseUrl: "",
viewFileUrl: process.env.VUE_APP_FILE_API,
headers: { Authorization: "Bearer " + getAccessToken() }, // headers: { Authorization: "Bearer " + getAccessToken() }, //
fileList: [], fileList: [],
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/uploadDetail", // uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/uploadDetail", //
@ -110,7 +111,7 @@ export default {
const list = Array.isArray(val)? val : this.value.split(","); const list = Array.isArray(val)? val : this.value.split(",");
this.fileList = list.map((item) => { this.fileList = list.map((item) => {
if (typeof item === "string") { if (typeof item === "string") {
item = { name: item, url: item }; item = { name: item, url: this.viewFileUrl+item };
} }
item.uid = item.uid || new Date().getTime() + temp++; item.uid = item.uid || new Date().getTime() + temp++;
return item; return item;
@ -134,7 +135,7 @@ export default {
const list = Array.isArray(this.value)? this.value : this.value.split(","); const list = Array.isArray(this.value)? this.value : this.value.split(",");
this.fileList = list.map((item) => { this.fileList = list.map((item) => {
if (typeof item === "string") { if (typeof item === "string") {
item = { name: item, url: item }; item = { name: item, url: this.viewFileUrl+item };
} }
item.uid = item.uid || new Date().getTime() + temp++; item.uid = item.uid || new Date().getTime() + temp++;
return item; return item;

View File

@ -76,6 +76,7 @@ export default {
dialogImageUrl: "", dialogImageUrl: "",
dialogVisible: false, dialogVisible: false,
hideUpload: false, hideUpload: false,
viewFileUrl: process.env.VUE_APP_FILE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", //
headers: { Authorization: "Bearer " + getAccessToken() }, // headers: { Authorization: "Bearer " + getAccessToken() }, //
fileList: [] fileList: []
@ -91,7 +92,7 @@ export default {
this.fileList = list.map(item => { this.fileList = list.map(item => {
if (typeof item === "string") { if (typeof item === "string") {
// edit by // edit by
item = { name: item, url: item }; item = { name: item, url: this.viewFileUrl+item };
} }
return item; return item;
}); });