import { IconExit, IconNext, IconPrev } from "@/assets/icons";
import { initEditor } from "@/modules/editor";
import { Design_Page_Size } from "@/modules/editor/dicts/CompOptions";
import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
import { Button, Dropdown } from "ant-design-vue";
import { cloneDeep } from "lodash";
import Modal from "queenjs/adapter/vue/components/modal";
import { defineComponent, nextTick, provide, ref } from "vue";
import { any } from "vue-types";
import { ShareBox } from "./ShareBox";
const NotFoundComp = () =>
无效的组件
;
export default defineComponent({
props: {
data: any(),
},
setup(props) {
const editor = initEditor();
const { helper, controls } = editor;
const page = controls.pageCtrl;
controls.pageCtrl.setDesignData(cloneDeep(props.data));
const pageRef = ref();
const compRef = ref();
provide("isPreview", true);
function getPageH() {
const rootPage = controls.pageCtrl.rootPage;
const pageH = rootPage?.layout?.size[1] || Design_Page_Size[1];
return helper.designToNaturalSize(pageH, {
adaptiveH: true,
});
}
function getPageStyles() {
const pageRoot = page.rootPage;
const isPcDesign = pageRoot?.value.useFor == "pc";
const isLongPage = pageRoot?.value.pageMode == "long";
if (!isPcDesign) {
let mobileStle: any = {
height: getPageH(),
width: "375px",
margin: "0 auto",
};
if (isLongPage) {
mobileStle.overflowY = "auto";
} else {
mobileStle.marginBottom = "70px";
}
return mobileStle;
}
// pc
let s: any = { height: "100%", margin: "0 auto" };
if (!isLongPage) {
const pageLayout = {
height: pageRef.value?.clientHeight,
width: pageRef.value?.clientWidth,
};
const ph = pageLayout.height - 170;
const width = (ph * 16) / 9;
s = {
...s,
width: width + "px",
padding: "40px 0 70px",
};
} else {
s = {
...s,
width: "100%",
overflowY: "auto",
height: "calc(100% + 40px)",
};
}
return s;
}
nextTick(() => {
const pageRoot = page.rootPage;
const isShort = pageRoot?.value.pageMode == "short";
if (isShort) controls.previewCtrl.initSwiper(compRef.value);
});
const Content = () => {
const pageRoot = page.rootPage;
const isShort = pageRoot?.value.pageMode == "short";
const pageStyles = getPageStyles();
return (
<>
{controls.pageCtrl.streamCardIds.map((item) => {
const c = helper.findComp(item) as DesignComp;
const Comp =
controls.compUICtrl.state.components.get(c.compKey)
?.Component || NotFoundComp;
return (
);
})}
{/* buttons */}
{isShort && (
{controls.previewCtrl.state.activeIndex}/
{pageRoot.children.default.length}
)}
>
);
};
return () => {
const { data } = props;
return (
{data.title}
}
trigger="click"
placement="bottomRight"
>
);
};
},
});