mirror of
https://github.com/rubickCenter/rubick
synced 2025-10-27 07:01:26 +08:00
✨ API 部分迁移完成
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const {ipcRenderer} = require("electron");
|
||||
const { ipcRenderer, shell } = require("electron");
|
||||
const os = require("os");
|
||||
|
||||
const ipcSendSync = (type, data) => {
|
||||
const returnValue = ipcRenderer.sendSync("msg-trigger", {
|
||||
@@ -9,11 +10,18 @@ const ipcSendSync = (type, data) => {
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
const ipcSend = (type, data) => {
|
||||
ipcRenderer.send("msg-trigger", {
|
||||
type,
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
window.rubick = {
|
||||
hooks: {},
|
||||
// 事件
|
||||
onPluginEnter(cb) {
|
||||
console.log(window.rubick.hooks)
|
||||
console.log(window.rubick.hooks);
|
||||
typeof cb === "function" && (window.rubick.hooks.onPluginEnter = cb);
|
||||
},
|
||||
onPluginReady(cb) {
|
||||
@@ -24,9 +32,9 @@ window.rubick = {
|
||||
},
|
||||
|
||||
// 窗口交互
|
||||
hideMainWindow() {
|
||||
ipcSendSync("hideMainWindow");
|
||||
},
|
||||
// hideMainWindow() {
|
||||
// ipcSendSync("hideMainWindow");
|
||||
// },
|
||||
showMainWindow() {
|
||||
ipcSendSync("showMainWindow");
|
||||
},
|
||||
@@ -44,4 +52,66 @@ window.rubick = {
|
||||
isFocus,
|
||||
});
|
||||
},
|
||||
removeSubInput() {
|
||||
delete window.rubick.hooks.onSubInputChange;
|
||||
ipcSendSync("removeSubInput");
|
||||
},
|
||||
setSubInputValue(text) {
|
||||
ipcSendSync("setSubInputValue", { text });
|
||||
},
|
||||
getPath(name) {
|
||||
return ipcSendSync("getPath", { name });
|
||||
},
|
||||
showNotification(body, clickFeatureCode) {
|
||||
ipcSend("showNotification", { body, clickFeatureCode });
|
||||
},
|
||||
copyImage(img) {
|
||||
return ipcSendSync("copyImage", { img });
|
||||
},
|
||||
copyText(text) {
|
||||
return ipcSendSync("copyText", { text });
|
||||
},
|
||||
copyFile: (file) => {
|
||||
return ipcSendSync("copyFile", { file })
|
||||
},
|
||||
db: {
|
||||
put: (data) => ipcSendSync("dbPut", { data }),
|
||||
get: (id) => ipcSendSync("dbGet", { id }),
|
||||
remove: (doc) => ipcSendSync("dbRemove", { doc }),
|
||||
bulkDocs: (docs) => ipcSendSync("dbBulkDocs", { docs }),
|
||||
allDocs: (key) => ipcSendSync("dbAllDocs", { key }),
|
||||
},
|
||||
isDarkColors() {
|
||||
return false;
|
||||
},
|
||||
getFeatures() {
|
||||
return ipcSendSync("getFeatures");
|
||||
},
|
||||
setFeature(feature) {
|
||||
return ipcSendSync("setFeature", { feature });
|
||||
},
|
||||
removeFeature(code) {
|
||||
return ipcSendSync("removeFeature", { code });
|
||||
},
|
||||
|
||||
// 系统
|
||||
shellOpenExternal(url) {
|
||||
shell.openExternal(url);
|
||||
},
|
||||
|
||||
isMacOs() {
|
||||
return os.type() === "Darwin";
|
||||
},
|
||||
|
||||
isWindows() {
|
||||
return os.type() === "Windows_NT";
|
||||
},
|
||||
|
||||
isLinux() {
|
||||
return os.type() === "Linux";
|
||||
},
|
||||
|
||||
shellOpenPath(path) {
|
||||
shell.openPath(path);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user