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
|
* @Author: ShawnPhang
|
||||||
* @Date: 2022-02-22 15:06:14
|
* @Date: 2022-02-22 15:06:14
|
||||||
* @Description: 设置图片类型元素
|
* @Description: 设置图片类型元素
|
||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>, Jeremy Yu <https://github.com/JeremyYu-cn>
|
||||||
* @LastEditTime: 2024-01-11 17:36:44
|
* @LastEditTime: 2024-03-01 20:55:51
|
||||||
*/
|
*/
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { getImage } from '../getImgDetail'
|
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 cloneItem = JSON.parse(JSON.stringify(item))
|
||||||
const { width: screenWidth, height: screenHeight } = store.getters.dPage
|
const { width: screenWidth, height: screenHeight } = store.getters.dPage
|
||||||
let { width: imgWidth, height: imgHeight } = item
|
let { width: imgWidth, height: imgHeight } = item
|
||||||
if (!imgWidth || !imgHeight) {
|
if (!imgWidth || !imgHeight) {
|
||||||
const actual: any = await getImage(item.url)
|
const actual = await getImage(item.url)
|
||||||
cloneItem.width = imgWidth = actual.width
|
cloneItem.width = imgWidth = actual.width
|
||||||
cloneItem.height = imgHeight = actual.height
|
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 wText from '@/components/modules/widgets/wText/wText.vue'
|
||||||
import wImage from '@/components/modules/widgets/wImage/wImage.vue'
|
import wImage from '@/components/modules/widgets/wImage/wImage.vue'
|
||||||
import wSvg from '@/components/modules/widgets/wSvg/wSvg.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
|
let setting = data
|
||||||
if (type === 'text') {
|
if (type === 'text') {
|
||||||
!item.fontFamily && !item.color ? (setting = JSON.parse(JSON.stringify(wText.setting))) : (setting = item)
|
!item.fontFamily && !item.color ? (setting = JSON.parse(JSON.stringify(wText.setting))) : (setting = item)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2023-10-09 10:42:54
|
* @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()
|
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
|
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