2017-04-11 6 views
0

角度と電子が一緒にルーティングについて話している様子を理解するのに問題があります。私は何をしたいか電子とのメインウィンドウを作成した後 は、ルートを使って、あるそのルートで新しいウィンドウを開くことなく、次のようなエラーが返されます。Angular2と電子ルートの問題

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) 

電子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 gc testを使用して作成されたシンプルでクリーンなコンポーネントが必要です。

誰かがエラーの理解を助けることができますか?私はので、電子・angular2に対処しようとするのは間違った方法でこの問題を得ていた

おかげ

答えて

0

電子main.jsにおいて:正しい方法で対処し、ちょうど電子からAngular2 ActivatedRoute + ipcMainを使用する電子とAngular2間にパラメータを渡す

Angular2成分で

ipcMain.on('chat', (e, args) => { 
    console.log('mainjs threadId: ', args); 
    threadId = args; 
    createChatWindow(threadId); 
}); 

function createChatWindow(threadId) { 
    // Initialize the window to our specified dimensions 
    chatWin = new BrowserWindow({width: 400, height: 500}); 

    // Specify entry point 
    chatWin.loadURL('http://localhost:4200/attendantsupportchat;threadId='+threadId.threadId+';type='+threadId.type); 
    console.log(threadId.threadId); 

    // Remove window once app is closed 
    chatWin.on('closed', function() { 
    win = null; 
    }); 
}; 

import { ActivatedRoute } from '@angular/router'; 

次に、コンストラクタで次のように初期化します。

public activatedRoute: ActivatedRoute; 

などのように必要な場合に使用しますローカル約1 4200`が、何:// localhostを:

+0

それは、ホストされたアプリケーションのために働く 'HTTP役に立つことができ

this.paramsFromElectron = this.activatedRoute.snapshot.params; this.threadId = this.paramsFromElectron.threadId; this.threadType = this.paramsFromElectron.type; 

希望? – Ismael

関連する問題