init
This commit is contained in:
19
src/main/window/page/app-packages.ts
Normal file
19
src/main/window/page/app-packages.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export const createAppPackagesPage = (window?: BrowserWindow) => {
|
||||
const mainWindow =
|
||||
window ||
|
||||
new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'), // 如果有 preload 脚本
|
||||
},
|
||||
});
|
||||
mainWindow.loadFile(path.join(__dirname, '../renderer/packages/index.html')); // Vite 构建后的文件
|
||||
return mainWindow;
|
||||
};
|
||||
19
src/main/window/page/enter.ts
Normal file
19
src/main/window/page/enter.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export const createEnterPage = (window?: BrowserWindow) => {
|
||||
const mainWindow =
|
||||
window ||
|
||||
new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'), // 如果有 preload 脚本
|
||||
},
|
||||
});
|
||||
mainWindow.loadFile(path.join(__dirname, '../renderer/enter/index.html')); // Vite 构建后的文件
|
||||
return mainWindow;
|
||||
};
|
||||
18
src/main/window/page/index.ts
Normal file
18
src/main/window/page/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getCacheAssistantConfig, LocalElectronAppUrl } from '@/modules/config';
|
||||
import { createEnterPage } from './enter';
|
||||
import { createAppPackagesPage } from './app-packages';
|
||||
import { BrowserWindow } from 'electron';
|
||||
|
||||
export const checkShowPage = async (window?: BrowserWindow) => {
|
||||
const assistantConfig = getCacheAssistantConfig();
|
||||
const { pageApi, proxy } = assistantConfig;
|
||||
if (!pageApi) {
|
||||
createEnterPage(window);
|
||||
return;
|
||||
}
|
||||
if (!proxy || proxy.length === 0) {
|
||||
createAppPackagesPage(window);
|
||||
return;
|
||||
}
|
||||
return window?.loadURL(LocalElectronAppUrl);
|
||||
};
|
||||
19
src/main/window/page/introduce.ts
Normal file
19
src/main/window/page/introduce.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export const createIntroducePage = (window?: BrowserWindow) => {
|
||||
const mainWindow =
|
||||
window ||
|
||||
new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'), // 如果有 preload 脚本
|
||||
},
|
||||
});
|
||||
mainWindow.loadFile(path.join(__dirname, '../renderer/index.html')); //
|
||||
return mainWindow;
|
||||
};
|
||||
6
src/main/window/relunch.ts
Normal file
6
src/main/window/relunch.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { app } from 'electron';
|
||||
|
||||
export const relunch = () => {
|
||||
app.relaunch({});
|
||||
app.quit();
|
||||
};
|
||||
11
src/main/window/window-manager.ts
Normal file
11
src/main/window/window-manager.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
|
||||
export class WindowsManager {
|
||||
static window: BrowserWindow;
|
||||
static setWindow = (window: BrowserWindow) => {
|
||||
WindowsManager.window = window;
|
||||
};
|
||||
static getWindow = () => {
|
||||
return WindowsManager.window;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user