Merge remote-tracking branch 'origin/master'

This commit is contained in:
khy 2024-10-15 19:51:27 +08:00
commit 78d3175151
49 changed files with 652 additions and 591 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -23,8 +23,11 @@
<div>
<div class="drag-placement">组件放置区域</div>
<div class="component">
<Icon :icon="element.icon" :size="32" />
<span class="mt-4px text-12px">{{ element.name }}</span>
<!-- <Icon :icon="element.icon" :size="32" /> -->
<div>
<img :src="element.icon" />
</div>
<span class="text-12px">{{ element.name }}</span>
</div>
</div>
</template>
@ -142,8 +145,9 @@ const handleCloneComponent = (component: DiyComponent<any>) => {
.component.active,
.component:hover {
color: var(--el-color-white);
background: var(--el-color-primary);
// color: var(--el-color-white);
// background: var(--el-color-primary);
background: #f6f6f6;
.el-icon {
color: var(--el-color-white);

View File

@ -26,12 +26,13 @@ export interface CarouselItemProperty {
// 跳转链接
url: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-09.png'
// 定义组件
export const component = {
id: 'Carousel',
name: '轮播图',
icon: 'system-uicons:carousel',
// icon: 'system-uicons:carousel',
icon: logo,
property: {
type: 'default',
indicator: 'dot',

View File

@ -22,12 +22,13 @@ export interface CouponCardProperty {
// 组件样式
style: ComponentStyle
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-19.png'
// 定义组件
export const component = {
id: 'CouponCard',
name: '优惠券',
icon: 'ep:ticket',
// icon: 'ep:ticket',
icon: logo,
property: {
columns: 1,
bgImg: '',

View File

@ -13,12 +13,13 @@ export interface DividerProperty {
// 类型
borderType: 'solid' | 'dashed' | 'dotted' | 'none'
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-12.png'
// 定义组件
export const component = {
id: 'Divider',
name: '分割线',
icon: 'tdesign:component-divider-vertical',
// icon: 'tdesign:component-divider-vertical',
icon: logo,
property: {
height: 30,
lineWidth: 1,

View File

@ -21,12 +21,13 @@ export interface FloatingActionButtonItemProperty {
// 文字颜色
textColor: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-07.png'
// 定义组件
export const component = {
id: 'FloatingActionButton',
name: '悬浮按钮',
icon: 'tabler:float-right',
// icon: 'tabler:float-right',
icon: logo,
position: 'fixed',
property: {
direction: 'vertical',

View File

@ -25,12 +25,13 @@ export interface HotZoneItemProperty {
// 左
left: number
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-14.png'
// 定义组件
export const component = {
id: 'HotZone',
name: '热区',
icon: 'tabler:hand-click',
// icon: 'tabler:hand-click',
icon: logo,
property: {
imgUrl: '',
list: [] as HotZoneItemProperty[],

View File

@ -9,12 +9,13 @@ export interface ImageBarProperty {
// 组件样式
style: ComponentStyle
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-08.png'
// 定义组件
export const component = {
id: 'ImageBar',
name: '图片展示',
icon: 'ep:picture',
// icon: 'ep:picture',
icon: logo,
property: {
imgUrl: '',
url: '',

View File

@ -29,12 +29,13 @@ export interface MagicCubeItemProperty {
// 左
left: number
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-13.png'
// 定义组件
export const component = {
id: 'MagicCube',
name: '广告魔方',
icon: 'bi:columns',
// icon: 'bi:columns',
icon: logo,
property: {
borderRadiusTop: 0,
borderRadiusBottom: 0,

View File

@ -49,12 +49,13 @@ export const EMPTY_MENU_GRID_ITEM_PROPERTY = {
bgColor: '#FF6000'
}
} as MenuGridItemProperty
import logo from '@/assets/imgs/DiyEditorImges/组件图标-04.png'
// 定义组件
export const component = {
id: 'MenuGrid',
name: '宫格导航',
icon: 'bi:grid-3x3-gap',
// icon: 'bi:grid-3x3-gap',
icon: logo,
property: {
column: 3,
list: [cloneDeep(EMPTY_MENU_GRID_ITEM_PROPERTY)],

View File

@ -6,6 +6,7 @@
<el-radio-group v-model="formData.column">
<el-radio :label="3">3</el-radio>
<el-radio :label="4">4</el-radio>
<el-radio :label="5">5</el-radio>
</el-radio-group>
</el-form-item>

View File

@ -31,12 +31,13 @@ export const EMPTY_MENU_LIST_ITEM_PROPERTY = {
subtitle: '副标题',
subtitleColor: '#bbb'
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-05.png'
// 定义组件
export const component = {
id: 'MenuList',
name: '列表导航',
icon: 'fa-solid:list',
// icon: 'fa-solid:list',
icon: logo,
property: {
list: [cloneDeep(EMPTY_MENU_LIST_ITEM_PROPERTY)],
style: {

View File

@ -46,12 +46,13 @@ export const EMPTY_MENU_SWIPER_ITEM_PROPERTY = {
bgColor: '#FF6000'
}
} as MenuSwiperItemProperty
import logo from '@/assets/imgs/DiyEditorImges/组件图标-03.png'
// 定义组件
export const component = {
id: 'MenuSwiper',
name: '菜单导航',
icon: 'bi:grid-3x2-gap',
// icon: 'bi:grid-3x2-gap',
icon: logo,
property: {
layout: 'iconText',
row: 1,

View File

@ -21,12 +21,13 @@ export interface NoticeContentProperty {
// 链接地址
url: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-02.png'
// 定义组件
export const component = {
id: 'NoticeBar',
name: '公告栏',
icon: 'ep:bell',
// icon: 'ep:bell',
icon: logo,
property: {
iconUrl: 'http://mall.yudao.iocoder.cn/static/images/xinjian.png',
contents: [

View File

@ -13,12 +13,13 @@ export interface PopoverItemProperty {
// 显示类型:仅显示一次、每次启动都会显示
showType: 'once' | 'always'
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-06.png'
// 定义组件
export const component = {
id: 'Popover',
name: '弹窗广告',
icon: 'carbon:popup',
// icon: 'carbon:popup',
icon: logo,
position: 'fixed',
property: {
list: [{ showType: 'once' }]

View File

@ -57,12 +57,13 @@ export interface ProductCardFieldProperty {
// 颜色
color: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-15.png'
// 定义组件
export const component = {
id: 'ProductCard',
name: '商品卡片',
icon: 'fluent:text-column-two-left-24-filled',
// icon: 'fluent:text-column-two-left-24-filled',
icon: logo,
property: {
layoutType: 'oneColBigImg',
fields: {

View File

@ -36,12 +36,13 @@ export interface ProductListFieldProperty {
// 颜色
color: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-16.png'
// 定义组件
export const component = {
id: 'ProductList',
name: '商品栏',
icon: 'fluent:text-column-two-24-filled',
// icon: 'fluent:text-column-two-24-filled',
icon: logo,
property: {
layoutType: 'twoCol',
fields: {

View File

@ -7,12 +7,13 @@ export interface PromotionArticleProperty {
// 组件样式
style: ComponentStyle
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-20.png'
// 定义组件
export const component = {
id: 'PromotionArticle',
name: '营销文章',
icon: 'ph:article-medium',
// icon: 'ph:article-medium',
icon: logo,
property: {
style: {
bgType: 'color',

View File

@ -37,12 +37,13 @@ export interface PromotionCombinationFieldProperty {
// 颜色
color: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-17.png'
// 定义组件
export const component = {
id: 'PromotionCombination',
name: '拼团',
icon: 'mdi:account-group',
// icon: 'mdi:account-group',
icon: logo,
property: {
layoutType: 'oneCol',
fields: {

View File

@ -58,12 +58,13 @@ export interface PromotionPointFieldProperty {
// 颜色
color: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-21.png'
// 定义组件
export const component = {
id: 'PromotionPoint',
name: '积分商城',
icon: 'ep:present',
// icon: 'ep:present',
icon: logo,
property: {
layoutType: 'oneColBigImg',
fields: {

View File

@ -36,12 +36,13 @@ export interface PromotionSeckillFieldProperty {
// 颜色
color: string
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-18.png'
// 定义组件
export const component = {
id: 'PromotionSeckill',
name: '秒杀',
icon: 'mdi:calendar-time',
// icon: 'mdi:calendar-time',
icon: logo,
property: {
activityId: undefined,
layoutType: 'oneCol',

View File

@ -15,12 +15,12 @@ export interface SearchProperty {
// 文字位置
export type PlaceholderPosition = 'left' | 'center'
import logo from '@/assets/imgs/DiyEditorImges/组件图标-01.png'
// 定义组件
export const component = {
id: 'SearchBar',
name: '搜索框',
icon: 'ep:search',
icon: logo,
property: {
height: 28,
showScan: false,

View File

@ -38,12 +38,13 @@ export interface TitleBarProperty {
// 组件样式
style: ComponentStyle
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-10.png'
// 定义组件
export const component = {
id: 'TitleBar',
name: '标题栏',
icon: 'material-symbols:line-start',
icon: logo,
property: {
title: '主标题',
description: '副标题',

View File

@ -1,29 +1,115 @@
<template>
<div class="flex flex-col">
<div class="flex items-center justify-between p-x-18px p-y-24px">
<div class="flex flex-col" style=" margin-bottom: 27px;">
<div class="new-main">
<div class="flex items-center justify-between p-x-18px p-y-24px " style="padding-bottom:15px;">
<div class="flex flex-1 items-center gap-16px">
<el-avatar :size="60">
<Icon icon="ep:avatar" :size="60" />
</el-avatar>
<span class="text-18px font-bold">芋道源码</span>
<span class="text-18px font-bold">用户名称</span>
</div>
<Icon icon="tdesign:qrcode" :size="20" />
</div>
<div
<div class="new-usercard" style="z-index: 9999;">
<div class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center">
<div class="value-box ss-flex ss-col-bottom">
<div class="value-text ss-line-1">0.00</div>
<div class="unit-text ss-m-l-6">
<!-- -->
</div>
</div>
<div class="menu-title ss-m-t-28">余额</div>
</div>
<div class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center">
<div class="value-box ss-flex ss-col-bottom">
<div class="value-text">0</div>
<div class="unit-text ss-m-l-6">
<!-- -->
</div>
</div>
<div class="menu-title ss-m-t-28">优惠券</div>
</div>
<div class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center">
<div class="value-box ss-flex ss-col-bottom">
<div class="value-text">0</div>
<div class="unit-text ss-m-l-6">
<!-- -->
</div>
</div>
<div class="menu-title ss-m-t-28">积分</div>
</div>
</div>
<div class="new-bottom">
<img src="https://zysc.fjptzykj.com:3000/shangcheng/64776e2edc3c2f15295e7c3976ba301e08f9170f99a2e845d8f33bd65179b177.png"
alt="" />
<div class="btn">
立即开通
</div>
</div>
</div>
<!-- <div
class="flex items-center justify-between justify-between bg-white p-x-20px p-y-8px text-12px"
>
<span class="color-#ff690d">点击绑定手机号</span>
<span class="rounded-26px bg-#ff6100 p-x-8px p-y-5px color-white">去绑定</span>
</div>
</div> -->
</div>
</template>
<script setup lang="ts">
import { UserCardProperty } from './config'
import { UserCardProperty } from './config'
/** 用户卡片 */
defineOptions({ name: 'UserCard' })
//
defineProps<{ property: UserCardProperty }>()
/** 用户卡片 */
defineOptions({ name: 'UserCard' })
//
defineProps<{ property : UserCardProperty }>()
</script>
<style scoped lang="scss"></style>
<style scoped lang="scss">
.new-main {
position: relative;
background: url('@/assets/imgs/userCar/seckilbg.png') no-repeat;
background-size: cover;
padding-bottom: 53px;
.value-box {
margin-bottom: 6px;
}
.new-usercard {
width: 100%;
display: flex;
justify-content: space-around;
}
div {
text-align: center;
color: white;
}
.new-bottom {
position: absolute;
bottom: -28px;
width: 100%;
z-index: 999999999999999;
img {
width: 92%;
}
.btn {
position: absolute;
bottom: 19px;
right: 29px;
background: white;
border-radius: 12px;
padding: 4px 8px;
font-size: 14px;
color: #946d2d;
}
}
}
</style>

View File

@ -1,5 +1,6 @@
<template>
<el-image src="https://shopro.sheepjs.com/admin/static/images/shop/decorate/orderCardStyle.png" />
<!-- <el-image src="https://shopro.sheepjs.com/admin/static/images/shop/decorate/orderCardStyle.png" /> -->
<el-image src=" https://zysc.fjptzykj.com:3000/shangcheng/0ba158a1a2de7d39c6cec22cfe54736237438f63893b09c7453b5b5e3482f826.png" />
</template>
<script setup lang="ts">
import { UserOrderProperty } from './config'

View File

@ -17,12 +17,13 @@ export interface VideoPlayerStyle extends ComponentStyle {
// 视频高度
height: number
}
import logo from '@/assets/imgs/DiyEditorImges/组件图标-11.png'
// 定义组件
export const component = {
id: 'VideoPlayer',
name: '视频播放',
icon: 'ep:video-play',
// icon: 'ep:video-play',
icon: logo,
property: {
videoUrl: '',
posterUrl: '',

View File

@ -31,7 +31,7 @@
<!-- 中心区域 -->
<el-container class="editor-container">
<!-- 左侧组件库ComponentLibrary -->
<ComponentLibrary ref="componentLibrary" :list="libs" v-if="libs && libs.length > 0" />
<ComponentLibrary ref="componentLibrary" :list="libs" v-if="libs && libs.length > 0 && isShow" />
<!-- 中心设计区域ComponentContainer -->
<div class="editor-center page-prop-area" @click="handlePageSelected">
<!-- 手机顶部 -->
@ -39,94 +39,54 @@
<!-- 手机顶部状态栏 -->
<img src="@/assets/imgs/diy/statusBar.png" alt="" class="status-bar" />
<!-- 手机顶部导航栏 -->
<ComponentContainer
v-if="showNavigationBar"
:component="navigationBarComponent"
:show-toolbar="false"
:active="selectedComponent?.id === navigationBarComponent.id"
@click="handleNavigationBarSelected"
class="cursor-pointer!"
/>
<ComponentContainer v-if="showNavigationBar" :component="navigationBarComponent"
:show-toolbar="false" :active="selectedComponent?.id === navigationBarComponent.id"
@click="handleNavigationBarSelected" class="cursor-pointer!" />
</div>
<!-- 绝对定位的组件例如 弹窗浮动按钮等 -->
<div
v-for="(component, index) in pageComponents"
:key="index"
@click="handleComponentSelected(component, index)"
>
<component
v-if="component.position === 'fixed' && selectedComponent?.uid === component.uid"
:is="component.id"
:property="component.property"
/>
<div v-for="(component, index) in pageComponents" :key="index"
@click="handleComponentSelected(component, index)">
<component v-if="component.position === 'fixed' && selectedComponent?.uid === component.uid"
:is="component.id" :property="component.property" />
</div>
<!-- 手机页面编辑区域 -->
<el-scrollbar
height="100%"
wrap-class="editor-design-center page-prop-area"
view-class="phone-container"
:view-style="{
<el-scrollbar height="100%" wrap-class="editor-design-center page-prop-area"
view-class="phone-container" :view-style="{
backgroundColor: pageConfigComponent.property.backgroundColor,
backgroundImage: `url(${pageConfigComponent.property.backgroundImage})`
}"
>
<draggable
class="page-prop-area drag-area"
v-model="pageComponents"
item-key="index"
:animation="200"
filter=".component-toolbar"
ghost-class="draggable-ghost"
:force-fallback="true"
group="component"
@change="handleComponentChange"
>
}">
<draggable class="page-prop-area drag-area" v-model="pageComponents" item-key="index"
:animation="200" filter=".component-toolbar" ghost-class="draggable-ghost"
:force-fallback="true" group="component" @change="handleComponentChange">
<template #item="{ element, index }">
<ComponentContainer
v-if="!element.position || element.position === 'center'"
:component="element"
:active="selectedComponentIndex === index"
:can-move-up="index > 0"
<ComponentContainer v-if="!element.position || element.position === 'center'"
:component="element" :active="selectedComponentIndex === index" :can-move-up="index > 0"
:can-move-down="index < pageComponents.length - 1"
@move="(direction) => handleMoveComponent(index, direction)"
@copy="handleCopyComponent(index)"
@delete="handleDeleteComponent(index)"
@click="handleComponentSelected(element, index)"
/>
@copy="handleCopyComponent(index)" @delete="handleDeleteComponent(index)"
@click="handleComponentSelected(element, index)" />
</template>
</draggable>
</el-scrollbar>
<!-- 手机底部导航 -->
<div v-if="showTabBar" :class="['editor-design-bottom', 'component', 'cursor-pointer!']">
<ComponentContainer
:component="tabBarComponent"
:show-toolbar="false"
:active="selectedComponent?.id === tabBarComponent.id"
@click="handleTabBarSelected"
/>
<ComponentContainer :component="tabBarComponent" :show-toolbar="false"
:active="selectedComponent?.id === tabBarComponent.id" @click="handleTabBarSelected" />
</div>
<!-- 固定布局的组件 操作按钮区 -->
<div class="fixed-component-action-group">
<el-tag
v-if="showPageConfig"
size="large"
<el-tag v-if="showPageConfig" size="large"
:effect="selectedComponent?.uid === pageConfigComponent.uid ? 'dark' : 'plain'"
:type="selectedComponent?.uid === pageConfigComponent.uid ? '' : 'info'"
@click="handleComponentSelected(pageConfigComponent)"
>
@click="handleComponentSelected(pageConfigComponent)">
<Icon :icon="pageConfigComponent.icon" :size="12" />
<span>{{ pageConfigComponent.name }}</span>
</el-tag>
<template v-for="(component, index) in pageComponents" :key="index">
<el-tag
v-if="component.position === 'fixed'"
size="large"
closable
<el-tag v-if="component.position === 'fixed'" size="large" closable
:effect="selectedComponent?.uid === component.uid ? 'dark' : 'plain'"
:type="selectedComponent?.uid === component.uid ? '' : 'info'"
@click="handleComponentSelected(component)"
@close="handleDeleteComponent(index)"
>
@click="handleComponentSelected(component)" @close="handleDeleteComponent(index)">
<Icon :icon="component.icon" :size="12" />
<span>{{ component.name }}</span>
</el-tag>
@ -135,11 +95,8 @@
</div>
<!-- 右侧属性面板ComponentContainerProperty -->
<el-aside class="editor-right" width="350px" v-if="selectedComponent?.property">
<el-card
shadow="never"
body-class="h-[calc(100%-var(--el-card-padding)-var(--el-card-padding))]"
class="h-full"
>
<el-card shadow="never" body-class="h-[calc(100%-var(--el-card-padding)-var(--el-card-padding))]"
class="h-full">
<!-- 组件名称 -->
<template #header>
<div class="flex items-center gap-8px">
@ -147,15 +104,10 @@
<span>{{ selectedComponent?.name }}</span>
</div>
</template>
<el-scrollbar
class="m-[calc(0px-var(--el-card-padding))]"
view-class="p-[var(--el-card-padding)] p-b-[calc(var(--el-card-padding)+var(--el-card-padding))] property"
>
<component
:key="selectedComponent?.uid || selectedComponent?.id"
:is="selectedComponent?.id + 'Property'"
v-model="selectedComponent.property"
/>
<el-scrollbar class="m-[calc(0px-var(--el-card-padding))]"
view-class="p-[var(--el-card-padding)] p-b-[calc(var(--el-card-padding)+var(--el-card-padding))] property">
<component :key="selectedComponent?.uid || selectedComponent?.id"
:is="selectedComponent?.id + 'Property'" v-model="selectedComponent.property" />
</el-scrollbar>
</el-card>
</el-aside>
@ -165,10 +117,7 @@
<!-- 预览弹框 -->
<Dialog v-model="previewDialogVisible" title="预览" width="700">
<div class="flex justify-around">
<IFrame
class="w-375px border-4px border-rounded-8px border-solid p-2px h-667px!"
:src="previewUrl"
/>
<IFrame class="w-375px border-4px border-rounded-8px border-solid p-2px h-667px!" :src="previewUrl" />
<div class="flex flex-col">
<el-text>手机扫码预览</el-text>
<Qrcode :text="previewUrl" logo="/logo.gif" />
@ -177,45 +126,45 @@
</Dialog>
</template>
<script lang="ts">
//
import { components } from './components/mobile/index'
export default {
//
import { components } from './components/mobile/index'
export default {
components: { ...components }
}
}
</script>
<script lang="ts" setup>
import draggable from 'vuedraggable'
import ComponentLibrary from './components/ComponentLibrary.vue'
import { cloneDeep, includes } from 'lodash-es'
import { component as PAGE_CONFIG_COMPONENT } from '@/components/DiyEditor/components/mobile/PageConfig/config'
import { component as NAVIGATION_BAR_COMPONENT } from './components/mobile/NavigationBar/config'
import { component as TAB_BAR_COMPONENT } from './components/mobile/TabBar/config'
import { isString } from '@/utils/is'
import { DiyComponent, DiyComponentLibrary, PageConfig } from '@/components/DiyEditor/util'
import { componentConfigs } from '@/components/DiyEditor/components/mobile'
import { array, oneOfType } from 'vue-types'
import { propTypes } from '@/utils/propTypes'
import draggable from 'vuedraggable'
import ComponentLibrary from './components/ComponentLibrary.vue'
import { cloneDeep, includes } from 'lodash-es'
import { component as PAGE_CONFIG_COMPONENT } from '@/components/DiyEditor/components/mobile/PageConfig/config'
import { component as NAVIGATION_BAR_COMPONENT } from './components/mobile/NavigationBar/config'
import { component as TAB_BAR_COMPONENT } from './components/mobile/TabBar/config'
import { isString } from '@/utils/is'
import { DiyComponent, DiyComponentLibrary, PageConfig } from '@/components/DiyEditor/util'
import { componentConfigs } from '@/components/DiyEditor/components/mobile'
import { array, oneOfType } from 'vue-types'
import { propTypes } from '@/utils/propTypes'
/** 页面装修详情页 */
defineOptions({ name: 'DiyPageDetail' })
/** 页面装修详情页 */
defineOptions({ name: 'DiyPageDetail' })
//
const componentLibrary = ref()
//
const pageConfigComponent = ref<DiyComponent<any>>(cloneDeep(PAGE_CONFIG_COMPONENT))
//
const navigationBarComponent = ref<DiyComponent<any>>(cloneDeep(NAVIGATION_BAR_COMPONENT))
//
const tabBarComponent = ref<DiyComponent<any>>(cloneDeep(TAB_BAR_COMPONENT))
//
const componentLibrary = ref()
//
const pageConfigComponent = ref<DiyComponent<any>>(cloneDeep(PAGE_CONFIG_COMPONENT))
//
const navigationBarComponent = ref<DiyComponent<any>>(cloneDeep(NAVIGATION_BAR_COMPONENT))
//
const tabBarComponent = ref<DiyComponent<any>>(cloneDeep(TAB_BAR_COMPONENT))
//
const selectedComponent = ref<DiyComponent<any>>()
//
const selectedComponentIndex = ref<number>(-1)
//
const pageComponents = ref<DiyComponent<any>[]>([])
//
const props = defineProps({
//
const selectedComponent = ref<DiyComponent<any>>()
//
const selectedComponentIndex = ref<number>(-1)
//
const pageComponents = ref<DiyComponent<any>[]>([])
//
const props = defineProps({
// Json
modelValue: oneOfType<string | PageConfig>([String, Object]).isRequired,
//
@ -229,12 +178,14 @@ const props = defineProps({
//
showPageConfig: propTypes.bool.def(true),
//
previewUrl: propTypes.string.def('')
})
previewUrl: propTypes.string.def(''),
//
isShow:propTypes.bool.def(true),
})
//
// pageConfigComponent navigationBarComponentpageComponentstabBarComponent
watch(
//
// pageConfigComponent navigationBarComponentpageComponentstabBarComponent
watch(
() => props.modelValue,
() => {
const modelValue = isString(props.modelValue)
@ -249,15 +200,15 @@ watch(
const component = componentConfigs[item.id]
return { ...component, property: item.property }
})
console.log(modelValue,"pageComponents.value")
console.log(modelValue, "pageComponents.value")
},
{
immediate: true
}
)
)
//
const handleSave = () => {
//
const handleSave = () => {
const pageConfig = {
page: pageConfigComponent.value.property,
navigationBar: navigationBarComponent.value.property,
@ -275,41 +226,41 @@ const handleSave = () => {
emits('update:modelValue', modelValue)
//
emits('save', pageConfig)
}
}
//
const handlePageSelected = (event: any) => {
//
const handlePageSelected = (event : any) => {
if (!props.showPageConfig) return
// page-prop-area
if (includes(event?.target?.classList, 'page-prop-area')) {
handleComponentSelected(unref(pageConfigComponent))
}
}
}
/**
/**
* 选中组件
*
* @param component 组件
* @param index 组件的索引
*/
const handleComponentSelected = (component: DiyComponent<any>, index: number = -1) => {
const handleComponentSelected = (component : DiyComponent<any>, index : number = -1) => {
selectedComponent.value = component
selectedComponentIndex.value = index
}
}
//
const handleNavigationBarSelected = () => {
//
const handleNavigationBarSelected = () => {
handleComponentSelected(unref(navigationBarComponent))
}
}
//
const handleTabBarSelected = () => {
//
const handleTabBarSelected = () => {
handleComponentSelected(unref(tabBarComponent))
}
}
//
const handleComponentChange = (dragEvent: any) => {
//
const handleComponentChange = (dragEvent : any) => {
//
if (dragEvent.added) {
const { element, newIndex } = dragEvent.added
@ -320,38 +271,38 @@ const handleComponentChange = (dragEvent: any) => {
//
selectedComponentIndex.value = newIndex
}
}
}
//
const swapComponent = (oldIndex: number, newIndex: number) => {
//
const swapComponent = (oldIndex : number, newIndex : number) => {
;[pageComponents.value[oldIndex], pageComponents.value[newIndex]] = [
pageComponents.value[newIndex],
pageComponents.value[oldIndex]
]
//
selectedComponentIndex.value = newIndex
}
}
/** 移动组件(上移、下移) */
const handleMoveComponent = (index: number, direction: number) => {
/** 移动组件(上移、下移) */
const handleMoveComponent = (index : number, direction : number) => {
const newIndex = index + direction
if (newIndex < 0 || newIndex >= pageComponents.value.length) return
swapComponent(index, newIndex)
}
}
/** 复制组件 */
const handleCopyComponent = (index: number) => {
/** 复制组件 */
const handleCopyComponent = (index : number) => {
const component = cloneDeep(pageComponents.value[index])
component.uid = new Date().getTime()
pageComponents.value.splice(index + 1, 0, component)
}
}
/**
/**
* 删除组件
* @param index 当前组件index
*/
const handleDeleteComponent = (index: number) => {
const handleDeleteComponent = (index : number) => {
//
pageComponents.value.splice(index, 1)
if (index < pageComponents.value.length) {
@ -366,28 +317,28 @@ const handleDeleteComponent = (index: number) => {
// 3.
handleComponentSelected(unref(pageConfigComponent))
}
}
}
//
const emits = defineEmits(['reset', 'preview', 'save', 'update:modelValue'])
//
const emits = defineEmits(['reset', 'preview', 'save', 'update:modelValue'])
//
const reload = inject<() => void>('reload')
//
const handleReset = () => {
//
const reload = inject<() => void>('reload')
//
const handleReset = () => {
if (reload) reload()
emits('reset')
}
}
//
const previewDialogVisible = ref(false)
const handlePreview = () => {
//
const previewDialogVisible = ref(false)
const handlePreview = () => {
previewDialogVisible.value = true
emits('preview')
}
}
//
const setDefaultSelectedComponent = () => {
//
const setDefaultSelectedComponent = () => {
if (props.showPageConfig) {
selectedComponent.value = unref(pageConfigComponent)
} else if (props.showNavigationBar) {
@ -395,22 +346,22 @@ const setDefaultSelectedComponent = () => {
} else if (props.showTabBar) {
selectedComponent.value = unref(tabBarComponent)
}
}
}
watch(
watch(
() => [props.showPageConfig, props.showNavigationBar, props.showTabBar],
() => setDefaultSelectedComponent()
)
)
onMounted(() => setDefaultSelectedComponent())
onMounted(() => setDefaultSelectedComponent())
</script>
<style lang="scss" scoped>
/* 手机宽度 */
$phone-width: 375px;
$toolbar-height: 42px;
/* 手机宽度 */
$phone-width: 375px;
$toolbar-height: 42px;
/* 根节点样式 */
.editor {
/* 根节点样式 */
.editor {
display: flex;
height: 100%;
margin: calc(0px - var(--app-content-padding));
@ -446,10 +397,7 @@ $toolbar-height: 42px;
/* 中心操作区 */
.editor-container {
height: calc(
100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) -
$toolbar-height
);
height: calc(100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - $toolbar-height );
/* 右侧属性面板 */
.editor-right {
@ -548,6 +496,7 @@ $toolbar-height: 42px;
:deep(.el-tag) {
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
border: none;
.el-tag__content {
width: 100%;
display: flex;
@ -562,5 +511,5 @@ $toolbar-height: 42px;
}
}
}
}
}
</style>

View File

@ -2,7 +2,7 @@
<DiyEditor v-if="formData && !formLoading" v-model="currentFormData!.property"
:title="templateItems[selectedTemplateItem].name" :libs="libs" :show-page-config="selectedTemplateItem !== 0"
:show-tab-bar="selectedTemplateItem === 0" :show-navigation-bar="selectedTemplateItem !== 0"
:preview-url="previewUrl" @save="submitForm" @reset="handleEditorReset">
:preview-url="previewUrl" @save="submitForm" @reset="handleEditorReset" :isShow="false">
<template #toolBarLeft>
<!-- <el-radio-group
v-model="selectedTemplateItem"