Commit c0ae1dcd authored by rocosen's avatar rocosen

Update main.ts

parent 75c3308a
...@@ -15,6 +15,8 @@ import { autoUpdater } from 'electron-updater'; ...@@ -15,6 +15,8 @@ import { autoUpdater } from 'electron-updater';
import log from 'electron-log'; import log from 'electron-log';
import MenuBuilder from './menu'; import MenuBuilder from './menu';
import { resolveHtmlPath } from './util'; import { resolveHtmlPath } from './util';
const { resolve } = require('path');
class AppUpdater { class AppUpdater {
constructor() { constructor() {
log.transports.file.level = 'info'; log.transports.file.level = 'info';
...@@ -26,9 +28,24 @@ class AppUpdater { ...@@ -26,9 +28,24 @@ class AppUpdater {
let mainWindow: BrowserWindow | null = null; let mainWindow: BrowserWindow | null = null;
let win: BrowserWindow | null = null; let win: BrowserWindow | null = null;
const isDev = process.env.NODE_ENV === 'development'
function urls(per: any) {
let opts = require('url').format({
protocol: 'file:',
slashes: true,
pathname: resolve(__dirname, 'assets', 'index.html'),
})
// win.resize(size2Width(), size2Height())
if (isDev) {
opts = `http://localhost:1212`
}
return opts + per
}
const winURL = process.env.NODE_ENV === 'development' const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:1212` ? `http://localhost:1212`
: `file://${__dirname}/index.html` : `file://${__dirname}/assets/index.html`
ipcMain.on('resize-site', (event) => { ipcMain.on('resize-site', (event) => {
if (win) { if (win) {
...@@ -53,7 +70,7 @@ ipcMain.on('createNewWindow', () => { ...@@ -53,7 +70,7 @@ ipcMain.on('createNewWindow', () => {
// parent: win, //win是主窗口 // parent: win, //win是主窗口
}); });
// win.loadURL(path.join('file:', __dirname, 'new.html')); //new.html是新开窗口的渲染进程 // win.loadURL(path.join('file:', __dirname, 'new.html')); //new.html是新开窗口的渲染进程
win.loadURL(winURL+"#/site"); win.loadURL(urls('#/site'));
// win.loadFile(path.join(__dirname)); // win.loadFile(path.join(__dirname));
// win.loadFile('./index.html', { // win.loadFile('./index.html', {
// hash: 'site', // hash: 'site',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment