mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-10 23:54:57 +08:00
feat: 选取本地图标支持svg
This commit is contained in:
parent
3ec52e5729
commit
e99de56baa
@ -640,13 +640,15 @@ getQuickCommandScriptFile = ext => {
|
|||||||
|
|
||||||
getBase64Ico = async filepath => {
|
getBase64Ico = async filepath => {
|
||||||
let sourceImage, ext = path.extname(filepath).slice(1)
|
let sourceImage, ext = path.extname(filepath).slice(1)
|
||||||
if (ext == 'png' || ext == 'jpg' || ext == 'jpeg' || ext == 'bmp' || ext == 'ico') {
|
if (['png', 'jpg', 'jpeg', 'bmp', 'ico', 'gif', 'svg'].includes(ext)) {
|
||||||
|
if (ext == 'svg') ext = 'svg+xml'
|
||||||
sourceImage = `data:image/${ext};base64,` + fs.readFileSync(filepath, 'base64')
|
sourceImage = `data:image/${ext};base64,` + fs.readFileSync(filepath, 'base64')
|
||||||
} else {
|
} else {
|
||||||
sourceImage = utools.getFileIcon(filepath)
|
sourceImage = utools.getFileIcon(filepath)
|
||||||
}
|
}
|
||||||
let compressedImage = await getCompressedIco(sourceImage)
|
let compressedImage = await getCompressedIco(sourceImage)
|
||||||
return compressedImage.length > sourceImage.length ? sourceImage : compressedImage
|
if (sourceImage.length < compressedImage.length && ext == 'png') compressedImage = sourceImage
|
||||||
|
return compressedImage
|
||||||
}
|
}
|
||||||
|
|
||||||
getCompressedIco = async (img, width = 40) => {
|
getCompressedIco = async (img, width = 40) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user