Files
fe-manage/src/hooks/useMediaComponent.js
陈昱达 8a20689aeb feat(course): 实现课程标签管理功能
- 新增课程标签API模块,支持标签分页查询、创建、修改状态等操作
- 开发课程标签组件,支持标签搜索、创建、删除和数量限制
- 集成标签组件到专业模式页面,替换原有标签选择器
- 优化课程创建组件,重构表单状态管理和操作流程
- 升级Element Plus组件版本,支持el-select-v2等新组件
- 添加lodash依赖用于防抖搜索功能
- 调整样式和布局,优化标签显示和交互体验
2025-11-26 19:00:06 +08:00

37 lines
995 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;
if (emit) {
emit("update:dialogVideoForm", { ...localDialogVideoForm.value });
}
};
const fileBaseUrl = `${process.env.VUE_APP_BOE_API_URL}${process.env.VUE_APP_FILE_PATH}`;
return {
localDialogVideoForm,
updateFormValue,
fileBaseUrl,
};
}