test
This commit is contained in:
@@ -3,14 +3,15 @@ import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
// 创建透明窗口
|
||||
export const createTransWindow = () => {
|
||||
const window = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
height: 1000,
|
||||
transparent: true,
|
||||
frame: false,
|
||||
});
|
||||
window.loadURL(process?.env?.ASSISTANT_HOME ?? 'https://kevisual.silkyai.cn/root/talkshow-admin/');
|
||||
window.loadURL(process?.env?.ASSISTANT_HOME ?? 'https://kevisual.cn/root/center/');
|
||||
setTimeout(() => {
|
||||
window.setPosition(0, 0, true);
|
||||
}, 1000);
|
||||
@@ -29,6 +30,6 @@ export const createDemoWinodw = (window?: BrowserWindow, opts?: any) => {
|
||||
...opts?.webPreferences,
|
||||
},
|
||||
});
|
||||
window.loadURL(process?.env?.ASSISTANT_HOME ?? 'https://kevisual.silkyai.cn/root/talkshow-admin/');
|
||||
window.loadURL(process?.env?.ASSISTANT_HOME ?? 'https://kevisual.cn/root/center/');
|
||||
return window;
|
||||
};
|
||||
|
||||
25
src/main/hot-keys/index.ts
Normal file
25
src/main/hot-keys/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// 注册快捷键 ctrl+q
|
||||
import { globalShortcut } from 'electron';
|
||||
|
||||
export const registerHotKeys = (app: Electron.App) => {
|
||||
const ret = globalShortcut.register('CommandOrControl+Q', () => {
|
||||
console.log('CommandOrControl+Q is pressed');
|
||||
app.quit();
|
||||
});
|
||||
|
||||
if (!ret) {
|
||||
console.log('registration failed');
|
||||
}
|
||||
|
||||
// Check whether a shortcut is registered.
|
||||
console.log(globalShortcut.isRegistered('CommandOrControl+Q'));
|
||||
};
|
||||
|
||||
export const unregisterHotKeys = () => {
|
||||
globalShortcut.unregisterAll();
|
||||
};
|
||||
|
||||
// Unregister a shortcut.
|
||||
export const unregisterHotKey = (key: string) => {
|
||||
globalShortcut.unregister(key);
|
||||
};
|
||||
@@ -1,19 +1,11 @@
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { createSession } from './session/index.ts';
|
||||
import { handle } from './handle/index.ts';
|
||||
import { loadMenu } from './menu/index.ts';
|
||||
import { getLogPath, log } from './app.ts';
|
||||
import { checkShowPage } from './window/page/index.ts';
|
||||
import { closeProcess, createProcess } from './process/index.ts';
|
||||
import { getElectronResourcePath, isMac } from './system/env.ts';
|
||||
// import { checkForUpdates } from './updater/index.ts';
|
||||
import { createTransWindow, createDemoWinodw } from './browsers/trans.ts';
|
||||
|
||||
// @ts-ignore
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
import { getElectronResourcePath } from './system/env.ts';
|
||||
import { createDemoWinodw } from './browsers/trans.ts';
|
||||
import { registerHotKeys } from "./hot-keys/index.ts";
|
||||
|
||||
let mainWindow: BrowserWindow | null;
|
||||
|
||||
@@ -23,22 +15,16 @@ async function createWindow() {
|
||||
log.info('createWindow');
|
||||
log.info('path', getLogPath());
|
||||
loadMenu();
|
||||
// await checkShowPage(mainWindow);
|
||||
let transWindow = createDemoWinodw();
|
||||
transWindow.on('closed', () => {
|
||||
transWindow = null;
|
||||
});
|
||||
// mainWindow.on('closed', () => {
|
||||
// mainWindow = null;
|
||||
// });
|
||||
}
|
||||
|
||||
app.on('ready', async () => {
|
||||
// await createProcess();
|
||||
createWindow();
|
||||
// if (!isMac()) {
|
||||
// checkForUpdates();
|
||||
// }
|
||||
registerHotKeys(app);
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
||||
@@ -47,7 +47,7 @@ export const createProcess = async () => {
|
||||
env: {
|
||||
...process.env,
|
||||
// KEVISUAL_URL: 'https://kevisual.xiongxiao.me',
|
||||
KEVISUAL_URL: 'https://kevisual.silkyai.cn',
|
||||
KEVISUAL_URL: 'https://kevisual.cn',
|
||||
NODE_ENV_PARENT: 'fork',
|
||||
},
|
||||
});
|
||||
|
||||
6
src/main/utils/current-path.ts
Normal file
6
src/main/utils/current-path.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
// @ts-ignore
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
13
src/main/utils/run-cli.ts
Normal file
13
src/main/utils/run-cli.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {spawn} from 'child_process';
|
||||
|
||||
export const runCli =async () =>{
|
||||
|
||||
const cli = 'ev -h';
|
||||
const cmd = spawn(cli, { shell: true, stdio: 'inherit', cwd: process.cwd() });
|
||||
cmd.on('close', (code) => {
|
||||
console.log(`child process exited with code ${code}`);
|
||||
});
|
||||
cmd.on('error', (err) => {
|
||||
console.error('Failed to start subprocess.', err);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user