refactor: reorganize project structure and implement self-managed i18n/theme for components

This commit is contained in:
yuding
2025-12-04 15:24:44 +08:00
parent 4dd923f19e
commit c45cdc9f7d
41 changed files with 3081 additions and 2010 deletions

View File

@@ -0,0 +1,48 @@
import { BimButtonGroup } from '../components/button-group';
import type { ButtonGroupOptions } from '../components/button-group/index.type';
import type { ThemeConfig } from '../themes/types';
/**
* 通用按钮组管理器
* 负责创建和管理除底部工具栏以外的其他按钮组。
*/
export class ButtonGroupManager {
private activeGroups: BimButtonGroup[] = [];
private container: HTMLElement;
constructor(container: HTMLElement) {
this.container = container;
}
/**
* 创建一个新的按钮组
*/
public create(options: Omit<ButtonGroupOptions, 'container'>): BimButtonGroup {
// 自动创建一个 div 作为容器
const groupContainer = document.createElement('div');
this.container.appendChild(groupContainer);
const group = new BimButtonGroup({
container: groupContainer,
...options
});
// 立即初始化
group.init();
this.activeGroups.push(group);
return group;
}
public updateTheme(theme: ThemeConfig) {
this.activeGroups.forEach(g => g.setTheme(theme));
}
public refresh() {
this.activeGroups.forEach(g => g.render());
}
public destroy() {
this.activeGroups.forEach(g => g.destroy());
this.activeGroups = [];
}
}