feat: 用缓存处理对话中的项目切换问题
This commit is contained in:
@@ -179,10 +179,10 @@ export class AISelectboxToolManager {
|
||||
mouseMoveEvent(e) {
|
||||
if (!this.targetObject) return;
|
||||
if (!this.isDragging) return;
|
||||
var width = e.absolutePointer.x - this.startX
|
||||
var height = e.absolutePointer.y - this.startY
|
||||
var left = this.startX
|
||||
var top = this.startY
|
||||
let width = e.absolutePointer.x - this.startX
|
||||
let height = e.absolutePointer.y - this.startY
|
||||
let left = this.startX
|
||||
let top = this.startY
|
||||
if (width < 0) {
|
||||
left += width
|
||||
width = -width
|
||||
|
||||
@@ -17,7 +17,7 @@ fabric.Object.prototype.toObject = function () {
|
||||
const arr = [...fabric.Object.prototype.customProperties]
|
||||
args.forEach(v => (Array.isArray(v) ? arr.push(...v) : arr.push(v)))
|
||||
if (this.fill?.source === null) {
|
||||
let image = new Image()
|
||||
const image = new Image()
|
||||
image.crossOrigin = 'anonymous'
|
||||
image.src = this.info?.fill?.source
|
||||
this.fill.source = image
|
||||
@@ -65,17 +65,17 @@ export class CanvasManager {
|
||||
}
|
||||
}
|
||||
setCanvasViewSize(options) {
|
||||
var canvasViewWidth = options.canvasViewWidth || 1920
|
||||
var canvasViewHeight = options.canvasViewHeight || 1080
|
||||
const canvasViewWidth = options.canvasViewWidth || 1920
|
||||
const canvasViewHeight = options.canvasViewHeight || 1080
|
||||
this.canvas.setWidth(canvasViewWidth)
|
||||
this.canvas.setHeight(canvasViewHeight)
|
||||
}
|
||||
/** 初始化画布 */
|
||||
async initCanvas(options: CanvasInitOptions) {
|
||||
this.layerManager = this.stateManager.layerManager
|
||||
var canvasWidth = options.canvasWidth || 750
|
||||
var canvasHeight = options.canvasHeight || 600
|
||||
var image = null;
|
||||
let canvasWidth = options.canvasWidth || 750
|
||||
let canvasHeight = options.canvasHeight || 600
|
||||
let image = null;
|
||||
if (options.url) {
|
||||
await new Promise((resolve) => {
|
||||
fabric.Image.fromURL(options.url, async (img) => {
|
||||
@@ -188,8 +188,8 @@ export class CanvasManager {
|
||||
async updateSubLayerClipPath() {
|
||||
const objects = this.getObjects().filter((v: any) => v.type !== "group" && !!v.info?.id);
|
||||
for (let i = 0; i < objects.length; i++) {
|
||||
let object = objects[i]
|
||||
let path = this.getObjectById(object.info.parentId)?.clipPath
|
||||
const object = objects[i]
|
||||
const path = this.getObjectById(object.info.parentId)?.clipPath
|
||||
object.set({ clipPath: path || null })
|
||||
}
|
||||
this.renderAll()
|
||||
@@ -381,7 +381,7 @@ export class CanvasManager {
|
||||
}
|
||||
/** 处理JSON为正常画布 */
|
||||
processCanvasDisUrlJSON(obj: { canvas: string, images: Object }) {
|
||||
var json = obj.canvas;
|
||||
let json = obj.canvas;
|
||||
const images = obj.images || {}
|
||||
for (const key in images) {
|
||||
json = json.replace(new RegExp(key), images[key])
|
||||
|
||||
@@ -64,10 +64,10 @@ export class LayerManager {
|
||||
getLayerById(id) {
|
||||
function call(arr) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let v = arr[i]
|
||||
const v = arr[i]
|
||||
if (v.info.id === id) return v
|
||||
if (v.children) {
|
||||
let layer = call(v.children)
|
||||
const layer = call(v.children)
|
||||
if (layer) return layer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,8 +220,8 @@ export class ObjectManager {
|
||||
const isWidth = object.hasOwnProperty('width')
|
||||
const isHeight = object.hasOwnProperty('height')
|
||||
if (isWidth || isHeight) {
|
||||
let width = isWidth ? options.width : object.width
|
||||
let height = isHeight ? options.height : object.height
|
||||
const width = isWidth ? options.width : object.width
|
||||
const height = isHeight ? options.height : object.height
|
||||
if (type === "polygon") {
|
||||
if (object.points.length === 10) {// 五角星
|
||||
options.points = getStarArr(width, height)
|
||||
|
||||
@@ -58,10 +58,10 @@ export class ShapeToolManager {
|
||||
}
|
||||
mouseMoveEvent(e) {
|
||||
if (!this.isDragging) return;
|
||||
var width = e.absolutePointer.x - this.startX
|
||||
var height = e.absolutePointer.y - this.startY
|
||||
var left = this.startX
|
||||
var top = this.startY
|
||||
let width = e.absolutePointer.x - this.startX
|
||||
let height = e.absolutePointer.y - this.startY
|
||||
let left = this.startX
|
||||
let top = this.startY
|
||||
if (width < 0) {
|
||||
left += width
|
||||
width = -width
|
||||
|
||||
@@ -89,7 +89,7 @@ export class StateManager {
|
||||
/** 撤回状态 */
|
||||
undoState() {
|
||||
if (this.running.value) return
|
||||
var index = this.historyIndex.value - 1
|
||||
const index = this.historyIndex.value - 1
|
||||
const state = this.historyList.value[index]
|
||||
if (!state) return
|
||||
this.running.value = true
|
||||
@@ -103,7 +103,7 @@ export class StateManager {
|
||||
/** 重做状态 */
|
||||
redoState() {
|
||||
if (this.running.value) return
|
||||
var index = this.historyIndex.value + 1
|
||||
const index = this.historyIndex.value + 1
|
||||
const state = this.historyList.value[index]
|
||||
if (!state) return
|
||||
this.running.value = true
|
||||
|
||||
@@ -16,8 +16,8 @@ export const initThree = (threeDom)=>{
|
||||
/**
|
||||
* 创建渲染器对象
|
||||
*/
|
||||
let width = threeDom.offsetWidth; //窗口宽度
|
||||
let height = threeDom.offsetHeight; //窗口高度
|
||||
const width = threeDom.offsetWidth; //窗口宽度
|
||||
const height = threeDom.offsetHeight; //窗口高度
|
||||
const renderer = new THREE.WebGLRenderer({
|
||||
antialias: true,
|
||||
logarithmicDepthBuffer: true,//深度缓存 防止模型闪烁重影
|
||||
@@ -35,9 +35,9 @@ export const initThree = (threeDom)=>{
|
||||
|
||||
// 设置渲染器大小
|
||||
//环境光
|
||||
let ambient = new THREE.AmbientLight(0xffffff,.8);
|
||||
const ambient = new THREE.AmbientLight(0xffffff,.8);
|
||||
scene.add(ambient);
|
||||
let controls = new OrbitControls(camera,renderer.domElement)//监听鼠标、键盘事件;
|
||||
const controls = new OrbitControls(camera,renderer.domElement)//监听鼠标、键盘事件;
|
||||
// controls.minDistance = 500; // 设置相机与焦点的最小距离
|
||||
// controls.maxDistance = 4000; // 设置相机与焦点的最大距离
|
||||
controls.mouseButtons = {
|
||||
@@ -166,14 +166,14 @@ export const addModel = async (
|
||||
load: any
|
||||
) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
var fbxLoader = new GLTFLoader();
|
||||
let drac = new DRACOLoader()
|
||||
const fbxLoader = new GLTFLoader();
|
||||
const drac = new DRACOLoader()
|
||||
drac.setDecoderPath('/draco/')
|
||||
fbxLoader.setDRACOLoader(drac)
|
||||
|
||||
fbxLoader.load(url,
|
||||
(obj: any) => {
|
||||
let scene = obj.scene;
|
||||
const scene = obj.scene;
|
||||
scene.traverse((child: any) => {
|
||||
if (child.isMesh) {
|
||||
// 如果是基础材质,转换为标准材质
|
||||
|
||||
@@ -27,13 +27,13 @@ export class GenerateManager {
|
||||
async getTasksIdImg() {
|
||||
clearInterval(this.getTaskIdsImgTime)
|
||||
this.getTaskIdsImgTime = setInterval(()=>{
|
||||
let taskIds = this.taskIds.map((item)=>item.taskId)
|
||||
const taskIds = this.taskIds.map((item)=>item.taskId)
|
||||
getTaskidResult({taskIds}).then((rv:any)=>{
|
||||
//找出成功和失败的任务
|
||||
let returnedTasks = rv.filter((item)=>item.status == 'RETURNED' || item.status == 'FAILED')
|
||||
const returnedTasks = rv.filter((item)=>item.status == 'RETURNED' || item.status == 'FAILED')
|
||||
if(returnedTasks.length == 0)return
|
||||
//剔除调成功的
|
||||
let taskIds_ = JSON.parse(JSON.stringify(this.taskIds))
|
||||
const taskIds_ = JSON.parse(JSON.stringify(this.taskIds))
|
||||
this.taskIds = taskIds_.filter(itemA =>
|
||||
!returnedTasks.some(itemB => itemB.taskId === itemA.taskId)
|
||||
)
|
||||
|
||||
@@ -142,7 +142,7 @@ export class NodeManager {
|
||||
|
||||
copyNodeById(id: string) {
|
||||
const node = this.stateManager.getNodeById(id)
|
||||
let copyNode = JSON.parse(JSON.stringify(node))
|
||||
const copyNode = JSON.parse(JSON.stringify(node))
|
||||
const flowNode = this.stateManager.flowManager.getNodeById(id)
|
||||
if (!node) return console.warn(`${id}找不到对应节点`)
|
||||
if (node.data?.disableCopy) return console.warn(`${id}节点已禁用复制`)
|
||||
|
||||
@@ -276,7 +276,7 @@ export class StateManager {
|
||||
}
|
||||
/** 撤回状态 */
|
||||
undoState() {
|
||||
var index = this.historyIndex.value - 1
|
||||
const index = this.historyIndex.value - 1
|
||||
const state = this.historyList.value[index]
|
||||
if (!state) return
|
||||
this.historyIndex.value = index
|
||||
@@ -285,7 +285,7 @@ export class StateManager {
|
||||
}
|
||||
/** 重做状态 */
|
||||
redoState() {
|
||||
var index = this.historyIndex.value + 1
|
||||
const index = this.historyIndex.value + 1
|
||||
const state = this.historyList.value[index]
|
||||
if (!state) return
|
||||
this.historyIndex.value = index
|
||||
|
||||
Reference in New Issue
Block a user