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 @@ ...@@ -8348,6 +8348,7 @@
"version": "3.10.1", "version": "3.10.1",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
"integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==",
"license": "(MIT OR GPL-3.0-or-later)",
"dependencies": { "dependencies": {
"lie": "~3.3.0", "lie": "~3.3.0",
"pako": "~1.0.2", "pako": "~1.0.2",
......
...@@ -104,8 +104,8 @@ ...@@ -104,8 +104,8 @@
deck.blob = undefined; deck.blob = undefined;
url.custom = ''; url.custom = '';
}, },
clickClear : (e) : void => { clickClear : (e : MouseEvent) : void => {
let element = e.target; let element : HTMLElement | null = e.target as HTMLElement;
while (element) { while (element) {
if (['deckbutton'].includes(element.id) || element.classList.contains('Pics')) if (['deckbutton'].includes(element.id) || element.classList.contains('Pics'))
return undefined; return undefined;
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
deck.off(); deck.off();
}, },
download : () : void => { download : () : void => {
Download.start(deck.blob, `${deck.participant?.name}`); Download.start(deck.blob, `${deck.participant?.name}`, '.ydk');
} }
}); });
......
...@@ -89,6 +89,14 @@ ...@@ -89,6 +89,14 @@
> >
新建单淘赛 新建单淘赛
</view> </view>
<view
class = 'button'
id = 'decks'
@click = 'tournament.decks'
v-show = 'tournament.operatorChk()'
>
导出卡组
</view>
</div> </div>
</view> </view>
<view> <view>
...@@ -360,10 +368,12 @@ ...@@ -360,10 +368,12 @@
import {TournamentCreateObject, MatchUpdateObject, TournamentGet, ParticipantUpdateObject} from '../script/type.ts' import {TournamentCreateObject, MatchUpdateObject, TournamentGet, ParticipantUpdateObject} from '../script/type.ts'
import MatchTree from './matchTree.vue'; import MatchTree from './matchTree.vue';
import svgDeck from './svg/svgDeck.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({ let tournament = reactive({
this : undefined as undefined | Tournament, this : undefined as undefined | Tournament,
decks_loading : false,
status : { status : {
text : new Map([ text : new Map([
['Ready', '准备中'], ['Ready', '准备中'],
...@@ -519,6 +529,30 @@ ...@@ -519,6 +529,30 @@
t : tournament.this, t : tournament.this,
value : participant.copyValue 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 @@ ...@@ -729,8 +763,8 @@
} else } else
UniApp.error('请重试或检查网络设置', '刷新失败'); UniApp.error('请重试或检查网络设置', '刷新失败');
}, },
clickClear : (e) : void => { clickClear : (e : MouseEvent) : void => {
let element = e.target; let element : HTMLElement | null = e.target as HTMLElement;
while (element) { while (element) {
if (['body'].includes(element.id) || element.classList.contains('match')) if (['body'].includes(element.id) || element.classList.contains('match'))
return undefined; return undefined;
......
class DownloadFile { class DownloadFile {
start = async (blob, fileName) => { start = async (blob, fileName, exName) => {
// #ifdef H5 // #ifdef H5
if (window.showSaveFilePicker) { if (window.showSaveFilePicker) {
let opts = { let opts = {
suggestedName: `${fileName}.ydk`, suggestedName: `${fileName}${exName}`,
types: [{ types: [{
description: '', description: '',
accept: { accept: {
'application/octet-stream': ['.ydk'] 'application/octet-stream': [exName]
} }
}], }],
excludeAcceptAllOption: true 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