fix: use out/ directory for electron-vite dev mode compatibility
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
const electronAPI = {
|
||||
window: {
|
||||
minimize: () => ipcRenderer.send("window:minimize"),
|
||||
maximize: () => ipcRenderer.send("window:maximize"),
|
||||
close: () => ipcRenderer.send("window:close")
|
||||
},
|
||||
theme: {
|
||||
get: () => ipcRenderer.invoke("theme:get"),
|
||||
set: (theme) => ipcRenderer.send("theme:set", theme),
|
||||
onOsUpdated: (callback) => {
|
||||
ipcRenderer.on("theme:os-updated", (_e, isDark) => callback(isDark));
|
||||
}
|
||||
},
|
||||
dialog: {
|
||||
openFile: (options) => ipcRenderer.invoke("dialog:openFile", options)
|
||||
},
|
||||
credential: {
|
||||
encrypt: (text) => ipcRenderer.invoke("credential:encrypt", text),
|
||||
decrypt: (encoded) => ipcRenderer.invoke("credential:decrypt", encoded)
|
||||
},
|
||||
storage: {
|
||||
getConnections: () => ipcRenderer.invoke("storage:getConnections"),
|
||||
saveConnection: (conn) => ipcRenderer.invoke("storage:saveConnection", conn),
|
||||
deleteConnection: (id) => ipcRenderer.invoke("storage:deleteConnection", id),
|
||||
reorderConnections: (ids) => ipcRenderer.invoke("storage:reorderConnections", ids),
|
||||
getSettings: () => ipcRenderer.invoke("storage:getSettings"),
|
||||
saveSettings: (settings) => ipcRenderer.invoke("storage:saveSettings", settings)
|
||||
},
|
||||
redis: {
|
||||
connect: (id, opts) => ipcRenderer.invoke("redis:connect", id, opts),
|
||||
disconnect: (id) => ipcRenderer.invoke("redis:disconnect", id),
|
||||
execute: (id, command, args) => ipcRenderer.invoke("redis:execute", id, command, args),
|
||||
getInfo: (id) => ipcRenderer.invoke("redis:getInfo", id),
|
||||
scanKeys: (id, cursor, pattern, count) => ipcRenderer.invoke("redis:scanKeys", id, cursor, pattern, count),
|
||||
getKeyType: (id, key) => ipcRenderer.invoke("redis:getKeyType", id, key),
|
||||
getKeyTTL: (id, key) => ipcRenderer.invoke("redis:getKeyTTL", id, key),
|
||||
getString: (id, key) => ipcRenderer.invoke("redis:getString", id, key),
|
||||
setString: (id, key, value) => ipcRenderer.invoke("redis:setString", id, key, value),
|
||||
deleteKey: (id, key) => ipcRenderer.invoke("redis:deleteKey", id, key),
|
||||
hashScan: (id, key, cursor, count) => ipcRenderer.invoke("redis:hashScan", id, key, cursor, count),
|
||||
hashSet: (id, key, field, value) => ipcRenderer.invoke("redis:hashSet", id, key, field, value),
|
||||
hashDel: (id, key, field) => ipcRenderer.invoke("redis:hashDel", id, key, field),
|
||||
setTTL: (id, key, ttl) => ipcRenderer.invoke("redis:setTTL", id, key, ttl),
|
||||
selectDb: (id, db) => ipcRenderer.invoke("redis:selectDb", id, db),
|
||||
dbSize: (id) => ipcRenderer.invoke("redis:dbSize", id),
|
||||
// List
|
||||
listRange: (id, key, start, stop) => ipcRenderer.invoke("redis:listRange", id, key, start, stop),
|
||||
listLength: (id, key) => ipcRenderer.invoke("redis:listLength", id, key),
|
||||
listPush: (id, key, values) => ipcRenderer.invoke("redis:listPush", id, key, values),
|
||||
listSet: (id, key, index, value) => ipcRenderer.invoke("redis:listSet", id, key, index, value),
|
||||
listRemove: (id, key, count, value) => ipcRenderer.invoke("redis:listRemove", id, key, count, value),
|
||||
// Set
|
||||
setMembers: (id, key) => ipcRenderer.invoke("redis:setMembers", id, key),
|
||||
setSize: (id, key) => ipcRenderer.invoke("redis:setSize", id, key),
|
||||
setAdd: (id, key, members) => ipcRenderer.invoke("redis:setAdd", id, key, members),
|
||||
setRemove: (id, key, members) => ipcRenderer.invoke("redis:setRemove", id, key, members),
|
||||
// Sorted set
|
||||
zsetRange: (id, key, start, stop, withScores) => ipcRenderer.invoke("redis:zsetRange", id, key, start, stop, withScores),
|
||||
zsetSize: (id, key) => ipcRenderer.invoke("redis:zsetSize", id, key),
|
||||
zsetAdd: (id, key, score, member) => ipcRenderer.invoke("redis:zsetAdd", id, key, score, member),
|
||||
zsetRemove: (id, key, members) => ipcRenderer.invoke("redis:zsetRemove", id, key, members),
|
||||
// Slow log
|
||||
slowLogGet: (id, count) => ipcRenderer.invoke("redis:slowLogGet", id, count),
|
||||
slowLogLen: (id) => ipcRenderer.invoke("redis:slowLogLen", id),
|
||||
// Memory
|
||||
memoryUsage: (id, key) => ipcRenderer.invoke("redis:memoryUsage", id, key),
|
||||
batchDelete: (id, keys) => ipcRenderer.invoke("redis:batchDelete", id, keys),
|
||||
// Stream
|
||||
streamInfo: (id, key) => ipcRenderer.invoke("redis:streamInfo", id, key),
|
||||
streamRange: (id, key, start, end, count) => ipcRenderer.invoke("redis:streamRange", id, key, start, end, count),
|
||||
streamAdd: (id, key, streamId, fieldValues) => ipcRenderer.invoke("redis:streamAdd", id, key, streamId, fieldValues),
|
||||
streamTrim: (id, key, maxLen) => ipcRenderer.invoke("redis:streamTrim", id, key, maxLen),
|
||||
streamDel: (id, key, ids) => ipcRenderer.invoke("redis:streamDel", id, key, ids),
|
||||
// Key ops
|
||||
renameKey: (id, oldKey, newKey) => ipcRenderer.invoke("redis:renameKey", id, oldKey, newKey),
|
||||
existsKey: (id, key) => ipcRenderer.invoke("redis:existsKey", id, key),
|
||||
ping: (id) => ipcRenderer.invoke("redis:ping", id),
|
||||
isConnected: (id) => ipcRenderer.invoke("redis:isConnected", id)
|
||||
}
|
||||
};
|
||||
contextBridge.exposeInMainWorld("electronAPI", electronAPI);
|
||||
Reference in New Issue
Block a user