初始化
This commit is contained in:
49
src/components/map-panel/index.ts
Normal file
49
src/components/map-panel/index.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import type { ThemeConfig } from '../../themes/types';
|
||||
import { IBimComponent } from '../../types/component';
|
||||
import { localeManager } from '../../services/locale';
|
||||
import { themeManager } from '../../services/theme';
|
||||
|
||||
/**
|
||||
* 地图面板组件
|
||||
*/
|
||||
export class MapPanel implements IBimComponent {
|
||||
public element!: HTMLElement;
|
||||
private unsubscribeLocale: (() => void) | null = null;
|
||||
private unsubscribeTheme: (() => void) | null = null;
|
||||
|
||||
constructor() {}
|
||||
|
||||
public init(): void {
|
||||
this.element = this.createPanel();
|
||||
this.unsubscribeLocale = localeManager.subscribe(() => this.setLocales());
|
||||
this.unsubscribeTheme = themeManager.subscribe((theme) => this.setTheme(theme));
|
||||
|
||||
this.setLocales();
|
||||
this.setTheme(themeManager.getTheme());
|
||||
}
|
||||
|
||||
private createPanel(): HTMLElement {
|
||||
const panel = document.createElement('div');
|
||||
panel.className = 'map-panel';
|
||||
panel.style.padding = '20px';
|
||||
panel.style.color = '#fff';
|
||||
panel.textContent = '地图内容待实现';
|
||||
return panel;
|
||||
}
|
||||
|
||||
public setLocales(): void {
|
||||
// 更新文本
|
||||
}
|
||||
|
||||
public setTheme(_theme: ThemeConfig): void {
|
||||
// 应用主题
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
this.unsubscribeLocale?.();
|
||||
this.unsubscribeTheme?.();
|
||||
if (this.element && this.element.parentElement) {
|
||||
this.element.parentElement.removeChild(this.element);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user