mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-18 09:46:59 +08:00
feat: 支持 regex 类型
This commit is contained in:
parent
b08f4fab54
commit
d8846a0486
16892
package-lock.json
generated
Normal file
16892
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,28 @@ new Vue({
|
||||
const word = this.selectData.text;
|
||||
const isCh = isChinese(word);
|
||||
this.translate(word, isCh ? 'en' : 'zh');
|
||||
this.targetOptions = this.options.translate;
|
||||
this.targetOptions = JSON.parse(JSON.stringify(this.options.translate));
|
||||
(this.selectData.optionPlugin || []).forEach(plugin => {
|
||||
plugin.features.forEach(fe => {
|
||||
fe.cmds.forEach(cmd => {
|
||||
if (cmd.type === 'regex' && eval(cmd.match).test(word)) {
|
||||
this.targetOptions.push({
|
||||
type: 'ext',
|
||||
name: cmd.label,
|
||||
icon: plugin.icon,
|
||||
click: () => {
|
||||
ipcRenderer.send('superPanel-openPlugin', {
|
||||
cmd: cmd,
|
||||
plugin: plugin,
|
||||
feature: fe,
|
||||
data: word
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
} else if (!ext || path.parse(this.selectData.fileUrl).base === 'Desktop') {
|
||||
// 如果在桌面上或者没有选择任何文件,则展示通用选项
|
||||
this.targetOptions = this.options.common;
|
||||
@ -91,7 +112,6 @@ new Vue({
|
||||
// 如果是图片,则唤起图片选项
|
||||
const regImg = /\.(png|jpg|gif|jpeg|webp)$/;
|
||||
if (cmd.type === 'img' && regImg.test(ext)) {
|
||||
console.log(plugin);
|
||||
this.targetOptions.push({
|
||||
type: 'ext',
|
||||
name: cmd.label,
|
||||
|
Loading…
x
Reference in New Issue
Block a user