Skip to content

Commit

Permalink
- Fix double window bug
Browse files Browse the repository at this point in the history
- Transparent window title bar on Windows
  • Loading branch information
Rustem Mussabekov committed Jan 16, 2022
1 parent 84df1f6 commit e135d10
Show file tree
Hide file tree
Showing 6 changed files with 466 additions and 480 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Use Node.js 12.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x

- name: Add OSX certificate
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: windows-2019
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x
- name: install dependencies
run: yarn
- name: build
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Raindrop.io",
"productName": "Raindrop.io",
"version": "0.0.0",
"version": "5.4.16",
"description": "Crossplatform bookmarking app",
"main": "src/index.js",
"repository": {
Expand Down Expand Up @@ -34,13 +34,13 @@
"update-electron-app": "2.0.x"
},
"devDependencies": {
"@electron-forge/cli": "6.0.0-beta.61",
"@electron-forge/maker-appx": "6.0.0-beta.61",
"@electron-forge/maker-dmg": "6.0.0-beta.61",
"@electron-forge/maker-squirrel": "6.0.0-beta.61",
"@electron-forge/maker-zip": "6.0.0-beta.61",
"@electron-forge/publisher-github": "6.0.0-beta.61",
"electron": "13.0.x",
"@electron-forge/cli": "6.0.0-beta.63",
"@electron-forge/maker-appx": "6.0.0-beta.63",
"@electron-forge/maker-dmg": "6.0.0-beta.63",
"@electron-forge/maker-squirrel": "6.0.0-beta.63",
"@electron-forge/maker-zip": "6.0.0-beta.63",
"@electron-forge/publisher-github": "6.0.0-beta.63",
"electron": "16.0.x",
"shx": "^0.3.2"
}
}
35 changes: 0 additions & 35 deletions src/navigation.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
const { app, shell } = require('electron')
const { URL } = require('url')

function onWillNavigate(e, url) {
let origin, target

//origin
try{
origin = new URL(e.sender.getURL())
}catch(e) {
if (String(e).includes('Invalid URL'))
origin = new URL('about:blank')
else
throw e
}

//target
try{
target = new URL(url)
}catch(e) {
if (String(e).includes('Invalid URL'))
target = new URL('about:blank')
else
throw e
}

//external link
if (origin.host != target.host ||
origin.protocol != target.protocol){
onNewWindow(e, url)
return
}
}

function onNewWindow(e, url) {
e.preventDefault()
Expand All @@ -39,9 +7,6 @@ function onNewWindow(e, url) {

module.exports = function() {
app.on('web-contents-created', (e, contents) => {
if (contents.getType() == 'window')
contents.on('will-navigate', onWillNavigate)

contents.on('new-window', onNewWindow)
})
}
6 changes: 5 additions & 1 deletion src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class Window {
nativeWindowOpen: true,

//appearance
titleBarStyle: process.platform == 'darwin' ? 'hidden' : 'default',
titleBarStyle: (process.platform == 'darwin' || process.platform == 'win32') ? 'hidden' : 'default',
titleBarOverlay: {
color: nativeTheme.shouldUseDarkColors ? '#303030' : 'white',
symbolColor: nativeTheme.shouldUseDarkColors ? 'white' : 'black'
},
backgroundColor: nativeTheme.shouldUseDarkColors ? '#303030' : 'white',
fullscreenable: process.platform == 'darwin',

Expand Down
Loading

0 comments on commit e135d10

Please sign in to comment.