Skip to content

Commit

Permalink
feat: 对外统一类型接口
Browse files Browse the repository at this point in the history
  • Loading branch information
dogodo-cc committed Aug 9, 2024
1 parent cd51518 commit 0290ffa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/electron-badge/main/src/badge-unix.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Badge } from './badge';
import { app } from 'electron';
import type { BrowserWindow } from 'electron';
import { IbadgeStyleOpt } from './badge-generator';

// mac & linux

export class BadgeUnix extends Badge {
public constructor(max: number) {
super(max);
public constructor(max: number, win: BrowserWindow, style?: Partial<IbadgeStyleOpt>) {
super(max, win);
}

public update(val: number): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-badge/main/src/badge-win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class BadgeWin extends Badge {
generator: BadgeGenerator;

constructor(max: number, win: BrowserWindow, style?: Partial<IbadgeStyleOpt>) {
super(max);
super(max, win);
this.win = win;
this.generator = new BadgeGenerator(win, style);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/electron-badge/main/src/badge.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { IbadgeStyleOpt } from './badge-generator';
import type { BrowserWindow } from 'electron';

export abstract class Badge {
max = 99;

constructor(max = 99) {
constructor(max: number, win: BrowserWindow, style?: Partial<IbadgeStyleOpt>) {
this.max = max;
}

Expand Down
9 changes: 5 additions & 4 deletions packages/electron-badge/main/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BadgeUnix } from './badge-unix.js';
import { BadgeWin } from './badge-win.js';
import { BadgeUnix } from './badge-unix';
import { BadgeWin } from './badge-win';
export { Badge } from './badge';

const badge = process.platform === 'win32' ? BadgeWin : BadgeUnix;
export default process.platform === 'win32' ? BadgeWin : BadgeUnix;

export default badge;
export { BadgeUnix, BadgeWin };

0 comments on commit 0290ffa

Please sign in to comment.