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',
'avc',
'avi',
'avif',
'avs',
'bak',
'bas',

View File

@@ -66,14 +66,15 @@ export function encodeFilePath(filePath: string) {
export const getExtension = (fileName: string) => path.extname(fileName).slice(1)
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 =>
!/^https?:\/\//.test(endpoint)
? `${sslEnabled ? 'https' : 'http'}://${endpoint}`
: sslEnabled
? endpoint.replace('http://', 'https://')
: endpoint.replace('https://', 'http://')
export const formatEndpoint = (endpoint: string, sslEnabled: boolean): string => {
const hasProtocol = /^https?:\/\//.test(endpoint)
if (!hasProtocol) {
return `${sslEnabled ? 'https' : 'http'}://${endpoint}`
}
return sslEnabled ? endpoint.replace(/^http:\/\//, 'https://') : endpoint.replace(/^https:\/\//, 'http://')
}
export const trimPath = (path: string) => path.replace(/^\/+|\/+$/g, '').replace(/\/+/g, '/')