mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 03:14:57 +08:00
🐞 fix: 修复工具栏图标 & 添加调试工具
This commit is contained in:
@@ -66,6 +66,9 @@ class createThumbar implements Thumbar {
|
||||
private _next: ThumbarButton;
|
||||
private _play: ThumbarButton;
|
||||
private _pause: ThumbarButton;
|
||||
// 当前播放状态
|
||||
private _isPlaying: boolean = false;
|
||||
|
||||
constructor(win: BrowserWindow) {
|
||||
// 初始化数据
|
||||
this._win = win;
|
||||
@@ -77,12 +80,36 @@ class createThumbar implements Thumbar {
|
||||
this._next = this._thumbar.get(ThumbarKeys.Next)!;
|
||||
// 初始化工具栏
|
||||
this.updateThumbar();
|
||||
// 监听主题变化
|
||||
this.initThemeListener();
|
||||
}
|
||||
|
||||
// 初始化主题监听器
|
||||
private initThemeListener() {
|
||||
nativeTheme.on("updated", () => {
|
||||
this.refreshThumbarButtons();
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新工具栏按钮(主题变化时)
|
||||
private refreshThumbarButtons() {
|
||||
// 重新创建按钮
|
||||
this._thumbar = createThumbarButtons(this._win);
|
||||
this._play = this._thumbar.get(ThumbarKeys.Play)!;
|
||||
this._pause = this._thumbar.get(ThumbarKeys.Pause)!;
|
||||
this._prev = this._thumbar.get(ThumbarKeys.Prev)!;
|
||||
this._next = this._thumbar.get(ThumbarKeys.Next)!;
|
||||
// 更新工具栏
|
||||
this.updateThumbar(this._isPlaying);
|
||||
}
|
||||
|
||||
// 更新工具栏
|
||||
updateThumbar(playing: boolean = false, clean: boolean = false) {
|
||||
this._isPlaying = playing;
|
||||
if (clean) return this.clearThumbar();
|
||||
this._win.setThumbarButtons([this._prev, playing ? this._pause : this._play, this._next]);
|
||||
}
|
||||
|
||||
// 清除工具栏
|
||||
clearThumbar() {
|
||||
this._win.setThumbarButtons([]);
|
||||
|
||||
Reference in New Issue
Block a user