|
@@ -1,22 +1,33 @@
|
|
|
<template>
|
|
|
- <Layout style="height: 100vh;">
|
|
|
- <LayoutHeader style="background: #fff;">
|
|
|
+ <Layout style="height: 100vh">
|
|
|
+ <LayoutHeader style="background: #fff">
|
|
|
<div class="header-left">
|
|
|
- <h1>{{ projectStore.projectInfo.name || '大屏标题'}}</h1>
|
|
|
+ <h1>{{ projectStore.projectInfo.name || "大屏标题" }}</h1>
|
|
|
</div>
|
|
|
<div class="header-middle">
|
|
|
<MenuBar />
|
|
|
</div>
|
|
|
<div class="header-right">
|
|
|
- <Button size="small" style="margin-right: 8px;" @click="handlePreview"><DesktopOutlined/>预览</Button>
|
|
|
- <Button size="small" type="primary" @click="handleSave" :loading="loading"><SaveOutlined/>保存</Button>
|
|
|
+ <Button size="small" style="margin-right: 8px" @click="handlePreview"
|
|
|
+ ><DesktopOutlined />预览</Button
|
|
|
+ >
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="handleSave"
|
|
|
+ :loading="loading"
|
|
|
+ ><SaveOutlined />保存</Button
|
|
|
+ >
|
|
|
</div>
|
|
|
</LayoutHeader>
|
|
|
|
|
|
<LayoutContent>
|
|
|
- <div class="layer-wrapper" :style="{width: stageStore.showLayer ? '200px' : '0px'}">
|
|
|
+ <div
|
|
|
+ class="layer-wrapper"
|
|
|
+ :style="{ width: stageStore.showLayer ? '200px' : '0px' }"
|
|
|
+ >
|
|
|
<!-- 图层管理 -->
|
|
|
- <LayerManagement v-show="stageStore.showLayer"/>
|
|
|
+ <LayerManagement v-show="stageStore.showLayer" />
|
|
|
</div>
|
|
|
<div class="component-wrapper">
|
|
|
<!-- 组件库 -->
|
|
@@ -35,39 +46,93 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref } from "vue";
|
|
|
+import { ref, watch } from "vue";
|
|
|
import {
|
|
|
Layout,
|
|
|
LayoutHeader,
|
|
|
LayoutContent,
|
|
|
- Button
|
|
|
-} from 'ant-design-vue';
|
|
|
-import { DesktopOutlined, SaveOutlined } from '@ant-design/icons-vue';
|
|
|
-import { useProjectStore } from '@/store/modules/project';
|
|
|
-import { useStageStore } from '@/store/modules/stage';
|
|
|
+ Button,
|
|
|
+ message,
|
|
|
+} from "ant-design-vue";
|
|
|
+import { DesktopOutlined, SaveOutlined } from "@ant-design/icons-vue";
|
|
|
+import { useProjectStore } from "@/store/modules/project";
|
|
|
+import { useStageStore } from "@/store/modules/stage";
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+import { useRequest } from "vue-hooks-plus";
|
|
|
+import { useAppStore } from "@/store/modules/app";
|
|
|
+import { getPageDesignApi } from "@/api";
|
|
|
|
|
|
-import LayerManagement from './component/LayerManagement.vue';
|
|
|
-import ComponentLibary from './component/ComponentLibary.vue';
|
|
|
-import Workspace from './component/Workspace.vue';
|
|
|
-import Configurator from './component/Configurator.vue';
|
|
|
-import MenuBar from './component/MenuBar.vue';
|
|
|
+import LayerManagement from "./component/LayerManagement.vue";
|
|
|
+import ComponentLibary from "./component/ComponentLibary.vue";
|
|
|
+import Workspace from "./component/Workspace.vue";
|
|
|
+import Configurator from "./component/Configurator.vue";
|
|
|
+import MenuBar from "./component/MenuBar.vue";
|
|
|
+
|
|
|
+const route = useRoute();
|
|
|
|
|
|
const stageStore = useStageStore();
|
|
|
const projectStore = useProjectStore();
|
|
|
+const appStore = useAppStore();
|
|
|
const loading = ref(false);
|
|
|
|
|
|
-const handlePreview = () => {
|
|
|
- console.log('预览');
|
|
|
- localStorage.setItem('currentProject', JSON.stringify(projectStore.projectInfo));
|
|
|
- window.open('#/view?id=1');
|
|
|
+const { run, loading: loadingPage } = useRequest(getPageDesignApi, {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: (res) => {
|
|
|
+ const { appPageId, pcJson } = res;
|
|
|
+ if(pcJson) {
|
|
|
+ projectStore.setProjectInfo(JSON.parse(pcJson));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(appPageId) {
|
|
|
+ projectStore.updateProjectInfo({ pageId: appPageId });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onError: (e) => {
|
|
|
+ console.error(e);
|
|
|
+ message.error("获取页面信息失败");
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+/* 获取项目信息 */
|
|
|
+projectStore.getCurrentProjectInfo();
|
|
|
+// 传入pageId和token,获取页面信息
|
|
|
+if(route.query?.pageId && route.query?.token) {
|
|
|
+ const { token, pageId } = route.query;
|
|
|
+ localStorage.setItem("token", token as string);
|
|
|
+ run({id: pageId as string});
|
|
|
}
|
|
|
-const handleSave = () => {
|
|
|
- loading.value = true;
|
|
|
- // TODO 保存项目
|
|
|
- setTimeout(() => {
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => loadingPage.value,
|
|
|
+ () => {
|
|
|
+ appStore.setPageLoading(loadingPage.value);
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+const handlePreview = () => {
|
|
|
+ localStorage.setItem(
|
|
|
+ "currentProject",
|
|
|
+ JSON.stringify(projectStore.projectInfo)
|
|
|
+ );
|
|
|
+ window.open("#/view?id=1");
|
|
|
+};
|
|
|
+
|
|
|
+const handleSave = async () => {
|
|
|
+ try {
|
|
|
+ loading.value = true;
|
|
|
+ localStorage.setItem(
|
|
|
+ "currentProject",
|
|
|
+ JSON.stringify(projectStore.projectInfo)
|
|
|
+ );
|
|
|
+
|
|
|
+ await projectStore.handleSaveProject();
|
|
|
+ } catch (e) {
|
|
|
loading.value = false;
|
|
|
- }, 1000);
|
|
|
-}
|
|
|
+ message.error("保存失败");
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
@@ -80,9 +145,9 @@ const handleSave = () => {
|
|
|
border-bottom: solid 1px #eee;
|
|
|
z-index: 2;
|
|
|
.ant-btn {
|
|
|
- font-size: 12px
|
|
|
+ font-size: 12px;
|
|
|
}
|
|
|
- .header-left h1{
|
|
|
+ .header-left h1 {
|
|
|
width: 300px;
|
|
|
overflow: hidden;
|
|
|
white-space: nowrap;
|
|
@@ -120,4 +185,4 @@ const handleSave = () => {
|
|
|
background: #fff;
|
|
|
border-left: solid 1px #eee;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|