zhongrj
2025-03-28 4ff3eee77b41466d08117970970d01be6e48ffe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * @Author: GuLiMmo 2820890765@qq.com
 * @Date: 2024-03-12 17:59:03
 * @LastEditors: GuLiMmo 2820890765@qq.com
 * @LastEditTime: 2024-08-27 16:52:42
 * @FilePath: /drone-web/src/utils/common.ts
 * @Description:
 * Copyright (c) 2024 by GuLiMmo, All Rights Reserved.
 */
 
import { validatenull } from './validate'
 
/**
 * 下载文件
 * @param data
 * @param fileName
 */
export const downloadFile = (data: Blob, fileName: string) => {
  const lable = document.createElement('a')
  lable.href = window.URL.createObjectURL(data)
  lable.download = fileName
  lable.click()
  URL.revokeObjectURL(lable.href)
}
 
// 表单序列化
export const serialize = (data: { [x: string]: any }) => {
  const list: string[] = []
  Object.keys(data).forEach((ele) => {
    list.push(`${ele}=${data[ele]}`)
  })
  return list.join('&')
}
 
export const requireImg = (path: string) => {
  return new URL(`/src/assets/${path}`, import.meta.url).href
}