![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@electron-lab/title-bar
Advanced tools
提供了自定义标题栏的基本封装以及一个标准的 Windows 标题栏。
import TitleBar from '@electron-lab/title-bar';
<TitleBar>Electron Lab</TitleBar>;
import { initWindowListener } from '@electron-lab/title-bar/main';
const createWindow = (): void => {
const mainWindow = new BrowserWindow({
width: 1440,
height: 900,
frame: false,
});
initWindowListener(mainWindow);
};
app.on('ready', createWindow);
为了在多窗口时使用,需要对每个窗口设置单独的 windowId。
example:
import { initWindowListener } from '@electron-lab/title-bar/main';
const createWindow = (): void => {
const mainWindow = new BrowserWindow({
width: 1440,
height: 900,
frame: false,
});
initWindowListener(mainWindow, 'index');
// <TitleBar windowId="index" />
const subWindow = new BrowserWindow({});
initWindowListener(subWindow, 'sub');
// <TitleBar windowId="sub" />
};
app.on('ready', createWindow);
如果不设置 windowId,则默认为 "index"。
import { ActionButton } from '@electron-lab/title-bar';
<ActionButton.Min>minimize window</ActionButton.Min>;
<ActionButton.Min>
{(able, { isMax }) => {
return <Button> {isMax ? 'restore' : 'maximize'} </Button>;
}}
</ActionButton.Min>;
<ActionButton.Close>close window</ActionButton.Close>;
参数 Prop | 说明 comment | 类型 Type | 默认值 Default Value | 示例 Example |
---|---|---|---|---|
extra | 标题栏额外的渲染区域 | React.ReactNode | extra={<Button>设置</Button>} | |
backgroundColor | 背景颜色 | CSSProperties['backgroundColor'] | backgroundColor="red" | |
dark | 黑夜模式 | boolean | dark={true} | |
followBrowserWindowOptions | 是否跟随窗口的设置(假如对应的窗口设置了 isMaximizable,则按钮的最大化按钮会变成 disabled) | boolean | followBrowserWindowOptions={true} | |
hideButtonWhileDisable | 跟随窗口设置时,是否隐藏按钮 | boolean | hideButtonWhileDisable={false} | |
windowId | 窗口 id | string | "index" | windowId="index" |
参数 Prop | 说明 comment | 类型 Type | 默认值 Default Value | 示例 Example |
---|---|---|---|---|
children | 渲染的内容 | ReactNode | undefined | ((able: boolean, state: { isMax: boolean }) => ReactNode) | <ActionButton.Max>{(able,{isMax})=><div>isMax: {isMax}</div>}</ActionButton.Max> | |
followBrowserWindowOptions | 同 TitleBar.followBrowserWindowOptions | |||
hideButtonWhileDisable | 同 TitleBar.hideButtonWhileDisable | |||
windowId | 同 TitleBar.windowId |
参数 Prop | 说明 comment | 类型 Type | 默认值 Default Value | 示例 Example |
---|---|---|---|---|
children | 渲染的内容 | ReactNode | undefined | ((able: boolean) => ReactNode) | <ActionButton.Max>{(able,{isMax})=><div>isMax: {isMax}</div>}</ActionButton.Max> | |
followBrowserWindowOptions | 同 TitleBar.followBrowserWindowOptions | |||
hideButtonWhileDisable | 同 TitleBar.hideButtonWhileDisable | |||
windowId | 同 TitleBar.windowId |
初始化窗口控制的主进程 ipc 通讯监听。
initWindowListener: (window: electron.BrowserWindow,windowId?:string)
windowId 不设置则为 "index"
example:
import { initWindowListener } from '@electron-lab/title-bar/main';
const mainWindow = new BrowserWindow({
width: 1440,
height: 900,
frame: false,
});
initWindowListener(mainWindow, 'index');
// <TitleBar windowId="index" />
移除窗口控制的主进程 ipc 通讯监听。这个方法会在窗口关闭时自动执行移除,一般不需要使用。
removeWindowListener: (windowId:string)
example:
import { initWindowListener, removeWindowListener } from '@electron-lab/title-bar/main';
const mainWindow = new BrowserWindow({
width: 1440,
height: 900,
frame: false,
});
initWindowListener(mainWindow, 'index');
// <TitleBar windowId="index" />
// in some callback
() => {
removeWindowListener('index');
};
FAQs
提供了自定义标题栏的基本封装以及一个标准的 Windows 标题栏。
We found that @electron-lab/title-bar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.