修复材质导出问题,添加库打包模式
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import MaterialView from './components/MaterialView.vue';
|
||||
|
||||
// 禁用右键菜单
|
||||
document.addEventListener('contextmenu', (e) => e.preventDefault());
|
||||
// document.addEventListener('contextmenu', (e) => e.preventDefault());
|
||||
|
||||
</script>
|
||||
|
||||
|
@@ -1,9 +1,22 @@
|
||||
import { CADFiler, Database, DuplicateRecordCloning, PhysicalMaterialRecord } from "webcad_ue4_api";
|
||||
import { CADFactory, CADFiler, CADObject, Database, DuplicateRecordCloning, ObjectId, PhysicalMaterialRecord } from "webcad_ue4_api";
|
||||
|
||||
// TODO: Danger: 注意入侵性代码
|
||||
// 疑似是WebCAD中的漏洞,当传入new Database()时,
|
||||
// Database中的filer.ReadObject方法并不会为CadObject.objectId赋值,
|
||||
// 导致后续的CadObject.Id.Index发生空指针异常
|
||||
// 因此需要修改CAD中的Database.AllocationObjectId,尝试手动赋值
|
||||
// @ts-ignore
|
||||
Database.prototype.AllocationObjectId = function (this: Database, object: CADObject) {
|
||||
if (object.Id === undefined) object.objectId = new ObjectId(undefined, undefined);
|
||||
// @ts-ignore
|
||||
object.Id.Index = this.idIndex++;
|
||||
// @ts-ignore
|
||||
this.idMap.set(object.Id.Index, object.Id);
|
||||
}
|
||||
|
||||
export function MaterialOut(material: PhysicalMaterialRecord): string
|
||||
{
|
||||
let db = new Database();
|
||||
debugger;
|
||||
db.WblockCloneObejcts(
|
||||
[material],
|
||||
db.MaterialTable,
|
||||
|
@@ -11,7 +11,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { type Property } from 'csstype';
|
||||
import type { Property } from 'csstype';
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
|
@@ -13,6 +13,9 @@ import CfFlex from './CfFlex.vue';
|
||||
const scene = useScene();
|
||||
const container = useTemplateRef<HTMLElement>('container');
|
||||
|
||||
// 禁用右键菜单
|
||||
document.addEventListener('contextmenu', (e) => e.preventDefault());
|
||||
|
||||
onMounted(() => {
|
||||
scene.Initial(container.value);
|
||||
});
|
||||
|
7
src/helpers/helper.web.ts
Normal file
7
src/helpers/helper.web.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function DownloadFile(fileName: string, blob: Blob) {
|
||||
const tempLink = document.createElement('a');
|
||||
tempLink.href = URL.createObjectURL(blob as Blob);
|
||||
tempLink.download = fileName;
|
||||
tempLink.click();
|
||||
URL.revokeObjectURL(tempLink.href);
|
||||
}
|
5
src/lib/index.ts
Normal file
5
src/lib/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import MaterialView from "../components/MaterialView.vue";
|
||||
|
||||
export {
|
||||
MaterialView
|
||||
}
|
@@ -95,19 +95,10 @@ export const useScene = defineStore('scene', () => {
|
||||
materialName: string;
|
||||
}
|
||||
async function UploadMaterialAsync(request: UploadMaterialRequest) {
|
||||
const logoPath = await HandleUpdateLogo();
|
||||
// TODO: Warn: 是否要生成logo路径?
|
||||
// const logoPath = await HandleUpdateLogo();
|
||||
const matJson = MaterialOut(Material.value as PhysicalMaterialRecord);
|
||||
const data = await PostJson(MaterialUrls.create, {
|
||||
dir_id: request,
|
||||
name: request.materialName,
|
||||
logo: logoPath,
|
||||
// jsonString -> Deflate -> BinaryString -> Base64
|
||||
file: btoa(String.fromCharCode(...await DeflateAsync(matJson))),
|
||||
zip_type: 'gzip',
|
||||
});
|
||||
if (data.err_code !== RequestStatus.Ok) {
|
||||
throw new Error(data.err_msg);
|
||||
}
|
||||
console.log(matJson);
|
||||
}
|
||||
|
||||
async function HandleUpdateLogo() {
|
||||
|
Reference in New Issue
Block a user