💄 调整实用脚本UI,显示用户米游币数量

This commit is contained in:
BTMuli
2025-12-12 01:08:00 +08:00
parent 16af3dcd24
commit 8533516913
7 changed files with 198 additions and 162 deletions

View File

@@ -174,7 +174,9 @@ async function loadYaeBag(uid: string, data: TGApp.Plugins.Yae.BagListRes): Prom
} else if (skip === listM.length) {
showSnackbar.success(`未检测到数据更新,耗时 ${Math.floor(cost / 1000)}s`);
} else {
showSnackbar.success(`成功更新 ${listM.length - skip} 条数据`);
showSnackbar.success(
`成功更新 ${listM.length - skip} 条数据,耗时 ${Math.floor(cost / 1000)}s`,
);
}
} catch (e) {
console.error(e);

View File

@@ -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;

View File

@@ -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) {

View File

@@ -1,6 +1,5 @@
/**
* @file request/apiHubReq.ts
* @description apiHub下的请求
* apiHub下的请求
* @since Beta v0.8.2
*/
@@ -59,7 +58,7 @@ async function getGameList(): Promise<Array<TGApp.BBS.Game.Item>> {
}
/**
* @description 获取用户米游币任务完成情况
* 获取用户米游币任务列表
* @since Beta v0.7.2
* @param {Record<string,string>} cookie 用户 Cookie
* @return {Promise<TGApp.BBS.Mission.InfoRes>}
@@ -99,9 +98,9 @@ async function getShareConf(
}
/**
* @description 获取任务完成情况
* 获取用户米游币任务完成状态
* @since Beta v0.7.2
* @description **需要验证码登录的 Cookie**
* @remarks 需要验证码登录的 Cookie
* @param {Record<string,string>} cookie 用户 Cookie
* @return {Promise<TGApp.BBS.Mission.StateResp>}
*/

View File

@@ -21,16 +21,16 @@ declare namespace TGApp.BBS.Geetest {
* @since Beta v0.8.7
*/
type GtCreateRes = {
/* gt */
/** gt */
gt: string;
/* challenge */
/** challenge */
challenge: string;
/* 是否是新验证码 */
/** 是否是新验证码 */
new_captcha: number;
/* 验证成功标志 */
/** 验证成功标志 */
success: number;
/* 是否使用 Gt4 验证 */
use_v4: boolean;
/** 是否使用 Gt4 验证 */
use_v4?: boolean;
};
/**
@@ -38,15 +38,15 @@ declare namespace TGApp.BBS.Geetest {
* @since Beta v0.8.7
*/
type Gt4CreateRes = {
/* gt */
/** gt */
gt: string;
/* 是否是新验证码 */
/** 是否是新验证码 */
new_captcha: number;
/* 风险类型 */
/** 风险类型 */
risk_type: string;
/* 验证成功标志 */
/** 验证成功标志 */
success: number;
/* 是否使用 Gt4 验证 */
/** 是否使用 Gt4 验证 */
use_v4: boolean;
};
@@ -61,7 +61,7 @@ declare namespace TGApp.BBS.Geetest {
* @since Beta v0.7.1
*/
type VerifyRes = {
/* 极验验证 challenge */
/** 极验验证 challenge */
challenge: string;
};
@@ -70,19 +70,19 @@ declare namespace TGApp.BBS.Geetest {
* @since Beta v0.8.7
*/
type InitGeetestParams = {
/* gt */
/** gt */
gt: string;
/* challenge */
/** challenge */
challenge: string;
/* 是否离线 */
/** 是否离线 */
offline: boolean;
/* 是否是新验证码 */
/** 是否是新验证码 */
new_captcha: boolean;
/* 验证形式 */
/** 验证形式 */
product: string;
/* 宽度 */
/** 宽度 */
width: string;
/* 覆盖区域 */
/** 覆盖区域 */
area: string;
/** 是否使用 https 协议 */
https: boolean;
@@ -93,19 +93,19 @@ declare namespace TGApp.BBS.Geetest {
* @since Beta v0.8.7
*/
type InitGeetest4Params = {
/* 验证ID */
/** 验证ID */
captchaId: string;
/* 验证形式 */
/** 验证形式 */
riskType: string;
/* 展现形式 */
/** 展现形式 */
product: string;
/* 宽度 */
/** 宽度 */
nextWidth: string;
/* 用户信息 */
/** 用户信息 */
userInfo: unknown;
/* 语言 */
/** 语言 */
lang: string;
/* 协议头 */
/** 协议头 */
protocol: string;
};
@@ -114,15 +114,15 @@ declare namespace TGApp.BBS.Geetest {
* @since Beta v0.8.7
*/
type GeetestCaptcha = {
/* 将验证码添加到指定的选择器中 */
/** 将验证码添加到指定的选择器中 */
appendTo: (selector: string) => void;
/* 获取验证结果 */
/** 获取验证结果 */
getValidate: () => Promise<GeetestVerifyRes>;
/* 关闭回调 */
/** 关闭回调 */
onClose: (callback: () => void) => boolean;
/* 准备就绪回调 */
/** 准备就绪回调 */
onReady: (callback: () => void) => void;
/* 成功回调 */
/** 成功回调 */
onSuccess: (callback: () => void) => void;
};

View File

@@ -1,112 +1,109 @@
/**
* @file types/BBS/Mission.d.ts
* @description BBS 任务相关类型定义文件
* 米游币任务数据类型
* @since Beta v0.7.0
*/
declare namespace TGApp.BBS.Mission {
/**
* @description 任务信息返回
* @interface InfoResp
* @extends TGApp.BBS.Response.BaseWithData
* @description 任务信息返回响应
* @since Beta v0.7.0
* @property {TGApp.BBS.Mission.InfoRes} data 任务信息
* @return InfoResp
*/
type InfoResp = TGApp.BBS.Response.BaseWithData<InfoRes>;
/**
* @description 任务信息
* @interface InfoRes
* 任务信息返回
* @since Beta v0.7.0
* @property {Array<MissionItem>} missions 任务列表
* @property {Array<MissionItem>} more_missions 更多任务列表
* @return InfoRes
*/
type InfoRes = { missions: Array<MissionItem>; more_missions: Array<MissionItem> };
type InfoRes = {
/** 任务列表 */
missions: Array<MissionItem>;
/** 更多任务列表 */
more_missions: Array<MissionItem>;
};
/**
* @description 任务
* @interface MissionItem
* 任务
* @since Beta v0.7.0
* @property {number} id 任务 ID
* @property {string} name 任务名称
* @property {string} desc 任务描述
* @property {number} threshold 任务完成阈值
* @property {number} limit 任务限制
* @property {number} exp 任务经验
* @property {number} points 米游币
* @property {number} active_time 任务激活时间,秒级时间戳
* @property {number} end_time 任务结束时间
* @property {boolean} is_auto_send_award 是否自动发放奖励
* @property {number} continuous_cycle_times 连续周期次数
* @property {number} next_points 下一次奖励米游币
* @property {string} mission_key 任务 key
* @return MissionItem
*/
type MissionItem = {
/** 任务ID */
id: number;
/** 任务名称 */
name: string;
/** 任务描述 */
desc: string;
/** 阈值 */
threshold: number;
/** 完成次数 */
limit: number;
/** 提供经验 */
exp: number;
/** 米游币 */
points: number;
/** 激活时间戳(秒) */
active_time: number;
/** 结束时间戳(秒)
* @remarks 通常为0
*/
end_time: number;
/** 是否自动发送奖励 */
is_auto_send_award: boolean;
/** 持续次数 */
continuous_cycle_times: number;
/** 下一次完成奖励 */
next_points: number;
/**
* 任务Key
* @remarks 与状态的任务Key对应
*/
mission_key: string;
};
/**
* @description 任务状态返回
* @interface StateResp
* @extends TGApp.BBS.Response.BaseWithData
* 任务状态返回响应
* @since Beta v0.7.0
* @property {TGApp.BBS.Mission.StateRes} data 任务状态
* @return StateResp
*/
type StateResp = TGApp.BBS.Response.BaseWithData<StateRes>;
/**
* @description 任务状态
* @interface StateRes
* 任务状态
* @since Beta v0.7.0
* @property {Array<StateItem>} states 任务状态列表
* @property {number} already_received_points 已领取的米游币
* @property {number} total_points 总米游币
* @property {number} today_total_points 今日总米游币
* @property {boolean} is_unclaimed 是否有未领取的奖励
* @property {number} can_get_points 可领取的米游币
* @return StateRes
*/
type StateRes = {
/** 任务状态列表 */
states: Array<StateItem>;
/** 已领取米游币 */
already_received_points: number;
/** 米游币总数 */
total_points: number;
/** 今日获取米游币 */
today_total_points: number;
/** 是否有未领取的奖励 */
is_unclaimed: boolean;
/** 还能获取的米游币 */
can_get_points: number;
};
/**
* @description 任务状态项
* @interface StateItem
* 任务状态项
* @since Beta v0.7.0
* @property {number} mission_id 任务 ID
* @property {number} process 任务进度 0未完成1已完成
* @property {number} happened_times 发生次数
* @property {boolean} is_get_award 是否领取奖励
* @property {string} mission_key 任务 key
* @return StateItem
*/
type StateItem = {
/** 任务ID */
mission_id: number;
/**
* 任务进度
* @remarks 0-未完成1-已完成
*/
process: number;
/** 发生次数 */
happened_times: number;
/** 是否获取奖励 */
is_get_award: boolean;
/**
* 任务Key
* @remarks 与任务项Key对应
*/
mission_key: string;
};
}

View File

@@ -1,131 +1,119 @@
/**
* @file types/BBS/Sign.d.ts
* @description 米游社游戏签到模块相关类型声明
* 游戏签到类型声明
* @since Beta v0.7.2
*/
declare namespace TGApp.BBS.Sign {
/**
* @description 获取签到奖励信息返回
* @interface HomeResp
* 获取签到奖励信息返回响应
* @since Beta v0.7.2
* @extends TGApp.BBS.Response.BaseWithData
* @property {HomeRes} data - 返回数据
* @returns HomeResp
*/
type HomeResp = TGApp.BBS.Response.BaseWithData<HomeRes>;
/**
* @description 获取签到奖励信返回数据
* @interface HomeRes
* @property {number} month - 月份
* @property {Array<HomeAward>} awards - 签到奖励列表
* @property {string} biz - 业务标识
* @property {boolean} resign - 是否补签
* @property {HomeAwardExtra} short_extra_award - 签到额外奖励
* @returns HomeRes
* 签到奖励信
* @since Beta v0.7.2
*/
type HomeRes = {
/** 月份 */
month: number;
/** 奖励列表 */
awards: Array<HomeAward>;
/** 业务标识 */
biz: string;
/** 是否补签 TODO:描述不清晰 */
resign: boolean;
/** 活动额外奖励 */
short_extra_award: HomeAwardExtra;
};
/**
* @description 签到奖励
* @interface HomeAward
* @property {string} icon - 奖励图标
* @property {string} name - 奖励名称
* @property {number} cnt - 奖励数量
* @returns HomeAward
* 签到奖励
* @since Beta v0.7.2
*/
type HomeAward = { icon: string; name: string; cnt: number };
type HomeAward = {
/** 图标 */
icon: string;
/** 名称 */
name: string;
/** 数量 */
cnt: number;
};
/**
* @description 签到额外奖励
* @interface HomeAwardExtra
* @property {boolean} has_extra_award - 是否有额外奖励
* @property {string} start_time - 额外奖励开始时间
* @property {string} end_time - 额外奖励结束时间
* @property {Array<HomeAward>} list - 额外奖励列表
* @property {string} start_timestamp - 额外奖励开始时间戳
* @property {string} end_timestamp - 额外奖励结束时间戳
* @returns HomeAwardExtra
* 签到额外奖励
* @since Beta v0.7.2
*/
type HomeAwardExtra = {
/** 是否有活动 */
has_extra_award: boolean;
/** 开始时间 */
start_time: string;
/** 结束时间 */
end_time: string;
/** 奖励列表 */
list: Array<HomeAward>;
/** 开始时间戳(秒) */
start_timestamp: string;
/** 结束时间戳(秒) */
end_timestamp: string;
};
/**
* @description 获取签到信息返回
* 获取签到信息返回响应
* @interface InfoResp
* @since Beta v0.7.2
* @extends TGApp.BBS.Response.BaseWithData
* @property {InfoRes} data - 返回数据
* @returns InfoResp
*/
type InfoResp = TGApp.BBS.Response.BaseWithData<InfoRes>;
/**
* @description 获取签到信息返回数据
* @interface InfoRes
* 签到信息返回
* @since Beta v0.7.2
* @property {number} total_sign_day - 总签到天数
* @property {string} today - 今日日期
* @property {boolean} is_sign - 是否已签到
* @property {boolean} is_sub - 是否已补签
* @property {string} region - 服务器
* @property {number} sign_cnt_missed - 未签到天数
* @property {number} short_sign_day - 未知属性
* @property {boolean} send_first - 是否首签
* @return InfoRes
*/
type InfoRes = {
/** 总签到天数 */
total_sign_day: number;
/** 今日日期 */
today: string;
/** 是否签到 */
is_sign: boolean;
/** TODO: 未知字段 */
is_sub: boolean;
/**
* 服务器
* @remarks cn_gf01,cn_qd01等
*/
region: string;
/** 漏签天数 */
sign_cnt_missed: number;
/** 额外活动签到天数 */
short_sign_day: number;
/** TODO: 未知字段 */
send_first: boolean;
};
/**
* @description 签到返回
* @interface SignResp
* 签到返回响应
* @since Beta v0.7.2
* @extends TGApp.BBS.Response.BaseWithData
* @property {SignRes} data - 返回数据
* @returns SignResp
*/
type SignResp = TGApp.BBS.Response.BaseWithData<SignRes>;
/**
* @description 签到返回数据
* @interface SignRes
* 签到返回
* @since Beta v0.7.2
* @property {string} challenge - gt-challenge
* @property {string} code - 签到状态码
* @property {string} gt - gt
* @property {boolean} is_risk - 是否有风险
* @property {number} risk_code - 风险码
* @property {number} success - 是否成功
* @return SignRes
*/
type SignRes = {
/** 极验Challenge */
challenge: string;
/** 签到状态码 */
code: string;
/** 极验Gt */
gt: string;
/** 是否高风险 */
is_risk: boolean;
/** 风险码 */
risk_code: number;
/** 是否成功 */
success: number;
};
}