|
@@ -2,15 +2,24 @@
|
|
|
<div class="H5Editor">
|
|
|
<div class="H5Editor_left"></div>
|
|
|
<div class="H5Editor_center">
|
|
|
- <div class="page">
|
|
|
- <div
|
|
|
- class="pageMain"
|
|
|
- :style="{
|
|
|
- width: page.width + 'px',
|
|
|
- height: page.height + 'px',
|
|
|
- ...backgroundStyle()
|
|
|
- }"
|
|
|
- ></div>
|
|
|
+ <div class="pageClient">
|
|
|
+ <div class="page">
|
|
|
+ <div
|
|
|
+ class="pageMain"
|
|
|
+ :style="{
|
|
|
+ width: page.width + 'px',
|
|
|
+ 'min-height': page.height + 'px',
|
|
|
+ ...backgroundStyle(),
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <template
|
|
|
+ v-for="(item, index) in hoversList[selectPage].components || []"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <component :is="components[item.type]" :item="item"></component>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="H5Editor_right">
|
|
@@ -31,10 +40,20 @@
|
|
|
import { ref } from 'vue';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
|
|
+import image from './components/H5Editor/img.vue';
|
|
|
+import paragraph from './components/H5Editor/paragraph.vue';
|
|
|
+import fromComponent from './components/H5Editor/from.vue';
|
|
|
+
|
|
|
+const components = {
|
|
|
+ image,
|
|
|
+ paragraph,
|
|
|
+ fromComponent,
|
|
|
+};
|
|
|
+
|
|
|
const route = useRoute();
|
|
|
const item = JSON.parse(route.query.item || '{}');
|
|
|
-const hoversList = ref(item.hoversList || []);
|
|
|
const selectPage = ref(0);
|
|
|
+const hoversList = ref(item.hoversList || []);
|
|
|
const page = ref({ width: 375, height: 0 });
|
|
|
|
|
|
const selectPageFunc = (index = 0) => {
|
|
@@ -48,18 +67,18 @@ const img = new Image();
|
|
|
img.src = hoversList.value[selectPage.value].background_url || '';
|
|
|
|
|
|
img.onload = function () {
|
|
|
- console.log(this.width, this.height);
|
|
|
page.value.height = (this.height / this.width) * page.value.width;
|
|
|
};
|
|
|
|
|
|
const backgroundStyle = () => {
|
|
|
const back = hoversList.value[selectPage.value].background_url;
|
|
|
const color = /^#|^rgb/g.test(back);
|
|
|
- if (color) return {
|
|
|
- 'background-color': back
|
|
|
- };
|
|
|
+ if (color)
|
|
|
+ return {
|
|
|
+ 'background-color': back,
|
|
|
+ };
|
|
|
return {
|
|
|
- 'background-image': 'url(' + back + ')'
|
|
|
+ 'background-image': 'url(' + back + ')',
|
|
|
};
|
|
|
};
|
|
|
</script>
|
|
@@ -89,11 +108,17 @@ const backgroundStyle = () => {
|
|
|
position: relative;
|
|
|
}
|
|
|
|
|
|
-.H5Editor_center .page {
|
|
|
+.H5Editor_center .pageClient{
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
transform: translate(-50%, -50%);
|
|
|
+ padding: 15px 5px;
|
|
|
+ background-color: #000;
|
|
|
+ border-radius: 1em;
|
|
|
+}
|
|
|
+
|
|
|
+.H5Editor_center .page {
|
|
|
width: 375px;
|
|
|
height: 667px;
|
|
|
background-color: #fff;
|