添加了类型文件

This commit is contained in:
luyuan 2020-10-09 10:49:24 +08:00
parent 975821021d
commit 9237c995b5
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
3 changed files with 31 additions and 7 deletions

20
src/types/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
/**
*
*/
// 图片选择
export interface ImgInfo {
file: string;
}
// 表单提交的验证
export interface FromSend {
preventDefault: Function;
}
// 视频文件
export interface VideoInfo {
type: string;
name: string;
}

View File

@ -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);
}

View File

@ -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<boolean> = ref(false),
previewImage: Ref<string> = ref('');
const viewCover: Ref<boolean> = ref(false);
const previewImage: Ref<string> = 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));