mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
.
This commit is contained in:
parent
cba825cdbf
commit
82a68319f7
@ -3,20 +3,22 @@
|
||||
* @Date: 2022-03-06 13:53:30
|
||||
* @Description: 计算密集型任务
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2024-04-18 20:02:55
|
||||
* @LastEditTime: 2024-08-20 16:12:54
|
||||
*/
|
||||
export default class WebWorker {
|
||||
private worker: Worker | undefined
|
||||
|
||||
constructor(name: string) {
|
||||
constructor(useWorker: any) {
|
||||
if (typeof Worker === 'undefined') {
|
||||
console.error('Web Worker is not supported in this browser.')
|
||||
} else {
|
||||
const file = name ? `../widgets/${name}.worker.ts` : null
|
||||
file &&
|
||||
(this.worker = new Worker(new URL(file, import.meta.url), {
|
||||
type: 'module',
|
||||
}))
|
||||
// 动态引入无法打包,必须是静态的
|
||||
// const file = name ? `../widgets/${name}.worker.ts` : null
|
||||
// file &&
|
||||
// (this.worker = new Worker(new URL(file, import.meta.url), {
|
||||
// type: 'module',
|
||||
// }))
|
||||
this.worker = new useWorker()
|
||||
}
|
||||
}
|
||||
public start(data?: any, cb?: Function) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Date: 2022-01-10 14:57:53
|
||||
* @Description: Psd文件解析
|
||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||
* @LastEditTime: 2024-08-18 21:06:05
|
||||
* @LastEditTime: 2024-08-20 16:14:18
|
||||
-->
|
||||
<template>
|
||||
<div id="page-design-index" ref="pageDesignIndex">
|
||||
@ -58,7 +58,8 @@ import designBoard from '@/components/modules/layout/designBoard/index.vue'
|
||||
import zoomControl from '@/components/modules/layout/zoomControl/index.vue'
|
||||
import HeaderOptions, { TEmitChangeData } from './components/UploadTemplate.vue'
|
||||
import ProgressLoading from '@/components/common/ProgressLoading/index.vue'
|
||||
import MyWorker from '@/utils/plugins/webWorker'
|
||||
import useWorker from '@/utils/plugins/webWorker'
|
||||
import psdWorker from '../utils/plugins/worker/loadPSD.worker.ts?worker'
|
||||
// import { processPSD2Page } from '@/utils/plugins/psd'
|
||||
import { createBase64 } from '@/utils/plugins/psd'
|
||||
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'
|
||||
@ -97,7 +98,7 @@ const { dZoom } = storeToRefs(useCanvasStore())
|
||||
const zoomControlRef = ref<typeof zoomControl | null>()
|
||||
|
||||
let loading: ReturnType<typeof useLoading> | null = null
|
||||
const myWorker = new MyWorker('loadPSD')
|
||||
const myWorker = new useWorker(psdWorker)
|
||||
|
||||
onMounted(async () => {
|
||||
groupStore.initGroupJson(JSON.stringify(wGroupSetting))
|
||||
|
Loading…
x
Reference in New Issue
Block a user