Commit 19c0c0a9 authored by xiaoye's avatar xiaoye

fix

parent 9e159479
......@@ -149,6 +149,29 @@
</checkbox-group>
</view>
<br>
<uni-card
id = 'collaborators'
title = '协作者'
:is-full = 'true'
>
<uni-list>
<uni-list-chat
v-for = '(i, v) in tournament.collaborators'
:avatarCircle = 'true'
:clickable = true
:avatar = 'i.avatar'
:title = 'i.username'
:note = "i.id >= 0 ? i.id.toString() : ''"
>
<view>
<view class = 'button'>
<uni-icons type = 'trash'></uni-icons>
</view>
</view>
</uni-list-chat>
</uni-list>
</uni-card>
<br>
<view class = 'button' @click = 'tournament.update()'>
<view>
<span>设置</span>
......@@ -178,7 +201,6 @@
:localdata = 'tournament.rule.range'
></uni-data-select>
<view v-show = "create.rule.select == 'Swiss'">
<!-- <uni-easyinput type = 'number' placeholder = '轮数' v-model = 'create.rule.settings.rounds'/> -->
<uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'create.rule.settings.winScore'/>
<uni-easyinput type = 'number' placeholder = '平局分' v-model = 'create.rule.settings.drawScore'/>
<uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'create.rule.settings.byeScore'/>
......@@ -239,9 +261,9 @@
</template>
<script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import { TournamentFindObject, TournamentCreateObject, ruleSettings } from '../script/type.ts';
import { TournamentFindObject, TournamentCreateObject, ruleSettings, UserObject } from '../script/type.ts';
import Uniapp from '../script/uniapp.ts';
import Tabulator from '../script/post.ts';
import {Tabulator, User} from '../script/post.ts';
import Tournament from '../script/tournament.ts';
import ApiKey from '../script/apikey.ts';
import Mycard from '../script/mycard.ts';
......@@ -400,8 +422,8 @@
tournament.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
}
},
collaborators : [] as Array<number>,
init : (t : Tournament) : void => {
collaborators : [] as Array<UserObject>,
init : async (t : Tournament) : Promise<void> => {
if (!t) return;
tournament.this = t;
tournament.name = t.name;
......@@ -409,7 +431,12 @@
tournament.visibility.select = t.visibility;
tournament.rule.select = t.rule;
tournament.rule.settings = Object.assign({}, t.ruleSettings);
tournament.collaborators = t.collaborators;
let collaborators : Array<UserObject> = [];
for (const id of t.collaborators) {
const i = tournament.collaborators.find(i => i.id == id) ?? await User.Find.Id(id);
if (i) collaborators.push(i);
}
tournament.collaborators = collaborators;
},
clear : () : void => {
tournament.this = undefined;
......@@ -424,11 +451,13 @@
if (tournament.visibility.select == '')
// @ts-ignore
tournament.visibility.select = tournament.this.visibility;
const collaborators = tournament.collaborators.map(user => user.id);
emitter.emit(updateTournament, {
name: tournament.name,
description: tournament.description,
visibility: tournament.visibility.select,
collaborators : tournament.collaborators,
collaborators : collaborators,
rule : tournament.rule.select,
ruleSettings : tournament.rule.settings
} as TournamentCreateObject);
......@@ -483,22 +512,22 @@
});
const test = async () => {
let response = await Tabulator.Tournament.Create(Mycard.token, {
name: "test",
description: "暂无介绍。",
rule: "SingleElimination",
ruleSettings: {
rounds: 0,
winScore: 0,
drawScore: 0,
byeScore: 0,
hasThirdPlaceMatch: true
},
visibility: "Public",
collaborators: [
1
]
});
// let response = await Tabulator.Tournament.Create(Mycard.token, {
// name: "test",
// description: "暂无介绍。",
// rule: "SingleElimination",
// ruleSettings: {
// rounds: 0,
// winScore: 0,
// drawScore: 0,
// byeScore: 0,
// hasThirdPlaceMatch: true
// },
// visibility: "Public",
// collaborators: [
// 1
// ]
// });
// await Tabulator.Tournament.Delete(token, 3);
// await Tabulator.Tournament.FindALL(token, {});
// await Tabulator.Tournament.Update(token, 3, {
......
......@@ -208,7 +208,7 @@
<script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import emitter from '../script/emitter.ts'
import Tabulator from '../script/post.ts';
import {Tabulator, User} from '../script/post.ts';
import Tournament from '../script/tournament.ts';
import Participant from '../script/participant.ts';
import Match from '../script/match.ts';
......
......@@ -19,7 +19,8 @@ import {
ApiKeyFindObject,
AllTournament,
AllParticipant,
AllMatch
AllMatch,
UserObject
} from './type.ts'
class TabulatorAPI {
......@@ -558,6 +559,54 @@ class TabulatorAPI {
}
}
class Users {
url : AxiosInstance;
constructor(url : string) {
this.url = axios.create({
baseURL : url
});
}
Find = {
Name : async (name : string) : Promise<UserObject | undefined> => {
let response : {
data : {
user : UserObject;
};
};
try {
response = await this.url.get(`users/${encodeURIComponent(name)}.json`);
return response.data.user;
}
catch(error) {
console.error(error);
return undefined;
}
},
Id : async (id : number) : Promise<UserObject | undefined> => {
let response : {
data : {
user : UserObject;
};
};
try {
response = await this.url.get(`users/_id_${id}.json`);
return response.data.user;
}
catch(error) {
console.error(error);
return undefined;
}
}
}
}
const User = new Users('https://sapi.moecube.com:444/accounts')
const Tabulator = new TabulatorAPI('https://api-tabulator-dev.moecube.com');
export default Tabulator;
\ No newline at end of file
export {
Tabulator,
User
};
\ No newline at end of file
......@@ -146,6 +146,12 @@ interface AllMatch extends All {
matchs : Array<Match>;
}
interface UserObject {
avatar : string
id : 777668
username : string
}
export {
Score,
TournamentObject,
......@@ -164,5 +170,6 @@ export {
AllTournament,
AllParticipant,
AllMatch,
ruleSettings
ruleSettings,
UserObject
}
\ No newline at end of file
......@@ -45,6 +45,14 @@
width: var(--size);
height: 80%;
overflow-y: auto;
#collaborators {
overflow-y: auto;
overflow-x: auto;
height: 40vh;
:deep(.uni-list-chat) {
width: 200%;
}
}
.button {
border: 1px solid #409eff;
display: grid;
......
......@@ -309,7 +309,7 @@
// }
.uni-list-chat--hover {
background-color: $hover;
// background-color: $hover;
}
.uni-list--border {
......
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