electron-about-window
Advanced tools
Comparing version 1.12.1 to 1.13.0
@@ -7,2 +7,3 @@ /// <reference types="electron" /> | ||
package_json_dir?: string; | ||
about_page_dir?: string; | ||
bug_report_url?: string; | ||
@@ -20,4 +21,6 @@ bug_link_text?: string; | ||
use_version_info?: boolean; | ||
show_close_button?: string; | ||
win_title?: string; | ||
} | ||
export default function openAboutWindow(into: AboutWindowInfo | string): Electron.BrowserWindow; |
{ | ||
"name": "electron-about-window", | ||
"version": "1.12.1", | ||
"version": "1.13.0", | ||
"description": "'About App' window for Electron application", | ||
@@ -8,4 +8,4 @@ "main": "src/index.js", | ||
"dep": "npm install", | ||
"build": "tsc --pretty -p src/", | ||
"watch": "tsc --watch --pretty -p src/", | ||
"build": "tsc -p src/", | ||
"watch": "tsc --watch -p src/", | ||
"tslint": "tslint -p ./src", | ||
@@ -36,10 +36,10 @@ "stylelint": "stylelint styles/*.css", | ||
"devDependencies": { | ||
"@types/node": "^10.3.2", | ||
"electron": "^2.0.2", | ||
"stylelint": "^9.2.1", | ||
"stylelint-config-standard": "^18.2.0", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.9.1" | ||
"@types/node": "^12.0.2", | ||
"electron": "^5.0.1", | ||
"stylelint": "^10.0.1", | ||
"stylelint-config-standard": "^18.3.0", | ||
"tslint": "^5.16.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -15,2 +15,3 @@ 'About This App' Window for [Electron](https://github.com/atom/electron) Apps | ||
- [x] Adjust window size to its contents automatically | ||
- [x] Optional close button | ||
- [x] CSS customizability | ||
@@ -32,2 +33,3 @@ | ||
package_json_dir?: string; | ||
about_page_dir?: string; | ||
bug_report_url?: string; | ||
@@ -43,2 +45,4 @@ bug_link_text?: string; | ||
use_version_info?: boolean; | ||
show_close_button?: string; | ||
win_title?: string; | ||
}): BrowserWindow | ||
@@ -94,2 +98,5 @@ ``` | ||
| `use_version_info` | If `false`, the versions of electron, chrome, node, and v8 will not be displayed. Default is `true`. **Optional** | boolean | | ||
| `show_close_button` | If this is a valid string, a close button with this string be displayed. **Optional** | string | | ||
| `about_page_dir` | Directory path which contains `about.html` which is rendered in 'About this app' window. **Optional** | string | | ||
| `win_title` | Title string of the window. Default title is `About {app name}`. **Optional** | string | | ||
@@ -96,0 +103,0 @@ **Note:** If you set `use_inner_html` to `true`, please ensure that contents don't contain any untrusted external input |
@@ -95,3 +95,7 @@ "use strict"; | ||
} | ||
const index_html = 'file://' + path.join(__dirname, '..', 'about.html'); | ||
let base_path = info.about_page_dir; | ||
if (base_path === undefined || base_path === null || !base_path.length) { | ||
base_path = path.join(__dirname, '..'); | ||
} | ||
const index_html = 'file://' + path.join(base_path, 'about.html'); | ||
const options = Object.assign({ | ||
@@ -104,2 +108,5 @@ width: 400, | ||
icon: info.icon_path, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
}, | ||
}, info.win_options || {}); | ||
@@ -120,3 +127,5 @@ window = new (electron_1.BrowserWindow || electron_1.remote.BrowserWindow)(options); | ||
window.webContents.once('dom-ready', () => { | ||
const win_title = info.win_options ? info.win_options.title : null; | ||
delete info.win_options; | ||
info.win_options = { title: win_title }; | ||
window.webContents.send('about-window:info', info); | ||
@@ -123,0 +132,0 @@ if (info.open_devtools) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
const content = info.use_inner_html ? 'innerHTML' : 'innerText'; | ||
document.title = `About ${app_name}`; | ||
document.title = info.win_options.title || `About ${app_name}`; | ||
const title_elem = document.querySelector('.title'); | ||
@@ -54,3 +54,8 @@ title_elem.innerText = `${app_name} ${electron_1.remote.app.getVersion()}`; | ||
if (height > 0 && width > 0) { | ||
win.setContentSize(width, height + 40); | ||
if (info.show_close_button) { | ||
win.setContentSize(width, height + 40); | ||
} | ||
else { | ||
win.setContentSize(width, height + 52); | ||
} | ||
} | ||
@@ -72,3 +77,14 @@ } | ||
} | ||
if (info.show_close_button) { | ||
const buttons = document.querySelector('.buttons'); | ||
const close_button = document.createElement('button'); | ||
close_button.innerText = info.show_close_button; | ||
close_button.addEventListener('click', e => { | ||
e.preventDefault(); | ||
electron_1.remote.getCurrentWindow().close(); | ||
}); | ||
buttons.appendChild(close_button); | ||
close_button.focus(); | ||
} | ||
}); | ||
//# sourceMappingURL=renderer.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27192
339
120