Move About page into WebView.

This commit is contained in:
Zhongyi Tong
2017-06-17 22:37:42 +08:00
parent f85bca9879
commit e538543512
6 changed files with 18 additions and 14 deletions

View File

@@ -9,7 +9,7 @@ const BrowserWindow = electron.BrowserWindow;
const shell = electron.shell; const shell = electron.shell;
const appName = app.getName(); const appName = app.getName();
const {about} = require('./windowmanager'); // const {about} = require('./windowmanager');
function sendAction(action) { function sendAction(action) {
const win = BrowserWindow.getAllWindows()[0]; const win = BrowserWindow.getAllWindows()[0];
@@ -135,8 +135,10 @@ const darwinTpl = [
submenu: [ submenu: [
{ {
label: 'Zulip desktop', label: 'Zulip desktop',
click() { click(item, focusedWindow) {
about(); if (focusedWindow) {
sendAction('open-about');
}
} }
}, },
{ {

View File

@@ -18,6 +18,7 @@ class ServerManagerView {
this.$content = document.getElementById('content'); this.$content = document.getElementById('content');
this.settingsTabIndex = -1; this.settingsTabIndex = -1;
this.aboutTabIndex = -1;
this.activeTabIndex = -1; this.activeTabIndex = -1;
this.webviews = []; this.webviews = [];
this.tabs = []; this.tabs = [];
@@ -104,35 +105,35 @@ class ServerManagerView {
} }
openAbout() { openAbout() {
if (this.settingsTabIndex !== -1) { if (this.aboutTabIndex !== -1) {
this.activateTab(this.settingsTabIndex); this.activateTab(this.aboutTabIndex);
return; return;
} }
const url = 'file://' + __dirname + '/about.html'; const url = 'file://' + __dirname + '/about.html';
this.settingsTabIndex = this.webviews.length; this.aboutTabIndex = this.webviews.length;
this.tabs.push(new Tab({ this.tabs.push(new Tab({
url, url,
name: 'Settings', name: 'About',
type: Tab.SETTINGS_TAB, type: Tab.SETTINGS_TAB,
$root: this.$tabsContainer, $root: this.$tabsContainer,
onClick: this.activateTab.bind(this, this.settingsTabIndex) onClick: this.activateTab.bind(this, this.aboutTabIndex)
})); }));
this.webviews.push(new WebView({ this.webviews.push(new WebView({
$root: this.$content, $root: this.$content,
index: this.settingsTabIndex, index: this.aboutTabIndex,
url, url,
name: 'Settings', name: 'About',
isActive: () => { isActive: () => {
return this.settingsTabIndex === this.activeTabIndex; return this.activeTabIndex === this.aboutTabIndex;
}, },
onTitleChange: this.updateBadge.bind(this), onTitleChange: this.updateBadge.bind(this),
nodeIntegration: true nodeIntegration: true
})); }));
this.activateTab(this.settingsTabIndex); this.activateTab(this.aboutTabIndex);
} }
activateTab(index) { activateTab(index) {
@@ -191,6 +192,7 @@ class ServerManagerView {
} }
ipcRenderer.on('open-settings', this.openSettings.bind(this)); ipcRenderer.on('open-settings', this.openSettings.bind(this));
ipcRenderer.on('open-about', this.openAbout.bind(this));
} }
} }

View File

@@ -117,7 +117,7 @@ const createTray = function () {
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([{
label: 'About', label: 'About',
click() { click() {
ipcRenderer.send('trayabout'); sendAction('open-about');
} }
}, },
{ {

View File

@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<title>Zulip - Settings</title> <title>Zulip - Settings</title>
<link rel="stylesheet" href="../css/preference.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/preference.css" type="text/css" media="screen">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head> </head>
<body> <body>