Files
fe-manage/src/hooks/useMediaComponent.js
陈昱达 f07582d5c1 feat(course): 支持考试类型资源的选择与上传
- 新增试卷列表获取逻辑,支持考试类型资源展示
- 优化文件上传校验,统一获取文件类型与大小限制
- 调整课程列表请求方法名,增强代码可读性
- 移除冗余的showDialog响应式变量
- 新增自定义考试按钮,区分不同资源类型的上传入口
- 更新文件基础URL配置,使用环境变量动态设置
- 引入试卷相关API模块,支持考试资源操作接口调用
- 扩展useCreateCourseMaps钩子,增加获取试卷列表方法
2025-11-24 19:44:43 +08:00

35 lines
946 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ref, watch } from "vue";
/**
* 通用媒体组件hook用于处理媒体组件的公共逻辑
* @param {Object} props - 组件props
* @param {Function} emit - 组件emit函数
*/
export function useMediaComponent(props, emit) {
// Create a reactive copy of the prop for local modifications
const localDialogVideoForm = ref({ ...props.dialogVideoForm });
// Watch for changes in the prop and update the local copy
watch(
() => props.dialogVideoForm,
(newVal) => {
Object.assign(localDialogVideoForm.value, newVal);
},
{ deep: true }
);
// Update form values and emit changes
const updateFormValue = (field, value) => {
localDialogVideoForm.value[field] = value;
emit("update:dialogVideoForm", { ...localDialogVideoForm.value });
};
const fileBaseUrl = `${process.env.VUE_APP_BOE_API_URL}/upload`;
return {
localDialogVideoForm,
updateFormValue,
fileBaseUrl,
};
}