Feature(custom): support avif picture preview

This commit is contained in:
Kuingsmile 2024-07-31 14:14:41 +08:00
parent 26149ad703
commit 630eb03ef5
4 changed files with 63 additions and 60 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -21,6 +21,7 @@ export const availableIconList = [
'au', 'au',
'avc', 'avc',
'avi', 'avi',
'avif',
'avs', 'avs',
'bak', 'bak',
'bas', 'bas',

View File

@ -66,14 +66,15 @@ export function encodeFilePath(filePath: string) {
export const getExtension = (fileName: string) => path.extname(fileName).slice(1) export const getExtension = (fileName: string) => path.extname(fileName).slice(1)
export const isImage = (fileName: string) => export const isImage = (fileName: string) =>
['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'ico', 'svg'].includes(getExtension(fileName)) ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'ico', 'svg', 'avif'].includes(getExtension(fileName))
export const formatEndpoint = (endpoint: string, sslEnabled: boolean): string => export const formatEndpoint = (endpoint: string, sslEnabled: boolean): string => {
!/^https?:\/\//.test(endpoint) const hasProtocol = /^https?:\/\//.test(endpoint)
? `${sslEnabled ? 'https' : 'http'}://${endpoint}` if (!hasProtocol) {
: sslEnabled return `${sslEnabled ? 'https' : 'http'}://${endpoint}`
? endpoint.replace('http://', 'https://') }
: endpoint.replace('https://', 'http://') return sslEnabled ? endpoint.replace(/^http:\/\//, 'https://') : endpoint.replace(/^https:\/\//, 'http://')
}
export const trimPath = (path: string) => path.replace(/^\/+|\/+$/g, '').replace(/\/+/g, '/') export const trimPath = (path: string) => path.replace(/^\/+|\/+$/g, '').replace(/\/+/g, '/')

View File

@ -2,11 +2,12 @@
### 图片 ### 图片
| 格式 | 描述 | 格式 | 描述 | | 格式 | 描述 | 格式 | 描述 |
| :-----------------------------------------------------: | :----------: | :-------------------------------------------------------------: | :----------------: | | :---: | :----------: | :--------: | :----------------: |
| [.bmp](https://en.wikipedia.org/wiki/BMP_file_format) | 位图文件格式 | [.jpeg/.jpg](https://en.wikipedia.org/wiki/JPEG) | 联合照片专家组格式 | | .bmp | 位图文件格式 | .jpeg/.jpg | 联合照片专家组格式 |
| [.gif](https://en.wikipedia.org/wiki/GIF) | 图形交换格式 | [.png](https://en.wikipedia.org/wiki/Portable_Network_Graphics) | 可移植网络图形格式 | | .gif | 图形交换格式 | .png | 可移植网络图形格式 |
| [.ico](https://en.wikipedia.org/wiki/ICO_(file_format)) | 图标文件格式 | [.webp](https://developers.google.com/speed/webp/) | WebP格式 | | .ico | 图标文件格式 | .webp | WebP格式 |
| .svg | 可缩放矢量图 | .avif | AVIF格式 |
### 文本 ### 文本