添加资源上传

develoop
wenyu441069198 4 months ago
parent 6205c3fa39
commit efc569df5d
  1. 26
      src/views/courseResources/componse/resourceAdd.vue
  2. 2
      src/views/courseResources/index.vue

@ -3,6 +3,8 @@ 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: '',
@ -13,13 +15,25 @@ const defaultForm = {
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>

@ -85,7 +85,7 @@ const param = ref({
download: '0', download: '0',
content: '', content: '',
address: '/portal', address: '/portal',
type: '1', type: '4',
}) })
// //
const generateRecords = async (rescource) => { const generateRecords = async (rescource) => {

Loading…
Cancel
Save