From f000adc90b47769649a6a7083bb4ea590099d2af Mon Sep 17 00:00:00 2001 From: qq_59556663 Date: Mon, 23 Oct 2023 14:36:37 +0800 Subject: [PATCH] Auto Commit --- .inscode | 4 +++ src/App.vue | 69 ++++++++++++++++++-------------------------- src/uitls/preview.ts | 38 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 41 deletions(-) create mode 100644 src/uitls/preview.ts diff --git a/.inscode b/.inscode index 70c7853..9fec957 100644 --- a/.inscode +++ b/.inscode @@ -1,4 +1,5 @@ run = "npm i && npm run dev" +language = "node" [deployment] build = "npm i && npm run build" @@ -8,3 +9,6 @@ run = "npm run preview" PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" + +[debugger] +program = "main.js" diff --git a/src/App.vue b/src/App.vue index 633a5df..d647cb2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,47 +1,34 @@ - - - - + \ No newline at end of file diff --git a/src/uitls/preview.ts b/src/uitls/preview.ts new file mode 100644 index 0000000..b0706c4 --- /dev/null +++ b/src/uitls/preview.ts @@ -0,0 +1,38 @@ +//获取本地图片/视频链接 + +async function preview(e: any) { + + const buffer = await e.target.files[0].arrayBuffer(); + + return URL.createObjectURL(new Blob([buffer])); + +} + +/** + + * 截取本地视频第一帧 + + * 需要传入本地视频播放的video + + * @intercpt + +*/ + +//calssname==是渲染视频的video的id + +function intercpt(calssname: HTMLElement) { + + const canvas: any = document.createElement('canvas') + + const ratio = calssname.offsetHeight / 9 / 16 + + canvas.width = Math.ceil(calssname.offsetHeight / 9) * 16 + + canvas.height = calssname.offsetHeight + + canvas.getContext('2d').drawImage(calssname, 0, 0, canvas.width, canvas.height) + + return canvas.toDataURL('image/png', 1.0) + +} +export {preview ,intercpt} \ No newline at end of file -- GitLab