更新快捷动作的声明

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

View File

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

View File

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