|
@@ -317,11 +317,14 @@ async function processSplitConfig() {
|
|
|
}
|
|
|
// 裁切块,可能是一块,两块,三块... [start, width ...] => [0, 0.3] | [0, 0.55, 0.45, 0.55] | [0, 0.35, 0.33, 0.35, 0.66, 0.35]
|
|
|
// 要转变为 [[0, 0.3]] | [[0, 0.55], [0.45, 0.55]] | [[0, 0.35], [0.33, 0.35], [0.66, 0.35]]
|
|
|
- const splitConfigPairs = store.setting.splitConfig
|
|
|
- .map<[number, number]>((v, index, ary) =>
|
|
|
- index % 2 === 0 ? [v, ary[index + 1]] : [-1, -1]
|
|
|
- )
|
|
|
- .filter((v) => v[0] > -1);
|
|
|
+ const splitConfigPairs = store.setting.splitConfig.reduce<[number, number][]>(
|
|
|
+ (a, v, index) => {
|
|
|
+ // 偶数位组成数组的第一位,奇数位组成数组的第二位
|
|
|
+ index % 2 === 0 ? a.push([v, -1]) : (a.at(-1)![1] = v);
|
|
|
+ return a;
|
|
|
+ },
|
|
|
+ []
|
|
|
+ );
|
|
|
|
|
|
// 最大的 splitConfig 的宽度
|
|
|
const maxSplitConfig = Math.max(
|