refactor: font size and split fields
This commit is contained in:
@@ -8,18 +8,28 @@ import { DataEditorPanel, PropertiesEditorPanel } from './editor-panel';
|
||||
|
||||
interface DeckProps {
|
||||
size?: string;
|
||||
sizeW?: number;
|
||||
sizeH?: number;
|
||||
grid?: string;
|
||||
gridW?: number;
|
||||
gridH?: number;
|
||||
bleed?: string;
|
||||
padding?: string;
|
||||
fontSize?: number;
|
||||
layers?: string;
|
||||
fixed?: boolean | string;
|
||||
}
|
||||
|
||||
customElement<DeckProps>('md-deck', {
|
||||
size: '54x86',
|
||||
grid: '5x8',
|
||||
size: '',
|
||||
sizeW: 54,
|
||||
sizeH: 86,
|
||||
grid: '',
|
||||
gridW: 5,
|
||||
gridH: 8,
|
||||
bleed: '1',
|
||||
padding: '2',
|
||||
fontSize: 3,
|
||||
layers: '',
|
||||
fixed: false
|
||||
}, (props, { element }) => {
|
||||
@@ -43,11 +53,29 @@ customElement<DeckProps>('md-deck', {
|
||||
// 创建 store 并加载数据
|
||||
const store = createDeckStore(resolvedSrc, (props.layers as string) || '');
|
||||
|
||||
// 初始化 store 属性
|
||||
store.actions.setSize(props.size || '54x86');
|
||||
store.actions.setGrid(props.grid || '5x8');
|
||||
// 解析 size 属性(支持旧格式 "54x86" 和新格式)
|
||||
if (props.size && props.size.includes('x')) {
|
||||
const [w, h] = props.size.split('x').map(Number);
|
||||
store.actions.setSizeW(w);
|
||||
store.actions.setSizeH(h);
|
||||
} else {
|
||||
store.actions.setSizeW(props.sizeW ?? 54);
|
||||
store.actions.setSizeH(props.sizeH ?? 86);
|
||||
}
|
||||
|
||||
// 解析 grid 属性(支持旧格式 "5x8" 和新格式)
|
||||
if (props.grid && props.grid.includes('x')) {
|
||||
const [w, h] = props.grid.split('x').map(Number);
|
||||
store.actions.setGridW(w);
|
||||
store.actions.setGridH(h);
|
||||
} else {
|
||||
store.actions.setGridW(props.gridW ?? 5);
|
||||
store.actions.setGridH(props.gridH ?? 8);
|
||||
}
|
||||
|
||||
store.actions.setBleed(props.bleed || '1');
|
||||
store.actions.setPadding(props.padding || '2');
|
||||
store.actions.setFontSize(props.fontSize ?? 3);
|
||||
|
||||
// 加载 CSV 数据
|
||||
store.actions.loadCardsFromPath(resolvedSrc, (props.layers as string) || '');
|
||||
|
||||
Reference in New Issue
Block a user