|
|
@@ -42,6 +42,7 @@ import { overviewId, params, tabulationId } from "@/example/env.ts";
|
|
|
import { listener } from "@/utils/event.ts";
|
|
|
import { mergeFuns, repeatedlyOnly } from "@/utils/shared.ts";
|
|
|
import saveAs from "@/utils/file-serve.ts";
|
|
|
+import { genLoading } from "@/example/loadding.ts";
|
|
|
|
|
|
const props = defineProps<{ title: string }>();
|
|
|
const draw = useDraw();
|
|
|
@@ -250,87 +251,89 @@ const setViewToKanKanCover = async () => {
|
|
|
return blob;
|
|
|
};
|
|
|
|
|
|
-const saveHandler = repeatedlyOnly(async () => {
|
|
|
- const storeData = draw.getData();
|
|
|
- const [tabBlob, listBlob, kkBlob, scale, rect, syncItems] = await draw.enterTemp(
|
|
|
- async () => {
|
|
|
- const back = draw.config.back;
|
|
|
- const [rect, syncItems, recover] = await setViewToTableCover();
|
|
|
- await nextTick();
|
|
|
- const mat = draw.viewer.transform.invert();
|
|
|
- const scale =
|
|
|
- lineLen(mat.point({ x: 1, y: 0 }), mat.point({ x: 0, y: 0 })) *
|
|
|
- draw.store.config.proportion.scale;
|
|
|
- const tabBlob = await getImage(draw, "image/png");
|
|
|
- draw.config.back = back;
|
|
|
- await nextTick();
|
|
|
- const listBlob = await getImage(draw, "image/jpg");
|
|
|
- recover();
|
|
|
- await nextTick();
|
|
|
+const saveHandler = genLoading(
|
|
|
+ repeatedlyOnly(async () => {
|
|
|
+ const storeData = draw.getData();
|
|
|
+ const [tabBlob, listBlob, kkBlob, scale, rect, syncItems] = await draw.enterTemp(
|
|
|
+ async () => {
|
|
|
+ const back = draw.config.back;
|
|
|
+ const [rect, syncItems, recover] = await setViewToTableCover();
|
|
|
+ await nextTick();
|
|
|
+ const mat = draw.viewer.transform.invert();
|
|
|
+ const scale =
|
|
|
+ lineLen(mat.point({ x: 1, y: 0 }), mat.point({ x: 0, y: 0 })) *
|
|
|
+ draw.store.config.proportion.scale;
|
|
|
+ const tabBlob = await getImage(draw, "image/png");
|
|
|
+ draw.config.back = back;
|
|
|
+ await nextTick();
|
|
|
+ const listBlob = await getImage(draw, "image/jpg");
|
|
|
+ recover();
|
|
|
+ await nextTick();
|
|
|
|
|
|
- const kkBlob = await setViewToKanKanCover();
|
|
|
- return [tabBlob, listBlob, kkBlob, scale, rect, syncItems] as const;
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
- let tabUrl = null;
|
|
|
- let listUrl = null;
|
|
|
- let kankanUrl = null;
|
|
|
- if (!tabBlob || !listBlob || !kkBlob) {
|
|
|
- ElMessage.error("截图保存失败");
|
|
|
- } else {
|
|
|
- console.error(window.platform.uploadResourse);
|
|
|
- [tabUrl, listUrl, kankanUrl] = await Promise.all([
|
|
|
- window.platform.uploadResourse(new File([tabBlob], `tabulation-cover.png`)),
|
|
|
- window.platform.uploadResourse(new File([listBlob], `list-cover.png`)),
|
|
|
- window.platform.uploadResourse(new File([kkBlob], `kankan-cover.png`)),
|
|
|
- ]);
|
|
|
- }
|
|
|
+ const kkBlob = await setViewToKanKanCover();
|
|
|
+ return [tabBlob, listBlob, kkBlob, scale, rect, syncItems] as const;
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
- tabulationId.value = await window.platform.getTabulationId(overviewId.value);
|
|
|
- await refreshTabulationData();
|
|
|
+ let tabUrl = null;
|
|
|
+ let listUrl = null;
|
|
|
+ let kankanUrl = null;
|
|
|
+ if (!tabBlob || !listBlob || !kkBlob) {
|
|
|
+ ElMessage.error("截图保存失败");
|
|
|
+ } else {
|
|
|
+ console.error(window.platform.uploadResourse);
|
|
|
+ [tabUrl, listUrl, kankanUrl] = await Promise.all([
|
|
|
+ window.platform.uploadResourse(new File([tabBlob], `tabulation-cover.png`)),
|
|
|
+ window.platform.uploadResourse(new File([listBlob], `list-cover.png`)),
|
|
|
+ window.platform.uploadResourse(new File([kkBlob], `kankan-cover.png`)),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
|
|
|
- const cover = {
|
|
|
- url: tabUrl,
|
|
|
- width: rect.width,
|
|
|
- height: rect.height,
|
|
|
- proportion: { ...draw.store.config.proportion, scale },
|
|
|
- syncItems,
|
|
|
- };
|
|
|
+ tabulationId.value = await window.platform.getTabulationId(overviewId.value);
|
|
|
+ await refreshTabulationData();
|
|
|
|
|
|
- console.log(tabulationData.value.store);
|
|
|
- const tabStore = await repTabulationStore(
|
|
|
- tabulationData.value.paperKey,
|
|
|
- storeData.config.compass.rotation,
|
|
|
- cover,
|
|
|
- tabulationData.value.isAutoGen ? undefined : tabulationData.value.store
|
|
|
- );
|
|
|
+ const cover = {
|
|
|
+ url: tabUrl,
|
|
|
+ width: rect.width,
|
|
|
+ height: rect.height,
|
|
|
+ proportion: { ...draw.store.config.proportion, scale },
|
|
|
+ syncItems,
|
|
|
+ };
|
|
|
|
|
|
- console.log(tabStore);
|
|
|
- tabStore.config.compass = storeData.config.compass;
|
|
|
- const body: any = {
|
|
|
- ...overviewData.value,
|
|
|
- listCover: listUrl,
|
|
|
- store: storeData,
|
|
|
- viewport: draw!.viewer.transform.m,
|
|
|
- caseTabulation: {
|
|
|
- ...tabulationData.value,
|
|
|
- id: tabulationId.value,
|
|
|
- title: overviewData.value.title,
|
|
|
+ console.log(tabulationData.value.store);
|
|
|
+ const tabStore = await repTabulationStore(
|
|
|
+ tabulationData.value.paperKey,
|
|
|
+ storeData.config.compass.rotation,
|
|
|
cover,
|
|
|
- store: tabStore,
|
|
|
- overviewId: overviewId.value,
|
|
|
- },
|
|
|
- };
|
|
|
- if (window.platform.sceneDraw) {
|
|
|
- body.kankanCover = kankanUrl;
|
|
|
- }
|
|
|
+ tabulationData.value.isAutoGen ? undefined : tabulationData.value.store
|
|
|
+ );
|
|
|
|
|
|
- overviewId.value = await window.platform.saveOverviewData(overviewId.value, body);
|
|
|
- tabulationId.value = await window.platform.getTabulationId(overviewId.value);
|
|
|
- console.log("保存完毕");
|
|
|
- emit("saveAfter");
|
|
|
-});
|
|
|
+ console.log(tabStore);
|
|
|
+ tabStore.config.compass = storeData.config.compass;
|
|
|
+ const body: any = {
|
|
|
+ ...overviewData.value,
|
|
|
+ listCover: listUrl,
|
|
|
+ store: storeData,
|
|
|
+ viewport: draw!.viewer.transform.m,
|
|
|
+ caseTabulation: {
|
|
|
+ ...tabulationData.value,
|
|
|
+ id: tabulationId.value,
|
|
|
+ title: overviewData.value.title,
|
|
|
+ cover,
|
|
|
+ store: tabStore,
|
|
|
+ overviewId: overviewId.value,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ if (window.platform.sceneDraw) {
|
|
|
+ body.kankanCover = kankanUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ overviewId.value = await window.platform.saveOverviewData(overviewId.value, body);
|
|
|
+ tabulationId.value = await window.platform.getTabulationId(overviewId.value);
|
|
|
+ console.log("保存完毕");
|
|
|
+ emit("saveAfter");
|
|
|
+ })
|
|
|
+);
|
|
|
|
|
|
onUnmounted(
|
|
|
listener(document.documentElement, "keydown", (ev) => {
|