重构: 添加全局文件及图片上传配置
parent
3eb3c7551d
commit
ef831bacb0
|
@ -30,6 +30,8 @@ from conf.env import *
|
||||||
SECRET_KEY = 'django-insecure--z8%exyzt7e_%i@1+#1mm=%lb5=^fx_57=1@a+_y7bg5-w%)sm'
|
SECRET_KEY = 'django-insecure--z8%exyzt7e_%i@1+#1mm=%lb5=^fx_57=1@a+_y7bg5-w%)sm'
|
||||||
# 初始化plugins插件路径到环境变量中
|
# 初始化plugins插件路径到环境变量中
|
||||||
PLUGINS_PATH = os.path.join(BASE_DIR, 'plugins')
|
PLUGINS_PATH = os.path.join(BASE_DIR, 'plugins')
|
||||||
|
sys.path.insert(0, os.path.join(PLUGINS_PATH))
|
||||||
|
|
||||||
[sys.path.insert(0, os.path.join(PLUGINS_PATH, ele)) for ele in os.listdir(PLUGINS_PATH) if
|
[sys.path.insert(0, os.path.join(PLUGINS_PATH, ele)) for ele in os.listdir(PLUGINS_PATH) if
|
||||||
os.path.isdir(os.path.join(PLUGINS_PATH, ele)) and not ele.startswith('__')]
|
os.path.isdir(os.path.join(PLUGINS_PATH, ele)) and not ele.startswith('__')]
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ import {
|
||||||
import { request } from '@/api/service'
|
import { request } from '@/api/service'
|
||||||
import util from '@/libs/util'
|
import util from '@/libs/util'
|
||||||
import XEUtils from 'xe-utils'
|
import XEUtils from 'xe-utils'
|
||||||
import { urlPrefix as deptPrefix } from '@/views/system/dept/api'
|
import { urlPrefix as deptPrefix } from '@/views/system/dept/'
|
||||||
|
const uploadUrl = util.baseURL() + 'api/system/file/'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
// vxe0
|
// vxe0
|
||||||
|
@ -105,7 +106,7 @@ Vue.use(D2pFullEditor, {
|
||||||
Vue.use(D2pDemoExtend)
|
Vue.use(D2pDemoExtend)
|
||||||
Vue.use(D2pFileUploader)
|
Vue.use(D2pFileUploader)
|
||||||
Vue.use(D2pUploader, {
|
Vue.use(D2pUploader, {
|
||||||
defaultType: 'cos',
|
defaultType: 'form',
|
||||||
cos: {
|
cos: {
|
||||||
domain: 'https://d2p-demo-1251260344.cos.ap-guangzhou.myqcloud.com',
|
domain: 'https://d2p-demo-1251260344.cos.ap-guangzhou.myqcloud.com',
|
||||||
bucket: 'd2p-demo-1251260344',
|
bucket: 'd2p-demo-1251260344',
|
||||||
|
@ -159,8 +160,20 @@ Vue.use(D2pUploader, {
|
||||||
domain: 'http://d2p.file.veryreader.com'
|
domain: 'http://d2p.file.veryreader.com'
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
action: util.baseURL() + 'upload/form/upload',
|
action: uploadUrl,
|
||||||
name: 'file'
|
name: 'file',
|
||||||
|
data: {}, // 上传附加参数
|
||||||
|
headers: {
|
||||||
|
Authorization: 'JWT ' + util.cookies.get('token')
|
||||||
|
},
|
||||||
|
type: 'form',
|
||||||
|
successHandle (ret, option) {
|
||||||
|
if (ret.data === null || ret.data === '') {
|
||||||
|
throw new Error('上传失败')
|
||||||
|
}
|
||||||
|
return { url: ret.data.data.url, key: option.data.key }
|
||||||
|
},
|
||||||
|
withCredentials: false // 是否带cookie
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -257,7 +270,7 @@ Vue.prototype.commonEndColumns = function (param = {}) {
|
||||||
type: 'table-selector',
|
type: 'table-selector',
|
||||||
dict: {
|
dict: {
|
||||||
cache: true,
|
cache: true,
|
||||||
url: '/api/system/dept/?limit=999&status=1',
|
url: deptPrefix + '?limit=999&status=1',
|
||||||
isTree: true,
|
isTree: true,
|
||||||
value: 'id', // 数据字典中value字段的属性名
|
value: 'id', // 数据字典中value字段的属性名
|
||||||
label: 'name', // 数据字典中label字段的属性名
|
label: 'name', // 数据字典中label字段的属性名
|
||||||
|
@ -267,7 +280,7 @@ Vue.prototype.commonEndColumns = function (param = {}) {
|
||||||
component
|
component
|
||||||
}) => {
|
}) => {
|
||||||
return request({
|
return request({
|
||||||
url: url,
|
url: url
|
||||||
}).then(ret => {
|
}).then(ret => {
|
||||||
return ret.data.data
|
return ret.data.data
|
||||||
})
|
})
|
||||||
|
|
|
@ -281,7 +281,7 @@ export default {
|
||||||
handleAvatarSuccess (res, file) {
|
handleAvatarSuccess (res, file) {
|
||||||
console.log(11, res)
|
console.log(11, res)
|
||||||
this.fileList = [{ url: util.baseURL() + res.data.url, name: file.name }]
|
this.fileList = [{ url: util.baseURL() + res.data.url, name: file.name }]
|
||||||
this.userInfo.avatar = util.baseURL() + res.data.url;
|
this.userInfo.avatar = util.baseURL() + res.data.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { request } from '@/api/service'
|
import { request } from '@/api/service'
|
||||||
import util from '@/libs/util'
|
|
||||||
const uploadUrl = process.env.VUE_APP_API + '/api/system/img/'
|
|
||||||
export const crudOptions = (vm) => {
|
export const crudOptions = (vm) => {
|
||||||
return {
|
return {
|
||||||
pageOptions: {
|
pageOptions: {
|
||||||
|
@ -85,20 +83,6 @@ export const crudOptions = (vm) => {
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
uploader: {
|
|
||||||
action: uploadUrl,
|
|
||||||
name: 'file',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'JWT ' + util.cookies.get('token')
|
|
||||||
},
|
|
||||||
type: 'form',
|
|
||||||
successHandle (ret, option) {
|
|
||||||
if (ret.data == null || ret.data === '') {
|
|
||||||
throw new Error('上传失败')
|
|
||||||
}
|
|
||||||
return { url: ret.data.data.url, key: option.data.key }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
elProps: { // 与el-uploader 配置一致
|
elProps: { // 与el-uploader 配置一致
|
||||||
multiple: false,
|
multiple: false,
|
||||||
limit: 5 // 限制5个文件
|
limit: 5 // 限制5个文件
|
||||||
|
@ -139,20 +123,6 @@ export const crudOptions = (vm) => {
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
uploader: {
|
|
||||||
action: uploadUrl,
|
|
||||||
name: 'file',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'JWT ' + util.cookies.get('token')
|
|
||||||
},
|
|
||||||
type: 'form',
|
|
||||||
successHandle (ret, option) {
|
|
||||||
if (ret.data == null || ret.data === '') {
|
|
||||||
throw new Error('上传失败')
|
|
||||||
}
|
|
||||||
return { url: ret.data.data.url, key: option.data.key }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
elProps: { // 与el-uploader 配置一致
|
elProps: { // 与el-uploader 配置一致
|
||||||
multiple: false,
|
multiple: false,
|
||||||
limit: 5 // 限制5个文件
|
limit: 5 // 限制5个文件
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { BUTTON_STATUS_BOOL } from '@/config/button'
|
||||||
import { urlPrefix as deptPrefix } from '../dept/api'
|
import { urlPrefix as deptPrefix } from '../dept/api'
|
||||||
import util from '@/libs/util'
|
import util from '@/libs/util'
|
||||||
|
|
||||||
const uploadUrl = util.baseURL() + 'api/system/file/'
|
|
||||||
export const crudOptions = (vm) => {
|
export const crudOptions = (vm) => {
|
||||||
return {
|
return {
|
||||||
pageOptions: {
|
pageOptions: {
|
||||||
|
@ -264,19 +263,6 @@ export const crudOptions = (vm) => {
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
uploader: {
|
|
||||||
action: uploadUrl,
|
|
||||||
headers: {
|
|
||||||
Authorization: 'JWT ' + util.cookies.get('token')
|
|
||||||
},
|
|
||||||
type: 'form',
|
|
||||||
successHandle (ret, option) {
|
|
||||||
if (ret.data === null || ret.data === '') {
|
|
||||||
throw new Error('上传失败')
|
|
||||||
}
|
|
||||||
return { url: util.baseURL() + ret.data.url, key: option.data.key }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
elProps: { // 与el-uploader 配置一致
|
elProps: { // 与el-uploader 配置一致
|
||||||
multiple: true,
|
multiple: true,
|
||||||
limit: 5 // 限制5个文件
|
limit: 5 // 限制5个文件
|
||||||
|
|
Loading…
Reference in New Issue