重构: 添加全局文件及图片上传配置
							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' | ||||
| # 初始化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 | ||||
|  os.path.isdir(os.path.join(PLUGINS_PATH, ele)) and not ele.startswith('__')] | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,7 +15,8 @@ import { | |||
| import { request } from '@/api/service' | ||||
| import util from '@/libs/util' | ||||
| 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 | ||||
|  | @ -105,7 +106,7 @@ Vue.use(D2pFullEditor, { | |||
| Vue.use(D2pDemoExtend) | ||||
| Vue.use(D2pFileUploader) | ||||
| Vue.use(D2pUploader, { | ||||
|   defaultType: 'cos', | ||||
|   defaultType: 'form', | ||||
|   cos: { | ||||
|     domain: 'https://d2p-demo-1251260344.cos.ap-guangzhou.myqcloud.com', | ||||
|     bucket: 'd2p-demo-1251260344', | ||||
|  | @ -159,8 +160,20 @@ Vue.use(D2pUploader, { | |||
|     domain: 'http://d2p.file.veryreader.com' | ||||
|   }, | ||||
|   form: { | ||||
|     action: util.baseURL() + 'upload/form/upload', | ||||
|     name: 'file' | ||||
|     action: uploadUrl, | ||||
|     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', | ||||
|       dict: { | ||||
|         cache: true, | ||||
|         url: '/api/system/dept/?limit=999&status=1', | ||||
|         url: deptPrefix + '?limit=999&status=1', | ||||
|         isTree: true, | ||||
|         value: 'id', // 数据字典中value字段的属性名 | ||||
|         label: 'name', // 数据字典中label字段的属性名 | ||||
|  | @ -267,7 +280,7 @@ Vue.prototype.commonEndColumns = function (param = {}) { | |||
|           component | ||||
|         }) => { | ||||
|           return request({ | ||||
|             url: url, | ||||
|             url: url | ||||
|           }).then(ret => { | ||||
|             return ret.data.data | ||||
|           }) | ||||
|  |  | |||
|  | @ -149,7 +149,7 @@ export default { | |||
|       headers: { | ||||
|         Authorization: 'JWT ' + util.cookies.get('token') | ||||
|       }, | ||||
|       fileList:[], | ||||
|       fileList: [], | ||||
|       userInfo: { | ||||
|         name: '', | ||||
|         gender: '', | ||||
|  | @ -197,7 +197,7 @@ export default { | |||
|         params: {} | ||||
|       }).then((res) => { | ||||
|         _self.userInfo = res.data | ||||
|         _self.fileList = [{name:'avatar.png',url:res.data.avatar}] | ||||
|         _self.fileList = [{ name: 'avatar.png', url: res.data.avatar }] | ||||
|       }) | ||||
|     }, | ||||
|     /** | ||||
|  | @ -278,10 +278,10 @@ export default { | |||
|      * @param res | ||||
|      * @param file | ||||
|      */ | ||||
|     handleAvatarSuccess(res, file) { | ||||
|       console.log(11,res) | ||||
|       this.fileList =[{ url: util.baseURL() + res.data.url, name:file.name }] | ||||
|       this.userInfo.avatar = util.baseURL() + res.data.url; | ||||
|     handleAvatarSuccess (res, file) { | ||||
|       console.log(11, res) | ||||
|       this.fileList = [{ url: util.baseURL() + res.data.url, name: file.name }] | ||||
|       this.userInfo.avatar = util.baseURL() + res.data.url | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ export default { | |||
|       util.cookies.set('token', res.access) | ||||
|       util.cookies.set('refresh', res.refresh) | ||||
|       // 设置 vuex 用户信息 | ||||
|       await dispatch('d2admin/user/set', { name: res.name, user_id: res.userId,avatar:res.avatar }, { root: true }) | ||||
|       await dispatch('d2admin/user/set', { name: res.name, user_id: res.userId, avatar: res.avatar }, { root: true }) | ||||
|       // 用户登录后从持久化数据加载一系列的设置 | ||||
|       await dispatch('load') | ||||
|     }, | ||||
|  |  | |||
|  | @ -1,6 +1,4 @@ | |||
| import { request } from '@/api/service' | ||||
| import util from '@/libs/util' | ||||
| const uploadUrl = process.env.VUE_APP_API + '/api/system/img/' | ||||
| export const crudOptions = (vm) => { | ||||
|   return { | ||||
|     pageOptions: { | ||||
|  | @ -85,20 +83,6 @@ export const crudOptions = (vm) => { | |||
|         form: { | ||||
|           component: { | ||||
|             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 配置一致 | ||||
|                 multiple: false, | ||||
|                 limit: 5 // 限制5个文件 | ||||
|  | @ -139,20 +123,6 @@ export const crudOptions = (vm) => { | |||
|         form: { | ||||
|           component: { | ||||
|             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 配置一致 | ||||
|                 multiple: false, | ||||
|                 limit: 5 // 限制5个文件 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ import { BUTTON_STATUS_BOOL } from '@/config/button' | |||
| import { urlPrefix as deptPrefix } from '../dept/api' | ||||
| import util from '@/libs/util' | ||||
| 
 | ||||
| const uploadUrl = util.baseURL() + 'api/system/file/' | ||||
| export const crudOptions = (vm) => { | ||||
|   return { | ||||
|     pageOptions: { | ||||
|  | @ -264,19 +263,6 @@ export const crudOptions = (vm) => { | |||
|         form: { | ||||
|           component: { | ||||
|             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 配置一致 | ||||
|                 multiple: true, | ||||
|                 limit: 5 // 限制5个文件 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 李强
						李强