88 <el-form-item label =" 视频标题" >
99 <el-input v-model =" title" placeholder =" 请输入视频标题" required />
1010 </el-form-item >
11+ <el-form-item label =" 视频分类" >
12+ <el-select
13+ v-model =" category"
14+ placeholder =" 请选择视频分类"
15+ style =" width : 100% "
16+ required
17+ >
18+ <el-option
19+ v-for =" item in videoCategories"
20+ :key =" item.value"
21+ :label =" item.label"
22+ :value =" item.value"
23+ />
24+ </el-select >
25+ </el-form-item >
1126 <el-form-item label =" 视频文件" >
1227 <div class =" file-input-wrapper" >
1328 <input
6984import { Picture , VideoCamera } from ' @element-plus/icons-vue' ;
7085
7186const title = ref (' ' );
87+ const category = ref (' ' );
7288const videoFile = ref <File | null >(null );
7389const thumbFile = ref <File | null >(null );
7490const loading = ref (false );
7591const token = useCookie (' token' );
7692
93+ const appConfig = useAppConfig ();
94+ const videoCategories = appConfig .videoCategories ;
95+
7796definePageMeta ({
7897 middleware : () => {
7998 if (! token .value ) {
80- if (process .client ) {
99+ if (import . meta .client ) {
81100 ElMessage .warning (' 请先登录' );
82101 }
83102 return navigateTo (' /login' );
@@ -101,6 +120,7 @@ const handleUpload = async () => {
101120
102121 const formData = new FormData ();
103122 formData .append (' title' , title .value );
123+ formData .append (' category' , category .value );
104124 formData .append (' video' , videoFile .value );
105125 formData .append (' thumbnail' , thumbFile .value );
106126
@@ -114,7 +134,7 @@ const handleUpload = async () => {
114134 });
115135 ElMessage .success (' 上传成功' );
116136 navigateTo (' /' );
117- } catch (error : any ) {
137+ } catch (error ) {
118138 ElMessage .error (error .data ?.statusMessage || ' 上传失败' );
119139 } finally {
120140 loading .value = false ;
0 commit comments