refactor: allow chinese layer names
This commit is contained in:
parent
4d1c40ed3e
commit
b09560a4e5
|
|
@ -1,4 +1,4 @@
|
||||||
import { createStore } from 'solid-js/store';
|
import { createStore } from 'solid-js/store';
|
||||||
import { calculateDimensions } from './dimensions';
|
import { calculateDimensions } from './dimensions';
|
||||||
import { loadCSV, CSV } from '../../utils/csv-loader';
|
import { loadCSV, CSV } from '../../utils/csv-loader';
|
||||||
import { initLayerConfigs, formatLayers, initLayerConfigsForSide } from './layer-parser';
|
import { initLayerConfigs, formatLayers, initLayerConfigsForSide } from './layer-parser';
|
||||||
|
|
@ -321,7 +321,7 @@ export function createDeckStore(
|
||||||
|
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
setState({
|
setState({
|
||||||
error: 'CSV 文件为空或格式不正确',
|
error: `CSV ${path} 文件为空或格式不正确`,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
@ -337,7 +337,7 @@ export function createDeckStore(
|
||||||
updateDimensions();
|
updateDimensions();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setState({
|
setState({
|
||||||
error: `加载 CSV 失败:${err instanceof Error ? err.message : '未知错误'}`,
|
error: `加载 CSV ${path} 失败:${err instanceof Error ? err.message : '未知错误'}`,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export function parseLayers(layersStr: string): Layer[] {
|
||||||
|
|
||||||
const layers: Layer[] = [];
|
const layers: Layer[] = [];
|
||||||
// 匹配:prop:x1,y1-x2,y2[ffontSize][direction][align]
|
// 匹配:prop:x1,y1-x2,y2[ffontSize][direction][align]
|
||||||
const regex = /(\w+):(\d+),(\d+)-(\d+),(\d+)(?:f([\d.]+))?([nsew])?([lcr])?/g;
|
const regex = /([^: ]+):(\d+),(\d+)-(\d+),(\d+)(?:f([\d.]+))?([nsew])?([lcr])?/g;
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = regex.exec(layersStr)) !== null) {
|
while ((match = regex.exec(layersStr)) !== null) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue