Merge branch 'main' of ssh://biboer.cn:21174/gavin/lupin-demo
This commit is contained in:
@@ -65,6 +65,7 @@ export function useLuopan(
|
|||||||
const resolver = new ColorResolver(configObj.theme, configObj.background);
|
const resolver = new ColorResolver(configObj.theme, configObj.background);
|
||||||
const builder = new SectorBuilder(resolver, {
|
const builder = new SectorBuilder(resolver, {
|
||||||
textRadialPosition: textRadialPosition.value,
|
textRadialPosition: textRadialPosition.value,
|
||||||
|
insetDistance: configObj.insetDistance,
|
||||||
});
|
});
|
||||||
const sectorLayers = configObj.layers.filter(isSectorLayer);
|
const sectorLayers = configObj.layers.filter(isSectorLayer);
|
||||||
return sectorLayers.flatMap((layer, index) => builder.buildLayer(layer, index));
|
return sectorLayers.flatMap((layer, index) => builder.buildLayer(layer, index));
|
||||||
@@ -104,6 +105,9 @@ export function useLuopan(
|
|||||||
strokeOpacity: typeof configObj.strokeOpacity === 'number'
|
strokeOpacity: typeof configObj.strokeOpacity === 'number'
|
||||||
? configObj.strokeOpacity
|
? configObj.strokeOpacity
|
||||||
: undefined,
|
: undefined,
|
||||||
|
insetDistance: typeof configObj.insetDistance === 'number'
|
||||||
|
? configObj.insetDistance
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
config.value = resolvedConfig;
|
config.value = resolvedConfig;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export const parseConfig = (jsonText: string): LuopanConfig => {
|
|||||||
strokeWidth: typeof config.strokeWidth === 'number' ? config.strokeWidth : undefined,
|
strokeWidth: typeof config.strokeWidth === 'number' ? config.strokeWidth : undefined,
|
||||||
strokeColor: typeof config.strokeColor === 'string' ? config.strokeColor : undefined,
|
strokeColor: typeof config.strokeColor === 'string' ? config.strokeColor : undefined,
|
||||||
strokeOpacity: typeof config.strokeOpacity === 'number' ? config.strokeOpacity : undefined,
|
strokeOpacity: typeof config.strokeOpacity === 'number' ? config.strokeOpacity : undefined,
|
||||||
|
insetDistance: typeof config.insetDistance === 'number' ? config.insetDistance : undefined,
|
||||||
outerRadius: typeof config.outerRadius === 'number' ? config.outerRadius : undefined,
|
outerRadius: typeof config.outerRadius === 'number' ? config.outerRadius : undefined,
|
||||||
theme: normalizeTheme(config.theme),
|
theme: normalizeTheme(config.theme),
|
||||||
layers: config.layers as LuopanConfig['layers'],
|
layers: config.layers as LuopanConfig['layers'],
|
||||||
|
|||||||
@@ -18,17 +18,23 @@ const ensureTrailingSlash = (input: string): string =>
|
|||||||
interface SectorBuilderOptions {
|
interface SectorBuilderOptions {
|
||||||
textRadialPosition?: TextRadialPosition;
|
textRadialPosition?: TextRadialPosition;
|
||||||
svgIconPath?: string;
|
svgIconPath?: string;
|
||||||
|
insetDistance?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SectorBuilder {
|
export class SectorBuilder {
|
||||||
private colorResolver: ColorResolver;
|
private colorResolver: ColorResolver;
|
||||||
private textRadialPosition: TextRadialPosition;
|
private textRadialPosition: TextRadialPosition;
|
||||||
private svgIconPath: string;
|
private svgIconPath: string;
|
||||||
|
private insetDistance: number;
|
||||||
|
|
||||||
constructor(colorResolver: ColorResolver, options: SectorBuilderOptions = {}) {
|
constructor(colorResolver: ColorResolver, options: SectorBuilderOptions = {}) {
|
||||||
this.colorResolver = colorResolver;
|
this.colorResolver = colorResolver;
|
||||||
this.textRadialPosition = options.textRadialPosition ?? 'middle';
|
this.textRadialPosition = options.textRadialPosition ?? 'middle';
|
||||||
this.svgIconPath = ensureTrailingSlash(options.svgIconPath ?? 'src/assets/icons/');
|
this.svgIconPath = ensureTrailingSlash(options.svgIconPath ?? 'src/assets/icons/');
|
||||||
|
this.insetDistance =
|
||||||
|
typeof options.insetDistance === 'number'
|
||||||
|
? Math.max(0, options.insetDistance)
|
||||||
|
: SECTOR_INSET_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildLayer(layer: SectorLayerConfig, layerIndex: number): Sector[] {
|
buildLayer(layer: SectorLayerConfig, layerIndex: number): Sector[] {
|
||||||
@@ -57,7 +63,7 @@ export class SectorBuilder {
|
|||||||
layer.rOuter,
|
layer.rOuter,
|
||||||
aStart,
|
aStart,
|
||||||
aEnd,
|
aEnd,
|
||||||
SECTOR_INSET_DISTANCE
|
this.insetDistance
|
||||||
)
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface LuopanConfig {
|
|||||||
strokeWidth?: number;
|
strokeWidth?: number;
|
||||||
strokeColor?: string;
|
strokeColor?: string;
|
||||||
strokeOpacity?: number;
|
strokeOpacity?: number;
|
||||||
|
insetDistance?: number;
|
||||||
outerRadius?: number;
|
outerRadius?: number;
|
||||||
theme: ThemeConfig;
|
theme: ThemeConfig;
|
||||||
layers: LayerConfig[];
|
layers: LayerConfig[];
|
||||||
|
|||||||
Reference in New Issue
Block a user