feat(circle): change size

This commit is contained in:
zhangheng
2026-04-15 11:04:42 +08:00
parent d3d9e8385b
commit 72b1dacf1c
4 changed files with 133 additions and 39 deletions

View File

@@ -6,6 +6,17 @@ import { useObjectStore } from "./store"
import { useBottomToolsStore } from "./useBottomToolsStore"
import { safeClone } from "./utils/clone"
export const NODE_SIZE_MIN = 6
export const NODE_SIZE_MAX = 24
export const DEFAULT_NODE_SIZE = 10
const clampNodeSize = (value: number) => {
const nextValue = Number.isFinite(value)
? Math.round(value)
: DEFAULT_NODE_SIZE
return Math.min(NODE_SIZE_MAX, Math.max(NODE_SIZE_MIN, nextValue))
}
interface TopToolsState {
// 标注页面是否仅查看
isView: boolean
@@ -34,6 +45,8 @@ interface TopToolsState {
setAssistToolEnabled: (val: boolean) => void
assistToolSize: number
setAssistToolSize: (val: number) => void
nodeSize: number
setNodeSize: (val: number) => void
showTags: boolean
setShowTags: (val: boolean) => void
showTagsConfigs: string[]
@@ -94,6 +107,7 @@ const initialTopToolsState = {
crosshairStatus: "hidden" as "hidden" | "line" | "carve",
assistToolEnabled: false,
assistToolSize: 10,
nodeSize: DEFAULT_NODE_SIZE,
drawOption: "default" as "default" | "intersect" | "unite",
saveCurrentScale: false,
scale: 1,
@@ -183,6 +197,12 @@ export const useTopToolsStore = create<TopToolsState>()(
...state,
assistToolSize: Math.max(1, val),
})),
nodeSize: initialTopToolsState.nodeSize,
setNodeSize: (val) =>
set((state: TopToolsState) => ({
...state,
nodeSize: clampNodeSize(val),
})),
showTags: false,
setShowTags: (val) =>
set((state: TopToolsState) => ({