mirror of
https://gitee.com/dromara/go-view.git
synced 2024-12-04 20:59:26 +08:00
feat: 新增数据请求配置
This commit is contained in:
parent
c399277350
commit
501dfdc223
@ -13,8 +13,8 @@
|
|||||||
<n-space>
|
<n-space>
|
||||||
<slot name="ri-left"> </slot>
|
<slot name="ri-left"> </slot>
|
||||||
<lang-select></lang-select>
|
<lang-select></lang-select>
|
||||||
<Theme-select></Theme-select>
|
|
||||||
<theme-color-select></theme-color-select>
|
<theme-color-select></theme-color-select>
|
||||||
|
<Theme-select></Theme-select>
|
||||||
<slot name="ri-right"> </slot>
|
<slot name="ri-right"> </slot>
|
||||||
</n-space>
|
</n-space>
|
||||||
</div>
|
</div>
|
||||||
|
24
src/packages/index.d.ts
vendored
24
src/packages/index.d.ts
vendored
@ -1,11 +1,11 @@
|
|||||||
import { Component } from '@/router/types'
|
import type { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
import type { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
|
||||||
// 组件配置
|
// 组件配置
|
||||||
export type ConfigType = {
|
export type ConfigType = {
|
||||||
key: string
|
key: string
|
||||||
chartKey: string,
|
chartKey: string
|
||||||
conKey: string,
|
conKey: string
|
||||||
title: string
|
title: string
|
||||||
category: string
|
category: string
|
||||||
categoryName: string
|
categoryName: string
|
||||||
@ -13,22 +13,27 @@ export type ConfigType = {
|
|||||||
image: string | (() => Promise<typeof import('*.png')>)
|
image: string | (() => Promise<typeof import('*.png')>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据请求
|
||||||
|
interface requestConfig {
|
||||||
|
data: RequestConfigType
|
||||||
|
}
|
||||||
|
|
||||||
// 组件实例类
|
// 组件实例类
|
||||||
export interface PublicConfigType {
|
export interface PublicConfigType extends requestConfig {
|
||||||
id: string
|
id: string
|
||||||
rename?: string
|
rename?: string
|
||||||
attr: { x: number; y: number; w: number; h: number; zIndex: number }
|
attr: { x: number; y: number; w: number; h: number; zIndex: number }
|
||||||
styles: { opacity: number, animations: string[] }
|
styles: { opacity: number; animations: string[] }
|
||||||
setPosition: Function
|
setPosition: Function
|
||||||
}
|
}
|
||||||
export interface CreateComponentType extends PublicConfigType {
|
export interface CreateComponentType extends PublicConfigType {
|
||||||
key: string
|
key: string
|
||||||
chartConfig: Omit<ConfigType, 'node' | 'conNode'>
|
chartConfig: ConfigType
|
||||||
option: GlobalThemeJsonType
|
option: GlobalThemeJsonType
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取组件实例类中某个key对应value类型的方法
|
// 获取组件实例类中某个key对应value类型的方法
|
||||||
export type PickCreateComponentType<T extends keyof CreateComponentType> = Pick<CreateComponentType, T>[T]
|
export type PickCreateComponentType<T extends keyof CreateComponentType> = Pick<CreateComponentType,T>[T]
|
||||||
|
|
||||||
// 包分类枚举
|
// 包分类枚举
|
||||||
export enum PackagesCategoryEnum {
|
export enum PackagesCategoryEnum {
|
||||||
@ -48,7 +53,8 @@ export enum PackagesCategoryName {
|
|||||||
|
|
||||||
// 获取组件
|
// 获取组件
|
||||||
export enum FetchComFlagType {
|
export enum FetchComFlagType {
|
||||||
VIEW, CONFIG
|
VIEW,
|
||||||
|
CONFIG
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图表包类型
|
// 图表包类型
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import { getUUID } from '@/utils'
|
import { getUUID } from '@/utils'
|
||||||
import { PublicConfigType } from '@/packages/index.d'
|
import { PublicConfigType } from '@/packages/index.d'
|
||||||
|
import { RequestDataTypeEnum, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
|
||||||
|
const requestConfig: RequestConfigType = {
|
||||||
|
requestDataType: RequestDataTypeEnum.STATIC,
|
||||||
|
}
|
||||||
|
|
||||||
export class publicConfig implements PublicConfigType {
|
export class publicConfig implements PublicConfigType {
|
||||||
public id = getUUID()
|
public id = getUUID()
|
||||||
@ -12,6 +17,11 @@ export class publicConfig implements PublicConfigType {
|
|||||||
opacity: 1,
|
opacity: 1,
|
||||||
animations: []
|
animations: []
|
||||||
}
|
}
|
||||||
|
public data = {
|
||||||
|
requestDataType: RequestDataTypeEnum.STATIC
|
||||||
|
}
|
||||||
|
// 数据获取
|
||||||
|
public requestData = { ...requestConfig }
|
||||||
// 设置坐标
|
// 设置坐标
|
||||||
public setPosition(x: number, y: number): void {
|
public setPosition(x: number, y: number): void {
|
||||||
this.attr.x = x
|
this.attr.x = x
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { HistoryActionTypeEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d'
|
import { HistoryActionTypeEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d'
|
||||||
import { ChartColorsNameType, GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
import type {
|
||||||
|
ChartColorsNameType,
|
||||||
|
GlobalThemeJsonType
|
||||||
|
} from '@/settings/chartThemes/index'
|
||||||
|
|
||||||
// 编辑画布属性
|
// 编辑画布属性
|
||||||
export enum EditCanvasTypeEnum {
|
export enum EditCanvasTypeEnum {
|
||||||
@ -10,7 +13,7 @@ export enum EditCanvasTypeEnum {
|
|||||||
SCALE = 'scale',
|
SCALE = 'scale',
|
||||||
USER_SCALE = 'userScale',
|
USER_SCALE = 'userScale',
|
||||||
LOCK_SCALE = 'lockScale',
|
LOCK_SCALE = 'lockScale',
|
||||||
IS_DRAG= 'isDrag',
|
IS_DRAG = 'isDrag'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑区域
|
// 编辑区域
|
||||||
@ -30,7 +33,7 @@ export type EditCanvasType = {
|
|||||||
[EditCanvasTypeEnum.IS_DRAG]: boolean
|
[EditCanvasTypeEnum.IS_DRAG]: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// 滤镜
|
// 滤镜/背景色/宽高主题等
|
||||||
export enum EditCanvasConfigEnum {
|
export enum EditCanvasConfigEnum {
|
||||||
WIDTH = 'width',
|
WIDTH = 'width',
|
||||||
HEIGHT = 'height',
|
HEIGHT = 'height',
|
||||||
@ -108,14 +111,33 @@ export type RecordChartType = {
|
|||||||
export enum ChartEditStoreEnum {
|
export enum ChartEditStoreEnum {
|
||||||
EDIT_RANGE = 'editRange',
|
EDIT_RANGE = 'editRange',
|
||||||
EDIT_CANVAS = 'editCanvas',
|
EDIT_CANVAS = 'editCanvas',
|
||||||
EDIT_CANVAS_CONFIG = 'editCanvasConfig',
|
|
||||||
RIGHT_MENU_SHOW = 'rightMenuShow',
|
RIGHT_MENU_SHOW = 'rightMenuShow',
|
||||||
MOUSE_POSITION = 'mousePosition',
|
MOUSE_POSITION = 'mousePosition',
|
||||||
TARGET_CHART = 'targetChart',
|
TARGET_CHART = 'targetChart',
|
||||||
RECORD_CHART = 'recordChart',
|
RECORD_CHART = 'recordChart',
|
||||||
|
// 以下需要存储
|
||||||
|
EDIT_CANVAS_CONFIG = 'editCanvasConfig',
|
||||||
|
REQUEST_CONFIG = 'requestConfig',
|
||||||
COMPONENT_LIST = 'componentList'
|
COMPONENT_LIST = 'componentList'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据相关
|
||||||
|
export enum RequestDataTypeEnum {
|
||||||
|
// 静态数据
|
||||||
|
STATIC = 'static',
|
||||||
|
// 请求数据
|
||||||
|
AJAX = 'ajax'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据配置
|
||||||
|
export type RequestConfigType = {
|
||||||
|
// 获取数据的方式
|
||||||
|
requestDataType: RequestDataTypeEnum,
|
||||||
|
// 请求源地址
|
||||||
|
requestUrl?: string,
|
||||||
|
requestInterval?: number
|
||||||
|
}
|
||||||
|
|
||||||
// Store 类型
|
// Store 类型
|
||||||
export interface ChartEditStoreType {
|
export interface ChartEditStoreType {
|
||||||
[ChartEditStoreEnum.EDIT_CANVAS]: EditCanvasType
|
[ChartEditStoreEnum.EDIT_CANVAS]: EditCanvasType
|
||||||
@ -124,10 +146,12 @@ export interface ChartEditStoreType {
|
|||||||
[ChartEditStoreEnum.MOUSE_POSITION]: MousePositionType
|
[ChartEditStoreEnum.MOUSE_POSITION]: MousePositionType
|
||||||
[ChartEditStoreEnum.TARGET_CHART]: TargetChartType
|
[ChartEditStoreEnum.TARGET_CHART]: TargetChartType
|
||||||
[ChartEditStoreEnum.RECORD_CHART]?: RecordChartType
|
[ChartEditStoreEnum.RECORD_CHART]?: RecordChartType
|
||||||
|
[ChartEditStoreEnum.REQUEST_CONFIG]: RequestConfigType
|
||||||
[ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[]
|
[ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChartEditStorage {
|
export interface ChartEditStorage {
|
||||||
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: EditCanvasConfigType,
|
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: EditCanvasConfigType
|
||||||
|
[ChartEditStoreEnum.REQUEST_CONFIG]: RequestConfigType
|
||||||
[ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[]
|
[ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[]
|
||||||
}
|
}
|
@ -15,6 +15,8 @@ import {
|
|||||||
MousePositionType,
|
MousePositionType,
|
||||||
TargetChartType,
|
TargetChartType,
|
||||||
RecordChartType,
|
RecordChartType,
|
||||||
|
RequestConfigType,
|
||||||
|
RequestDataTypeEnum,
|
||||||
EditCanvasConfigType
|
EditCanvasConfigType
|
||||||
} from './chartEditStore.d'
|
} from './chartEditStore.d'
|
||||||
|
|
||||||
@ -82,6 +84,12 @@ export const useChartEditStore = defineStore({
|
|||||||
// 全局配置
|
// 全局配置
|
||||||
chartThemeSetting: globalThemeJson
|
chartThemeSetting: globalThemeJson
|
||||||
},
|
},
|
||||||
|
// 数据请求处理
|
||||||
|
requestConfig: {
|
||||||
|
requestDataType: RequestDataTypeEnum.STATIC,
|
||||||
|
requestUrl: undefined,
|
||||||
|
requestInterval: 10
|
||||||
|
},
|
||||||
// 图表数组(需存储给后端)
|
// 图表数组(需存储给后端)
|
||||||
componentList: []
|
componentList: []
|
||||||
}),
|
}),
|
||||||
@ -104,6 +112,9 @@ export const useChartEditStore = defineStore({
|
|||||||
getRecordChart(): RecordChartType | undefined {
|
getRecordChart(): RecordChartType | undefined {
|
||||||
return this.recordChart
|
return this.recordChart
|
||||||
},
|
},
|
||||||
|
getRequestConfig(): RequestConfigType {
|
||||||
|
return this.requestConfig
|
||||||
|
},
|
||||||
getComponentList(): CreateComponentType[] {
|
getComponentList(): CreateComponentType[] {
|
||||||
return this.componentList
|
return this.componentList
|
||||||
},
|
},
|
||||||
@ -111,7 +122,8 @@ export const useChartEditStore = defineStore({
|
|||||||
getStorageInfo(): ChartEditStorage {
|
getStorageInfo(): ChartEditStorage {
|
||||||
return {
|
return {
|
||||||
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: this.getEditCanvasConfig,
|
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: this.getEditCanvasConfig,
|
||||||
[ChartEditStoreEnum.COMPONENT_LIST]: this.getComponentList
|
[ChartEditStoreEnum.COMPONENT_LIST]: this.getComponentList,
|
||||||
|
[ChartEditStoreEnum.REQUEST_CONFIG]: this.getRequestConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>全局接口配置</h1>
|
<div>
|
||||||
|
<setting-item-box name="源地址" :alone="true">
|
||||||
|
<n-input
|
||||||
|
v-model:value="requestConfig.requestUrl"
|
||||||
|
placeholder="源地址如: http://127.0.0.1"
|
||||||
|
></n-input>
|
||||||
|
</setting-item-box>
|
||||||
|
<setting-item-box name="更新间隔">
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="requestConfig.requestInterval"
|
||||||
|
min="0"
|
||||||
|
:show-button="false"
|
||||||
|
placeholder="为 0 不更新"
|
||||||
|
>
|
||||||
|
<template #suffix>
|
||||||
|
秒
|
||||||
|
</template>
|
||||||
|
</n-input-number>
|
||||||
|
</setting-item-box>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, Ref } from 'vue'
|
||||||
</script>
|
import { SettingItemBox } from '@/components/ChartItemSetting/index'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
|
||||||
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
|
const requestConfig: Ref<RequestConfigType> = computed(() => {
|
||||||
|
return chartEditStore.getRequestConfig
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts" >
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
@ -74,7 +74,7 @@ const selectId = computed(() => chartEditStore.getTargetChart.selectId)
|
|||||||
const selectTatget = computed(
|
const selectTatget = computed(
|
||||||
() => chartEditStore.getComponentList[chartEditStore.fetchTargetIndex()]
|
() => chartEditStore.getComponentList[chartEditStore.fetchTargetIndex()]
|
||||||
)
|
)
|
||||||
const selectAttr = computed(() => selectTatget.value.attr)
|
const selectAttr = computed(() => selectTatget.value.attr || {})
|
||||||
|
|
||||||
// * 画布坐标
|
// * 画布坐标
|
||||||
const canvasPositionList = computed(() => {
|
const canvasPositionList = computed(() => {
|
||||||
|
@ -44,7 +44,7 @@ const lines = {
|
|||||||
/* 横线 */
|
/* 横线 */
|
||||||
#mb-ruler .v-container .lines .line {
|
#mb-ruler .v-container .lines .line {
|
||||||
/* 最大缩放 200% */
|
/* 最大缩放 200% */
|
||||||
height: 200vw!important;
|
width: 200vw!important;
|
||||||
border-top: 1px dashed v-bind('themeColor') !important;
|
border-top: 1px dashed v-bind('themeColor') !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user