Commit 468d8419 authored by xiaoye's avatar xiaoye

追加卡组批量导出

parent f91d0f06
Pipeline #41411 passed with stages
in 1 minute and 47 seconds
......@@ -8348,6 +8348,7 @@
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
"integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==",
"license": "(MIT OR GPL-3.0-or-later)",
"dependencies": {
"lie": "~3.3.0",
"pako": "~1.0.2",
......
......@@ -104,8 +104,8 @@
deck.blob = undefined;
url.custom = '';
},
clickClear : (e) : void => {
let element = e.target;
clickClear : (e : MouseEvent) : void => {
let element : HTMLElement | null = e.target as HTMLElement;
while (element) {
if (['deckbutton'].includes(element.id) || element.classList.contains('Pics'))
return undefined;
......@@ -114,7 +114,7 @@
deck.off();
},
download : () : void => {
Download.start(deck.blob, `${deck.participant?.name}`);
Download.start(deck.blob, `${deck.participant?.name}`, '.ydk');
}
});
......
......@@ -89,6 +89,14 @@
>
新建单淘赛
</view>
<view
class = 'button'
id = 'decks'
@click = 'tournament.decks'
v-show = 'tournament.operatorChk()'
>
导出卡组
</view>
</div>
</view>
<view>
......@@ -360,10 +368,12 @@
import {TournamentCreateObject, MatchUpdateObject, TournamentGet, ParticipantUpdateObject} from '../script/type.ts'
import MatchTree from './matchTree.vue';
import svgDeck from './svg/svgDeck.vue';
import svgCards from './svg/svgCards.vue';
import Download from '../script/download.js';
import JSZip from 'jszip';
let tournament = reactive({
this : undefined as undefined | Tournament,
decks_loading : false,
status : {
text : new Map([
['Ready', '准备中'],
......@@ -519,6 +529,30 @@
t : tournament.this,
value : participant.copyValue
});
},
decks : async () : Promise<void> => {
if (!tournament.this || tournament.decks_loading) return;
tournament.decks_loading = true;
try {
const zip = new JSZip();
for (const i of participant.array) {
if (!i.deck) continue;
console.log(i.deck.toYdkString())
const blob = new Blob([i.deck.toYdkString()], { type: 'text/plain;charset=utf-8' });
zip.file(`${i.qq ? i.qq.toString() + '-' : ''}${i.name}.ydk`, blob);
}
const content = await zip.generateAsync({
type: "blob",
compressionOptions: {
level: 9
}
});
Download.start(content, `${tournament.this.name}`, '.zip');
} catch (e) {
console.error(e)
} finally {
tournament.decks_loading = false;
}
}
});
......@@ -729,8 +763,8 @@
} else
UniApp.error('请重试或检查网络设置', '刷新失败');
},
clickClear : (e) : void => {
let element = e.target;
clickClear : (e : MouseEvent) : void => {
let element : HTMLElement | null = e.target as HTMLElement;
while (element) {
if (['body'].includes(element.id) || element.classList.contains('match'))
return undefined;
......
class DownloadFile {
start = async (blob, fileName) => {
start = async (blob, fileName, exName) => {
// #ifdef H5
if (window.showSaveFilePicker) {
let opts = {
suggestedName: `${fileName}.ydk`,
suggestedName: `${fileName}${exName}`,
types: [{
description: '',
accept: {
'application/octet-stream': ['.ydk']
'application/octet-stream': [exName]
}
}],
excludeAcceptAllOption: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment