基礎框架 兼容視頻格式

  • 基礎框架 兼容視頻格式 修改 \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
繁體地址,請注明出處:http://hk.pswp.cn/diannao/84717.shtml
英文地址,請注明出處:http://en.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…