mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
✨ 前瞻兑换码查看
This commit is contained in:
@@ -13,65 +13,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>数据请求测试</h1>
|
||||
<div class="btn-list">
|
||||
<v-btn class="test-btn" @click="tryGetList">获取角色列表</v-btn>
|
||||
<v-btn class="test-btn" @click="tryGetDetail">获取角色详情</v-btn>
|
||||
</div>
|
||||
<div class="test-grid">
|
||||
<TuaAvatarBox v-for="avatar in avatarList" :key="avatar.base.id" :model-value="avatar" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
import showSnackbar from "../../components/func/snackbar.js";
|
||||
import TuaAvatarBox from "../../components/userAvatar/tua-avatar-box.vue";
|
||||
import TSUserAvatar from "../../plugins/Sqlite/modules/userAvatar.js";
|
||||
import { useUserStore } from "../../store/modules/user.js";
|
||||
import TGRequest from "../../web/request/TGRequest.js";
|
||||
|
||||
const userStore = useUserStore();
|
||||
const avatarList = ref<TGApp.Game.Avatar.DetailList[]>();
|
||||
|
||||
async function tryGetList(): Promise<void> {
|
||||
const ck = userStore.cookie;
|
||||
if (!userStore.cookie) {
|
||||
showSnackbar({ text: "请先登录!", color: "warn" });
|
||||
return;
|
||||
}
|
||||
const cookie = { account_id: ck!.account_id, cookie_token: ck!.cookie_token };
|
||||
const account = userStore.account;
|
||||
const res = await TGRequest.User.byCookie.getAvatarList(cookie, account.gameUid);
|
||||
if (!Array.isArray(res)) {
|
||||
showSnackbar({ text: `[${res.retcode}] ${res.message}`, color: "error" });
|
||||
return;
|
||||
}
|
||||
console.log(res);
|
||||
showSnackbar({ text: "获取成功!", color: "success" });
|
||||
}
|
||||
|
||||
async function tryGetDetail(): Promise<void> {
|
||||
const ck = userStore.cookie;
|
||||
if (!userStore.cookie) {
|
||||
showSnackbar({ text: "请先登录!", color: "warn" });
|
||||
return;
|
||||
}
|
||||
const cookie = { account_id: ck!.account_id, cookie_token: ck!.cookie_token };
|
||||
const account = userStore.account;
|
||||
const idList = await TSUserAvatar.getAllAvatarId();
|
||||
const res = await TGRequest.User.byCookie.getAvatarDetail(cookie, account.gameUid, idList);
|
||||
if ("retcode" in res) {
|
||||
showSnackbar({ text: `[${res.retcode}] ${res.message}`, color: "error" });
|
||||
return;
|
||||
}
|
||||
console.log(res);
|
||||
showSnackbar({ text: "获取成功!", color: "success" });
|
||||
userStore.propMap = res.property_map;
|
||||
avatarList.value = res.list;
|
||||
}
|
||||
</script>
|
||||
<script lang="ts" setup></script>
|
||||
<style lang="css" scoped>
|
||||
.test-box {
|
||||
display: flex;
|
||||
@@ -127,10 +71,4 @@ async function tryGetDetail(): Promise<void> {
|
||||
.test-4 {
|
||||
background: var(--box-bg-4);
|
||||
}
|
||||
|
||||
.test-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user