diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 973977d..8ec11b2 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -16,6 +16,7 @@ declare module 'axios' { + // 图片选择 export interface ImgInfo { file: string; diff --git a/src/utils/vod.ts b/src/utils/vod.ts new file mode 100644 index 0000000..27e32ff --- /dev/null +++ b/src/utils/vod.ts @@ -0,0 +1,41 @@ +import { get } from '@/api/base' +import TcVod from "vod-js-sdk-v6" + +interface OnFunctio { + (info: unknown): unknown; +} + +interface UploaderDone { + fileId: string; + video: { + url: string; + verify_content: string; + } +} + +export async function uploadflie(file: File,on?: OnFunctio): Promise { + const getSignature = () => { + return new Promise((res) => { + get('signature').then((data) => { + console.log(data) + res(data.data) + }) + }) + } + // const res = await get('signature'); + // console.log(res.data) + const tcVod = new TcVod({ + getSignature: getSignature + }) + const uploader = tcVod.upload({ + mediaFile: file + }) + if(on != undefined){ + uploader.on('media_progress', (info) => { + on(info) + }) + } + const data = uploader.done(); + return data; + +} \ No newline at end of file diff --git a/src/views/mine/Archives.vue b/src/views/mine/Archives.vue index 76e60b4..0414f29 100644 --- a/src/views/mine/Archives.vue +++ b/src/views/mine/Archives.vue @@ -92,7 +92,7 @@
短视频
@@ -261,6 +261,7 @@ import { computed, defineComponent, reactive, Ref, ref } from "vue"; import { UserOutlined, SmileOutlined, PlaySquareOutlined } from '@ant-design/icons-vue'; import NavBottom from '@/components/NavBottom.vue'; +import { uploadflie } from "@/utils/vod" import store from '@/store'; export default defineComponent({ @@ -429,6 +430,18 @@ export default defineComponent({ console.log('12'); } + interface AntUpload{ + action: string; + data: unknown; + file: File; + } + async function uploads(file: AntUpload){ + let res = await uploadflie(file.file, (info) => { + console.log(info) + }); + console.log(res) + } + // uploadflie() return { modalNode, formData, @@ -450,7 +463,8 @@ export default defineComponent({ passwordForm, updateUserPassword, submitInfo, - userinfo + userinfo, + uploads } } });