2017-12-28 26 views
0

私のアプリケーションに問題がありました。私は良いオプションのウィンドウであるログインウィンドウを作成しました。{transparent:true、frame:false}というオプションがあります。電子変更ウィンドウを再作成せずにオプション

ユーザーがログインした後で、ダッシュボードの背景が白でImが印刷可能なので、「透明」オプションをfalseに戻す必要があるダッシュボードにリダイレクトしたい完全に透明なウィンドウ上のフォント

Electronwindowを再作成せずにnone transparentに戻すための回避策はありますか?

app.js:

const electron = require('electron'); 
const { BrowserWindow } = electron; 
const { app } = electron; 
const window = require('electron-window'); 

const { MainProcess } = require("./modules/ipcHelper.js"); 

const io = require('socket.io-client'); 
const port = 8888; 
let socket; 

require('electron-reload')(__dirname) 

let mainWindow; 

app.on('ready',() => { 
    mainWindow = window.createWindow({ 
     width: 835, 
     height: 750, 
     frame: false, 
     transparent: true, 
    }); 

    let testwindow = new BrowserWindow({ 
     width: 835, 
     height: 750, 
     frame: false, 
     transparent: true, 
    }); 

    mainWindow.showUrl(`./app/index.html`,() => { 

    }); 

    let mainProcess = MainProcess(mainWindow); 

    mainProcess.onReady(() => { 
     mainProcess.on('auth', (arg, callback) => { 
      socket = io('http://' + arg.servername + ':' + port); 

      socket.on("connect",() => { 
       socket.emit('auth', { username: arg.username, password: arg.password }, (response) => { 
        if (response.success === true){ 
         callback({ success: true }); 
        //Here i want to set transparenty back to false 
        } 
        else 
         callback({ success: false, code: response.code }); 
       }); 
      }); 

      socket.on("connect_error",() => { 
       callback({ success: false, code: 3 }); 
      }); 


     }); 
    }); 
}) 

答えて

0

BrowserWindowは、あなたがその場でそのようなプロパティを変更するために使用できる方法の束を持っています。私はあなたがレンダラプロセスでこれをやっている場合は、あなたがremote

https://github.com/electron/electron/blob/master/docs/api/remote.md

を使用して、それへのアクセスを取得する必要がありますあなたが探しているものが win.setOpacity()

https://github.com/electron/electron/blob/master/docs/api/browser-window.md#winsetopacityopacity-windows-macos

だと思う

+0

getOpacityおよび/またはsetOpacityは機能しません。私はそれが関数ではないというエラーを取得しています。 – Arayni

+0

この場合の 'win'は、変更しようとしているウィンドウへの参照であることを確認します。たとえば、メインウィンドウの場合: 'remote.getCurrentWindow()' –

+0

私はメインプロセスで働いていますので、グローバルで宣言されたvar mainWindowを使って作業しています – Arayni

関連する問題