fix: 修复 preload 路径 (.mjs 而不是 .js)
- electron-vite v3 输出 .mjs 文件 - 更新 preload 路径为 index.mjs - 这是 window.electronAPI undefined 的根本原因
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ function createWindow(): void {
|
|||||||
title: 'JRedisDesktop',
|
title: 'JRedisDesktop',
|
||||||
backgroundColor: nativeTheme.shouldUseDarkColors ? '#0f0f1a' : '#f8fafc',
|
backgroundColor: nativeTheme.shouldUseDarkColors ? '#0f0f1a' : '#f8fafc',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: join(__dirname, '../preload/index.js'),
|
preload: join(__dirname, '../preload/index.mjs'),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
sandbox: false,
|
sandbox: false,
|
||||||
|
|||||||
@@ -126,6 +126,9 @@ export const useConnectionStore = defineStore('connection', () => {
|
|||||||
async function testConnection(opts: {
|
async function testConnection(opts: {
|
||||||
host: string; port: number; auth?: string; username?: string; tls?: boolean
|
host: string; port: number; auth?: string; username?: string; tls?: boolean
|
||||||
}): Promise<{ success: boolean; error?: string }> {
|
}): Promise<{ success: boolean; error?: string }> {
|
||||||
|
if (!window.electronAPI) {
|
||||||
|
return { success: false, error: 'Electron API not ready' }
|
||||||
|
}
|
||||||
const testId = `test_${Date.now()}`
|
const testId = `test_${Date.now()}`
|
||||||
try {
|
try {
|
||||||
const result = await window.electronAPI.redis.connect(testId, {
|
const result = await window.electronAPI.redis.connect(testId, {
|
||||||
|
|||||||
Reference in New Issue
Block a user