|
|
@ -3,23 +3,37 @@ import { ref } from 'vue' |
|
|
|
const visibilerDrawer = ref(false) |
|
|
|
const visibilerDrawer = ref(false) |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
import { CourseResourceControllerService } from '../../../../generated/services/CourseResourceControllerService' |
|
|
|
import { CourseResourceControllerService } from '../../../../generated/services/CourseResourceControllerService' |
|
|
|
|
|
|
|
import tool from '@/utils/oss.js' |
|
|
|
|
|
|
|
import { id } from 'element-plus/es/locales.mjs'; |
|
|
|
//默认数据 |
|
|
|
//默认数据 |
|
|
|
const defaultForm = { |
|
|
|
const defaultForm = { |
|
|
|
description: '', |
|
|
|
description: '', |
|
|
|
id: '', |
|
|
|
id:'', |
|
|
|
img: '', //封面 |
|
|
|
img: '', //封面 |
|
|
|
name: '', |
|
|
|
name: '', |
|
|
|
type: '', //资源类型 |
|
|
|
type: '', //资源类型 |
|
|
|
path: '', |
|
|
|
path: '', |
|
|
|
} |
|
|
|
} |
|
|
|
const imageUrl = ref('') |
|
|
|
const imageUrl = ref('') |
|
|
|
const onSelectFile = (uploadFile) => { |
|
|
|
//上传阿里云oss |
|
|
|
// console.log(uploadFile) |
|
|
|
const upload = async (option) =>{ |
|
|
|
//预览图片 |
|
|
|
//预览图片 |
|
|
|
imageUrl.value = URL.createObjectURL(uploadFile.raw) |
|
|
|
imageUrl.value = URL.createObjectURL(option.raw) |
|
|
|
//将图片存入 |
|
|
|
const res = await tool.oss.upload(option.raw);//将图片存入阿里云 |
|
|
|
formModel.value.img = uploadFile.raw |
|
|
|
const url = "https://wenyu132.oss-cn-beijing.aliyuncs.com/" + res.name;//获取到存入阿里云后的url |
|
|
|
|
|
|
|
console.log(url); |
|
|
|
|
|
|
|
//将url赋值给要上传后端的参数里 |
|
|
|
|
|
|
|
formModel.value.img = url |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const onSelectFile = (uploadFile) => { |
|
|
|
|
|
|
|
// // console.log(uploadFile) |
|
|
|
|
|
|
|
// //预览图片 |
|
|
|
|
|
|
|
// imageUrl.value = URL.createObjectURL(uploadFile.raw) |
|
|
|
|
|
|
|
// //将图片存入 |
|
|
|
|
|
|
|
// formModel.value.img = uploadFile.raw |
|
|
|
|
|
|
|
// } |
|
|
|
//准备数据 |
|
|
|
//准备数据 |
|
|
|
|
|
|
|
|
|
|
|
const formModel = ref({ |
|
|
|
const formModel = ref({ |
|
|
@ -184,7 +198,7 @@ defineExpose({ |
|
|
|
:show-file-list="false" |
|
|
|
:show-file-list="false" |
|
|
|
:auto-upload="false" |
|
|
|
:auto-upload="false" |
|
|
|
:before-upload="beforeAvatarUpload" |
|
|
|
:before-upload="beforeAvatarUpload" |
|
|
|
:on-change="onSelectFile" |
|
|
|
:on-change="upload" |
|
|
|
> |
|
|
|
> |
|
|
|
<img v-if="imageUrl" :src="imageUrl" class="avatar" /> |
|
|
|
<img v-if="imageUrl" :src="imageUrl" class="avatar" /> |
|
|
|
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> |
|
|
|
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> |
|
|
|