From c8851ecd2acacd7aaddb441648221bc0cd85d1b6 Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Wed, 29 Jul 2015 10:52:37 +0900 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=96=84=EF=BC=9AUserNavator=E3=81=AB?= =?UTF-8?q?=E6=B4=BB=E6=80=A7=E5=8C=96=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8BPlanet=E3=81=8C=E3=81=A1=E3=82=83=E3=82=93=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- browser/main/Components/UserNavigator.jsx | 4 +- browser/main/Containers/UserContainer.jsx | 5 +- main.js | 139 +--------------------- modules/menu-template.js | 128 ++++++++++++++++++++ 4 files changed, 139 insertions(+), 137 deletions(-) create mode 100644 modules/menu-template.js diff --git a/browser/main/Components/UserNavigator.jsx b/browser/main/Components/UserNavigator.jsx index 1d01de14..00ea12e9 100644 --- a/browser/main/Components/UserNavigator.jsx +++ b/browser/main/Components/UserNavigator.jsx @@ -52,9 +52,11 @@ module.exports = React.createClass({ } }, render: function () { + console.log(this.props.currentUser) + console.log(this.props.currentPlanet) var planets = this.props.currentUser.Planets.map(function (planet, index) { return ( -
  • +
  • {planet.name[0]}
    {planet.userName}/{planet.name}
    diff --git a/browser/main/Containers/UserContainer.jsx b/browser/main/Containers/UserContainer.jsx index a82f7f76..1cb76ee5 100644 --- a/browser/main/Containers/UserContainer.jsx +++ b/browser/main/Containers/UserContainer.jsx @@ -95,7 +95,6 @@ module.exports = React.createClass({ } }, render: function () { - var currentPlanetName = this.props.params.planetName var currentUser = this.state.currentUser var user = this.state.user @@ -104,12 +103,12 @@ module.exports = React.createClass({ var currentPlanet = null currentUser.Planets.some(function (planet) { - if (planet.name === currentPlanetName) { + if (planet.userName === this.props.params.userName && planet.name === this.props.params.planetName) { currentPlanet = planet return true } return false - }) + }.bind(this)) var content if (this.isActive('userHome')) { diff --git a/main.js b/main.js index 1a460f40..b3948204 100644 --- a/main.js +++ b/main.js @@ -1,12 +1,10 @@ -var app = require('app') // Module to control application life. -var BrowserWindow = require('browser-window') // Module to create native browser window. +var app = require('app') +var BrowserWindow = require('browser-window') var Menu = require('menu') var Tray = require('tray') -// Report crashes to our server. + require('crash-reporter').start() -// Keep a global reference of the window object, if you don't, the window will -// be closed automatically when the javascript object is GCed. var mainWindow = null // app.on('window-all-closed', function () { @@ -15,132 +13,7 @@ var mainWindow = null app.on('ready', function () { // menu start - var template = [ - { - label: 'Electron', - submenu: [ - { - label: 'About Electron', - selector: 'orderFrontStandardAboutPanel:' - }, - { - type: 'separator' - }, - { - label: 'Services', - submenu: [] - }, - { - type: 'separator' - }, - { - label: 'Hide Electron', - accelerator: 'Command+H', - selector: 'hide:' - }, - { - label: 'Hide Others', - accelerator: 'Command+Shift+H', - selector: 'hideOtherApplications:' - }, - { - label: 'Show All', - selector: 'unhideAllApplications:' - }, - { - type: 'separator' - }, - { - label: 'Quit', - accelerator: 'Command+Q', - selector: 'terminate:' - } - ] - }, - { - label: 'Edit', - submenu: [ - { - label: 'Undo', - accelerator: 'Command+Z', - selector: 'undo:' - }, - { - label: 'Redo', - accelerator: 'Shift+Command+Z', - selector: 'redo:' - }, - { - type: 'separator' - }, - { - label: 'Cut', - accelerator: 'Command+X', - selector: 'cut:' - }, - { - label: 'Copy', - accelerator: 'Command+C', - selector: 'copy:' - }, - { - label: 'Paste', - accelerator: 'Command+V', - selector: 'paste:' - }, - { - label: 'Select All', - accelerator: 'Command+A', - selector: 'selectAll:' - } - ] - }, - { - label: 'View', - submenu: [ - { - label: 'Reload', - accelerator: 'Command+R', - click: function () { - BrowserWindow.getFocusedWindow().reload() - } - }, - { - label: 'Toggle DevTools', - accelerator: 'Alt+Command+I', - click: function () { - BrowserWindow.getFocusedWindow().toggleDevTools() - } - } - ] - }, - { - label: 'Window', - submenu: [ - { - label: 'Minimize', - accelerator: 'Command+M', - selector: 'performMiniaturize:' - }, - { - label: 'Close', - accelerator: 'Command+W', - selector: 'performClose:' - }, - { - type: 'separator' - }, - { - label: 'Bring All to Front', - selector: 'arrangeInFront:' - } - ] - }, - { - label: 'Help', - submenu: [] - } - ] + var template = require('./modules/menu-template') var menu = Menu.buildFromTemplate(template) @@ -204,8 +77,8 @@ app.on('ready', function () { function makeNewMainWindow () { console.log('new Window!') mainWindow = new BrowserWindow({ - width: 920, - height: 640, + width: 1080, + height: 720, 'web-preferences': { 'overlay-scrollbars': true } diff --git a/modules/menu-template.js b/modules/menu-template.js new file mode 100644 index 00000000..33da0d3f --- /dev/null +++ b/modules/menu-template.js @@ -0,0 +1,128 @@ +var BrowserWindow = require('browser-window') + +module.exports = [ + { + label: 'Electron', + submenu: [ + { + label: 'About Electron', + selector: 'orderFrontStandardAboutPanel:' + }, + { + type: 'separator' + }, + { + label: 'Services', + submenu: [] + }, + { + type: 'separator' + }, + { + label: 'Hide Electron', + accelerator: 'Command+H', + selector: 'hide:' + }, + { + label: 'Hide Others', + accelerator: 'Command+Shift+H', + selector: 'hideOtherApplications:' + }, + { + label: 'Show All', + selector: 'unhideAllApplications:' + }, + { + type: 'separator' + }, + { + label: 'Quit', + accelerator: 'Command+Q', + selector: 'terminate:' + } + ] + }, + { + label: 'Edit', + submenu: [ + { + label: 'Undo', + accelerator: 'Command+Z', + selector: 'undo:' + }, + { + label: 'Redo', + accelerator: 'Shift+Command+Z', + selector: 'redo:' + }, + { + type: 'separator' + }, + { + label: 'Cut', + accelerator: 'Command+X', + selector: 'cut:' + }, + { + label: 'Copy', + accelerator: 'Command+C', + selector: 'copy:' + }, + { + label: 'Paste', + accelerator: 'Command+V', + selector: 'paste:' + }, + { + label: 'Select All', + accelerator: 'Command+A', + selector: 'selectAll:' + } + ] + }, + { + label: 'View', + submenu: [ + { + label: 'Reload', + accelerator: 'Command+R', + click: function () { + BrowserWindow.getFocusedWindow().reload() + } + }, + { + label: 'Toggle DevTools', + accelerator: 'Alt+Command+I', + click: function () { + BrowserWindow.getFocusedWindow().toggleDevTools() + } + } + ] + }, + { + label: 'Window', + submenu: [ + { + label: 'Minimize', + accelerator: 'Command+M', + selector: 'performMiniaturize:' + }, + { + label: 'Close', + accelerator: 'Command+W', + selector: 'performClose:' + }, + { + type: 'separator' + }, + { + label: 'Bring All to Front', + selector: 'arrangeInFront:' + } + ] + }, + { + label: 'Help', + submenu: [] + } +]