mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
feat: add design features type
This commit is contained in:
parent
0d59f5c58f
commit
7ab19a6294
@ -2,17 +2,25 @@
|
||||
* @Author: ShawnPhang
|
||||
* @Date: 2022-02-22 15:06:14
|
||||
* @Description: 设置图片类型元素
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2024-01-11 17:36:44
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>, Jeremy Yu <https://github.com/JeremyYu-cn>
|
||||
* @LastEditTime: 2024-03-01 20:55:51
|
||||
*/
|
||||
import store from '@/store'
|
||||
import { getImage } from '../getImgDetail'
|
||||
export default async function setItem2Data(item: any) {
|
||||
|
||||
export type TItem2DataParam = {
|
||||
width: number
|
||||
height: number
|
||||
url: string
|
||||
model?: string
|
||||
}
|
||||
|
||||
export default async function setItem2Data(item: TItem2DataParam) {
|
||||
const cloneItem = JSON.parse(JSON.stringify(item))
|
||||
const { width: screenWidth, height: screenHeight } = store.getters.dPage
|
||||
let { width: imgWidth, height: imgHeight } = item
|
||||
if (!imgWidth || !imgHeight) {
|
||||
const actual: any = await getImage(item.url)
|
||||
const actual = await getImage(item.url)
|
||||
cloneItem.width = imgWidth = actual.width
|
||||
cloneItem.height = imgHeight = actual.height
|
||||
}
|
||||
|
@ -11,7 +11,8 @@ import setImageData from '@/common/methods/DesignFeatures/setImage'
|
||||
import wText from '@/components/modules/widgets/wText/wText.vue'
|
||||
import wImage from '@/components/modules/widgets/wImage/wImage.vue'
|
||||
import wSvg from '@/components/modules/widgets/wSvg/wSvg.vue'
|
||||
export default async function(type: string, item: any, data: any) {
|
||||
|
||||
export default async function(type: string, item: TCommonItemData, data: Record<string, any>) {
|
||||
let setting = data
|
||||
if (type === 'text') {
|
||||
!item.fontFamily && !item.color ? (setting = JSON.parse(JSON.stringify(wText.setting))) : (setting = item)
|
||||
|
@ -5,7 +5,7 @@
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2023-10-09 10:42:54
|
||||
*/
|
||||
export const getImage = (imgItem: string | File) => {
|
||||
export const getImage = (imgItem: string | File): Promise<HTMLImageElement> => {
|
||||
// 创建对象
|
||||
const img = new Image()
|
||||
|
||||
|
10
src/types/global.d.ts
vendored
10
src/types/global.d.ts
vendored
@ -7,3 +7,13 @@ type TCommResResult<T> = {
|
||||
result: T
|
||||
}
|
||||
|
||||
|
||||
|
||||
type TCommonItemData = {
|
||||
fontFamily?: string
|
||||
color?: string
|
||||
fontSize: number
|
||||
width?: number
|
||||
fontWeight: number
|
||||
value: TItem2DataParam
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user