mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-25 05:29:45 +08:00
💄 调整实用脚本UI,显示用户米游币数量
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
<!-- 米游币任务 -->
|
||||
<template>
|
||||
<div class="tusm-box">
|
||||
<div class="tusm-top">
|
||||
<div class="tusm-title">米游币任务({{ todayPoints }}/{{ totalPoints }})</div>
|
||||
<div class="tusm-acts">
|
||||
<span>{{ cancelLike ? "点赞后取消" : "点赞后不取消" }}</span>
|
||||
<v-switch v-model="cancelLike" class="tusm-switch" color="var(--tgc-od-red)" />
|
||||
<v-btn :loading="loadState" class="tusm-btn" @click="tryRefresh()">刷新</v-btn>
|
||||
<v-btn :loading="loadMission" class="tusm-btn" @click="tryAuto()">执行</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tusm-mid">
|
||||
<div class="tusm-total">
|
||||
<span>持有米游币:</span>
|
||||
<span>{{ userPoints }}</span>
|
||||
</div>
|
||||
<div class="tusm-switch-box">
|
||||
<span>{{ cancelLike ? "点赞后取消" : "直接点赞" }}</span>
|
||||
<v-switch v-model="cancelLike" class="tusm-switch" color="var(--tgc-od-red)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="tusm-content">
|
||||
<div v-for="mission in parseMissions" :key="mission.id" class="mission-item">
|
||||
<div class="left">
|
||||
@@ -44,14 +53,23 @@ import TGLogger from "@utils/TGLogger.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref, shallowRef, watch } from "vue";
|
||||
|
||||
/** 用于渲染的任务项 */
|
||||
type ParseMission = {
|
||||
/** 任务ID */
|
||||
id: number;
|
||||
/** 任务Key */
|
||||
key: string;
|
||||
/** 任务名称 */
|
||||
name: string;
|
||||
/** 任务进度 */
|
||||
process: number;
|
||||
/** 任务总进度 */
|
||||
total: number;
|
||||
/** 是否完成任务 */
|
||||
status: boolean;
|
||||
/** 米游币奖励 */
|
||||
reward: number;
|
||||
/** 完成次数 */
|
||||
cycleTimes?: number;
|
||||
};
|
||||
|
||||
@@ -62,6 +80,7 @@ const loadScript = defineModel<boolean>();
|
||||
|
||||
const todayPoints = ref<number>(0);
|
||||
const totalPoints = ref<number>(0);
|
||||
const userPoints = ref<number>(0);
|
||||
const loadState = ref<boolean>(false);
|
||||
const loadMission = ref<boolean>(false);
|
||||
const parseMissions = shallowRef<Array<ParseMission>>([]);
|
||||
@@ -74,6 +93,7 @@ watch(
|
||||
() => {
|
||||
todayPoints.value = 0;
|
||||
totalPoints.value = 0;
|
||||
userPoints.value = 0;
|
||||
parseMissions.value = [];
|
||||
missionList.value = [];
|
||||
},
|
||||
@@ -247,6 +267,7 @@ async function refreshState(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
if (missionList.value.length === 0) {
|
||||
await TGLogger.Script("[米游币任务]未检测到任务列表,正在获取");
|
||||
const listResp = await apiHubReq.mission.list(ckState);
|
||||
console.log("米游币任务列表", listResp);
|
||||
if (listResp.retcode !== 0) {
|
||||
await TGLogger.Script(
|
||||
`[米游币任务]获取任务列表失败:${listResp.retcode} ${listResp.message}`,
|
||||
@@ -259,6 +280,7 @@ async function refreshState(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
}
|
||||
await TGLogger.Script("[米游币任务]正在获取任务状态");
|
||||
const stateResp = await apiHubReq.mission.state(ckState);
|
||||
console.log("米游币任务状态", stateResp);
|
||||
if (stateResp.retcode !== 0) {
|
||||
await TGLogger.Script(
|
||||
`[米游币任务]获取任务状态失败:${stateResp.retcode} ${stateResp.message}`,
|
||||
@@ -269,6 +291,7 @@ async function refreshState(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
await TGLogger.Script("[米游币任务]获取任务状态成功");
|
||||
todayPoints.value = stateResp.data.already_received_points;
|
||||
totalPoints.value = stateResp.data.today_total_points;
|
||||
userPoints.value = stateResp.data.total_points;
|
||||
await TGLogger.Script("[米游币任务]合并任务数据");
|
||||
mergeMission(missionList.value, stateResp.data.states);
|
||||
await TGLogger.Script("[米游币任务]任务数据合并完成");
|
||||
@@ -288,6 +311,7 @@ async function autoSign(ck: TGApp.App.Account.Cookie, ch?: string): Promise<void
|
||||
const ckSign = { stoken: ck.stoken, stuid: ck.stuid, mid: ck.mid };
|
||||
await painterReq.forum.recent(26, 2, 1, undefined, 20, ckSign);
|
||||
const resp = await apiHubReq.sign(ckSign, 2, ch);
|
||||
console.log("打卡情况", resp);
|
||||
if (resp.retcode !== 0) {
|
||||
if (resp.retcode !== 1034) {
|
||||
await TGLogger.Script(`[米游币任务]打卡失败:${resp.retcode} ${resp.message}`);
|
||||
@@ -318,10 +342,10 @@ async function autoSign(ck: TGApp.App.Account.Cookie, ch?: string): Promise<void
|
||||
border-radius: 4px;
|
||||
background: var(--box-bg-1);
|
||||
color: var(--box-text-1);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tusm-top {
|
||||
.tusm-top,
|
||||
.tusm-mid {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
@@ -340,6 +364,14 @@ async function autoSign(ck: TGApp.App.Account.Cookie, ch?: string): Promise<void
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tusm-switch-box {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
column-gap: 8px;
|
||||
}
|
||||
|
||||
.tusm-switch {
|
||||
display: flex;
|
||||
height: 36px;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<!-- 游戏签到 TODO: 补签 -->
|
||||
<template>
|
||||
<div class="tuss-box">
|
||||
<div class="tuss-top">
|
||||
<div class="tuss-title">签到任务</div>
|
||||
<div class="tuss-acts">
|
||||
<v-btn @click="tryRefresh()" class="tuss-btn" :loading="loadState">刷新</v-btn>
|
||||
<v-btn @click="tryAuto()" class="tuss-btn" :loading="loadSign">执行</v-btn>
|
||||
<v-btn :loading="loadState" class="tuss-btn" @click="tryRefresh()">刷新</v-btn>
|
||||
<v-btn :loading="loadSign" class="tuss-btn" @click="tryAuto()">执行</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tuss-content">
|
||||
<div
|
||||
v-for="(item, idx) in signAccounts"
|
||||
:key="idx"
|
||||
@click="item.selected = !item.selected"
|
||||
:class="{ selected: item.selected }"
|
||||
class="tuss-item"
|
||||
@click="item.selected = !item.selected"
|
||||
>
|
||||
<v-icon v-if="item.selected" color="var(--tgc-od-blue)">
|
||||
mdi-checkbox-marked-outline
|
||||
@@ -23,23 +24,23 @@
|
||||
<div class="tuss-icon">
|
||||
<img :src="item.info.icon" alt="icon" />
|
||||
<div
|
||||
class="delete"
|
||||
v-if="item.account.gameBiz !== 'hk4e_cn'"
|
||||
@click.stop="deleteAccount(item)"
|
||||
class="delete"
|
||||
title="删除账户"
|
||||
@click.stop="deleteAccount(item)"
|
||||
>
|
||||
<v-icon size="12" color="var(--tgc-od-red)">mdi-delete</v-icon>
|
||||
<v-icon color="var(--tgc-od-red)" size="12">mdi-delete</v-icon>
|
||||
</div>
|
||||
</div>
|
||||
<span>{{ item.account.gameUid }} {{ item.account.regionName }}</span>
|
||||
</div>
|
||||
<div class="tuss-stat">
|
||||
<div
|
||||
class="tuss-reward"
|
||||
v-if="item.reward"
|
||||
:title="`${item.reward.name}x${item.reward.cnt}`"
|
||||
class="tuss-reward"
|
||||
>
|
||||
<TMiImg :src="item.reward.icon" alt="icon" :ori="true" />
|
||||
<TMiImg :ori="true" :src="item.reward.icon" alt="icon" />
|
||||
<span>{{ item.reward.cnt }}</span>
|
||||
</div>
|
||||
<v-icon v-if="item.stat?.is_sign" color="var(--tgc-od-green)" title="已签到">
|
||||
@@ -51,7 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import TMiImg from "@comp/app/t-mi-img.vue";
|
||||
import showDialog from "@comp/func/dialog.js";
|
||||
import showGeetest from "@comp/func/geetest.js";
|
||||
@@ -66,12 +67,26 @@ import TGLogger from "@utils/TGLogger.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
type SignGameInfo = { title: string; icon: string; gid: number };
|
||||
/** 签到游戏信息 */
|
||||
type SignGameInfo = {
|
||||
/** 名称 */
|
||||
title: string;
|
||||
/** 图标 */
|
||||
icon: string;
|
||||
/** 分区ID */
|
||||
gid: number;
|
||||
};
|
||||
/** 签到账号信息 */
|
||||
type SignAccount = {
|
||||
/** 是否已选中 */
|
||||
selected: boolean;
|
||||
/** 账号信息 */
|
||||
account: TGApp.Sqlite.Account.Game;
|
||||
/** 游戏信息 */
|
||||
info: SignGameInfo;
|
||||
/** 签到状态 */
|
||||
stat?: TGApp.BBS.Sign.InfoRes;
|
||||
/** 奖励信息 */
|
||||
reward?: TGApp.BBS.Sign.HomeAward;
|
||||
};
|
||||
|
||||
@@ -222,6 +237,7 @@ async function refreshState(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
);
|
||||
if (item.reward === undefined) {
|
||||
const rewardResp = await lunaReq.home(item.account, cookie);
|
||||
console.log("签到奖励", item, rewardResp);
|
||||
if ("retcode" in rewardResp) {
|
||||
await TGLogger.Script(
|
||||
`[签到任务]获取签到奖励失败:${rewardResp.retcode} ${rewardResp.message}`,
|
||||
@@ -230,6 +246,7 @@ async function refreshState(ck: TGApp.App.Account.Cookie): Promise<void> {
|
||||
} else item.reward = rewardResp.awards[dayNow - 1];
|
||||
}
|
||||
const statResp = await lunaReq.info(item.account, cookie);
|
||||
console.log("签到状态", item, statResp);
|
||||
if ("retcode" in statResp) {
|
||||
await TGLogger.Script(`[签到任务]获取签到状态失败:${statResp.retcode} ${statResp.message}`);
|
||||
showSnackbar.error(`[${statResp.retcode}] ${statResp.message}`);
|
||||
@@ -251,6 +268,7 @@ async function trySign(ac: SignAccount[], ck: TGApp.App.Account.Cookie): Promise
|
||||
let challenge: string | undefined = undefined;
|
||||
while (!check) {
|
||||
const signResp = await lunaReq.sign(item.account, cookie, challenge);
|
||||
console.log("签到信息", item, signResp);
|
||||
if (challenge !== undefined) challenge = undefined;
|
||||
if ("retcode" in signResp) {
|
||||
if (signResp.retcode === 1034) {
|
||||
|
||||
Reference in New Issue
Block a user