fix: mask image load

This commit is contained in:
PengXiaoPeng 2023-07-23 23:57:16 +08:00
parent 5546174bc0
commit 1248258537
2 changed files with 7 additions and 6 deletions

View File

@ -35,5 +35,3 @@ export const getWorks = (params: Type.Object = {}) => fetch('design/poster', par
// 作品列表
export const getMyDesign = (params: Type.Object = {}) => fetch('design/my', params, 'get')
export const test = (params: Type.Object = {}) => fetch('https://res.palxp.com/api/upload', params, 'post')

View File

@ -48,7 +48,6 @@ export default defineComponent({
const { data } = await api.home[id ? 'getWorks' : 'getTempDetail']({ id: id || tempid })
const content = JSON.parse(data)
content.page.backgroundImage && content.page.backgroundImage.split('.')[1] === 'palxp' && (content.page.backgroundImage += '@small')
this.$store.commit('setDPage', content.page)
id ? this.$store.commit('setDWidgets', content.widgets) : this.setTemplate(content.widgets)
await this.$nextTick()
@ -75,7 +74,7 @@ export default defineComponent({
if (item.imgUrl && !item.isNinePatch) {
const cNodes: any = (window as any).document.getElementById(item.uuid).childNodes
for (const el of cNodes) {
if (el.className === 'img__box') {
if (el.className && el.className.includes('img__box')) {
imgsData.push(el.firstChild)
}
}
@ -85,7 +84,11 @@ export default defineComponent({
}
} catch (e) {}
})
// TODO:
if (content.page.backgroundImage) {
const preloadBg = new Preload([content.page.backgroundImage])
await preloadBg.imgs()
}
try {
const { list } = await api.material.getFonts({ ids: fontData.map((x: any) => x.id) })
fontData.forEach((item: any) => {
@ -124,7 +127,7 @@ export default defineComponent({
async font2style(fontContent: any, fontData: any = []) {
return new Promise((resolve: Function) => {
Promise.all(
// ttf
// ttf/otf
Object.keys(fontContent).map(async (key) => {
const font = fontData.find((font: any) => font.value === key) as any
if (font.id) {