mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
Merge pull request #85 from JeremyYu-cn/feat-upgrade-vue3
feat: add api function ts type
This commit is contained in:
commit
aa1112ee94
@ -46,7 +46,29 @@ type TGetTempDetail = {
|
||||
type?: number
|
||||
}
|
||||
|
||||
export const getTempDetail = (params: TGetTempDetail) => fetch<{data: string}>('design/temp', params, 'get')
|
||||
type TTempDetail = {
|
||||
/** 分类 */
|
||||
category: number
|
||||
/** 封面 */
|
||||
cover: string
|
||||
/** 创建时间 */
|
||||
created_time: string
|
||||
/** Template内容 */
|
||||
data: string
|
||||
/** 高度 */
|
||||
height: number
|
||||
id: number
|
||||
/** 来源 */
|
||||
original: string
|
||||
resource: string
|
||||
state: string
|
||||
tag: string | null
|
||||
title: string
|
||||
updated_time: string
|
||||
width: number
|
||||
}
|
||||
|
||||
export const getTempDetail = (params: TGetTempDetail) => fetch<TTempDetail>('design/temp', params, 'get')
|
||||
|
||||
type TGetCategoriesParams = {
|
||||
type?: number
|
||||
@ -66,8 +88,28 @@ export const getCategories = (params: TGetCategoriesParams) => fetch<TgetCategor
|
||||
export const saveTemp = (params: Type.Object = {}) => fetch('design/edit', params, 'post')
|
||||
// export const delTemp = (params: Type.Object = {}) => fetch('/api/template/temp_del', params)
|
||||
|
||||
type TGetCompListParam = {
|
||||
search?: string
|
||||
page?: number
|
||||
type?: number
|
||||
pageSize: number
|
||||
cate: number
|
||||
}
|
||||
|
||||
/** 获取组件返回类型 */
|
||||
export type TGetCompListResult = {
|
||||
cover: string
|
||||
height: number
|
||||
id: number
|
||||
state: number
|
||||
title: string
|
||||
width: number
|
||||
}
|
||||
|
||||
type getCompListReturn = TPageRequestResult<TGetCompListResult[]>
|
||||
|
||||
// 组件相关接口
|
||||
export const getCompList = (params: Type.Object = {}) => fetch('design/list', params, 'get')
|
||||
export const getCompList = (params: TGetCompListParam) => fetch<getCompListReturn>('design/list', params, 'get')
|
||||
export const removeComp = (params: Type.Object = {}) => fetch('design/del', params, 'post')
|
||||
// export const getCompDetail = (params: Type.Object = {}) => fetch('/api/template/temp_info', params, 'get')
|
||||
|
||||
|
@ -38,8 +38,6 @@ export type TGetListData = {
|
||||
|
||||
export type TGetListResult = TPageRequestResult<TGetListData[]>
|
||||
|
||||
|
||||
|
||||
// 获取素材列表:
|
||||
export const getList = (params: TGetListParam) => fetch<TGetListResult>('design/material', params)
|
||||
|
||||
@ -60,7 +58,18 @@ export type TGetFontItemData = {
|
||||
|
||||
// 获取字体
|
||||
export const getFonts = (params: TGetFontParam = {}) => fetch<TPageRequestResult<TGetFontItemData[]>>('design/fonts', params)
|
||||
export const getFontSub = (params: Type.Object = {}, extra: any = {}) => fetch('design/font_sub', params, 'get', {}, extra)
|
||||
|
||||
type TGetFontSubParam = {
|
||||
font_id: string | number
|
||||
id: string | number
|
||||
content: string
|
||||
}
|
||||
|
||||
type TGetFontSubExtra = {
|
||||
responseType?: string
|
||||
}
|
||||
|
||||
export const getFontSub = (params: TGetFontSubParam, extra: TGetFontSubExtra = {}) => fetch<Blob | string>('design/font_sub', params, 'get', {}, extra)
|
||||
|
||||
type TGetImageListParams = {
|
||||
page?: number
|
||||
@ -74,16 +83,49 @@ export type TGetImageListResult = {
|
||||
url: string
|
||||
user_id: number
|
||||
id: string
|
||||
thumb: string
|
||||
} & IGetTempListData
|
||||
thumb?: string
|
||||
} & Partial<IGetTempListData>
|
||||
|
||||
// 图库列表
|
||||
export const getImagesList = (params: TGetImageListParams) => fetch<TPageRequestResult<TGetImageListResult[]>>('design/imgs', params, 'get')
|
||||
|
||||
type TMyPhotoParams = {
|
||||
|
||||
page: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
/** 获取我的资源管理返回 */
|
||||
export type TMyPhotoResult = {
|
||||
created_time: string
|
||||
height: number
|
||||
id: number
|
||||
url: string
|
||||
user_id: number
|
||||
width: number
|
||||
} & IGetTempListData
|
||||
|
||||
// 我的上传列表
|
||||
export const getMyPhoto = (params: TGetImageListParams) => fetch<TPageRequestResult<TGetImageListResult[]>>('design/user/image', params)
|
||||
export const deleteMyPhoto = (params: Type.Object = {}) => fetch('design/user/image/del', params, 'post')
|
||||
export const deleteMyWorks = (params: Type.Object = {}) => fetch('design/poster/del', params, 'post')
|
||||
export const getMyPhoto = (params: TMyPhotoParams) => fetch<TPageRequestResult<TMyPhotoResult[]>>('design/user/image', params)
|
||||
|
||||
type TDeleteMyPhotoParams = {
|
||||
id: string | number
|
||||
key: string
|
||||
}
|
||||
|
||||
export const deleteMyPhoto = (params: TDeleteMyPhotoParams) => fetch<void>('design/user/image/del', params, 'post')
|
||||
|
||||
type TDeleteMyWorksParams = {
|
||||
id: string | number
|
||||
}
|
||||
|
||||
export const deleteMyWorks = (params: TDeleteMyWorksParams) => fetch<void>('design/poster/del', params, 'post')
|
||||
|
||||
type TAddMyPhotoParam = {
|
||||
width: number
|
||||
height: number
|
||||
url: string
|
||||
}
|
||||
|
||||
// 添加图片
|
||||
export const addMyPhoto = (params: Type.Object = {}) => fetch('design/user/add_image', params)
|
||||
export const addMyPhoto = (params: TAddMyPhotoParam) => fetch<void>('design/user/add_image', params)
|
||||
|
@ -45,7 +45,7 @@ import api from '@/api'
|
||||
import wImage from '../../widgets/wImage/wImage.vue'
|
||||
import setImageData, { TItem2DataParam } from '@/common/methods/DesignFeatures/setImage'
|
||||
import useConfirm from '@/common/methods/confirm'
|
||||
import { TGetImageListResult } from '@/api/material'
|
||||
import { TGetImageListResult, TMyPhotoResult } from '@/api/material'
|
||||
import photoList from './components/photoList.vue'
|
||||
import imgWaterFall from './components/imgWaterFall.vue'
|
||||
import { TUploadDoneData } from '@/components/common/Uploader/index.vue'
|
||||
|
@ -27,10 +27,10 @@
|
||||
:key="efi + 'effect'"
|
||||
:style="{
|
||||
color: ef.filling && ef.filling.enable && ef.filling.type === 0 ? ef.filling.color : 'transparent',
|
||||
webkitTextStroke: ef.stroke && ef.stroke.enable ? `${ef.stroke.width / coefficient}px ${ef.stroke.color}` : '',
|
||||
WebkitTextStroke: ef.stroke && ef.stroke.enable ? `${ef.stroke.width / coefficient}px ${ef.stroke.color}` : '',
|
||||
textShadow: ef.shadow && ef.shadow.enable ? `${ef.shadow.offsetX / coefficient}px ${ef.shadow.offsetY / coefficient}px ${ef.shadow.blur / coefficient}px ${ef.shadow.color}` : undefined,
|
||||
backgroundImage: ef.filling && ef.filling.enable ? (ef.filling.type === 0 ? undefined : getGradientOrImg(ef)) : undefined,
|
||||
webkitBackgroundClip: ef.filling && ef.filling.enable ? (ef.filling.type === 0 ? undefined : 'text') : undefined,
|
||||
WebkitBackgroundClip: ef.filling && ef.filling.enable ? (ef.filling.type === 0 ? undefined : 'text') : undefined,
|
||||
}"
|
||||
class="demo"
|
||||
>
|
||||
@ -117,7 +117,9 @@ import numberInput from '../numberInput.vue'
|
||||
import draggable from 'vuedraggable'
|
||||
import api from '@/api'
|
||||
import getGradientOrImg from '../../widgets/wText/getGradientOrImg'
|
||||
let froze_font_effect_list: Record<string, any>[] = []
|
||||
import { TGetCompListResult } from '@/api/home'
|
||||
|
||||
let froze_font_effect_list: TGetCompListResult[] = []
|
||||
|
||||
type TProps = {
|
||||
modelValue?: Record<string, any>
|
||||
@ -132,7 +134,7 @@ type TEmits = {
|
||||
type TState = {
|
||||
strength: number
|
||||
visiable: boolean
|
||||
list: Record<string,any>[]
|
||||
list: TGetCompListResult[]
|
||||
layers: Record<string, any>[]
|
||||
draging: boolean
|
||||
unfold: boolean
|
||||
|
@ -28,7 +28,7 @@ export const font2style = async (fontContent: any, fontData: any = []) => {
|
||||
}
|
||||
try {
|
||||
const result = await api.material.getFontSub(params, extra)
|
||||
fontContent[key] = font.oid ? result : await blob2Base64(result)
|
||||
fontContent[key] = font.oid ? result : await blob2Base64(result as Blob)
|
||||
} catch (e) {
|
||||
console.log('字体获取失败', e)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user