mirror of
https://github.com/rubickCenter/rubick
synced 2026-02-25 08:21:21 +08:00
:feature: 日常更新
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
const { ipcRenderer, shell } = require("electron");
|
||||
const os = require("os");
|
||||
const { ipcRenderer, shell } = require('electron');
|
||||
const os = require('os');
|
||||
|
||||
const ipcSendSync = (type, data) => {
|
||||
const returnValue = ipcRenderer.sendSync("msg-trigger", {
|
||||
const returnValue = ipcRenderer.sendSync('msg-trigger', {
|
||||
type,
|
||||
data
|
||||
data,
|
||||
});
|
||||
if (returnValue instanceof Error) throw returnValue;
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
const ipcSend = (type, data) => {
|
||||
ipcRenderer.send("msg-trigger", {
|
||||
ipcRenderer.send('msg-trigger', {
|
||||
type,
|
||||
data
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,99 +22,99 @@ window.rubick = {
|
||||
// 事件
|
||||
onPluginEnter(cb) {
|
||||
console.log(window.rubick.hooks);
|
||||
typeof cb === "function" && (window.rubick.hooks.onPluginEnter = cb);
|
||||
typeof cb === 'function' && (window.rubick.hooks.onPluginEnter = cb);
|
||||
},
|
||||
onPluginReady(cb) {
|
||||
typeof cb === "function" && (window.rubick.hooks.onPluginReady = cb);
|
||||
typeof cb === 'function' && (window.rubick.hooks.onPluginReady = cb);
|
||||
},
|
||||
onPluginOut(cb) {
|
||||
typeof cb === "function" && (window.rubick.hooks.onPluginOut = cb);
|
||||
typeof cb === 'function' && (window.rubick.hooks.onPluginOut = cb);
|
||||
},
|
||||
openPlugin(plugin) {
|
||||
ipcSendSync("loadPlugin", plugin);
|
||||
ipcSendSync('loadPlugin', plugin);
|
||||
},
|
||||
// 窗口交互
|
||||
hideMainWindow() {
|
||||
ipcSendSync("hideMainWindow");
|
||||
ipcSendSync('hideMainWindow');
|
||||
},
|
||||
showMainWindow() {
|
||||
ipcSendSync("showMainWindow");
|
||||
ipcSendSync('showMainWindow');
|
||||
},
|
||||
showOpenDialog(options) {
|
||||
ipcSendSync("showOpenDialog", options);
|
||||
ipcSendSync('showOpenDialog', options);
|
||||
},
|
||||
setExpendHeight(height) {
|
||||
ipcSendSync("setExpendHeight", height);
|
||||
ipcSendSync('setExpendHeight', height);
|
||||
},
|
||||
setSubInput(onChange, placeholder = "", isFocus) {
|
||||
typeof onChange === "function" &&
|
||||
setSubInput(onChange, placeholder = '', isFocus) {
|
||||
typeof onChange === 'function' &&
|
||||
(window.rubick.hooks.onSubInputChange = onChange);
|
||||
ipcSendSync("setSubInput", {
|
||||
ipcSendSync('setSubInput', {
|
||||
placeholder,
|
||||
isFocus
|
||||
isFocus,
|
||||
});
|
||||
},
|
||||
removeSubInput() {
|
||||
delete window.rubick.hooks.onSubInputChange;
|
||||
ipcSendSync("removeSubInput");
|
||||
ipcSendSync('removeSubInput');
|
||||
},
|
||||
setSubInputValue(text) {
|
||||
ipcSendSync("setSubInputValue", { text });
|
||||
ipcSendSync('setSubInputValue', { text });
|
||||
},
|
||||
subInputBlur() {
|
||||
ipcSendSync("subInputBlur");
|
||||
ipcSendSync('subInputBlur');
|
||||
},
|
||||
getPath(name) {
|
||||
return ipcSendSync("getPath", { name });
|
||||
return ipcSendSync('getPath', { name });
|
||||
},
|
||||
showNotification(body, clickFeatureCode) {
|
||||
ipcSend("showNotification", { body, clickFeatureCode });
|
||||
ipcSend('showNotification', { body, clickFeatureCode });
|
||||
},
|
||||
copyImage(img) {
|
||||
return ipcSendSync("copyImage", { img });
|
||||
return ipcSendSync('copyImage', { img });
|
||||
},
|
||||
copyText(text) {
|
||||
return ipcSendSync("copyText", { text });
|
||||
return ipcSendSync('copyText', { text });
|
||||
},
|
||||
copyFile: file => {
|
||||
return ipcSendSync("copyFile", { file });
|
||||
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 })
|
||||
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 }),
|
||||
},
|
||||
dbStorage: {
|
||||
setItem: (key, value) => {
|
||||
const target = { _id: String(key) };
|
||||
const result = ipcSendSync("dbGet", { id: target._id });
|
||||
const result = ipcSendSync('dbGet', { id: target._id });
|
||||
result && (target._rev = result._rev);
|
||||
target.value = value;
|
||||
const res = ipcSendSync("dbPut", { data: target });
|
||||
const res = ipcSendSync('dbPut', { data: target });
|
||||
if (res.error) throw new Error(res.message);
|
||||
},
|
||||
getItem: key => {
|
||||
const res = ipcSendSync("dbGet", { id: key });
|
||||
return res && "value" in res ? res.value : null;
|
||||
getItem: (key) => {
|
||||
const res = ipcSendSync('dbGet', { id: key });
|
||||
return res && 'value' in res ? res.value : null;
|
||||
},
|
||||
removeItem: (key) => {
|
||||
const res = ipcSendSync('dbGet', { id: key });
|
||||
res && ipcSendSync('dbRemove', { doc: res });
|
||||
},
|
||||
removeItem: key => {
|
||||
const res = ipcSendSync("dbGet", { id: key });
|
||||
res && ipcSendSync("dbRemove", { doc: res });
|
||||
}
|
||||
},
|
||||
isDarkColors() {
|
||||
return false;
|
||||
},
|
||||
getFeatures() {
|
||||
return ipcSendSync("getFeatures");
|
||||
return ipcSendSync('getFeatures');
|
||||
},
|
||||
setFeature(feature) {
|
||||
return ipcSendSync("setFeature", { feature });
|
||||
return ipcSendSync('setFeature', { feature });
|
||||
},
|
||||
removeFeature(code) {
|
||||
return ipcSendSync("removeFeature", { code });
|
||||
return ipcSendSync('removeFeature', { code });
|
||||
},
|
||||
|
||||
// 系统
|
||||
@@ -123,29 +123,29 @@ window.rubick = {
|
||||
},
|
||||
|
||||
isMacOs() {
|
||||
return os.type() === "Darwin";
|
||||
return os.type() === 'Darwin';
|
||||
},
|
||||
|
||||
isWindows() {
|
||||
return os.type() === "Windows_NT";
|
||||
return os.type() === 'Windows_NT';
|
||||
},
|
||||
|
||||
isLinux() {
|
||||
return os.type() === "Linux";
|
||||
return os.type() === 'Linux';
|
||||
},
|
||||
|
||||
shellOpenPath(path) {
|
||||
shell.openPath(path);
|
||||
},
|
||||
|
||||
getLocalId: () => ipcSendSync("getLocalId"),
|
||||
getLocalId: () => ipcSendSync('getLocalId'),
|
||||
|
||||
removePlugin() {
|
||||
ipcSend("removePlugin");
|
||||
ipcSend('removePlugin');
|
||||
},
|
||||
|
||||
shellShowItemInFolder: path => {
|
||||
ipcSend("shellShowItemInFolder", { path });
|
||||
shellShowItemInFolder: (path) => {
|
||||
ipcSend('shellShowItemInFolder', { path });
|
||||
},
|
||||
|
||||
redirect: (label, payload) => {
|
||||
@@ -153,6 +153,6 @@ window.rubick = {
|
||||
},
|
||||
|
||||
shellBeep: () => {
|
||||
ipcSend("shellBeep")
|
||||
ipcSend('shellBeep');
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user