更新快捷动作的声明

This commit is contained in:
fofolee 2024-12-22 11:55:10 +08:00
parent 2194b1cdfb
commit dece5dbd11
4 changed files with 107 additions and 30 deletions

View File

@ -73,30 +73,34 @@ if (!utools.isWindows())
if (utools.isMacOS())
process.env.PATH = `/opt/homebrew/bin:/opt/homebrew/sbin:${process.env.PATH}`;
const shortCodes = [
(open = (path) => {
const shortCodes = {
open: (path) => {
utools.shellOpenItem(path);
}),
(locate = (path) => {
},
locate: (path) => {
utools.shellShowItemInFolder(path);
}),
(visit = (url) => {
},
visit: (url) => {
utools.shellOpenExternal(url);
}),
(system = (cmd) => {
child_process.exec(cmd);
}),
(message = (msg) => {
},
system: (cmd) => {
let result = child_process.execSync(cmd, {
windowsHide: true,
encoding: "buffer",
});
return iconv.decode(result, utools.isWindows() ? "gbk" : "utf8");
},
message: (msg) => {
utools.showNotification(msg);
}),
(keyTap = (key, ...modifier) => utools.simulateKeyboardTap(key, ...modifier)),
(copyTo = (text) => {
},
keyTap: (key, ...modifier) => utools.simulateKeyboardTap(key, ...modifier),
copyTo: (text) => {
electron.clipboard.writeText(text);
}),
(send = (text) => {
},
send: (text) => {
utools.hideMainWindowTypeString(text);
}),
];
},
};
const ctlKey = utools.isMacOs() ? "command" : "control";
@ -580,8 +584,8 @@ let getSandboxFuns = () => {
os,
child_process,
};
shortCodes.forEach((f) => {
sandbox[f.name] = f;
Object.keys(shortCodes).forEach((f) => {
sandbox[f] = shortCodes[f];
});
return sandbox;
};

View File

@ -127,10 +127,7 @@ export default {
type: Object,
required: true,
},
allQuickCommandTags: {
type: Array,
required: true,
},
allQuickCommandTags: Array,
isLeaving: {
type: Boolean,
default: false,

View File

@ -251,12 +251,9 @@ export default {
}
);
// F11
this.rawEditor().addCommand(
monaco.KeyCode.F11,
() => {
this.$emit("keyStroke", "fullscreen");
}
);
this.rawEditor().addCommand(monaco.KeyCode.F11, () => {
this.$emit("keyStroke", "fullscreen");
});
},
getSelectionOrLineContent() {
let selection = this.rawEditor().getSelection();

View File

@ -0,0 +1,79 @@
/**
*
*
* ```js
* // 等同于
* utools.shellOpenItem(path)
* ```
*/
declare function open(path: string): void;
/**
*
*
* ```js
* // 等同于
* utools.shellShowItemInFolder(path)
* ```
*/
declare function locate(path: string): void;
/**
* 访 URL
*
* ```js
* // 等同于
* utools.shellOpenExternal(url)
* ```
*/
declare function visit(url: string): void;
/**
*
*
* ```js
* // 等同于
* child_process.execSync(cmd, { windowsHide: true } )
* ```
*/
declare function system(cmd: string): string;
/**
*
*
* ```js
* // 等同于
* utools.showNotification(msg)
* ```
*/
declare function message(msg: string): void;
/**
*
*
* ```js
* // 等同于
* utools.simulateKeyboardTap(key, ...modifier)
* ```
*/
declare function keyTap(key: string, ...modifier: string[]): void;
/**
*
*
* ```js
* // 等同于
* electron.clipboard.writeText(text)
* ```
*/
declare function copyTo(text: string): void;
/**
*
*
* ```js
* // 等同于
* utools.hideMainWindowTypeString(text)
* ```
*/
declare function send(text: string): void;