Vanessa 2025-02-25 23:48:53 +08:00
parent 33f8def8ce
commit 3464708aae
5 changed files with 30 additions and 27 deletions

View file

@ -34,17 +34,27 @@ export class Menu {
return this.menu.addItem(option);
}
addSeparator(index?: number, ignore = false, id?: string) {
if (ignore) {
addSeparator(options?: number | {
index?: number,
id?: string,
ignore?: boolean
}, ignoreParam = false) {
// 兼容 3.1.24 之前的版本 addSeparator(index?: number, ignore?: boolean): HTMLElement;
let id: string;
let index: number;
let ignore = false;
if (typeof options === "object") {
ignore = options.ignore || false;
index = options.index;
id = options.id;
} else if (typeof options === "number") {
index = options;
ignore = ignoreParam;
}
if (ignore || this.isOpen) {
return;
}
if (this.isOpen) {
return;
}
if (id) {
return this.menu.addSeparator(index, id);
}
return this.menu.addSeparator(index);
return this.menu.addItem({id, type: "separator", index});
}
open(options: IPosition) {