| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import store from '@/store'
- import { baseURL } from '@/utils/http'
- export type FileListType = {
- id: number
- fileName: string
- filePath: string
- thumb: string
- type: 'img' | 'video' | 'doc'
- }
- // 查看 权限 图片 /视频 、音频
- export const authFilesLookFu = (name: string, url: string) => {
- let flag = false
- const nameRes = name ? name : ''
- // pdf和txt 直接新窗口打开
- const arr0: ('.pdf' | '.txt')[] = ['.pdf', '.txt']
- arr0.forEach(v => {
- if (nameRes.toLowerCase().endsWith(v)) {
- if (url) window.open(baseURL + url)
- flag = true
- }
- })
- // 图片使用 antd的图片预览组件
- const arr1 = ['.png', '.jpg', '.jpeg', '.gif']
- arr1.forEach(v => {
- if (nameRes.toLowerCase().endsWith(v)) {
- if (url) {
- store.dispatch({
- type: 'layout/lookBigImg',
- payload: {
- url: baseURL + url,
- show: true
- }
- })
- }
- flag = true
- }
- })
- // 视频和音频 使用自己的封装的组件
- let type: '' | 'video' | 'audio' = ''
- const arr2 = ['.mp3', '.wav']
- arr2.forEach(v => {
- if (nameRes.toLowerCase().endsWith(v)) {
- type = 'audio'
- flag = true
- }
- })
- if (nameRes.toLowerCase().endsWith('.mp4')) {
- type = 'video'
- flag = true
- }
- if (type && url) {
- store.dispatch({
- type: 'layout/lookDom',
- payload: {
- src: url,
- type
- }
- })
- }
- return flag
- }
|