Merge pull request #160 from JeremyYu-cn/main

Fix: some type problems
This commit is contained in:
Jeremy Yu 2024-09-25 12:40:23 +08:00 committed by GitHub
commit 84a93e4344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 39 additions and 2213 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ node_modules
/dist /dist
config.json config.json
/.vite /.vite
yarn.lock
screenshot/node_modules/ screenshot/node_modules/
screenshot/dist/ screenshot/dist/

1
service/.gitignore vendored
View File

@ -11,6 +11,7 @@ yarn-error.log*
static static
config.json config.json
config.js config.js
yarn.lock
# Runtime data # Runtime data
pids pids

View File

@ -55,7 +55,9 @@ module.exports = {
try { try {
const detail = fs.readFileSync(path.resolve(__dirname, `../mock/materials/${cate}.json`), 'utf8') const detail = fs.readFileSync(path.resolve(__dirname, `../mock/materials/${cate}.json`), 'utf8')
send.success(res, { list: JSON.parse(detail) }) send.success(res, { list: JSON.parse(detail) })
} catch (error) {} } catch (error) {
console.log(error)
}
}, },
// design/imgs 获取照片素材(虚拟) // design/imgs 获取照片素材(虚拟)
async getPhotos(req: any, res: any) { async getPhotos(req: any, res: any) {

File diff suppressed because it is too large Load Diff

View File

@ -96,7 +96,7 @@ type TGetCompListParam = {
search?: string search?: string
page?: number page?: number
type?: number type?: number
pageSize: number pageSize?: number
cate?: number | string cate?: number | string
} }
@ -109,6 +109,7 @@ export type TGetCompListResult = {
title: string title: string
width: number width: number
name?: string name?: string
cate?: string
} }
type getCompListReturn = TPageRequestResult<TGetCompListResult[]> type getCompListReturn = TPageRequestResult<TGetCompListResult[]>

View File

@ -1,9 +1,9 @@
/* /*
* @Author: ShawnPhang * @Author: ShawnPhang <https://m.palxp.cn>
* @Date: 2021-08-27 14:42:15 * @Date: 2021-08-27 14:42:15
* @Description: * @Description:
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-08-11 19:27:41 * @LastEditTime: 2024-09-25 00:39:00
*/ */
import fetch from '@/utils/axios' import fetch from '@/utils/axios'
import _config from '@/config' import _config from '@/config'
@ -15,7 +15,7 @@ export const getKinds = (params: Type.Object = {}) => fetch('design/cate', param
type TGetListParam = { type TGetListParam = {
first_id?: number first_id?: number
second_id?: string second_id?: string
cate?: number cate?: string | number
pageSize?: number pageSize?: number
} }

View File

@ -13,7 +13,7 @@
<!-- <div class="el-upload__text">在此拖入或选择<em>上传图片</em></div> --> <!-- <div class="el-upload__text">在此拖入或选择<em>上传图片</em></div> -->
<div class="el-upload__text">自动抠图目前依赖后端服务需自行部署</div> <div class="el-upload__text">自动抠图目前依赖后端服务需自行部署</div>
</div> </div>
<div class="el-upload__tip el-upload__text"><em>体验前端效果演示以及修补编辑器随便上传一张图片即可触发</em></div> <div class="el-upload__tip el-upload__text"><em>体验前端效果演示以及修补编辑器任意上传一张图片即可触发</em></div>
</uploader> </uploader>
<el-progress v-if="!state.cutImage && state.progressText" :percentage="state.progress"> <el-progress v-if="!state.cutImage && state.progressText" :percentage="state.progress">
<el-button text> <el-button text>

View File

@ -55,7 +55,7 @@ type TState = {
list: TGetCompListResult[] list: TGetCompListResult[]
searchValue: string searchValue: string
currentCategory: TGetCompListResult | null currentCategory: TGetCompListResult | null
types: [] types: {cate: string, name: string}[]
showList: TGetCompListResult[][] showList: TGetCompListResult[][]
} }
@ -129,7 +129,7 @@ const load = async (init: boolean = false) => {
const res = await api.home.getCompList({ const res = await api.home.getCompList({
...pageOptions, ...pageOptions,
cate: state.currentCategory?.id, cate: state.currentCategory?.id || state.currentCategory?.cate,
}) })
if (init) { if (init) {
state.list = res?.list state.list = res?.list

View File

@ -1,9 +1,9 @@
<!-- <!--
* @Author: ShawnPhang * @Author: ShawnPhang <https://m.palxp.cn>
* @Date: 2021-08-27 15:16:07 * @Date: 2021-08-27 15:16:07
* @Description: 素材列表 * @Description: 素材列表
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-08-14 18:48:34 * @LastEditTime: 2024-09-25 00:39:00
--> -->
<template> <template>
<div class="wrap"> <div class="wrap">
@ -65,13 +65,14 @@ type TState = {
currentCheck: number currentCheck: number
colors: string[] colors: string[]
currentCategory: TCurrentCategory | null currentCategory: TCurrentCategory | null
types: [] types: { cate: string, name: string }[]
showList: TGetListData[][] showList: TGetListData[][]
searchKeyword: string searchKeyword: string
} }
type TCurrentCategory = { type TCurrentCategory = {
name: string name: string
cate?: string | number
id?: number id?: number
} }
@ -149,7 +150,7 @@ const load = async (init: boolean = false) => {
state.loading = true state.loading = true
pageOptions.page += 1 pageOptions.page += 1
const list = await api.material.getList({ const list = await api.material.getList({
...{ cate: state.currentCategory?.id, search: state.searchKeyword, ...pageOptions }, ...{ cate: state.currentCategory?.id || state.currentCategory?.cate, search: state.searchKeyword, ...pageOptions },
}) })
if (init) { if (init) {
state.list = list?.list state.list = list?.list
@ -168,6 +169,7 @@ const searchChange = (_: Event) => {
} }
const selectTypes = (item: TCurrentCategory) => { const selectTypes = (item: TCurrentCategory) => {
console.log(item)
state.currentCategory = item state.currentCategory = item
load(true) load(true)
} }

View File

@ -1,9 +1,9 @@
/* /*
* @Author: ShawnPhang * @Author: ShawnPhang <https://m.palxp.cn>
* @Date: 2024-04-05 06:23:23 * @Date: 2024-04-05 06:23:23
* @Description: * @Description:
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-08-12 09:27:06 * @LastEditTime: 2024-09-25 00:39:00
*/ */
export type TScreeData = { export type TScreeData = {
/** 记录编辑界面的宽度 */ /** 记录编辑界面的宽度 */
@ -53,13 +53,15 @@ export type TStoreAction = {
value: TPageState[T] value: TPageState[T]
// pushHistory?: boolean // pushHistory?: boolean
}): void }): void
getDPage(data: TPageState): () => TPageState getDPage(data: TPageState): TPageState
/** 设置dPage */ /** 设置dPage */
setDPage(data: TPageState): void setDPage(data: TPageState): void
/** 更新 Page从layouts获取*/ /** 更新 Page从layouts获取*/
updateDPage(): void updateDPage(): void
/** 设置底部工具栏高度 */ /** 设置底部工具栏高度 */
setBottomHeight(h: number): void setBottomHeight(h: number): void
/** 更新当前页面下标 */
setDCurrentPage(n: number): void
} }
export type TPageState = { export type TPageState = {

View File

@ -1,10 +1,10 @@
/* /*
* @Author: Jeremy Yu * @Author: Jeremy Yu <https://github.com/JeremyYu-cn>
* @Date: 2024-03-18 21:00:00 * @Date: 2024-03-18 21:00:00
* @Description: * @Description:
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-12 09:27:22 * @LastEditTime: 2024-09-25 00:39:00
*/ */
import { Store, defineStore } from 'pinia' import { Store, defineStore } from 'pinia'
@ -95,6 +95,10 @@ const CanvasStore = defineStore<"canvasStore", TCanvasState, {}, TStoreAction>("
/** 设置底部工具栏高度 */ /** 设置底部工具栏高度 */
setBottomHeight(h: number) { setBottomHeight(h: number) {
this.dBottomHeight = h this.dBottomHeight = h
},
/** 更新当前页面下标 */
setDCurrentPage(n: number) {
this.dCurrentPage = n
} }
} }
}) })

View File

@ -20,6 +20,7 @@ import { TUpdateAlignData, updateAlign } from "./actions/align";
// import { TWidgetJsonData, widgetJsonData } from "./getter"; // import { TWidgetJsonData, widgetJsonData } from "./getter";
import { TupdateLayerIndexData, ungroup, updateLayerIndex } from "./actions/layer"; import { TupdateLayerIndexData, ungroup, updateLayerIndex } from "./actions/layer";
import pageDefault from "../canvas/page-default"; import pageDefault from "../canvas/page-default";
import { TCanvasStore } from "../canvas";
export type TdWidgetData = TPageState & Partial<TCommonItemData> & { export type TdWidgetData = TPageState & Partial<TCommonItemData> & {
parent?: string parent?: string
@ -125,7 +126,7 @@ type TAction = {
resize: (data: TSize) => void resize: (data: TSize) => void
setWidgetStyle: (data: TsetWidgetStyleData) => void setWidgetStyle: (data: TsetWidgetStyleData) => void
setDWidgets: (data: TdWidgetData[]) => void setDWidgets: (data: TdWidgetData[]) => void
setDLayouts: (data: TdLayout) => void setDLayouts: (data: TdLayout[]) => void
updateDWidgets: () => void updateDWidgets: () => void
lockWidgets: () => void lockWidgets: () => void
setMouseEvent: (e: MouseEvent | null) => void setMouseEvent: (e: MouseEvent | null) => void
@ -201,8 +202,10 @@ const WidgetStore = defineStore<"widgetStore", TWidgetState, TGetter, TAction>("
autoResizeAll(data) { autoResizeAll(this, data) }, autoResizeAll(data) { autoResizeAll(this, data) },
setDLayouts(data) { setDLayouts(this, data) }, setDLayouts(data) { setDLayouts(this, data) },
getWidgets() { getWidgets() {
const pageStore = useCanvasStore() const pageStore = useCanvasStore() as TCanvasStore
!this.dLayouts[pageStore.dCurrentPage] && pageStore.dCurrentPage-- !this.dLayouts[pageStore.dCurrentPage] && pageStore.setDCurrentPage(pageStore.dCurrentPage - 1)
// !this.dLayouts[pageStore.dCurrentPage] && pageStore.dCurrentPage--
return this.dLayouts[pageStore.dCurrentPage].layers return this.dLayouts[pageStore.dCurrentPage].layers
} }
} }