index.d.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import { BaseEvent, EventLife, InteractEvents, InteractEventOn, InteractActionsType } from '@/enums/eventEnum'
  2. import type { GlobalThemeJsonType } from '@/settings/chartThemes/index'
  3. import type { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
  4. export enum ChartFrameEnum {
  5. // 支持 dataset 的 echarts 框架
  6. ECHARTS = 'echarts',
  7. // UI 组件框架
  8. NAIVE_UI = 'naiveUI',
  9. // 自定义带数据组件
  10. COMMON = 'common',
  11. // 无数据变更
  12. STATIC = 'static'
  13. }
  14. // 组件配置
  15. export type ConfigType = {
  16. // 组件 key
  17. key: string
  18. // 画布组件 key
  19. chartKey: string
  20. // 右侧设置面板组件 key
  21. conKey: string
  22. // 标题
  23. title: string
  24. // 分类
  25. category: string
  26. // 分类名称
  27. categoryName: string
  28. // 所属包
  29. package: string
  30. // 归类
  31. chartFrame?: ChartFrameEnum
  32. // 预览图
  33. image: string
  34. // 从指定路径创建创建该组件
  35. redirectComponent?: string
  36. // 组件预设的 dataset 值(图片/图标)
  37. dataset?: any
  38. // 禁用 拖拽或双击生成组件
  39. disabled?: boolean
  40. // 图标
  41. icon?: string
  42. // 事件
  43. configEvents?: { [T: string]: Function }
  44. }
  45. // 数据请求
  46. interface requestConfig {
  47. request: RequestConfigType
  48. }
  49. // Echarts 数据类型
  50. interface EchartsDataType {
  51. dimensions: string[]
  52. source: any[]
  53. }
  54. // 组件状态
  55. export interface StatusType {
  56. lock: boolean
  57. hide: boolean
  58. }
  59. // 滤镜/变换枚举
  60. export enum FilterEnum {
  61. // 是否启用
  62. FILTERS_SHOW = 'filterShow',
  63. // 透明度
  64. OPACITY = 'opacity',
  65. // 饱和度
  66. SATURATE = 'saturate',
  67. // 对比度
  68. CONTRAST = 'contrast',
  69. // 色相
  70. HUE_ROTATE = 'hueRotate',
  71. // 亮度
  72. BRIGHTNESS = 'brightness',
  73. // 旋转
  74. ROTATE_Z = 'rotateZ',
  75. ROTATE_X = 'rotateX',
  76. ROTATE_Y = 'rotateY',
  77. // 倾斜
  78. SKEW_X = 'skewX',
  79. SKEW_Y = 'skewY',
  80. // 混合模式
  81. BLEND_MODE = 'blendMode',
  82. //动画开关
  83. ANIMATIONS_OPEN = 'animationsOpen',
  84. //动画循环
  85. ANIMATIONS_CIRCULATE = 'animationsCirculate',
  86. //动画曲线
  87. ANIMATIONS_CURVE = 'animationsCurve',
  88. //动画方向
  89. ANIMATIONS_DIRECTION = 'animationsDirection',
  90. //动画时长
  91. CIRCULATE_PLAY_TIME = 'circulatePlayTime',
  92. //动画延迟时长
  93. CIRCULATE_DELAY_TIME = 'circulateDelayTime',
  94. //样式增强
  95. STYLE_ENHANCE= 'styleEnhance',
  96. }
  97. export const BlendModeEnumList = [
  98. { label: '正常', value: 'normal' },
  99. { label: '正片叠底', value: 'multiply' },
  100. { label: '叠加', value: 'overlay' },
  101. { label: '滤色', value: 'screen' },
  102. { label: '变暗', value: 'darken' },
  103. { label: '变亮', value: 'lighten' },
  104. { label: '颜色减淡', value: 'color-dodge' },
  105. { label: '颜色加深', value: 'color-burn;' },
  106. { label: '强光', value: 'hard-light' },
  107. { label: '柔光', value: 'soft-light' },
  108. { label: '差值', value: 'difference' },
  109. { label: '排除', value: 'exclusion' },
  110. { label: '色相', value: 'hue' },
  111. { label: '饱和度', value: 'saturation' },
  112. { label: '颜色', value: 'color' },
  113. { label: '亮度', value: 'luminosity' }
  114. ]
  115. // 组件实例类
  116. export interface PublicConfigType {
  117. id: string
  118. isGroup: boolean
  119. attr: { x: number; y: number; w: number; h: number; zIndex: number; offsetX: number; offsetY: number }
  120. styles: {
  121. [FilterEnum.FILTERS_SHOW]: boolean
  122. [FilterEnum.OPACITY]: number
  123. [FilterEnum.SATURATE]: number
  124. [FilterEnum.CONTRAST]: number
  125. [FilterEnum.HUE_ROTATE]: number
  126. [FilterEnum.BRIGHTNESS]: number
  127. [FilterEnum.ROTATE_Z]: number
  128. [FilterEnum.ROTATE_X]: number
  129. [FilterEnum.ROTATE_Y]: number
  130. [FilterEnum.SKEW_X]: number
  131. [FilterEnum.SKEW_Y]: number
  132. [FilterEnum.BLEND_MODE]: string
  133. // 动画
  134. animations: string[]
  135. // // 动画开关
  136. [FilterEnum.ANIMATIONS_OPEN]: boolean,
  137. // 动画循环
  138. [FilterEnum.ANIMATIONS_CIRCULATE]: boolean,
  139. //动画播放速度曲线默认平滑
  140. [FilterEnum.ANIMATIONS_CURVE]: string,
  141. //动画方向
  142. [FilterEnum.ANIMATIONS_DIRECTION]: string,
  143. // 动画时长/秒
  144. [FilterEnum.CIRCULATE_PLAY_TIME]: number,
  145. // 动画延迟时长/秒
  146. [FilterEnum.CIRCULATE_DELAY_TIME]: number,
  147. // 样式自定义增强
  148. [FilterEnum.STYLE_ENHANCE]: string,
  149. }
  150. preview?: {
  151. // 预览超出隐藏
  152. overFlowHidden?: boolean
  153. }
  154. filter?: string
  155. status: StatusType
  156. interactActions?: InteractActionsType[]
  157. events: {
  158. baseEvent: {
  159. [K in BaseEvent]?: string
  160. }
  161. advancedEvents: {
  162. [K in EventLife]?: string
  163. }
  164. interactEvents: {
  165. [InteractEvents.INTERACT_ON]: InteractEventOn | undefined
  166. [InteractEvents.INTERACT_COMPONENT_ID]: string | undefined
  167. [InteractEvents.INTERACT_FN]: { [name: string]: string }
  168. }[]
  169. }
  170. }
  171. export interface CreateComponentType extends PublicConfigType, requestConfig {
  172. key: string
  173. chartConfig: ConfigType
  174. option: GlobalThemeJsonType
  175. groupList?: Array<CreateComponentType>
  176. }
  177. // 组件成组实例类
  178. export interface CreateComponentGroupType extends CreateComponentType {
  179. groupList: Array<CreateComponentType>
  180. }
  181. // 获取组件实例类中某个key对应value类型的方法
  182. export type PickCreateComponentType<T extends keyof CreateComponentType> = Pick<CreateComponentType, T>[T]
  183. // 包分类枚举
  184. export enum PackagesCategoryEnum {
  185. CHARTS = 'Charts',
  186. TABLES = 'Tables',
  187. INFORMATIONS = 'Informations',
  188. PHOTOS = 'Photos',
  189. ICONS = 'Icons',
  190. DECORATES = 'Decorates'
  191. }
  192. // 包分类名称
  193. export enum PackagesCategoryName {
  194. CHARTS = '图表',
  195. TABLES = '列表',
  196. INFORMATIONS = '信息',
  197. PHOTOS = '图片',
  198. ICONS = '图标',
  199. DECORATES = '小组件'
  200. }
  201. // 获取组件
  202. export enum FetchComFlagType {
  203. VIEW,
  204. CONFIG
  205. }
  206. // 图表包类型
  207. export type PackagesType = {
  208. [PackagesCategoryEnum.CHARTS]: ConfigType[]
  209. [PackagesCategoryEnum.INFORMATIONS]: ConfigType[]
  210. [PackagesCategoryEnum.TABLES]: ConfigType[]
  211. [PackagesCategoryEnum.PHOTOS]: ConfigType[]
  212. [PackagesCategoryEnum.ICONS]: ConfigType[]
  213. [PackagesCategoryEnum.DECORATES]: ConfigType[]
  214. }