Experimental Tabs # 2
This commit is contained in:
parent
27383e1bc1
commit
4eb40ccd42
|
@ -10,16 +10,20 @@
|
|||
.documentFull {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 39px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
overflow: auto;
|
||||
right: 0;
|
||||
left: 0;
|
||||
}
|
||||
.discord-webview {
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 38px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
.active-webview {
|
||||
display: inherit
|
||||
|
|
|
@ -3,6 +3,9 @@ const { join } = require("path")
|
|||
const { pathToFileURL } = require("url")
|
||||
const { remote } = require("electron")
|
||||
|
||||
let webviews = new Map()
|
||||
window.webviews = webviews
|
||||
|
||||
window.onload = () => {
|
||||
const ChromeTabs = require("chrome-tabs")
|
||||
require("chrome-tabs/css/chrome-tabs.css")
|
||||
|
@ -13,9 +16,6 @@ window.onload = () => {
|
|||
let chromeTabs = new ChromeTabs()
|
||||
chromeTabs.init(tabs)
|
||||
|
||||
let webviews = new Map()
|
||||
window.webviews = webviews
|
||||
|
||||
tabs.addEventListener('activeTabChange', ({detail}) => {
|
||||
let webview = webviews.get(detail.tabEl)
|
||||
if(!webview){
|
||||
|
@ -34,6 +34,7 @@ window.onload = () => {
|
|||
webview.classList.add("discord-webview")
|
||||
webview.classList.add("webview-active")
|
||||
webview.setAttribute("preload", pathToFileURL(join(__dirname, "../mainScreenPreload.js")))
|
||||
webview.shadowRoot.childNodes.item(1).style.height = "100%"
|
||||
webviews.set(detail.tabEl, webview)
|
||||
document.querySelector(".documentFull").appendChild(webview)
|
||||
webview.addEventListener("dom-ready", () => {
|
||||
|
@ -80,3 +81,10 @@ require.extensions[".css"] = (m, filename) => {
|
|||
}
|
||||
|
||||
const faviconURL = pathToFileURL(join(__dirname, "../images/discord.png"))
|
||||
|
||||
window.onbeforeunload = (ev) => {
|
||||
if(!webviews)return
|
||||
webviews.forEach(webview => {
|
||||
webview.src = 'about:blank'
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue