Angular2和电子路线问题

时间:2017-04-11 11:02:44

标签: angular electron

我在理解角度和电子如何协同处理路由时遇到了问题。 用电子创建主窗口之后,我想要做的是,使用路线,打开一个带有该路线的新窗口,但返回错误如下:

    http://localhost:4200/test/inline.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/polyfills.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/scripts.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/styles.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/vendor.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/main.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/inline.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/polyfills.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/scripts.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/styles.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/vendor.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/test/main.bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)

Electron main.js文件是:

'use strict';
const electron = require('electron');
// Module to control application life.
const { app, BrowserWindow, ipcMain } = electron;

let win;
let winAttendant;

ipcMain.on('supportRequest', (e, type, threadObjectId) => {
    // console.log(args[0]);
    // e.sender.send('channel1', 'ok got it');
    // console.log('1:' + e + '2:' + type + '3:'+ threadObjectId)
    if (type == 1) {
        attendantWindow(1, threadObjectId);
    } else if (type == 2) {
        attendantWindow(2, threadObjectId);
    } else {
        attendantWindow(0);
    }

})

function attendantWindow(type, threadObjectId) {
    if (type == 1) {
        winAttendant = new BrowserWindow({
            x: 500,
            y: 500,
            minWidth: 300,
            minHeight: 650
        });

        winAttendant.loadURL('http://localhost:4200/attendantpage/'+ threadObjectId);

        winAttendant.on('closed', () => {
            // Dereference the window object, usually you would store windows
            // in an array if your app supports multi windows, this is the time
            // when you should delete the corresponding element.
            win = null;
        });
    } else if (type == 2) {
        console.log('type is: 2 and id: ' + threadObjectId)
        winAttendant = new BrowserWindow({
            x: 500,
            y: 500,
            minWidth: 300,
            minHeight: 650
        });
        console.log('http://localhost:4200/test/');
        winAttendant.loadURL('http://localhost:4200/test/');

        winAttendant.on('closed', () => {
            // Dereference the window object, usually you would store windows
            // in an array if your app supports multi windows, this is the time
            // when you should delete the corresponding element.
            win = null;
        });
    } else {
        winAttendant.close();
    }
}

function createWindow() {

    let electronScreen = electron.screen;
    let size = electronScreen.getPrimaryDisplay().workAreaSize;

    // Create the browser window.
    win = new BrowserWindow({
        minWidth: 900,
        minHeight: 700,
        center: true
    });

    let url = 'file://' + __dirname + '/index.html';
    let Args = process.argv.slice(1);

    Args.forEach(function (val) {
        if (val === "--serve") {
            url = 'http://localhost:4200'
        }
    });

    // and load the index.html of the app.
    win.loadURL(url);

    // Open the DevTools.
    // win.webContents.openDevTools();

    // Emitted when the window is closed.
    win.on('closed', () => {
        // Dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        win = null;
    });
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
    // On OS X it is common for applications and their menu bar
    // to stay active until the user quits explicitly with Cmd + Q
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('activate', () => {
    // On OS X it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (win === null) {
        createWindow();
    }
});

要在新窗口中打开的组件是使用ng g c test创建的一个简单的新的干净组件。

有人可以帮我理解错误吗?

由于

0 个答案:

没有答案