|
@@ -1,11 +1,10 @@
|
|
-import { IconAdd, IconMove } from "@/assets/icons";
|
|
|
|
-import { CompObject } from "@/modules/editor/controllers/SelectCtrl/compObj";
|
|
|
|
|
|
+
|
|
import { css } from "@linaria/core";
|
|
import { css } from "@linaria/core";
|
|
-import { IconDelete } from "@queenjs/icons";
|
|
|
|
|
|
+
|
|
import { defineComponent, onMounted, ref } from "vue";
|
|
import { defineComponent, onMounted, ref } from "vue";
|
|
import { string ,bool} from "vue-types";
|
|
import { string ,bool} from "vue-types";
|
|
import { useEditor } from "../../..";
|
|
import { useEditor } from "../../..";
|
|
-import { useCompRef , useCompEditLayerRef} from "./hooks";
|
|
|
|
|
|
+import { useCompRef } from "./hooks";
|
|
|
|
|
|
export const View = defineComponent({
|
|
export const View = defineComponent({
|
|
props: {
|
|
props: {
|
|
@@ -16,18 +15,12 @@ export const View = defineComponent({
|
|
setup(props, { slots, emit }) {
|
|
setup(props, { slots, emit }) {
|
|
const { store, actions, helper, controls } = useEditor();
|
|
const { store, actions, helper, controls } = useEditor();
|
|
const compRef = useCompRef(props.compId);
|
|
const compRef = useCompRef(props.compId);
|
|
- const editorLayerRef = props.editlayer? useCompEditLayerRef(props.compId) : ref();
|
|
|
|
-
|
|
|
|
|
|
+
|
|
return () => {
|
|
return () => {
|
|
- const comp = helper.findComp(props.compId);
|
|
|
|
|
|
+ const comp = controls.compCtrl.getObj<object>(props.compId);
|
|
if (!comp) return store.isEditMode ? <div>无效组件</div> : null;
|
|
if (!comp) return store.isEditMode ? <div>无效组件</div> : 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();
|
|
|
|
|
|
+ const isGroupComp = helper.isGroupComp(props.compId);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div
|
|
<div
|
|
@@ -36,9 +29,8 @@ export const View = defineComponent({
|
|
viewStyle,
|
|
viewStyle,
|
|
store.isEditMode && controls.selectCtrl._state != 0 && editCompStyle,
|
|
store.isEditMode && controls.selectCtrl._state != 0 && editCompStyle,
|
|
isGroupComp && groupCompCls,
|
|
isGroupComp && groupCompCls,
|
|
- store.currStreamCardId == props.compId && CurrCompStyle,
|
|
|
|
]}
|
|
]}
|
|
- style={helper.createStyle(comp.layout)}
|
|
|
|
|
|
+ style={comp.createStyle()}
|
|
onClick={(e) => {
|
|
onClick={(e) => {
|
|
if (!store.isEditMode) {
|
|
if (!store.isEditMode) {
|
|
e.stopPropagation();
|
|
e.stopPropagation();
|
|
@@ -60,61 +52,12 @@ export const View = defineComponent({
|
|
>
|
|
>
|
|
{slots.default?.()}
|
|
{slots.default?.()}
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- {store.isEditMode && isStreamCard && store.currStreamCardId == props.compId && <Hudop compId={props.compId} />}
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- store.isEditMode && props.editlayer && <div ref={editorLayerRef} class={editAreaStyle}>
|
|
|
|
-
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
};
|
|
};
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
-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 () => (
|
|
|
|
- <div class="hudop shadow" ref={opref}>
|
|
|
|
- {store.streamCardIds.length > 1 && (
|
|
|
|
- <IconMove
|
|
|
|
- class="draganchor"
|
|
|
|
- onMousedown={() => actions.pickComp(props.compId)}
|
|
|
|
- />
|
|
|
|
- )}
|
|
|
|
- {store.streamCardIds.length > 1 && (
|
|
|
|
- <IconDelete
|
|
|
|
- onClick={(e: any) => {
|
|
|
|
- e.stopPropagation();
|
|
|
|
- actions.removeStreamCard(props.compId);
|
|
|
|
- }}
|
|
|
|
- />
|
|
|
|
- )}
|
|
|
|
- <IconAdd
|
|
|
|
- onClick={(e: any) => {
|
|
|
|
- e.stopPropagation();
|
|
|
|
- const index = store.streamCardIds.indexOf(props.compId) + 1;
|
|
|
|
- actions.addCompToDesign("Container", index);
|
|
|
|
- }}
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
const viewStyle = css`
|
|
const viewStyle = css`
|
|
position: relative;
|
|
position: relative;
|
|
font-size: 0;
|
|
font-size: 0;
|
|
@@ -125,23 +68,6 @@ const viewStyle = css`
|
|
height: 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`
|
|
const editCompStyle = css`
|
|
@@ -150,31 +76,6 @@ const editCompStyle = css`
|
|
}
|
|
}
|
|
`;
|
|
`;
|
|
|
|
|
|
-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`
|
|
const groupCompCls = css`
|
|
outline: 2px solid @inf-primary-color !important;
|
|
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;
|
|
|
|
-`
|
|
|
|
|
|
+`;
|