From 9237c995b51e6f904c77a6d9657fbc0a9fcb55a1 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Fri, 9 Oct 2020 10:49:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/index.d.ts | 20 ++++++++++++++++++++ src/views/mine/ReleaseVideo.vue | 7 ++++--- src/views/mine/ReleaseWebcast.vue | 11 +++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 src/types/index.d.ts diff --git a/src/types/index.d.ts b/src/types/index.d.ts new file mode 100644 index 0000000..05d1018 --- /dev/null +++ b/src/types/index.d.ts @@ -0,0 +1,20 @@ +/** + * 只添加了一些必要的参数,并没有写完整,因为剩下的大部分用不到 + */ + + +// 图片选择 +export interface ImgInfo { + file: string; +} + +// 表单提交的验证 +export interface FromSend { + preventDefault: Function; +} + +// 视频文件 +export interface VideoInfo { + type: string; + name: string; +} \ No newline at end of file diff --git a/src/views/mine/ReleaseVideo.vue b/src/views/mine/ReleaseVideo.vue index fd4c0f4..19947d0 100644 --- a/src/views/mine/ReleaseVideo.vue +++ b/src/views/mine/ReleaseVideo.vue @@ -53,6 +53,7 @@ import { defineComponent, reactive, Ref, ref } from 'vue'; import { PlaySquareOutlined, PlusOutlined } from '@ant-design/icons-vue'; import NavBottom from '@/components/NavBottom.vue'; import { previewCover } from '@/static/js/common'; +import { ImgInfo } from '@/types'; export default defineComponent({ name: 'ReleaseWebcast', @@ -81,7 +82,7 @@ export default defineComponent({ /** * 封面改变触发事件 */ - function coverChange(info: any): void { + function coverChange(info: ImgInfo): void { // console.log(info); // 获取预览图片 previewCover(info.file).then(url => previewImage.value = url); @@ -108,7 +109,7 @@ export default defineComponent({ /** * 删除封面 */ - function cancelCover(file: any): void { + function cancelCover(file: number): void { console.log(file); } @@ -117,7 +118,7 @@ export default defineComponent({ * @param file 上传的文件 */ const beforeVideoUpload = (file: any): boolean => { - // console.log(file); + console.log(file); if(file.type != '') { // handleRemove(file); } diff --git a/src/views/mine/ReleaseWebcast.vue b/src/views/mine/ReleaseWebcast.vue index 4f7c669..bd447b2 100644 --- a/src/views/mine/ReleaseWebcast.vue +++ b/src/views/mine/ReleaseWebcast.vue @@ -87,6 +87,7 @@ import { useForm } from '@ant-design-vue/use'; import NavBottom from '@/components/NavBottom.vue'; import RankList from './RankList.vue'; import { previewCover } from '@/static/js/common'; +import { FromSend, ImgInfo } from "@/types/index" export default defineComponent({ name: 'ReleaseWebcast', @@ -144,13 +145,14 @@ export default defineComponent({ }); // 是否显示封面预览 封面的路径 - const viewCover: Ref = ref(false), - previewImage: Ref = ref(''); + const viewCover: Ref = ref(false); + const previewImage: Ref = ref(''); /** * 封面改变触发事件 */ - function coverChange(info: any): void { + + function coverChange(info: ImgInfo): void { // console.log(info); // 获取预览图片 previewCover(info.file).then(url => previewImage.value = url); @@ -162,7 +164,8 @@ export default defineComponent({ /** * 表单提交 */ - const onSubmit = (e: any) => { + + const onSubmit = (e: FromSend) => { e.preventDefault(); validate().then(() => { console.log(toRaw(form));