BrowserWindow - win.isVisibleOnAllWorkspaces()

概述

返回窗口是否在所有桌面可见。

基本信息

属性
模块 BrowserWindow
类型 Method
鸿蒙支持 支持

OHOS 依赖与基本表现

属性
系统权限依赖 无需申请
主窗 支持
子窗 支持
悬浮窗 支持
添加JIT权限 支持
坚盾模式 支持

差异说明

属性
是否存在差异 存在差异
差异说明 workspaces 概念差异:isVisibleOnAllWorkspaces 查询语义与桌面端不一致

Demo

const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');

let mainWindow = null;

function sendLog(type, message) {
  if (mainWindow && !mainWindow.isDestroyed()) {
    mainWindow.webContents.send('log-message', { type, message, time: new Date().toLocaleTimeString() });
  }
}

app.whenReady().then(() => {
  mainWindow = new BrowserWindow({
    width: 1400, height: 900,
    webPreferences: { preload: path.join(__dirname, '..', 'preload.js'), contextIsolation: true, nodeIntegration: false },
    title: 'Test: method:isVisibleOnAllWorkspaces',
  });
  mainWindow.loadFile(path.join(__dirname, '..', 'index.html'));

  ipcMain.handle('method:isVisibleOnAllWorkspaces', () => mainWindow.isVisibleOnAllWorkspaces());
});

app.on('window-all-closed', () => { app.quit(); });