!2860 优化:酷家乐材质映射数据请求

pull/2862/MERGE
黄诗津 3 months ago committed by ChenX
parent 227d33b768
commit a3bd61d8ba

@ -96,6 +96,7 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
UpdateOption(cof: IConfigOption<KJLImportConfigOption>)
{
this.UpdataVersion(cof);
this.materialList = [];
Object.assign(this.m_Option, cof.option);
if (this.uiOption)
this.uiOption = {
@ -159,16 +160,19 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
this.materialList.push({ keyIndex: i, kjlName: mtl.kjlName, materialName: "", url: "", isSelect: false, isRender: false });
}
await this.AsyncLoadMaterials();
await this.AsyncLoadMaterials(0);
});
};
AsyncLoadMaterials = async () =>
AsyncLoadMaterials = async (startIndex: number) =>
{
this.queue.clear();
for (let i = 0, length = this.m_Option.materials.length; i < length; i++)
for (let i = startIndex; i < startIndex + 11; i++)
{
if (i >= this.m_Option.materials.length) continue;
let mtl = this.m_Option.materials[i];
if (!mtl || !mtl.id) continue;
let mtlInfo = this.materialList[i];
this.queue.add(async () =>
{
let promise: Promise<{ materialName: string, url: string; }>;
@ -183,7 +187,7 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
}
let { materialName, url } = await promise;
this.materialList[i] = { keyIndex: i, kjlName: mtl.kjlName, materialName, url, isSelect: false, isRender: true };
Object.assign(mtlInfo, { keyIndex: i, kjlName: mtl.kjlName, materialName, url, isSelect: false, isRender: true });
});
}
};

@ -8,17 +8,39 @@ import { KJLMaterialMapData } from "./KJLMaterialMapData";
@observer
export class KJLMaterialMap extends React.Component<{ store: KJLImportConfigStore; }>
{
private scrollEl = React.createRef<HTMLDivElement>();
private timer = null;
componentWillUnmount(): void
{
this.props.store.materialMap.clear();
}
render()
{
let store = this.props.store;
return (
<div className="KJLMaterialMap frame">
<div></div>
<div>
<div
ref={this.scrollEl}
onScroll={(e) =>
{
if (this.timer !== null)
{
clearTimeout(this.timer);
}
this.timer = setTimeout(() =>
{
if (this.scrollEl.current)
{
let scrollTop = this.scrollEl.current.scrollTop;
let index = Math.max(Math.floor((scrollTop - 30) / 52) - 1, 0);
this.props.store.AsyncLoadMaterials(index);
}
this.timer = null;
}, 100);
}}
>
<div className="info-header">
<Checkbox
label="全选"

@ -2,6 +2,7 @@ import { Intent } from "@blueprintjs/core";
import React from "react";
import { autoHoleFaceSettingStore } from "../../Add-on/AutoHoleFaceSetting";
import { oneClickInspectionStore } from "../../Add-on/BoardInspection/OneClickInspectionStore";
import { KJLImportConfigStore } from "../../Add-on/KJL/KJLImportConfig/KJLImportConfigStore";
import { doorRelatesInfoStore } from "../../Add-on/ParseDoorRelatesInfo/DoorRelatesInfoStore";
import { TemplateTagCommand, templateTagCommand } from "../../Add-on/Template/TemplateTagCommand";
import { app } from "../../ApplicationServices/Application";
@ -786,6 +787,7 @@ export class UserConfigStore extends Singleton
drillStore.deleteHoleTemps.clear();
app.Editor.ModalManage.DestoryAll();
RightPanelStore.GetInstance().m_IsShow = false;
KJLImportConfigStore.GetInstance().materialMap.clear();
app.WebSocket.Close();
}
}

Loading…
Cancel
Save