chore: 修改项目信息结构

This commit is contained in:
奔跑的面条
2022-05-27 11:49:25 +08:00
parent e674a1ece4
commit ca27e87241
4 changed files with 54 additions and 22 deletions
+20 -3
View File
@@ -8,6 +8,23 @@ import type {
GlobalThemeJsonType,
} from '@/settings/chartThemes/index'
// 项目数据枚举
export enum ProjectInfoEnum {
// 名称
PROJECT_NAME = 'projectName',
// 描述
REMARKS = 'remarks',
// 缩略图
THUMBNAIL= 'thumbnail'
}
// 项目数据
export type ProjectInfoType = {
projectName: string,
remarks: string,
thumbnail: string
}
// 编辑画布属性
export enum EditCanvasTypeEnum {
EDIT_LAYOUT_DOM = 'editLayoutDom',
@@ -44,8 +61,6 @@ export type EditCanvasType = {
// 画布数据/滤镜/背景色/宽高主题等
export enum EditCanvasConfigEnum {
PROJECT_NAME = 'projectName',
REMARKS = 'remarks',
WIDTH = 'width',
HEIGHT = 'height',
CHART_THEME_COLOR = 'chartThemeColor',
@@ -57,7 +72,7 @@ export enum EditCanvasConfigEnum {
}
// 画布属性(需保存)
export interface EditCanvasConfigType {
export type EditCanvasConfigType = {
// 项目名称
[EditCanvasConfigEnum.PROJECT_NAME]: string,
// 项目描述
@@ -129,6 +144,7 @@ export type RecordChartType = {
// Store 枚举
export enum ChartEditStoreEnum {
PROJECT_INFO = 'projectInfo',
EDIT_RANGE = 'editRange',
EDIT_CANVAS = 'editCanvas',
RIGHT_MENU_SHOW = 'rightMenuShow',
@@ -161,6 +177,7 @@ export type RequestConfigType = {
// Store 类型
export interface ChartEditStoreType {
[ChartEditStoreEnum.PROJECT_INFO]: ProjectInfoType
[ChartEditStoreEnum.EDIT_CANVAS]: EditCanvasType
[ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: EditCanvasConfigType
[ChartEditStoreEnum.RIGHT_MENU_SHOW]: boolean
@@ -15,6 +15,7 @@ import { HistoryActionTypeEnum, HistoryItemType, HistoryTargetTypeEnum } from '@
import { MenuEnum, SyncEnum } from '@/enums/editPageEnum'
import {
ProjectInfoType,
ChartEditStoreEnum,
ChartEditStorage,
ChartEditStoreType,
@@ -33,6 +34,12 @@ const settingStore = useSettingStore()
export const useChartEditStore = defineStore({
id: 'useChartEditStore',
state: (): ChartEditStoreType => ({
// 项目数据
projectInfo: {
projectName: '',
remarks: '',
thumbnail: ''
},
// 画布属性
editCanvas: {
// 编辑区域 Dom
@@ -72,10 +79,6 @@ export const useChartEditStore = defineStore({
// -----------------------
// 画布属性(需存储给后端)
editCanvasConfig: {
// 项目名称
projectName: '',
// 描述
remarks: '',
// 默认宽度
width: 1920,
// 默认高度
@@ -117,6 +120,9 @@ export const useChartEditStore = defineStore({
componentList: []
}),
getters: {
getProjectInfo(): ProjectInfoType {
return this.projectInfo
},
getMousePosition(): MousePositionType {
return this.mousePosition
},
@@ -151,6 +157,10 @@ export const useChartEditStore = defineStore({
}
},
actions: {
// * 设置 peojectInfo 数据项
setProjectInfo<T extends keyof ProjectInfoType, K extends ProjectInfoType[T]>(key: T, value: K) {
this.projectInfo[key] = value
},
// * 设置 editCanvas 数据项
setEditCanvas<T extends keyof EditCanvasType, K extends EditCanvasType[T]>(key: T, value: K) {
this.editCanvas[key] = value