diff --git a/src/api/image/index.ts b/src/api/image/index.ts index 81ec74de..da492b53 100644 --- a/src/api/image/index.ts +++ b/src/api/image/index.ts @@ -10,10 +10,10 @@ export function getImagePages(params?: QueryPgaes): AxiosPromise { +export function getImageCategory(params?: QueryCategory): AxiosPromise { return request({ url: 'api/image/category', method: 'get', - params, + params }); } \ No newline at end of file diff --git a/src/api/image/types.ts b/src/api/image/types.ts index 0fde8828..0a1767d5 100644 --- a/src/api/image/types.ts +++ b/src/api/image/types.ts @@ -53,5 +53,5 @@ export interface ImagePageResult { export interface ImageCategoryResult { code: number msg: string - data: ImagePage + data: ImageHits[] } \ No newline at end of file diff --git a/src/configs/images.ts b/src/configs/images.ts index 87c10139..b23d22b4 100644 --- a/src/configs/images.ts +++ b/src/configs/images.ts @@ -261,23 +261,23 @@ export const EmbossMatrix = [ 1, 1, 1, 1, 0.7, -1, -1, -1, -1 ] // backgrounds, fashion, nature, science, education, feelings, health, people, religion, // places, animals, industry, computer, food, sports, transportation, travel, buildings, business, music export const ImageCategoryInfo = [ - {id: 0, name: '背景', type: 'backgrounds'}, - {id: 1, name: '时尚', type: 'fashion'}, - {id: 2, name: '自然', type: 'nature'}, - {id: 3, name: '科学', type: 'science'}, - {id: 4, name: '教育', type: 'education'}, - {id: 5, name: '情感', type: 'feelings'}, - {id: 6, name: '健康', type: 'health'}, - {id: 7, name: '人物', type: 'people'}, - {id: 8, name: '宗教', type: 'religion'}, - {id: 9, name: '场所', type: 'places'}, - {id: 9, name: '动物', type: 'animals'}, - {id: 9, name: '工业', type: 'industry'}, - {id: 9, name: '计算机', type: 'computer'}, - {id: 9, name: '食品', type: 'food'}, - {id: 9, name: '体育', type: 'sports'}, - {id: 9, name: '交通', type: 'transportation'}, - {id: 9, name: '旅游', type: 'travel'}, - {id: 9, name: '建筑', type: 'buildings'}, - {id: 9, name: '商业', type: 'business'}, + {id: 0, name: '背景', type: 'backgrounds', data: []}, + {id: 1, name: '时尚', type: 'fashion', data: []}, + {id: 2, name: '自然', type: 'nature', data: []}, + {id: 3, name: '科学', type: 'science', data: []}, + {id: 4, name: '教育', type: 'education', data: []}, + {id: 5, name: '情感', type: 'feelings', data: []}, + {id: 6, name: '健康', type: 'health', data: []}, + {id: 7, name: '人物', type: 'people', data: []}, + {id: 8, name: '宗教', type: 'religion', data: []}, + {id: 9, name: '场所', type: 'places', data: []}, + {id: 10, name: '动物', type: 'animals', data: []}, + {id: 11, name: '工业', type: 'industry', data: []}, + {id: 12, name: '计算机', type: 'computer', data: []}, + {id: 13, name: '食品', type: 'food', data: []}, + {id: 14, name: '体育', type: 'sports', data: []}, + {id: 15, name: '交通', type: 'transportation', data: []}, + {id: 16, name: '旅游', type: 'travel', data: []}, + {id: 17, name: '建筑', type: 'buildings', data: []}, + {id: 18, name: '商业', type: 'business', data: []}, ] \ No newline at end of file diff --git a/src/store/modules/main.ts b/src/store/modules/main.ts index 650c09f9..9f187b34 100644 --- a/src/store/modules/main.ts +++ b/src/store/modules/main.ts @@ -2,9 +2,10 @@ import { Object as FabricObject } from 'fabric' import { customAlphabet } from 'nanoid' import { defineStore } from 'pinia' import { SYS_FONTS } from '@/configs/fonts' +import { ImageCategoryInfo } from '@/configs/images' import { getSupportFonts } from '@/utils/fonts' import { CanvasElement } from '@/types/canvas' -import { RightStates, PointElement, ImageCategory } from '@/types/elements' +import { RightStates, PointElement, ImageCategoryData } from '@/types/elements' import { ExportTypes, PoolType, SystemFont } from '@/types/common' import useCanvas from '@/views/Canvas/useCanvas' @@ -15,7 +16,8 @@ export interface MainState { clonedObject: FabricObject | undefined currentPoint: PointElement | null rightState: RightStates - imageCategory: ImageCategory[] + imageCategoryType: string[] + imageCategoryData: ImageCategoryData[] activeElementIdList: string[] handleElementId: string sizeMode: number @@ -44,7 +46,8 @@ export const useMainStore = defineStore('main', { leavedObject: undefined, currentPoint: null, rightState: RightStates.ELEMENT_WORKER, - imageCategory: [], + imageCategoryType: [], + imageCategoryData: ImageCategoryInfo, activeElementIdList: [], // 被选中的元素ID集合,包含 handleElementId handleElementId: '', // 正在操作的元素ID sizeMode: 0, // 模板样式 diff --git a/src/types/elements.ts b/src/types/elements.ts index 97128ad3..15c18d3f 100644 --- a/src/types/elements.ts +++ b/src/types/elements.ts @@ -1,4 +1,4 @@ -import { ImagePage } from "@/api/image/types" +import { ImageHits } from "@/api/image/types" export const enum ElementNames { TEXTBOX = 'textbox', TEXT = 'text', @@ -221,7 +221,9 @@ export const enum LayerCommand { BOTTOM = 'bottom', } -export interface ImageCategory { +export interface ImageCategoryData { + id: number type: string - data: ImagePage + name: string + data: ImageHits[] } \ No newline at end of file diff --git a/src/views/Editor/CanvasMenu/components/ImageComponents/ImageCategory.vue b/src/views/Editor/CanvasMenu/components/ImageComponents/ImageCategory.vue index 2ae645d4..45f0d3ba 100644 --- a/src/views/Editor/CanvasMenu/components/ImageComponents/ImageCategory.vue +++ b/src/views/Editor/CanvasMenu/components/ImageComponents/ImageCategory.vue @@ -1,10 +1,10 @@