|
@@ -5,13 +5,22 @@
|
|
|
<t-space direction="vertical" class="panel">
|
|
|
<div class="form-item">
|
|
|
<label>画布尺寸</label>
|
|
|
- <t-input-number label="W" placeholder="宽" theme="column" min="1" />
|
|
|
+ <t-input-number
|
|
|
+ label="W"
|
|
|
+ :value="meta2dInfo?.width"
|
|
|
+ placeholder="宽"
|
|
|
+ theme="column"
|
|
|
+ min="1"
|
|
|
+ @change="changeValue($event, 'width')"
|
|
|
+ />
|
|
|
<t-input-number
|
|
|
class="ml-8"
|
|
|
label="H"
|
|
|
placeholder="高"
|
|
|
theme="column"
|
|
|
min="1"
|
|
|
+ :value="meta2dInfo?.height"
|
|
|
+ @change="changeValue($event, 'height')"
|
|
|
/>
|
|
|
<t-dropdown
|
|
|
:minColumnWidth="180"
|
|
@@ -21,93 +30,16 @@
|
|
|
>
|
|
|
<t-icon name="more" class="ml-8 hover" />
|
|
|
<t-dropdown-menu>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 大屏
|
|
|
- <span class="desc">
|
|
|
- 1920
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 1080
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
+ <t-dropdown-item
|
|
|
+ v-for="item in screenList"
|
|
|
+ @click="selectedSreen(item)"
|
|
|
+ >
|
|
|
<div class="flex between">
|
|
|
- 网页
|
|
|
+ {{ item.name }}
|
|
|
<span class="desc">
|
|
|
- 1440
|
|
|
+ {{ item.width }}
|
|
|
<span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 1024
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 平板12.9"
|
|
|
- <span class="desc">
|
|
|
- 1024
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 1366
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 平板11"
|
|
|
- <span class="desc">
|
|
|
- 834
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 1194
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 平板Mini
|
|
|
- <span class="desc">
|
|
|
- 768
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 1024
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 华为P8
|
|
|
- <span class="desc">
|
|
|
- 360
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 640
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 华为P40
|
|
|
- <span class="desc">
|
|
|
- 395
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 856
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 手机1
|
|
|
- <span class="desc">
|
|
|
- 430
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 932
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </t-dropdown-item>
|
|
|
- <t-dropdown-item>
|
|
|
- <div class="flex between">
|
|
|
- 手机2
|
|
|
- <span class="desc">
|
|
|
- 375
|
|
|
- <span style="font-size: 10px; margin: 0 4px">x</span>
|
|
|
- 812
|
|
|
+ {{ item.height }}
|
|
|
</span>
|
|
|
</div>
|
|
|
</t-dropdown-item>
|
|
@@ -122,19 +54,24 @@
|
|
|
format="CSS"
|
|
|
:color-modes="['monochrome']"
|
|
|
:show-primary-color-preview="false"
|
|
|
+ :value="meta2dInfo?.background"
|
|
|
+ @change="changeValue($event, 'background')"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="form-item">
|
|
|
<label>背景图片</label>
|
|
|
<t-upload
|
|
|
class="ml-8"
|
|
|
- v-model="data.files"
|
|
|
+ v-model="bgfile"
|
|
|
action="/api/image/upload"
|
|
|
theme="image"
|
|
|
accept="image/*"
|
|
|
:headers="headers"
|
|
|
:data="updataData"
|
|
|
+ :auto-upload="true"
|
|
|
+ :upload-all-files-in-one-request="false"
|
|
|
@success="fileSuccessed"
|
|
|
+ @remove = fileRemoved
|
|
|
/>
|
|
|
</div>
|
|
|
</t-space>
|
|
@@ -213,22 +150,120 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { onBeforeMount, reactive } from 'vue';
|
|
|
-import axios from 'axios';
|
|
|
-import { getCookie } from '@/services/cookie';
|
|
|
-
|
|
|
-import ElementTree from './ElementTree.vue';
|
|
|
+import { onMounted, reactive, onUnmounted, ref } from "vue";
|
|
|
+import { getCookie } from "@/services/cookie";
|
|
|
+import ElementTree from "./ElementTree.vue";
|
|
|
+import { Meta2dData } from "@meta2d/core";
|
|
|
|
|
|
const headers = {
|
|
|
- Authorization: 'Bearer ' + (localStorage.token || getCookie('token') || ''),
|
|
|
+ Authorization: "Bearer " + (localStorage.token || getCookie("token") || ""),
|
|
|
};
|
|
|
-const updataData = { directory: '/项目' };
|
|
|
+const updataData = { directory: "/项目" };
|
|
|
|
|
|
const data = reactive<any>({
|
|
|
tab: 1,
|
|
|
});
|
|
|
|
|
|
-const fileSuccessed = async () => {};
|
|
|
+const bgfile = ref<any[]>([]);
|
|
|
+
|
|
|
+const meta2dInfo = ref<Meta2dData | any>();
|
|
|
+
|
|
|
+const screenList = reactive([
|
|
|
+ {
|
|
|
+ name: "大屏",
|
|
|
+ width: 1920,
|
|
|
+ height: 1080,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "网页",
|
|
|
+ width: 1440,
|
|
|
+ height: 1024,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '平板12.9"',
|
|
|
+ width: 1024,
|
|
|
+ height: 1366,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '平板11"',
|
|
|
+ width: 834,
|
|
|
+ height: 1194,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "平板Mini",
|
|
|
+ width: 768,
|
|
|
+ height: 1024,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "华为P8",
|
|
|
+ width: 360,
|
|
|
+ height: 640,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "华为P40",
|
|
|
+ width: 395,
|
|
|
+ height: 856,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "手机1",
|
|
|
+ width: 430,
|
|
|
+ height: 932,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "手机2",
|
|
|
+ width: 375,
|
|
|
+ height: 812,
|
|
|
+ },
|
|
|
+]);
|
|
|
+
|
|
|
+const selectedSreen = (item: any) => {
|
|
|
+ (<any>globalThis).meta2d.store.data.width = item.width;
|
|
|
+ (<any>globalThis).meta2d.store.data.height = item.height;
|
|
|
+ (<any>globalThis).meta2d.store.patchFlagsBackground = true;
|
|
|
+ (<any>globalThis).meta2d.render();
|
|
|
+ openData();
|
|
|
+};
|
|
|
+
|
|
|
+const fileSuccessed = async (content: any) => {
|
|
|
+ (<any>globalThis).meta2d.store.patchFlagsBackground = true;
|
|
|
+ (<any>globalThis).meta2d.setBackgroundImage(content.response.url);
|
|
|
+ (<any>globalThis).meta2d.store.patchFlagsBackground = true;
|
|
|
+ (<any>globalThis).meta2d.render();
|
|
|
+};
|
|
|
+
|
|
|
+const fileRemoved = () => {
|
|
|
+ (<any>globalThis).meta2d.setBackgroundImage('');
|
|
|
+ (<any>globalThis).meta2d.store.patchFlagsBackground = true;
|
|
|
+ (<any>globalThis).meta2d.render();
|
|
|
+ bgfile.value = [];
|
|
|
+}
|
|
|
+
|
|
|
+const changeValue = (e: any, key: string) => {
|
|
|
+ (<any>globalThis).meta2d.store.data[key] = e;
|
|
|
+ (<any>globalThis).meta2d.render();
|
|
|
+ openData();
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ openData();
|
|
|
+ (<any>globalThis).meta2d.on("opened", openData);
|
|
|
+});
|
|
|
+
|
|
|
+onUnmounted(() => {
|
|
|
+ (<any>globalThis).meta2d.off("opened", openData);
|
|
|
+});
|
|
|
+
|
|
|
+function openData() {
|
|
|
+ meta2dInfo.value = Object.assign({}, (<any>globalThis).meta2d.store.data);
|
|
|
+ if ((<any>globalThis).meta2d.store.data.bkImage) {
|
|
|
+ bgfile.value = [
|
|
|
+ {
|
|
|
+ name: (<any>globalThis).meta2d.store.data.bkImage,
|
|
|
+ url: (<any>globalThis).meta2d.store.data.bkImage,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="postcss" scoped>
|
|
|
.props {
|