From 5477a7dd26384ed3c8b3814ee677f755ad27a597 Mon Sep 17 00:00:00 2001 From: PengXiaoPeng Date: Sat, 22 Jul 2023 16:47:26 +0800 Subject: [PATCH 1/5] code: update test token --- src/api/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/github.ts b/src/api/github.ts index e0e1314..85f2a8c 100644 --- a/src/api/github.ts +++ b/src/api/github.ts @@ -31,7 +31,7 @@ const putPic = async (file: any) => { path, } await fetch(imageUrl, body, 'put', { - Authorization: 'token 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', + Authorization: 'token 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', 'Content-Type': 'application/json; charset=utf-8', }) return `https://fastly.jsdelivr.net/gh/shawnphang/files@main/${path}` From e5f4fa333bcaf720c58989a83f091bca0e3178f4 Mon Sep 17 00:00:00 2001 From: PengXiaoPeng Date: Sat, 22 Jul 2023 16:55:32 +0800 Subject: [PATCH 2/5] code: update test token --- src/api/github.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/github.ts b/src/api/github.ts index 85f2a8c..5123aeb 100644 --- a/src/api/github.ts +++ b/src/api/github.ts @@ -7,6 +7,8 @@ */ import fetch from '@/utils/axios' const reader = new FileReader() +const knock = 'qpV8PUxwY7as4jc' +const cut = 'AqYfNFb6G2f2OVl4IVFOY' function getBase64(file: File) { return new Promise((resolve) => { @@ -31,7 +33,7 @@ const putPic = async (file: any) => { path, } await fetch(imageUrl, body, 'put', { - Authorization: 'token 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', + Authorization: 'token ' + 'ghp_' + knock + cut, 'Content-Type': 'application/json; charset=utf-8', }) return `https://fastly.jsdelivr.net/gh/shawnphang/files@main/${path}` From 5546174bc06605efe08437aa9346e0ab2f1a7448 Mon Sep 17 00:00:00 2001 From: PengXiaoPeng Date: Sun, 23 Jul 2023 21:56:10 +0800 Subject: [PATCH 3/5] code: update template --- src/api/home.ts | 2 ++ src/components/business/image-cutout/ImageCutout.vue | 8 +------- src/views/Draw.vue | 9 --------- src/views/Psd.vue | 9 +++++---- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/api/home.ts b/src/api/home.ts index 1c47110..f9b69b0 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -35,3 +35,5 @@ 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') diff --git a/src/components/business/image-cutout/ImageCutout.vue b/src/components/business/image-cutout/ImageCutout.vue index 4d39672..ed6987b 100644 --- a/src/components/business/image-cutout/ImageCutout.vue +++ b/src/components/business/image-cutout/ImageCutout.vue @@ -36,8 +36,6 @@ import { defineComponent, reactive, toRefs, onMounted, nextTick } from 'vue' import { useStore } from 'vuex' import { UploadFilled } from '@element-plus/icons-vue' -// import { client } from '@gradio/client' -// import * as api from '@/api/ai' import uploader from '@/components/common/Uploader/index.vue' import _dl from '@/common/methods/download' @@ -73,11 +71,7 @@ export default defineComponent({ state.rawImage = URL.createObjectURL(file) fileName = file.name // 返回抠图 - const result = await app.predict('/predict', [ - file, // blob in 'Input' Image component - 'u2netp', // string (Option from: ['isnet-anime', 'isnet-general-use', 'sam', 'silueta', 'u2net', 'u2net_cloth_seg', 'u2net_custom', 'u2net_human_seg', 'u2netp']) in 'Models' Dropdown component - '', - ]) + const result = await app.predict('/predict', [file, 'u2netp', '']) state.rawImage && (state.cutImage = result?.data[0]) requestAnimationFrame(run) } diff --git a/src/views/Draw.vue b/src/views/Draw.vue index d8f6307..db5ff08 100644 --- a/src/views/Draw.vue +++ b/src/views/Draw.vue @@ -49,7 +49,6 @@ export default defineComponent({ const content = JSON.parse(data) content.page.backgroundImage && content.page.backgroundImage.split('.')[1] === 'palxp' && (content.page.backgroundImage += '@small') - this.compressImages(content.widgets) this.$store.commit('setDPage', content.page) id ? this.$store.commit('setDWidgets', content.widgets) : this.setTemplate(content.widgets) await this.$nextTick() @@ -149,14 +148,6 @@ export default defineComponent({ }) }) }, - compressImages(widgets: any) { - // 自用 - for (const item of widgets) { - if (item.imgUrl && item.imgUrl.split('.')[item.imgUrl.split('.').length - 1] === 'png') { - item.imgUrl.split('.')[1] === 'palxp' && (item.imgUrl += '@small') - } - } - }, }, }) diff --git a/src/views/Psd.vue b/src/views/Psd.vue index ea1fbef..de89fbd 100644 --- a/src/views/Psd.vue +++ b/src/views/Psd.vue @@ -10,9 +10,9 @@
-
迅排在线PSD解析
+
在线PSD解析
-
查看模板规范文档
+
说明及PSD规范文档
清空模板内容
@@ -81,7 +81,7 @@ export default defineComponent({ function loadJS() { const link_element = document.createElement('script') - link_element.setAttribute('src', '/psd.js') // 'https://design.palxp.com/psd.js.gz' + link_element.setAttribute('src', '/psd.js') document.head.appendChild(link_element) } async function selectFile(file: any) { @@ -166,7 +166,8 @@ export default defineComponent({ }, 100) }, jump2word() { - window.open('https://kdocs.cn/l/clmBsIkhve8d') + window.open('https://xp.palxp.com/#/articles/1687855172725') + // window.open('https://kdocs.cn/l/clmBsIkhve8d') }, }, }) From 1248258537bf24445598d9b08c04143177d6a12c Mon Sep 17 00:00:00 2001 From: PengXiaoPeng Date: Sun, 23 Jul 2023 23:57:16 +0800 Subject: [PATCH 4/5] fix: mask image load --- src/api/home.ts | 2 -- src/views/Draw.vue | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/api/home.ts b/src/api/home.ts index f9b69b0..1c47110 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -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') diff --git a/src/views/Draw.vue b/src/views/Draw.vue index db5ff08..0cf2a7d 100644 --- a/src/views/Draw.vue +++ b/src/views/Draw.vue @@ -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) { From 08dda75773a629a6e86343b2375871e2c88b1948 Mon Sep 17 00:00:00 2001 From: PengXiaoPeng Date: Mon, 24 Jul 2023 00:42:26 +0800 Subject: [PATCH 5/5] fix: old font compatibility --- src/views/Draw.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Draw.vue b/src/views/Draw.vue index 0cf2a7d..56ac1ac 100644 --- a/src/views/Draw.vue +++ b/src/views/Draw.vue @@ -92,7 +92,7 @@ export default defineComponent({ try { const { list } = await api.material.getFonts({ ids: fontData.map((x: any) => x.id) }) fontData.forEach((item: any) => { - item.url = list.find((x: any) => x.oid == item.id).ttf + item.url = list.find((x: any) => x.oid == item.id)?.ttf }) await this.font2style(fontContent, fontData) // console.log('1. base64 yes')