mirror of
https://gitee.com/dromara/go-view.git
synced 2024-11-29 18:28:28 +08:00
fix: 新增图层
This commit is contained in:
parent
9659027502
commit
b3d723d323
4
Makefile
4
Makefile
@ -9,8 +9,12 @@ build:
|
||||
lint:
|
||||
npm run lint
|
||||
|
||||
new:
|
||||
npm run new
|
||||
|
||||
|
||||
help:
|
||||
@echo " make dev 开发模式"
|
||||
@echo " make build 编译模式"
|
||||
@echo " make new 通过自动化流程创建代码"
|
||||
@echo " make lint 格式校验"
|
@ -1,15 +1,15 @@
|
||||
import { getUUID } from '@/utils'
|
||||
import { BarCommonConfig } from './index'
|
||||
|
||||
export const chartSize = {
|
||||
w: 500,
|
||||
h: 300
|
||||
}
|
||||
import { ConfigType } from '@/packages/index.d'
|
||||
import omit from 'lodash/omit'
|
||||
|
||||
export default class Config {
|
||||
private id: string = getUUID()
|
||||
private key: string = BarCommonConfig.key
|
||||
public attr = { x: 0, y: 0, ...chartSize }
|
||||
|
||||
chartData: Exclude<ConfigType, ['node']> = omit(BarCommonConfig, ['node'])
|
||||
|
||||
public attr = { x: 0, y: 0, w: 500, h: 300 }
|
||||
|
||||
// 图表配置项
|
||||
public config = {
|
||||
|
@ -2,7 +2,6 @@ import BarCommon from './index.vue'
|
||||
import image from '@/assets/images/chart/charts/bar_x.png'
|
||||
import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
import { chartSize } from './config'
|
||||
|
||||
export const BarCommonConfig: ConfigType = {
|
||||
key: 'VBarCommon',
|
||||
@ -12,5 +11,4 @@ export const BarCommonConfig: ConfigType = {
|
||||
package: PackagesCategoryEnum.CHARTS,
|
||||
node: BarCommon,
|
||||
image: image,
|
||||
chartData: { chartSize }
|
||||
}
|
||||
|
6
src/packages/index.d.ts
vendored
6
src/packages/index.d.ts
vendored
@ -7,12 +7,6 @@ export type ConfigType = {
|
||||
category: string
|
||||
categoryName: string
|
||||
package: string
|
||||
chartData: {
|
||||
chartSize: {
|
||||
w: number
|
||||
h: number
|
||||
}
|
||||
}
|
||||
node: Component
|
||||
image: string | (() => Promise<typeof import('*.png')>)
|
||||
[T: string]: unknown
|
||||
|
@ -42,15 +42,22 @@ export type MousePositionType = {
|
||||
[EditCanvasTypeEnum.Y]: number
|
||||
}
|
||||
|
||||
// 操作目标
|
||||
export type TargetChartType = {
|
||||
index: number
|
||||
}
|
||||
|
||||
// Store 类型
|
||||
export enum chartEditStoreEnum {
|
||||
EDITCANVAS = 'editCanvas',
|
||||
MOUSEPOSITION = 'mousePosition',
|
||||
COMPONENT_LIST = 'componentList'
|
||||
COMPONENT_LIST = 'componentList',
|
||||
TARGET_CHART = 'targetChart'
|
||||
}
|
||||
|
||||
export interface chartEditStoreType {
|
||||
[chartEditStoreEnum.EDITCANVAS]: EditCanvasType
|
||||
[chartEditStoreEnum.MOUSEPOSITION]: MousePositionType
|
||||
[chartEditStoreEnum.TARGET_CHART]: TargetChartType
|
||||
[chartEditStoreEnum.COMPONENT_LIST]: any[]
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ export const useChartEditStoreStore = defineStore({
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
targetChart: {
|
||||
index: 0
|
||||
},
|
||||
componentList: []
|
||||
}),
|
||||
getters: {
|
||||
|
10
src/store/modules/chartHistoryStore/chartHistoryStore.d.ts
vendored
Normal file
10
src/store/modules/chartHistoryStore/chartHistoryStore.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export interface HistoryStackType {
|
||||
|
||||
}
|
||||
|
||||
export interface chartHistoryStoreType {
|
||||
// 后退栈
|
||||
backStack: [],
|
||||
// 前进栈
|
||||
forwardStack: []
|
||||
}
|
11
src/store/modules/chartHistoryStore/chartHistoryStore}.ts
Normal file
11
src/store/modules/chartHistoryStore/chartHistoryStore}.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { chartHistoryStoreType } from './chartHistoryStore.d'
|
||||
import { setLocalStorage, getLocalStorage } from '@/utils'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
|
||||
export const useChartHistoryStoreStore = defineStore({
|
||||
id: 'useChartHistoryStore',
|
||||
state: (): chartHistoryStoreType => ({}),
|
||||
getters: {},
|
||||
actions: {}
|
||||
})
|
@ -24,7 +24,7 @@ $dark: (
|
||||
linear-gradient(90deg, transparent 14px, $--color-text-2 0)
|
||||
),
|
||||
// hover 边框颜色
|
||||
hover-border-color: #55606e,
|
||||
hover-border-color: $--color-dark-bg-5,
|
||||
// 阴影
|
||||
box-shadow: 0 8px 20px #5252521f
|
||||
|
||||
|
@ -26,7 +26,7 @@ $light: (
|
||||
linear-gradient(90deg, transparent 14px, $--color-dark-bg-5 0)
|
||||
),
|
||||
// hover 边框颜色
|
||||
hover-border-color: $--color-light-bg-1,
|
||||
hover-border-color: $--color-light-bg-4,
|
||||
// 阴影
|
||||
box-shadow: 0 8px 20px #0000001a
|
||||
);
|
||||
|
@ -7,6 +7,10 @@
|
||||
transition: all 0.4s;
|
||||
}
|
||||
|
||||
.go-transition-quick {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.go-flex-center {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
@ -23,8 +23,7 @@ export const handleDrop = async (e: DragEvent) => {
|
||||
// 创建新图表组件
|
||||
let newComponent = await createComponent(dropData)
|
||||
|
||||
const { w, h } = dropData.chartData.chartSize
|
||||
newComponent.setPosition(e.offsetX - w / 2, e.offsetY - h / 2)
|
||||
newComponent.setPosition(e.offsetX - newComponent.attr.w / 2, e.offsetY - newComponent.attr.h / 2)
|
||||
chartEditStore.addComponentList(newComponent)
|
||||
|
||||
loadingFinish()
|
||||
|
@ -1,17 +1,63 @@
|
||||
<template>
|
||||
<div class="go-content-layers-list-item">
|
||||
<n-space>
|
||||
<div>图片</div>
|
||||
<b-text>
|
||||
文字
|
||||
<div class="go-content-layers-list-item go-flex-center">
|
||||
<n-image
|
||||
class="list-img"
|
||||
object-fit="contain"
|
||||
preview-disabled
|
||||
:src="image"
|
||||
:fallback-src="requireFallbackImg()"
|
||||
/>
|
||||
<n-ellipsis>
|
||||
<b-text class="list-text">
|
||||
{{ title }}
|
||||
</b-text>
|
||||
</n-space>
|
||||
</n-ellipsis>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { ref, toRefs } from 'vue'
|
||||
import { requireFallbackImg } from '@/utils'
|
||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||
// 全局颜色
|
||||
const designStore = useDesignStore()
|
||||
const themeColor = ref(designStore.getAppTheme)
|
||||
|
||||
const props = defineProps({
|
||||
componentData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const { image, title } = toRefs(props.componentData.chartData)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@include go(content-layers-list-items) {
|
||||
$centerHeight: 40px;
|
||||
$textSize: 10px;
|
||||
|
||||
@include go(content-layers-list-item) {
|
||||
justify-content: start !important;
|
||||
padding: 6px 10px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 5px;
|
||||
@extend .go-transition-quick;
|
||||
&:hover {
|
||||
@include filter-bg-color('background-color4');
|
||||
color: v-bind('themeColor');
|
||||
}
|
||||
.list-img {
|
||||
flex-shrink: 0;
|
||||
height: $centerHeight;
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
border: 1px solid;
|
||||
padding: 2px;
|
||||
@include hover-border-color('hover-border-color')
|
||||
}
|
||||
.list-text {
|
||||
padding-left: 10px;
|
||||
font-size: $textSize;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -13,7 +13,11 @@
|
||||
</template>
|
||||
|
||||
<!-- 图层内容 -->
|
||||
<ListItem v-for="item in chartEditStore.getComponentList" :key="item.id"/>
|
||||
<ListItem
|
||||
v-for="item in chartEditStore.getComponentList"
|
||||
:key="item.id"
|
||||
:componentData="item"
|
||||
/>
|
||||
</ContentBox>
|
||||
</template>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user