feat(all): 拖入花线迁移

This commit is contained in:
plum
2026-04-08 16:00:14 +08:00
parent 2605656dc4
commit 986da8ce42
5 changed files with 394 additions and 2 deletions
@@ -0,0 +1,60 @@
import { defineStore } from "pinia";
import { store } from "@/store";
interface IPathDrawingState {
active: boolean;
template: Record<string, any> | null;
submit: ((payload: IPathDrawingResult) => void) | null;
}
export interface IPathDrawingResult {
worldPoints: Array<{ x: number; y: number; z: number }>;
origin: { x: number; y: number; z: number };
options: Record<string, any>;
}
export interface IPathDrawingRequest {
template?: Record<string, any> | null;
submit?: (payload: IPathDrawingResult) => void;
}
function isPathDrawingRequest(payload: Record<string, any> | IPathDrawingRequest) {
return Object.prototype.hasOwnProperty.call(payload, "template") || Object.prototype.hasOwnProperty.call(payload, "submit");
}
export const usePathDrawingStore = defineStore({
id: "pathDrawing",
state: (): IPathDrawingState => ({
active: false,
template: null,
submit: null,
}),
getters: {
isActive: state => state.active,
getTemplate: state => state.template,
getSubmit: state => state.submit,
},
actions: {
start(payload: Record<string, any> | IPathDrawingRequest) {
const request = isPathDrawingRequest(payload) ? payload : { template: payload };
this.template = request.template ? JSON.parse(JSON.stringify(request.template)) : null;
this.submit = typeof request.submit === "function" ? request.submit : null;
this.active = true;
},
cancel() {
this.active = false;
this.template = null;
this.submit = null;
},
finish() {
this.active = false;
this.template = null;
this.submit = null;
},
},
});
export function usePathDrawingStoreWithOut() {
return usePathDrawingStore(store);
}