|
|
|
@ -295,30 +295,64 @@ export class FileServer extends Singleton
|
|
|
|
|
|
|
|
|
|
async Download(fid: string)
|
|
|
|
|
{
|
|
|
|
|
let fileInfo = await this.GetFileInfo(fid);
|
|
|
|
|
const store = TopPanelStore.GetInstance();
|
|
|
|
|
let file = deflate(fileInfo.file);
|
|
|
|
|
if (file)
|
|
|
|
|
FS.WriteFile(fileInfo.name + ".json", btoa(JSON.stringify({ file, id: store.shopId })));
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
const data = await PostJson(FileUrls.detail, { file_id: fid });
|
|
|
|
|
const fileInfo = data.files;
|
|
|
|
|
let file = "";
|
|
|
|
|
let fileName = "";
|
|
|
|
|
if (data.err_code === RequestStatus.Ok && fileInfo)
|
|
|
|
|
{
|
|
|
|
|
const parts = (fileInfo.update_date ?? fileInfo.create_date).split(/[- :]/);
|
|
|
|
|
const time = "-" + parts[0].slice(2) + parts[1] + parts[2] + "_" + parts[3] + parts[4];
|
|
|
|
|
fileName = `${fileInfo.name + time}.json`;
|
|
|
|
|
file = deflate(inflateBase64(fileInfo.file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file && fileName)
|
|
|
|
|
{
|
|
|
|
|
const store = TopPanelStore.GetInstance();
|
|
|
|
|
FS.WriteFile(fileName, btoa(JSON.stringify({ file, id: store.shopId })));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let isContinue = confirm("当前文件下载失败,是否重试?");
|
|
|
|
|
if (!isContinue) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async DownloadTemplate(fid: string)
|
|
|
|
|
{
|
|
|
|
|
let data = await PostJson(TemplateUrls.detail, { module_id: fid });
|
|
|
|
|
let templateInfo: IFileInfo;
|
|
|
|
|
if (data.err_code === RequestStatus.Ok && data.modules)
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
templateInfo = {
|
|
|
|
|
name: data.modules.name,
|
|
|
|
|
file: data.modules.file,
|
|
|
|
|
logo: data.modules.logo,
|
|
|
|
|
props: data.modules.props,
|
|
|
|
|
};
|
|
|
|
|
let data = await PostJson(TemplateUrls.detail, { module_id: fid });
|
|
|
|
|
let templateInfo: IFileInfo = {};
|
|
|
|
|
if (data.err_code === RequestStatus.Ok && data.modules)
|
|
|
|
|
{
|
|
|
|
|
templateInfo = {
|
|
|
|
|
name: data.modules.name,
|
|
|
|
|
file: data.modules.file,
|
|
|
|
|
logo: data.modules.logo,
|
|
|
|
|
props: data.modules.props,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { file, logo, props } = templateInfo;
|
|
|
|
|
if (file && logo && props)
|
|
|
|
|
{
|
|
|
|
|
const store = TopPanelStore.GetInstance();
|
|
|
|
|
FS.WriteFile(templateInfo.name + ".json", btoa(JSON.stringify({ file, id: store.shopId, logo, props, type: "template" })));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let isContinue = confirm("当前文件下载失败,是否重试?");
|
|
|
|
|
if (!isContinue) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const store = TopPanelStore.GetInstance();
|
|
|
|
|
let { file, logo, props } = templateInfo;
|
|
|
|
|
if (file && logo && props)
|
|
|
|
|
FS.WriteFile(templateInfo.name + ".json", btoa(JSON.stringify({ file, id: store.shopId, logo, props, type: "template" })));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private SaveCurrentFileInfo(fileInfo: IFileInfo)
|
|
|
|
|
{
|
|
|
|
|