初始化
This commit is contained in:
@@ -4,6 +4,7 @@ import { IBimComponent } from '../../types/component';
|
||||
import { localeManager, t } from '../../services/locale';
|
||||
import { themeManager } from '../../services/theme';
|
||||
import type { SectionBoxPanelOptions, SectionBoxRange } from './types';
|
||||
import { getIcon } from '../../utils/icon-manager';
|
||||
|
||||
const DEFAULT_RANGE: SectionBoxRange = {
|
||||
x: { min: 0, max: 100 },
|
||||
@@ -167,9 +168,16 @@ export class SectionBoxPanel implements IBimComponent {
|
||||
btn.className = 'section-box-btn';
|
||||
btn.title = label;
|
||||
|
||||
const iconMap: Record<string, string> = {
|
||||
hide: '隐藏',
|
||||
reverse: '反向',
|
||||
fit: '适应到模型',
|
||||
reset: '重置'
|
||||
};
|
||||
|
||||
const icon = document.createElement('div');
|
||||
icon.className = 'section-box-btn-icon';
|
||||
icon.innerHTML = this.getIconSVG(type);
|
||||
icon.innerHTML = getIcon(iconMap[type] || type);
|
||||
|
||||
const labelEl = document.createElement('div');
|
||||
labelEl.className = 'section-box-btn-label';
|
||||
@@ -313,16 +321,6 @@ export class SectionBoxPanel implements IBimComponent {
|
||||
if (this.reverseBtn) this.reverseBtn.classList.toggle('active', this.isReversed);
|
||||
}
|
||||
|
||||
private getIconSVG(type: string): string {
|
||||
const icons: Record<string, string> = {
|
||||
hide: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"/></svg>',
|
||||
reverse: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M9 3L5 6.99h3V14h2V6.99h3L9 3zm7 14.01V10h-2v7.01h-3L15 21l4-3.99h-3z"/></svg>',
|
||||
fit: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M13 3h-2v10h2V3zm4 8h2v10h-2V11zm-8 4H7v6h2v-6zm-4 3H3v3h2v-3z"/></svg>',
|
||||
reset: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>'
|
||||
};
|
||||
return icons[type] || '';
|
||||
}
|
||||
|
||||
public setLocales(): void {
|
||||
if (!this.hideLabelEl) return;
|
||||
this.hideLabelEl.textContent = t('sectionBox.actions.hide');
|
||||
|
||||
Reference in New Issue
Block a user