123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <template>
- <div class="page-wrapper">
- <editor v-show="showCom == 'EDITOR'" :linkInputDescImage="pageData.linkInputDescImage" @changeShowCom="changeShowCom" />
- <preview v-show="showCom == 'PREVIEW'"
- :previewData="previewData"
- :screenshotWebsiteData="screenshotWebsiteData"
- :showCom="showCom"
- :defaultLinkTitle="pageData.defaultLinkTitle"
- @publishFinish="publishFinish" />
- </div>
- </template>
- <script setup>
- import { ref, reactive, watch, defineProps, defineEmits } from "vue";
- import { screenshotWebsite } from "@/http/toolBoxApi";
- import editor from '@/view/iframe/publish/tool-box/child/editor.vue'
- import preview from '@/view/iframe/publish/tool-box/child/preview.vue'
- const props = defineProps({
- pageData: {
- type: Object,
- default: {
- linkInputDescImage: '',
- defaultLinkTitle: ''
- }
- },
- activePage: {
- type: String,
- default: 'EDITOR', // EDITOR PREVIEW
- },
- });
- const emits = defineEmits(["onToolBoxPageChange"]);
- watch(
- () => props.activePage,
- (newVal) => {
- showCom.value = newVal;
- },
- {
- deep: true
- }
- );
- let showCom = ref('EDITOR');
- let previewData = reactive({
- convertUrl: '',
- originUrl: '',
- appId: '',
- currentApp: {}
- })
- let screenshotWebsiteData = reactive({
- url: '',
- status: '',
- });
- const changeShowCom = (params) => {
- showCom.value = 'PREVIEW';
- previewData.convertUrl = params.convertUrl;
- previewData.originUrl = params.originUrl;
- previewData.appId = params.appId
- previewData.linkImagePath = params.linkImagePath || '';
- previewData.currentApp = params.currentApp || {};
- screenshotWebsiteData.url = '';
- screenshotWebsiteData.status = '';
- if(!params.appId || params.appId && !params.linkImagePath) {
- screenshotWebsite({
- params: {
- url: params.convertUrl
- }
- }).then(res => {
- if(showCom.value != 'PREVIEW') {
- return;
- }
- if(res.code == 0) {
- screenshotWebsiteData.url = res.data;
- screenshotWebsiteData.status = 1;
- } else {
- screenshotWebsiteData.status = 1;
- }
- }).catch(() => {
- if(showCom.value != 'PREVIEW') {
- return;
- }
- screenshotWebsiteData.status = 1;
- })
- }
- emits("onPageChange", {page: showCom.value});
- }
- const publishFinish = (params) => {
- emits("toolBoxPublishFinish", params);
- }
- </script>
- <style lang="scss" scoped>
- .page-wrapper {
- width: 100%;
- height: 100%;
- }
- </style>
|