|
@@ -31,7 +31,7 @@
|
|
|
<t-dropdown-item divider="true">
|
|
|
<a @click="downloadJson">下载JSON文件</a>
|
|
|
</t-dropdown-item>
|
|
|
- <!-- <t-dropdown-item>
|
|
|
+ <t-dropdown-item>
|
|
|
<a @click="downloadZip">
|
|
|
<div class="flex">
|
|
|
导出为ZIP文件 <span class="flex-grow"></span>
|
|
@@ -42,7 +42,7 @@
|
|
|
<t-dropdown-item>
|
|
|
<a @click="downloadHtml">
|
|
|
<div class="flex">
|
|
|
- 导出为HTML <span class="flex-grow"></span>
|
|
|
+ 下载离线部署包 <span class="flex-grow"></span>
|
|
|
<span><label>VIP</label></span>
|
|
|
</div>
|
|
|
</a>
|
|
@@ -50,7 +50,7 @@
|
|
|
<t-dropdown-item>
|
|
|
<a @click="downloadVue3">
|
|
|
<div class="flex">
|
|
|
- 导出为Vue3组件 <span class="flex-grow"></span>
|
|
|
+ 下载Vue3组件包 <span class="flex-grow"></span>
|
|
|
<span><label>VIP</label></span>
|
|
|
</div>
|
|
|
</a>
|
|
@@ -58,7 +58,7 @@
|
|
|
<t-dropdown-item>
|
|
|
<a @click="downloadVue2">
|
|
|
<div class="flex">
|
|
|
- 导出为Vue2组件 <span class="flex-grow"></span>
|
|
|
+ 下载Vue2组件包 <span class="flex-grow"></span>
|
|
|
<span><label>VIP</label></span>
|
|
|
</div>
|
|
|
</a>
|
|
@@ -66,11 +66,11 @@
|
|
|
<t-dropdown-item divider="true">
|
|
|
<a @click="downloadReact">
|
|
|
<div class="flex">
|
|
|
- 导出为React组件 <span class="flex-grow"></span>
|
|
|
+ 下载React组件包 <span class="flex-grow"></span>
|
|
|
<span><label>VIP</label></span>
|
|
|
</div>
|
|
|
</a>
|
|
|
- </t-dropdown-item> -->
|
|
|
+ </t-dropdown-item>
|
|
|
<t-dropdown-item>
|
|
|
<a @click="downloadPng">下载为PNG</a>
|
|
|
</t-dropdown-item>
|
|
@@ -458,11 +458,15 @@ const openZip = async (file: File) => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!user.isVip) {
|
|
|
+ // if (!user.isVip) {
|
|
|
+ // gotoAccount();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ if (!user.vip) {
|
|
|
+ MessagePlugin.info('需要开通普通会员~');
|
|
|
gotoAccount();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
const { default: JSZip } = await import('jszip');
|
|
|
const zip = new JSZip();
|
|
|
await zip.loadAsync(file);
|
|
@@ -612,11 +616,15 @@ const downloadZip = async () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!user.isVip) {
|
|
|
+ // if (!user.isVip) {
|
|
|
+ // // gotoAccount();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ if (!user.vip) {
|
|
|
+ MessagePlugin.info('需要开通普通会员~');
|
|
|
gotoAccount();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
|
|
|
const [{ default: JSZip }, { saveAs }] = await Promise.all([
|
|
|
import('jszip'),
|
|
@@ -642,21 +650,59 @@ const downloadZip = async () => {
|
|
|
saveAs(blob, `${_fileName}.zip`);
|
|
|
};
|
|
|
|
|
|
+const zip3D = (name:string) => {
|
|
|
+ const pen_3d = meta2d.store.data.pens.filter(
|
|
|
+ (pen) =>
|
|
|
+ pen.name === 'iframe' &&
|
|
|
+ (pen.tags.includes('meta3d') || pen.iframe.indexOf('3d') !== -1)
|
|
|
+ );
|
|
|
+ if (pen_3d && pen_3d.length) {
|
|
|
+ //存在3d场景
|
|
|
+ pen_3d.forEach((pen) => {
|
|
|
+ //发送消息
|
|
|
+ let params = queryURLParams(pen.iframe.split('?')[1]);
|
|
|
+ (
|
|
|
+ pen.calculative.singleton.div.children[0] as HTMLIFrameElement
|
|
|
+ ).contentWindow.postMessage(
|
|
|
+ JSON.stringify({
|
|
|
+ name,
|
|
|
+ id: params.id,
|
|
|
+ }),
|
|
|
+ '*'
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|
|
|
+function queryURLParams(value?: string) {
|
|
|
+ let url = value || window.location.href.split('?')[1];
|
|
|
+ const urlSearchParams = new URLSearchParams(url);
|
|
|
+ const params = Object.fromEntries(urlSearchParams.entries());
|
|
|
+ return params;
|
|
|
+}
|
|
|
+
|
|
|
const downloadHtml = async () => {
|
|
|
if (!(user && user.id)) {
|
|
|
MessagePlugin.warning(noLoginTip);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!user.isVip) {
|
|
|
+ // if (!user.isVip) {
|
|
|
+ // gotoAccount();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ if(user.vipDesc !== '超级会员'&&user.vipDesc !=='旗舰会员'){
|
|
|
+ MessagePlugin.info('需要开通超级会员~');
|
|
|
gotoAccount();
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
+ frameFlag = -1;
|
|
|
MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
|
|
|
-
|
|
|
+ zip3D('deploy');
|
|
|
const data: Meta2dBackData = meta2d.data();
|
|
|
if (data._id) delete data._id;
|
|
|
+ if (data.id) delete data.id;
|
|
|
+ if (data.image) delete data.image;
|
|
|
checkData(data);
|
|
|
const [{ default: JSZip }, { saveAs }] = await Promise.all([
|
|
|
import('jszip'),
|
|
@@ -709,21 +755,30 @@ const downloadReact = async () => {
|
|
|
downloadAsFrame(Frame.react);
|
|
|
};
|
|
|
|
|
|
+let frameFlag = -1;
|
|
|
+
|
|
|
async function downloadAsFrame(type: Frame) {
|
|
|
if (!(user && user.id)) {
|
|
|
MessagePlugin.warning(noLoginTip);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!user.isVip) {
|
|
|
+ // if (!user.isVip) {
|
|
|
+ // gotoAccount();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ if(user.vipDesc !=='旗舰会员'){
|
|
|
+ MessagePlugin.info('需要开通旗舰会员~');
|
|
|
gotoAccount();
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
+ frameFlag = type;
|
|
|
MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
|
|
|
-
|
|
|
+ zip3D(type===Frame.vue3?'toVue3':(type===Frame.vue2?'toVue2':'toReact'));
|
|
|
const data: Meta2dBackData = meta2d.data();
|
|
|
if (data._id) delete data._id;
|
|
|
+ if (data.id) delete data.id;
|
|
|
+ if (data.image) delete data.image;
|
|
|
checkData(data);
|
|
|
const [{ default: JSZip }, { saveAs }] = await Promise.all([
|
|
|
import('jszip'),
|
|
@@ -735,10 +790,17 @@ async function downloadAsFrame(type: Frame) {
|
|
|
'le5le.meta2d';
|
|
|
const _zip: any = zip.folder(`${_fileName}`);
|
|
|
_zip.file(
|
|
|
- 'data.json',
|
|
|
+ `${
|
|
|
+ type === Frame.vue3
|
|
|
+ ? 'meta2d-vue3'
|
|
|
+ : type === Frame.vue2
|
|
|
+ ? 'meta2d-vue2'
|
|
|
+ : 'meta2d-react'
|
|
|
+ }/public/json/data.json`,
|
|
|
JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
|
|
|
);
|
|
|
await Promise.all([
|
|
|
+ zipJs(_zip),
|
|
|
zipBkImg(_zip),
|
|
|
zipImages(_zip, meta2d.store.data.pens),
|
|
|
type === Frame.vue3
|
|
@@ -749,9 +811,32 @@ async function downloadAsFrame(type: Frame) {
|
|
|
]);
|
|
|
const blob = await zip.generateAsync({ type: 'blob' });
|
|
|
saveAs(blob, `${_fileName}.zip`);
|
|
|
+ frameFlag = -1;
|
|
|
}
|
|
|
|
|
|
-async function zipVue3Files(zip: JSZip) {
|
|
|
+async function zipJs(zip: JSZip) {
|
|
|
+ const files = ['/view/js/marked.min.js', '/view/js/lcjs.iife.js'];
|
|
|
+ await Promise.all(
|
|
|
+ files.map(async (filePath) => {
|
|
|
+ const res: Blob = await axios.get(filePath, {
|
|
|
+ responseType: 'blob',
|
|
|
+ });
|
|
|
+ zip.file(
|
|
|
+ `${
|
|
|
+ frameFlag === Frame.vue3
|
|
|
+ ? 'meta2d-vue3'
|
|
|
+ : frameFlag === Frame.vue2
|
|
|
+ ? 'meta2d-vue2'
|
|
|
+ : 'meta2d-react'
|
|
|
+ }/public` + filePath.replace('/view', ''),
|
|
|
+ res,
|
|
|
+ { createFolders: true }
|
|
|
+ );
|
|
|
+ })
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+async function _zipVue3Files(zip: JSZip) {
|
|
|
const files = [
|
|
|
'/view/js/marked.min.js',
|
|
|
'/view/js/lcjs.iife.js',
|
|
@@ -764,7 +849,23 @@ async function zipVue3Files(zip: JSZip) {
|
|
|
await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
|
|
|
}
|
|
|
|
|
|
-async function zipVue2Files(zip: JSZip) {
|
|
|
+//新
|
|
|
+async function zipVue3Files(zip: JSZip) {
|
|
|
+ const files = [
|
|
|
+ '/view/meta2d-vue3/src/components/Meta2d.vue',
|
|
|
+ '/view/meta2d-vue3/src/App.vue',
|
|
|
+ '/view/meta2d-vue3/src/main.js',
|
|
|
+ '/view/meta2d-vue3/src/style.css',
|
|
|
+ '/view/meta2d-vue3/index.html',
|
|
|
+ '/view/meta2d-vue3/package.json',
|
|
|
+ '/view/meta2d-vue3/README.md',
|
|
|
+ '/view/meta2d-vue3/vite.config.js',
|
|
|
+ ] as const;
|
|
|
+ // 文件同时加载
|
|
|
+ await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
|
|
|
+}
|
|
|
+
|
|
|
+async function _zipVue2Files(zip: JSZip) {
|
|
|
const files = [
|
|
|
'/view/js/marked.min.js',
|
|
|
'/view/js/lcjs.iife.js',
|
|
@@ -777,7 +878,22 @@ async function zipVue2Files(zip: JSZip) {
|
|
|
await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
|
|
|
}
|
|
|
|
|
|
-async function zipReactFiles(zip: JSZip) {
|
|
|
+async function zipVue2Files(zip: JSZip) {
|
|
|
+ const files = [
|
|
|
+ '/view/meta2d-vue2/src/components/Meta2d.vue',
|
|
|
+ '/view/meta2d-vue2/src/App.vue',
|
|
|
+ '/view/meta2d-vue2/src/main.js',
|
|
|
+ // '/view/meta2d-vue2/src/style.css',
|
|
|
+ '/view/meta2d-vue2/public/index.html',
|
|
|
+ '/view/meta2d-vue2/package.json',
|
|
|
+ '/view/meta2d-vue2/README.md',
|
|
|
+ // '/view/meta2d-vue3/vite.config.js',
|
|
|
+ ] as const;
|
|
|
+ // 文件同时加载
|
|
|
+ await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
|
|
|
+}
|
|
|
+
|
|
|
+async function _zipReactFiles(zip: JSZip) {
|
|
|
const files = [
|
|
|
'/view/js/marked.min.js',
|
|
|
'/view/js/lcjs.iife.js',
|
|
@@ -791,6 +907,21 @@ async function zipReactFiles(zip: JSZip) {
|
|
|
await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
|
|
|
}
|
|
|
|
|
|
+async function zipReactFiles(zip: JSZip) {
|
|
|
+ const files = [
|
|
|
+ '/view/meta2d-react/src/index.css',
|
|
|
+ '/view/meta2d-react/src/index.js',
|
|
|
+ '/view/meta2d-react/src/Meta2d.css',
|
|
|
+ '/view/meta2d-react/src/Meta2d.jsx',
|
|
|
+ '/view/meta2d-react/package.json',
|
|
|
+ '/view/meta2d-react/README.md',
|
|
|
+ '/view/meta2d-react/public/index.html',
|
|
|
+
|
|
|
+ ] as const;
|
|
|
+ // 文件同时加载
|
|
|
+ await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
|
|
|
+}
|
|
|
+
|
|
|
async function zipFiles(zip: JSZip) {
|
|
|
const files = [
|
|
|
'/view/js/marked.min.js',
|
|
@@ -860,9 +991,21 @@ async function zipImage(zip: JSZip, image: string) {
|
|
|
isZip: true,
|
|
|
},
|
|
|
});
|
|
|
- zip.file(cdn ? image.replace(cdn, '').replace(upCdn, '') : image, res, {
|
|
|
- createFolders: true,
|
|
|
- });
|
|
|
+ zip.file(
|
|
|
+ (frameFlag === -1
|
|
|
+ ? ''
|
|
|
+ : `${
|
|
|
+ frameFlag === Frame.vue3
|
|
|
+ ? 'meta2d-vue3'
|
|
|
+ : frameFlag === Frame.vue2
|
|
|
+ ? 'meta2d-vue2'
|
|
|
+ : 'meta2d-react'
|
|
|
+ }/public`) + (cdn ? image.replace(cdn, '').replace(upCdn, '') : image),
|
|
|
+ res,
|
|
|
+ {
|
|
|
+ createFolders: true,
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
const downloadImageTips =
|