弃用jimp

This commit is contained in:
fofolee
2024-12-30 19:49:28 +08:00
parent 5e2994fe6d
commit 7a79d3a443
10 changed files with 225 additions and 1904 deletions

View File

@@ -145,6 +145,7 @@
</template>
<script>
import pictureCompress from "picture-compressor";
export default {
name: "PersonalizeMenu",
@@ -169,8 +170,9 @@ export default {
const file =
mode === "light" ? this.selectFileLight : this.selectFileDark;
if (!file) return;
const processedImage = await window.imageProcessor(file.path);
const processedImage = await this.compressingPic(
window.resolveFileToBase64(file.path)
);
if (mode === "light") {
this.$root.profile.backgroundImgLight = processedImage;
@@ -188,6 +190,16 @@ export default {
this.$root.profile.glassEffect = val;
this.$root.saveProfile();
},
async compressingPic(img) {
let compressedImage = await pictureCompress({
img: img,
width: 1280,
height: 720,
type: "jpg",
quality: 0.8,
});
return compressedImage.img;
},
},
};
</script>

View File

@@ -92,7 +92,8 @@ export default {
options: ref(null),
loading: false,
icon8: {
platform: "office80,color,fluent,nolan,3d-fluency,isometric,emoji,dusk,stickers,plasticine,bubbles,cotton,clouds,doodle,arcade,pulsar-color,clr-gls,ultraviolet,flat_round,parakeet,neon,matisse,tiny-color,stencil,avantgarde,water-color,retro,3d-plastilina,stitch",
platform:
"office80,color,fluent,nolan,3d-fluency,isometric,emoji,dusk,stickers,plasticine,bubbles,cotton,clouds,doodle,arcade,pulsar-color,clr-gls,ultraviolet,flat_round,parakeet,neon,matisse,tiny-color,stencil,avantgarde,water-color,retro,3d-plastilina,stitch",
amount: "300",
baseUrl: "https://search.icons8.com/api/iconsets/v5/search",
},
@@ -158,7 +159,7 @@ export default {
this.localIconFile.slice(-4) === ".exe"
)
return this.setIcon(utools.getFileIcon(this.localIconFile));
this.compressingPic(window.getBase64Ico(this.localIconFile)).then(
this.compressingPic(window.resolveFileToBase64(this.localIconFile)).then(
(dataUrl) => {
dataUrl && this.setIcon(dataUrl);
}
@@ -177,13 +178,15 @@ export default {
argvs: imgUrl,
readfile: false,
});
let imgPath = window.getQuickcommandTempFile(imgInfo.ext, 'TempImgFile');
let imgPath = window.getQuickcommandTempFile(imgInfo.ext, "TempImgFile");
quickcommand
.downloadFile(imgUrl, imgPath)
.then(() => {
this.compressingPic(window.getBase64Ico(imgPath)).then((src) => {
callback(src);
});
this.compressingPic(window.resolveFileToBase64(imgPath)).then(
(src) => {
callback(src);
}
);
})
.catch((e) => {
quickcommand.showMessageBox("图片地址有误!", "error");

View File

@@ -51,7 +51,7 @@ export default {
};
try {
let res = await quickcommand.downloadFile(iconUrl, iconPath);
if (res) command.features.icon = window.getBase64Ico(iconPath);
if (res) command.features.icon = window.resolveFileToBase64(iconPath);
} catch (e) {}
this.importCommand(command);
utools.showNotification("操作成功!");

View File

@@ -120,7 +120,7 @@ export default {
features: {
cmds: this.nickName,
explain: this.feature.explain,
icon: window.getBase64Ico(this.plugin.logoPath),
icon: window.resolveFileToBase64(this.plugin.logoPath),
platform: this.plugin.platform || ["darwin", "win32", "linux"],
code: `key_${uid}`,
},

View File

@@ -2,193 +2,203 @@
* 所有的匹配类型
*/
const jsonSample = [
"关键词",
{
"type": "img",
"label": "图片匹配"
"关键词",
{
type: "img",
label: "图片匹配",
},
{
type: "files",
label: "文件匹配",
fileType: "file",
match: "/aaa/",
minLength: 1,
maxLength: 99,
},
{
type: "regex",
label: "文本正则匹配",
match: "/bbb/i",
minLength: 1,
maxLength: 99,
},
{
type: "over",
label: "无匹配时",
exclude: "/ccc/i",
minLength: 1,
maxLength: 99,
},
{
type: "window",
label: "窗口动作",
match: {
app: ["ddd.app", "eee.exe"],
title: "/fff/",
class: ["ggg"],
},
{
"type": "files",
"label": "文件匹配",
"fileType": "file",
"match": "/aaa/",
"minLength": 1,
"maxLength": 99
},
{
"type": "regex",
"label": "文本正则匹配",
"match": "/bbb/i",
"minLength": 1,
"maxLength": 99
},
{
"type": "over",
"label": "无匹配时",
"exclude": "/ccc/i",
"minLength": 1,
"maxLength": 99
},
{
"type": "window",
"label": "窗口动作",
"match": {
"app": [
"ddd.app",
"eee.exe"
],
"title": "/fff/",
"class": [
"ggg"
]
}
}
]
},
];
const commandTypes = {
key: {
name: "key",
label: "关键词",
icon: "font_download",
color: "teal",
matchLabel: "关键词",
desc: "直接在主输入框输入对应关键字,最通用的一种模式,关键字可以设置多个",
valueType: "array",
disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => rules,
verify: (rules) => !_.isEmpty(rules) || "关键词不能为空",
key: {
name: "key",
label: "关键词",
icon: "font_download",
color: "teal",
matchLabel: "关键词",
desc: "直接在主输入框输入对应关键字,最通用的一种模式,关键字可以设置多个",
valueType: "array",
disabledSpecialVars:
/{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => rules,
verify: (rules) => !_.isEmpty(rules) || "关键词不能为空",
},
regex: {
name: "regex",
label: "正则/划词",
icon: "rule",
color: "cyan",
matchLabel: "正则",
desc: "匹配主输入框或超级面板选中的文本,可以获取输入框文本或选中文本作为变量",
valueType: "regex",
disabledSpecialVars:
/{{SelectFile}}|{{MatchImage}}|{{WindowInfo.*?}}|{{pwd}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [
{
label: desc,
type: "regex",
match: rules,
minNum: 1,
},
],
verify: (rules) => !!rules > 0 || "正则不能为空",
tempPayload: async () => {
let values = await quickcommand.showInputBox(["需要处理的文本"]);
return values[0];
},
regex: {
name: "regex",
label: "正则/划词",
icon: "rule",
color: "cyan",
matchLabel: "正则",
desc: "匹配主输入框或超级面板选中的文本,可以获取输入框文本或选中文本作为变量",
valueType: "regex",
disabledSpecialVars: /{{SelectFile}}|{{MatchImage}}|{{WindowInfo.*?}}|{{pwd}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [{
label: desc,
type: "regex",
match: rules,
minNum: 1,
}, ],
verify: rules => !!rules > 0 || "正则不能为空",
tempPayload: async() => {
let values = await quickcommand.showInputBox(["需要处理的文本"])
return values[0]
}
},
over: {
name: "over",
label: "所有文本",
matchLabel: "无需设置",
icon: "emergency",
color: "light-green",
desc: "匹配主输入框的所有文本,但只有在该文本未设置对应的插件或功能时才生效",
valueType: null,
disabledSpecialVars:
/{{SelectFile}}|{{MatchImage}}|{{WindowInfo.*?}}|{{pwd}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [
{
label: desc,
type: "over",
minNum: 1,
},
],
verify: (rules) => true,
tempPayload: async () => {
let values = await quickcommand.showInputBox(["需要处理的文本"]);
return values[0];
},
over: {
name: "over",
label: "所有文本",
matchLabel: "无需设置",
icon: "emergency",
color: "light-green",
desc: "匹配主输入框的所有文本,但只有在该文本未设置对应的插件或功能时才生效",
valueType: null,
disabledSpecialVars: /{{SelectFile}}|{{MatchImage}}|{{WindowInfo.*?}}|{{pwd}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [{
label: desc,
type: "over",
minNum: 1,
}],
verify: rules => true,
tempPayload: async() => {
let values = await quickcommand.showInputBox(["需要处理的文本"])
return values[0]
}
},
window: {
name: "window",
label: "窗口/进程",
matchLabel: "进程名",
icon: "widgets",
color: "indigo",
desc: "匹配呼出uTools前或唤出超级面板时的活动窗口可以获取窗口的信息或文件夹路径作为变量",
valueType: "array",
disabledSpecialVars: /{{input}}|{{MatchImage}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [{
type: "window",
label: desc,
match: {
"app": rules
}
}],
verify: rules => !_.isEmpty(rules) || "进程名不能为空",
},
img: {
name: "img",
label: "图片",
matchLabel: "无需配置",
icon: "panorama",
color: "deep-orange",
desc: "匹配剪贴板的图片,并返回图片的 DataUrl",
valueType: null,
disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [{
label: desc,
type: "img",
}],
verify: rules => true,
tempPayload: () => window.getBase64Ico(utools.showOpenDialog({
title: "需要处理的图片",
filters: [{
name: 'Images',
extensions: ['png',
'jpg',
'jpeg',
'bmp',
'gif',
]
}]
})[0])
},
files: {
name: "files",
label: "复制/选中文件",
matchLabel: "正则",
icon: "description",
color: "light-blue",
desc: "匹配主输入框或超级面板选中的文件,可以获取复制及选中的文件信息作为变量",
valueType: "regex",
disabledSpecialVars: /{{input}}|{{MatchImage}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}/g,
matchToCmds: (rules, desc) => [{
type: "files",
label: desc,
match: rules.match,
fileType: rules.fileType,
minLength: 1,
}, ],
verify: rules => !!rules > 0 || "正则不能为空",
tempPayload: () => window.convertFilePathToUtoolsPayload(utools.showOpenDialog({
title: "需要处理的文件",
properties: ['openFile', 'multiSelections']
}))
},
professional: {
name: "professional",
label: "专业模式",
matchLabel: "json配置",
icon: "construction",
desc: "通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片或者指定文件数量、窗口类等",
valueType: "json",
disabledSpecialVars: null,
matchToCmds: (rules, desc) => JSON.parse(rules),
verify: rules => {
try {
JSON.parse(rules);
return true
} catch (error) {
return "专业模式json配置错误"
}
},
window: {
name: "window",
label: "窗口/进程",
matchLabel: "进程名",
icon: "widgets",
color: "indigo",
desc: "匹配呼出uTools前或唤出超级面板时的活动窗口可以获取窗口的信息或文件夹路径作为变量",
valueType: "array",
disabledSpecialVars: /{{input}}|{{MatchImage}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [
{
type: "window",
label: desc,
match: {
app: rules,
},
jsonSample: jsonSample
}
}
},
],
verify: (rules) => !_.isEmpty(rules) || "进程名不能为空",
},
img: {
name: "img",
label: "图片",
matchLabel: "无需配置",
icon: "panorama",
color: "deep-orange",
desc: "匹配剪贴板的图片,并返回图片的 DataUrl",
valueType: null,
disabledSpecialVars:
/{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => [
{
label: desc,
type: "img",
},
],
verify: (rules) => true,
tempPayload: () =>
window.resolveFileToBase64(
utools.showOpenDialog({
title: "需要处理的图片",
filters: [
{
name: "Images",
extensions: ["png", "jpg", "jpeg", "bmp", "gif"],
},
],
})[0]
),
},
files: {
name: "files",
label: "复制/选中文件",
matchLabel: "正则",
icon: "description",
color: "light-blue",
desc: "匹配主输入框或超级面板选中的文件,可以获取复制及选中的文件信息作为变量",
valueType: "regex",
disabledSpecialVars:
/{{input}}|{{MatchImage}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}/g,
matchToCmds: (rules, desc) => [
{
type: "files",
label: desc,
match: rules.match,
fileType: rules.fileType,
minLength: 1,
},
],
verify: (rules) => !!rules > 0 || "正则不能为空",
tempPayload: () =>
window.convertFilePathToUtoolsPayload(
utools.showOpenDialog({
title: "需要处理的文件",
properties: ["openFile", "multiSelections"],
})
),
},
professional: {
name: "professional",
label: "专业模式",
matchLabel: "json配置",
icon: "construction",
desc: "通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片或者指定文件数量、窗口类等",
valueType: "json",
disabledSpecialVars: null,
matchToCmds: (rules, desc) => JSON.parse(rules),
verify: (rules) => {
try {
JSON.parse(rules);
return true;
} catch (error) {
return "专业模式json配置错误";
}
},
jsonSample: jsonSample,
},
};
export default commandTypes
export default commandTypes;