import { IconAdd, IconMove } from "@/assets/icons";
import { CompObject } from "@/modules/editor/controllers/SelectCtrl/compObj";
import { css } from "@linaria/core";
import { IconDelete } from "@queenjs/icons";
import { defineComponent, onMounted, ref } from "vue";
import { string ,bool} from "vue-types";
import { useEditor } from "../../..";
import { useCompRef , useCompEditLayerRef} from "./hooks";
import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
export const View = defineComponent({
props: {
compId: string().isRequired,
editlayer: bool().def(true),
},
emits: ["dblclick", "click"],
setup(props, { slots, emit }) {
const { store, actions, helper, controls } = useEditor();
const compRef = useCompRef(props.compId);
const editorLayerRef = props.editlayer? useCompEditLayerRef(props.compId) : ref();
return () => {
const comp = helper.findComp(props.compId);
if (!comp) return store.isEditMode ?
无效组件
: null;
const isStreamCard = helper.isStreamCard(props.compId);
const isGroupComp = helper.isGroupComp(props.compId);
const isStreamChild = helper.isStreamCardChild(props.compId);
const obj = new CompObject(store.compMap[props.compId]);
const m = obj.worldTransform.clone();
m.invert();
let isFocus = store.isEditMode && store.selected.length > 1 && store.lastSelected == props.compId;
isFocus = isFocus || store.currCompId == props.compId;
const style = helper.createStyle(comp.layout, comp);
const page = helper.findRootComp() as DesignComp;
if (isStreamCard && page.value.pageMode == "short" && store.isPreview) {
// const cards = store.streamCardIds;
// const index = cards.indexOf(props.compId)
// style.position = "absolute";
// style.top = index * 100 + "vh";
style.height = "100vh"
}
if (comp.anim && comp.anim.transition) {
style.transition = "all 1s ease-out";
}
return (
{
if (!store.isEditMode) {
e.stopPropagation();
emit("click");
}
}}
onDblclick={() => emit("dblclick")}
>
{
if (
!store.isEditMode ||
!controls.dragAddCtrl.dragingCompKey ||
!helper.isStreamCard(props.compId)
)
return;
actions.pickComp(props.compId);
}}
>
{slots.default?.()}
{store.isEditMode && isStreamCard && store.currStreamCardId == props.compId &&
}
{
store.isEditMode && props.editlayer &&
}
);
};
},
});
export const Hudop = defineComponent({
props: {
compId: string().isRequired,
},
setup(props) {
const { store, actions, helper, controls } = useEditor();
const opref = ref();
onMounted(() => {
opref.value.editable = "hudop";
});
return () => (
{store.streamCardIds.length > 1 && (
actions.pickComp(props.compId)}
/>
)}
{store.streamCardIds.length > 1 && (
{
e.stopPropagation();
actions.removeStreamCard(props.compId);
}}
/>
)}
{
e.stopPropagation();
const index = store.streamCardIds.indexOf(props.compId) + 1;
actions.addCompToDesign("Container", index);
}}
/>
);
},
});
const viewStyle = css`
position: relative;
font-size: 0;
cursor: pointer;
> :first-child {
width: 100%;
height: 100%;
}
.hudop {
position: absolute;
top: 0px;
left: -46px;
background-color: white;
flex-direction: column;
color: black;
display: flex;
font-size: 12px;
width: 28px;
align-items: center;
border-radius: 4px;
z-index: 997;
.inficon {
padding: 8px;
}
}
`;
const editCompStyle = css`
&:hover {
outline: 2px dashed @inf-primary-color;
}
`;
const AnchorCompStyle = css`
outline: 2px dashed @inf-primary-color;
`;
const CurrCompStyle = css`
position: relative;
outline: 1px solid @inf-primary-color;
box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.5);
z-index: 998;
`;
const groupCompCls = css`
outline: 2px solid @inf-primary-color !important;
`;
const editAreaStyle = css`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
`
const editAreaTestStyle = css`
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: red;
`