基础框架 兼容视频格式

  • 基础框架 兼容视频格式 修改 \src\components\Upload\src\BasicUpload.vue 数据库新增 vue
<template><div class="w-full"><div class="upload"><div class="upload-card"><!--图片列表--><divclass="upload-card-item":style="getCSSProperties"v-for="(item, index) in imgList":key="`img_${index}`"><div v-if="type == 'video'" class="upload-card-item-info upload-card-item-info2"><video style="width: 100%; height: 100%;" controls :src="item"></video><div class="img-box-actions2"><n-icon size="18" class="mx-2 action-icon" @click="remove(index)"><DeleteOutlined /></n-icon></div></div><div v-else-if="type=='singleGraph'||type=='multiGraph'" class="upload-card-item-info"><div class="img-box"><img :src="item" /></div><div class="img-box-actions"><n-icon size="18" class="mx-2 action-icon" @click="preview(item)"><EyeOutlined /></n-icon><n-icon size="18" class="mx-2 action-icon" @click="remove(index)"><DeleteOutlined /></n-icon></div></div><div v-else class="upload-card-item-info"><div style="width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;"><n-icon size="40" :depth="4"><FileOutlined /></n-icon></div><div class="img-box-actions"><n-icon size="18" class="mx-2 action-icon" @click="remove(index)"><DeleteOutlined /></n-icon></div></div></div><!--上传图片 v-if="imgList.length < maxNumber"  --><div v-if="imgList.length < maxNumber"class="upload-card-item upload-card-item-select-picture":style="getCSSProperties"><n-uploadv-bind="$props":file-list-style="{ display: 'none' }"@before-upload="beforeUpload"@finish="finish"style="display:flex;justify-content: center;"><div class="flex flex-col justify-center" ><n-icon size="18" class="m-auto"><PlusOutlined /></n-icon><span class="upload-title">点击上传</span></div></n-upload></div></div></div><!--上传图片--><div ><n-alert title="提醒" type="info" closable v-if="helpText" class="flex w-full">{{ helpText }}</n-alert></div></div><!--预览图片--><n-modalv-model:show="showModal"preset="card"title="预览":bordered="false":style="{ width: '520px' }"><img :src="previewUrl" /></n-modal>
</template><script lang="ts">import { defineComponent, toRefs, reactive, computed, watch } from 'vue';import { EyeOutlined, DeleteOutlined, PlusOutlined,FileOutlined } from '@vicons/antd';import { basicProps } from './props';import { useMessage, useDialog } from 'naive-ui';import { ResultEnum } from '@/enums/httpEnum';import componentSetting from '@/settings/componentSetting';import { useGlobSetting } from '@/hooks/setting';import { isString } from '@/utils/is';const globSetting = useGlobSetting();export default defineComponent({name: 'BasicUpload',components: { EyeOutlined, DeleteOutlined, PlusOutlined,FileOutlined },props: {...basicProps,},emits: ['uploadChange', 'delete'],setup(props, { emit }) {const getCSSProperties = computed(() => {return {width: `${props.width}px`,height: `${props.height}px`,max: `${props.max}`,};});console.log('props:', props)const message = useMessage();const dialog = useDialog();const state = reactive({showModal: false,previewUrl: '',originalImgList: [] as string[],imgList: [] as string[],});//赋值默认图片显示watch(() => props.value,() => {if(props.value){state.imgList = props.value.map((item) => {return getImgUrl(item);});state.originalImgList  = props.value;}},{ immediate: true });//预览function preview(url: string) {state.showModal = true;state.previewUrl = url;}//删除function remove(index: number) {dialog.info({title: '提示',content: '你确定要删除吗?',positiveText: '确定',negativeText: '取消',onPositiveClick: () => {state.imgList.splice(index, 1);state.originalImgList.splice(index, 1);emit('uploadChange', state.originalImgList);emit('delete', state.originalImgList);},onNegativeClick: () => {},});}//组装完整图片地址function getImgUrl(url: string): string {const { imgUrl } = globSetting;return /(^http|https:\/\/)/g.test(url) ? url : `${imgUrl}${url}`;}function checkFileType(fileType:string[],filetype: string) {if(filetype.indexOf('/')!=-1){return fileType.includes(`.${filetype}`) || fileType.includes(`.${filetype.split('/')[1]}`);}return fileType.includes(filetype);// return componentSetting.upload.fileType.includes(fileType);}//上传之前function beforeUpload({ file }) {const fileInfo = file.file;const { maxSize, accept } = props;const acceptRef = (isString(accept) && accept.split(',')) || [];// 设置最大值,则判断if (maxSize && fileInfo.size / 1024 / 1024 >= maxSize) {message.error(`上传文件最大值不能超过${maxSize}M`);return false;}// 设置类型,则判断// let fileType : string[] = componentSetting.upload.fileType;// fileType = [...fileType,...acceptRef];// if (acceptRef.length > 0 && !checkFileType(fileInfo.type)) {if (!checkFileType(acceptRef,fileInfo.type)) {message.error(`您上传的格式为:${fileInfo.type.split('/')[1]},只能上传文件类型为${acceptRef.join(',')}`);return false;}return true;}//上传结束function finish({ event: Event }) {const res = eval('(' + (Event.target?Event.target.response:event.target.response)+ ')');const infoField = componentSetting.upload.apiSetting.infoField;const { code } = res;const message = res.msg || res.message || '上传失败';const result = res[infoField];//成功if (code === ResultEnum.SUCCESS) {let imgUrl: string = getImgUrl(result);state.imgList.push(imgUrl);state.originalImgList.push(result);emit('uploadChange', state.originalImgList);} else message.error(message);}return {...toRefs(state),finish,preview,remove,beforeUpload,getCSSProperties,};},});
</script><style lang="less">.upload {width: 100%;overflow: hidden;&-card {width: auto;height: auto;display: flex;flex-wrap: wrap;align-items: center;&-item {margin: 0 8px 8px 0;position: relative;padding: 8px;border: 1px solid #d9d9d9;border-radius: 2px;display: flex;justify-content: center;flex-direction: column;align-items: center;&:hover {background: 0 0;.upload-card-item-info::before {opacity: 1;}.upload-card-item-info2::before {content: normal;}&-info::before {opacity: 1;}}&-info {position: relative;height: 100%;width: 100%;padding: 0;overflow: hidden;&:hover {.img-box-actions {opacity: 1;}}&::before {position: absolute;z-index: 1;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.5);opacity: 0;transition: all 0.3s;content: ' ';}.img-box {position: relative;//padding: 8px;//border: 1px solid #d9d9d9;border-radius: 2px;}.img-box-actions {position: absolute;top: 50%;left: 50%;z-index: 10;white-space: nowrap;transform: translate(-50%, -50%);opacity: 0;transition: all 0.3s;display: flex;align-items: center;justify-content: space-between;&:hover {background: 0 0;}.action-icon {color: rgba(255, 255, 255, 0.85);&:hover {cursor: pointer;color: #fff;}}}.img-box-actions2 {position: absolute;top: 0;right: 0;z-index: 10;background: rgba(0, 0, 0, 0.5);.action-icon {color: rgba(255, 255, 255, 0.85);&:hover {cursor: pointer;color: #fff;}}}}}&-item-select-picture {border: 1px dashed #d9d9d9;border-radius: 2px;cursor: pointer;background: #fafafa;color: #666;.upload-title {color: #666;}}}}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/diannao/84717.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

qiankun 子应用怎样通过 props拿到子应用【注册之后挂载之前】主应用中发生变更的数据

场景描述&#xff1a;子应用需要在接口调用和页面渲染时&#xff0c;需要用到主应用登录之后拿到的用户数据 逻辑前提&#xff1a; 1、主应用在 main.js中通过 registerMicroApps注册了子应用 2、主应用登录之后将用户数据传递给子应用 >> 原先的做法&#xff08;有问题&…

Hooks 进阶:自定义 Hook 的设计与实践

引言 React Hooks 已成为现代 React 开发的核心范式&#xff0c;而自定义 Hook 则为我们提供了强大的代码复用机制。 自定义 Hook 的基础原理 自定义 Hook 本质上是一种函数复用机制&#xff0c;它允许我们将组件逻辑提取到可重用的函数中。与传统的高阶组件(HOC)和 render …

锂电电动扭剪扳手市场报告:现状、趋势与竞争格局深度解析

一、锂电电动扭剪扳手市场概述 锂电电动扭剪扳手作为建筑施工、钢结构安装等领域的关键工具&#xff0c;凭借其便携性、高效性及环保特性&#xff0c;正逐步替代传统手动及气动工具。该设备通过锂电池供电&#xff0c;结合智能扭矩控制技术&#xff0c;可精准完成高强度螺栓的…

[面试精选] 0076. 最小覆盖子串

文章目录 1. 题目链接2. 题目描述3. 题目示例4. 解题思路5. 题解代码6. 复杂度分析 1. 题目链接 76. 最小覆盖子串 - 力扣&#xff08;LeetCode&#xff09; 2. 题目描述 给你一个字符串 s 、一个字符串 t 。返回 s 中涵盖 t 所有字符的最小子串。如果 s 中不存在涵盖 t 所有字…

rabbitmq的高级特性

一.发送者的可靠性 1.生产者重试机制 修改publisher模块的application.yaml文件 spring:rabbitmq:connection-timeout: 1s # 设置MQ的连接超时时间template:retry:enabled: true # 开启超时重试机制initial-interval: 1000ms # 失败后的初始等待时间multiplier: 1 # 失败后下…

北京大学肖臻老师《区块链技术与应用》公开课:02-BTC-密码学原理

文章目录 1.比特币中用到的密码学的功能2. hash3. 签名 1.比特币中用到的密码学的功能 比特币中用到密码学中两个功能&#xff1a; hash、 签名。 2. hash hash函数的三个特性&#xff1a;抗碰撞性&#xff08;Collision Resistance&#xff09;、隐蔽性&#xff08;Hiding&…

Spring Cloud Gateway高并发限流——基于Redis实现方案解析

本文是一个基于 Spring Cloud Gateway 的分布式限流方案&#xff0c;使用Redis Lua实现高并发场景下的精准流量控制。该方案支持动态配置、多维度限流&#xff08;API路径/IP/用户&#xff09;&#xff0c;并包含完整的代码实现和性能优化建议。 一、架构设计 #mermaid-svg-vg…

SpringAI--RAG知识库

SpringAI–RAG知识库 RAG概念 什么是RAG&#xff1f; RAG(Retrieval-Augmented Genreation&#xff0c;检索增强生成)是一种结合信息检索技术和AI内容生成的混合架构&#xff0c;可以解决大模型的知识时效性限制和幻觉问题。 RAG在大语言模型生成回答之前&#xff0c;会先从…

【PhysUnits】14 二进制数的标准化表示(standardization.rs)

一、源码 这段代码主要用于处理二进制数的标准化表示。它定义了两个特质(trait) IfB0 和 IfB1&#xff0c;以及它们的实现&#xff0c;用于处理二进制数的前导零及前导一的简化。 use super::basic::{B0, B1, Z0, N1, Integer, NonZero, NonNegOne};/// 处理 B0<H> 类型…

将 ubutun 的网络模式 从NAT 改到 桥接模式后,无法上网,linux 没有IP地址 的解决方案

首先要将 ubutun 的网络模式设置为桥接模式 这里再从 NAT 模式改动成 桥接模式的时候&#xff0c;还出现了一个问题。改成桥接模式后&#xff0c;linux没有ip地址了。原因是 不知道什么时候 将 虚拟网络编辑器 中的值改动了 要选择这个 自动 选项

多模态大语言模型arxiv论文略读(九十)

Hybrid RAG-empowered Multi-modal LLM for Secure Data Management in Internet of Medical Things: A Diffusion-based Contract Approach ➡️ 论文标题&#xff1a;Hybrid RAG-empowered Multi-modal LLM for Secure Data Management in Internet of Medical Things: A Di…

电脑主板VGA长亮白灯

电脑主板VGA长亮白灯 起因解决方法注意事项&#xff1a; 起因 搬家没有拆机整机在车上晃荡导致显卡松动接触不良&#xff08;一般VGA长亮白灯都和显卡有关&#xff0c;主要排查显卡&#xff09; 解决方法 将显卡拆下重新安装即可 注意事项&#xff1a; 不可直接拔下显卡&a…

【监控】pushgateway中间服务组件

Pushgateway 是 Prometheus 生态中的一个中间服务组件&#xff0c;以独立工具形式存在&#xff0c;主要用于解决 Prometheus 无法直接获取监控指标的场景&#xff0c;弥补其定时拉取&#xff08;pull&#xff09;模式的不足。 其用途如下&#xff1a; 突破网络限制&#xff1…

打造AI智能旅行规划器:基于LLM和Crew AI的Agent实践

引言 今天来学习大佬开发的一个AI驱动的旅行规划应用程序&#xff0c;它能够自动处理旅行规划的复杂性——寻jni找航班、预订酒店以及优化行程。传统上&#xff0c;这个过程需要手动搜索多个平台&#xff0c;常常导致决策效率低下。 通过利用**代理型人工智能&#xff08;Age…

21. 自动化测试框架开发之Excel配置文件的测试用例改造

21. 自动化测试框架开发之Excel配置文件的测试用例改造 一、测试框架核心架构 1.1 组件依赖关系 # 核心库依赖 import unittest # 单元测试框架 import paramunittest # 参数化测试扩展 from chap3.po import * # 页面对象模型 from file_reader import E…

如何在电力系统中配置和管理SNTP时间同步?

在电力系统中配置和管理 SNTP 时间同步需结合行业标准&#xff08;如《DL/T 1100.1-2019》&#xff09;和分层架构特点&#xff0c;确保安全性、可靠性和精度适配。以下是具体操作指南&#xff0c;涵盖架构设计、设备配置、安全管理、运维监控四大核心环节&#xff0c;并附典型…

MTK-关于HW WCN的知识讲解

前言: 最近做项目过程中和硬件打交道比较多,现在关于整理下硬件的HW wcn的知识点 一 MTK常见的MT6631 Wi-Fi 2.4GHz 匹配调谐指南 ‌拓扑结构选择‌ 推荐采用并联电容拓扑(‌shunt cap topology‌)代替并联电感拓扑(‌shunt inductor topology‌),以减少潜在电路设计…

(1)课堂 1--5,这五节主要讲解 mysql 的概念,定义,下载安装与卸载

&#xff08;1&#xff09;谢谢老师&#xff1a; &#xff08;2&#xff09;安装 mysql &#xff1a; &#xff08;3&#xff09;镜像下载 &#xff0c;这个网址很好 &#xff1a; &#xff08;4&#xff09; 另一个虚拟机的是 zhang 123456 &#xff1a; 接着配置…

U-Boot ARMv8 平台异常处理机制解析

入口点&#xff1a;arch/arm/cpu/armv8/start.S 1. 判断是否定义了钩子&#xff0c;如有则执行&#xff0c;否则往下走。执行save_boot_params&#xff0c;本质就是保存一些寄存器的值。 2. 对齐修复位置无关码的偏移 假设U-Boot链接时基址为0x10000&#xff0c;但实际加载到0…

mysql安装教程--笔记

一、Windows 系统安装 方法1&#xff1a;使用 MySQL Installer&#xff08;推荐&#xff09; 1. 下载安装包 访问 MySQL 官网下载页面&#xff0c;选择 MySQL Installer for Windows。 2. 运行安装程序 双击下载的 .msi 文件&#xff0c;选择安装类型&#xff1a; ◦ Developer…