mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-15 07:05:21 +08:00
preload分割
This commit is contained in:
35
plugin/lib/shortCodes.js
Normal file
35
plugin/lib/shortCodes.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const electron = require("electron");
|
||||
const child_process = require("child_process");
|
||||
const iconv = require("iconv-lite");
|
||||
|
||||
const shortCodes = {
|
||||
open: (path) => {
|
||||
window.utools.shellOpenItem(path);
|
||||
},
|
||||
locate: (path) => {
|
||||
window.utools.shellShowItemInFolder(path);
|
||||
},
|
||||
visit: (url) => {
|
||||
window.utools.shellOpenExternal(url);
|
||||
},
|
||||
system: (cmd) => {
|
||||
let result = child_process.execSync(cmd, {
|
||||
windowsHide: true,
|
||||
encoding: "buffer",
|
||||
});
|
||||
return iconv.decode(result, window.utools.isWindows() ? "gbk" : "utf8");
|
||||
},
|
||||
message: (msg) => {
|
||||
window.utools.showNotification(msg);
|
||||
},
|
||||
keyTap: (key, ...modifier) =>
|
||||
window.utools.simulateKeyboardTap(key, ...modifier),
|
||||
copyTo: (text) => {
|
||||
electron.clipboard.writeText(text);
|
||||
},
|
||||
send: (text) => {
|
||||
window.utools.hideMainWindowTypeString(text);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = shortCodes;
|
||||
Reference in New Issue
Block a user