Commit 19c0c0a9 authored by xiaoye's avatar xiaoye

fix

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