Commit c56babd6 authored by xiaoye's avatar xiaoye

fix

parent e8af23d3
...@@ -25,11 +25,14 @@ ...@@ -25,11 +25,14 @@
"@dcloudio/uni-quickapp-webview": "3.0.0-4040520250104002", "@dcloudio/uni-quickapp-webview": "3.0.0-4040520250104002",
"@types/sql.js": "^1.4.9", "@types/sql.js": "^1.4.9",
"axios": "^1.8.4", "axios": "^1.8.4",
"js-base64": "^3.7.7",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"mitt": "^3.0.1", "mitt": "^3.0.1",
"sql.js": "^1.13.0",
"vite-plugin-vue-setup-extend": "^0.4.0", "vite-plugin-vue-setup-extend": "^0.4.0",
"vue": "^3.4.21", "vue": "^3.4.21",
"vue-i18n": "^9.1.9" "vue-i18n": "^9.1.9",
"ygopro-deck-encode": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"@dcloudio/types": "^3.4.8", "@dcloudio/types": "^3.4.8",
...@@ -8196,6 +8199,11 @@ ...@@ -8196,6 +8199,11 @@
"resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.3.7.tgz", "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.3.7.tgz",
"integrity": "sha512-9IXdWudL61npZjvLuVe/ktHiA41iE8qFyLB+4VDTblEsWBzeg8WQTlktdUK4CdncUqtUgUg0bbOmTE2bKBKaBQ==" "integrity": "sha512-9IXdWudL61npZjvLuVe/ktHiA41iE8qFyLB+4VDTblEsWBzeg8WQTlktdUK4CdncUqtUgUg0bbOmTE2bKBKaBQ=="
}, },
"node_modules/js-base64": {
"version": "3.7.7",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.7.tgz",
"integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw=="
},
"node_modules/js-tokens": { "node_modules/js-tokens": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
...@@ -10328,6 +10336,11 @@ ...@@ -10328,6 +10336,11 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/sql.js": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.13.0.tgz",
"integrity": "sha512-RJbVP1HRDlUUXahJ7VMTcu9Rm1Nzw+EBpoPr94vnbD4LwR715F3CcxE2G2k45PewcaZ57pjetYa+LoSJLAASgA=="
},
"node_modules/stack-utils": { "node_modules/stack-utils": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz",
...@@ -11596,6 +11609,11 @@ ...@@ -11596,6 +11609,11 @@
"engines": { "engines": {
"node": ">=10" "node": ">=10"
} }
},
"node_modules/ygopro-deck-encode": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/ygopro-deck-encode/-/ygopro-deck-encode-1.0.7.tgz",
"integrity": "sha512-SGlANLsPb9OOY+0ojlt6LtajnL/MFxMHs9sglYxICm6ju0D91M46J6CaxH0DfjmwYWmg5u3sk/TdCvU3MGSBVA=="
} }
} }
} }
...@@ -83,12 +83,7 @@ ...@@ -83,12 +83,7 @@
import {Tabulator, User} from '../script/post.ts'; import {Tabulator, User} from '../script/post.ts';
import Mycard from '../script/mycard.ts'; import Mycard from '../script/mycard.ts';
import emitter from '../script/emitter.ts' import emitter from '../script/emitter.ts'
import { import Const from '../script/const.ts'
updateTournament ,
tournamentInfo,
tournamentReload,
createOff
} from '../script/const.ts'
let create = reactive({ let create = reactive({
name : '', name : '',
...@@ -139,7 +134,7 @@ ...@@ -139,7 +134,7 @@
collaborators: collaborators collaborators: collaborators
}) })
) { ) {
emitter.emit(createOff); emitter.emit(Const.createOff);
create.clear(); create.clear();
} }
}, },
......
...@@ -240,6 +240,7 @@ ...@@ -240,6 +240,7 @@
pageSize = 20 pageSize = 20
:total = 'search.result.total' :total = 'search.result.total'
v-show = 'page.menu' v-show = 'page.menu'
@change = 'search.on()'
> >
</uni-pagination> </uni-pagination>
</transition> </transition>
...@@ -259,12 +260,7 @@ ...@@ -259,12 +260,7 @@
import ApiKey from '../script/apikey.ts'; import ApiKey from '../script/apikey.ts';
import Mycard from '../script/mycard.ts'; import Mycard from '../script/mycard.ts';
import emitter from '../script/emitter.ts' import emitter from '../script/emitter.ts'
import { import Const from '../script/const.ts'
updateTournament ,
tournamentInfo,
tournamentReload,
createOff
} from '../script/const.ts'
import PageTournament from './tournament.vue'; import PageTournament from './tournament.vue';
import Create from './drawer.vue'; import Create from './drawer.vue';
...@@ -448,7 +444,7 @@ ...@@ -448,7 +444,7 @@
tournament.visibility.select = tournament.this.visibility; tournament.visibility.select = tournament.this.visibility;
const collaborators = tournament.collaborators.map(user => user.id); const collaborators = tournament.collaborators.map(user => user.id);
emitter.emit(updateTournament, { emitter.emit(Const.updateTournament, {
name: tournament.name, name: tournament.name,
description: tournament.description, description: tournament.description,
visibility: tournament.visibility.select, visibility: tournament.visibility.select,
...@@ -488,15 +484,8 @@ ...@@ -488,15 +484,8 @@
page.show.drawer(); page.show.drawer();
if (page.tournament) if (page.tournament)
page.show.menu(); page.show.menu();
await search.on({ search.mine();
pageCount : 1, await search.on();
id : 0,
creator : Mycard.id >= 0 ? Mycard.id : 0,
name : '',
rule : '',
visibility : '',
status : ''
} as TournamentFindObject);
} }
}; };
...@@ -513,10 +502,10 @@ ...@@ -513,10 +502,10 @@
onBeforeMount(() : void => { onBeforeMount(() : void => {
Uniapp.chkScreen(size.get); Uniapp.chkScreen(size.get);
document.addEventListener("click", page.show.clear); document.addEventListener("click", page.show.clear);
emitter.on(tournamentInfo, page.show.drawer); emitter.on(Const.tournamentInfo, page.show.drawer);
// @ts-ignore // @ts-ignore
emitter.on(tournamentReload, tournament.init); emitter.on(tournamentReload, tournament.init);
emitter.on(createOff, creator.off); emitter.on(Const.createOff, creator.off);
const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/); const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/);
if (url && !isNaN(parseInt(url[1]))) { if (url && !isNaN(parseInt(url[1]))) {
...@@ -534,10 +523,10 @@ ...@@ -534,10 +523,10 @@
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("click", page.show.clear); document.removeEventListener("click", page.show.clear);
emitter.off(tournamentInfo, page.show.drawer); emitter.off(Const.tournamentInfo, page.show.drawer);
// @ts-ignore // @ts-ignore
emitter.off(tournamentReload, tournament.init); emitter.off(tournamentReload, tournament.init);
emitter.off(createOff, creator.off); emitter.off(Const.createOff, creator.off);
}); });
watch(() => { return search.date; }, () => { watch(() => { return search.date; }, () => {
......
This diff is collapsed.
const updateTournament = 'updateTournament'; class ConstData {
maxSize = 1024 * 10;
updateTournament = 'updateTournament';
tournamentInfo = 'tournamentInfo';
tournamentReload = 'tournamentReload';
createOff = 'createOff';
}
const tournamentInfo = 'tournamentInfo'; const Const = new ConstData();
const tournamentReload = 'tournamentReload';
const createOff = 'createOff'; export default Const;
export { \ No newline at end of file
updateTournament ,
tournamentInfo,
tournamentReload,
createOff
};
\ No newline at end of file
import { Score, ParticipantObject } from './type.ts'; import { Score, ParticipantObject, Deck } from './type.ts';
import YGOProDeck from 'ygopro-deck-encode';
import { Base64 } from 'js-base64';
class Participant { class Participant {
id : number; id : number;
...@@ -7,6 +9,7 @@ class Participant { ...@@ -7,6 +9,7 @@ class Participant {
tournamentId : number; tournamentId : number;
score : Score; score : Score;
deckbuf : string; deckbuf : string;
deck : YGOProDeck | undefined;
constructor(obj: ParticipantObject) { constructor(obj: ParticipantObject) {
this.name = obj.name; this.name = obj.name;
...@@ -15,6 +18,22 @@ class Participant { ...@@ -15,6 +18,22 @@ class Participant {
this.score = obj.score; this.score = obj.score;
this.deckbuf = obj.deckbuf ?? ''; this.deckbuf = obj.deckbuf ?? '';
this.quit = obj.quit ?? false; this.quit = obj.quit ?? false;
if (obj.deckbuf)
this.deck = YGOProDeck.fromUpdateDeckPayload(Base64.toUint8Array(this.deckbuf));
}
updateDeck = (ydk : string) : void => {
this.deck = YGOProDeck.fromYdkString(ydk);
this.deckbuf = Base64.fromUint8Array(this.deck.toUpdateDeckPayload());
this.deck.main = [...this.deck.main, ...this.deck.extra]
}
getDeck = () : Deck => {
return {
main : this.deck?.main ?? [],
extra : this.deck?.extra ?? [],
side : this.deck?.side ?? [],
};
} }
} }
......
...@@ -23,6 +23,7 @@ import { ...@@ -23,6 +23,7 @@ import {
UserObject, UserObject,
TournamentAParticipant TournamentAParticipant
} from './type.ts' } from './type.ts'
import UniApp from './uniapp.ts';
class TabulatorAPI { class TabulatorAPI {
url : AxiosInstance; url : AxiosInstance;
...@@ -129,7 +130,7 @@ class TabulatorAPI { ...@@ -129,7 +130,7 @@ class TabulatorAPI {
recordsPerPage : 20, recordsPerPage : 20,
pageCount : obj.pageCount ?? 1, pageCount : obj.pageCount ?? 1,
id : (obj.id ?? 0) > 0 ? obj.id : undefined, id : (obj.id ?? 0) > 0 ? obj.id : undefined,
creator : filter(obj.creator), managing : filter(obj.creator),
name : filter(obj.name), name : filter(obj.name),
rule : filter(obj.rule), rule : filter(obj.rule),
visibility : filter(obj.visibility), visibility : filter(obj.visibility),
...@@ -234,6 +235,28 @@ class TabulatorAPI { ...@@ -234,6 +235,28 @@ class TabulatorAPI {
return false; return false;
} }
}, },
UpdateYdk : async (token : string, id : number, res : UniApp.ChooseFileSuccessCallbackResult) : Promise<Boolean> => {
let response : {
data : string
};
try {
// @ts-ignore
const files : Array<UniApp.UploadFileOptionFiles> = res.tempFiles.map(file => ({
name: 'files',
uri: file.path,
type: file.type
}));
response = await UniApp.uploadFile(
`${this.url.defaults.baseURL}/api/tournament/${id}/upload-ydk`, files, { 'x-user-token' : token }
)
const data = JSON.parse(response.data)
return data.success;
}
catch(error) {
console.error(error);
return false;
}
}
} }
Participant = { Participant = {
Create : async (token : string, Data : ParticipantCreateObject, Array : Array<Participant> = []) : Promise<boolean> => { Create : async (token : string, Data : ParticipantCreateObject, Array : Array<Participant> = []) : Promise<boolean> => {
...@@ -612,8 +635,7 @@ class Users { ...@@ -612,8 +635,7 @@ class Users {
return undefined; return undefined;
} }
} }
} }
} }
const User = new Users('https://sapi.moecube.com:444/accounts') const User = new Users('https://sapi.moecube.com:444/accounts')
......
...@@ -158,6 +158,12 @@ interface UserObject { ...@@ -158,6 +158,12 @@ interface UserObject {
username : string username : string
} }
interface Deck {
main : Array<number>;
extra : Array<number>;
side : Array<number>;
}
export { export {
Score, Score,
TournamentObject, TournamentObject,
...@@ -178,5 +184,6 @@ export { ...@@ -178,5 +184,6 @@ export {
AllMatch, AllMatch,
ruleSettings, ruleSettings,
UserObject, UserObject,
TournamentAParticipant TournamentAParticipant,
Deck
} }
\ No newline at end of file
class UniappFuncs { class UniappFuncs {
async selectFile (f : Function) : Promise<any> { selectFile (type : Array<string>, f : Function, count : number = 100) : any {
let result; let result;
try { try {
// @ts-ignore // @ts-ignore
uni.chooseFile({ uni.chooseFile({
extension : ['.cdb'], extension : type,
// @ts-ignore count: count,
success : async (res : UniApp.ChooseFileSuccessCallbackResult) => { result = await f(res); } success : async (res : UniApp.ChooseFileSuccessCallbackResult) => { result = await f(res); }
}); });
} catch (err) { } catch (err) {
...@@ -15,6 +15,36 @@ class UniappFuncs { ...@@ -15,6 +15,36 @@ class UniappFuncs {
} }
} }
async uploadFile (url : string, files : Array<UniApp.UploadFileOptionFiles>, header : object) : Promise<any> {
return uni.uploadFile({
url : url,
files : files,
header : header,
});
}
async readFile (file) : Promise<string> {
if (typeof window !== 'undefined' && window.FileReader) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
// @ts-ignore
reader.onload = (e) => resolve(e.target.result as string);
reader.onerror = reject;
reader.readAsText(file);
});
} else {
return new Promise((resolve, reject) => {
// @ts-ignore
uni.readFile({
filePath: file.path,
encoding: 'utf-8',
success: (res) => resolve(res.data),
fail: reject
});
});
}
}
chkScreen (chk : Function) : void { chkScreen (chk : Function) : void {
chk(); chk();
// #ifdef H5 // #ifdef H5
...@@ -41,6 +71,6 @@ class UniappFuncs { ...@@ -41,6 +71,6 @@ class UniappFuncs {
} }
} }
const Uniapp = new UniappFuncs() const UniApp = new UniappFuncs()
export default Uniapp; export default UniApp;
\ No newline at end of file \ No newline at end of file
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
} }
#body { #body {
position: relative;
width: 80%; width: 80%;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
...@@ -59,6 +58,12 @@ ...@@ -59,6 +58,12 @@
} }
} }
#footer { #footer {
display: flex;
justify-content: center;
justify-items: center;
align-items: center;
column-gap: 10%;
width: 10%;
.button { .button {
border: 0.5px solid var(--color); border: 0.5px solid var(--color);
width: auto; width: auto;
...@@ -74,9 +79,7 @@ ...@@ -74,9 +79,7 @@
.match { .match {
border: 1px solid gray; border: 1px solid gray;
position: absolute;
z-index: 1; z-index: 1;
top : var(--top);
// left : 100%; // left : 100%;
width: 100%; width: 100%;
background-color: white; background-color: white;
......
...@@ -47,4 +47,21 @@ ...@@ -47,4 +47,21 @@
&-leave-from { &-leave-from {
transform: translateX(0%); transform: translateX(0%);
} }
}
.move_up {
&-enter-active,
&-leave-active {
transition: transform 0.5s ease;
}
&-enter-from,
&-leave-to {
transform: translateY(-200%);
}
&-enter-to,
&-leave-from {
transform: translateY(0%);
}
} }
\ No newline at end of file
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