mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
@@ -56,7 +56,7 @@
|
|||||||
<img src="/source/UI/userAbyss.webp" alt="abyss" class="side-icon" />
|
<img src="/source/UI/userAbyss.webp" alt="abyss" class="side-icon" />
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-list-item title.attr="祈愿记录" :link="true" href="/user/gacha" v-show="isDevEnv">
|
<v-list-item :title.attr="'祈愿记录'" :link="true" href="/user/gacha">
|
||||||
<template #title>祈愿记录</template>
|
<template #title>祈愿记录</template>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<img src="/source/UI/userGacha.webp" alt="gacha" class="side-icon" />
|
<img src="/source/UI/userGacha.webp" alt="gacha" class="side-icon" />
|
||||||
|
|||||||
332
src/components/userScripts/tus-mission.vue
Normal file
332
src/components/userScripts/tus-mission.vue
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tusm-box">
|
||||||
|
<div class="tusm-top">
|
||||||
|
<div class="tusm-title">米游币任务({{ todayPoints }}/{{ totalPoints }})</div>
|
||||||
|
<div class="tusm-acts">
|
||||||
|
<v-btn @click="tryRefresh()" class="tusm-btn">刷新</v-btn>
|
||||||
|
<v-btn @click="tryAuto()" class="tusm-btn">执行</v-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tusm-content">
|
||||||
|
<div v-for="mission in parseMissions" :key="mission.id" class="mission-item">
|
||||||
|
<div class="left">
|
||||||
|
<v-icon v-if="!mission.status" color="var(--tgc-od-grey)">mdi-circle</v-icon>
|
||||||
|
<v-icon v-else color="var(--tgc-od-green)">mdi-check-circle</v-icon>
|
||||||
|
<span>{{ mission.name }} - {{ mission.reward }}米游币</span>
|
||||||
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<span>
|
||||||
|
<v-progress-linear
|
||||||
|
rounded
|
||||||
|
:model-value="(mission.process / mission.total) * 100"
|
||||||
|
height="8"
|
||||||
|
color="var(--tgc-od-blue)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span>{{ mission.process }}/{{ mission.total }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import showSnackbar from "@comp/func/snackbar.js";
|
||||||
|
import { getRecentForumPostList } from "@Mys/request/painterReq.js";
|
||||||
|
import { getPostFull } from "@Mys/request/postReq.js";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
import { ref, shallowRef } from "vue";
|
||||||
|
|
||||||
|
import { useUserStore } from "@/store/modules/user.js";
|
||||||
|
import TGLogger from "@/utils/TGLogger.js";
|
||||||
|
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||||
|
|
||||||
|
type ParseMission = {
|
||||||
|
id: number;
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
process: number;
|
||||||
|
total: number;
|
||||||
|
status: boolean;
|
||||||
|
reward: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const { cookie } = storeToRefs(useUserStore());
|
||||||
|
const parseMissions = shallowRef<Array<ParseMission>>([]);
|
||||||
|
const missionList = shallowRef<Array<TGApp.BBS.Mission.MissionItem>>([]);
|
||||||
|
const todayPoints = ref<number>(0);
|
||||||
|
const totalPoints = ref<number>(0);
|
||||||
|
|
||||||
|
function mergeMission(
|
||||||
|
list: Array<TGApp.BBS.Mission.MissionItem>,
|
||||||
|
state: Array<TGApp.BBS.Mission.StateItem>,
|
||||||
|
): void {
|
||||||
|
const res: Array<ParseMission> = [];
|
||||||
|
for (const item of list) {
|
||||||
|
const stateFind = state.find((i) => i.mission_id === item.id);
|
||||||
|
if (!stateFind) {
|
||||||
|
res.push({
|
||||||
|
id: item.id,
|
||||||
|
key: item.mission_key,
|
||||||
|
name: item.name,
|
||||||
|
process: 0,
|
||||||
|
total: item.threshold,
|
||||||
|
status: false,
|
||||||
|
reward: item.points,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res.push({
|
||||||
|
id: item.id,
|
||||||
|
key: item.mission_key,
|
||||||
|
name: item.name,
|
||||||
|
total: item.threshold,
|
||||||
|
process: stateFind.happened_times,
|
||||||
|
status: stateFind.process === 1,
|
||||||
|
reward: item.points,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
res.sort((a, b) => a.id - b.id);
|
||||||
|
parseMissions.value = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function tryRefresh(): Promise<void> {
|
||||||
|
await TGLogger.ScriptSep("米游币任务");
|
||||||
|
await TGLogger.Script("[米游币任务]刷新任务状态");
|
||||||
|
if (!cookie.value) {
|
||||||
|
await TGLogger.Script("[米游币任务]未检测到Cookie");
|
||||||
|
showSnackbar.warn("当前账号未登录,请先登录");
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ck = {
|
||||||
|
stoken: cookie.value.stoken,
|
||||||
|
stuid: cookie.value.stuid,
|
||||||
|
mid: cookie.value.mid,
|
||||||
|
};
|
||||||
|
await refreshState(ck);
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function tryAuto(): Promise<void> {
|
||||||
|
await TGLogger.ScriptSep("米游币任务");
|
||||||
|
await TGLogger.Script("[米游币任务]开始执行任务");
|
||||||
|
if (!cookie.value) {
|
||||||
|
await TGLogger.Script("[米游币任务]未检测到Cookie");
|
||||||
|
showSnackbar.warn("当前账号未登录,请先登录");
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ck = {
|
||||||
|
stoken: cookie.value.stoken,
|
||||||
|
stuid: cookie.value.stuid,
|
||||||
|
mid: cookie.value.mid,
|
||||||
|
};
|
||||||
|
const ckPost = { ltoken: cookie.value.ltoken, ltuid: cookie.value.ltuid };
|
||||||
|
await refreshState(ck);
|
||||||
|
const signFind = parseMissions.value.find((i) => i.key === "continuous_sign");
|
||||||
|
if (signFind && !signFind.status) {
|
||||||
|
await autoSign(ck);
|
||||||
|
} else {
|
||||||
|
await TGLogger.Script("[米游币任务]未找到打卡任务或今日已打卡");
|
||||||
|
}
|
||||||
|
const postFilter = parseMissions.value.filter((i) => i.key !== "continuous_sign");
|
||||||
|
if (postFilter.every((i) => i.status)) {
|
||||||
|
await TGLogger.Script("[米游币任务]所有任务已完成");
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let isShare = false;
|
||||||
|
let likeCnt = 0;
|
||||||
|
let viewCnt = 0;
|
||||||
|
const shareFind = postFilter.find((i) => i.key === "share_post_0");
|
||||||
|
if (shareFind) isShare = shareFind.status;
|
||||||
|
const likeFind = postFilter.find((i) => i.key === "post_up_0");
|
||||||
|
if (likeFind) likeCnt = likeFind.process;
|
||||||
|
const viewFind = postFilter.find((i) => i.key === "view_post_0");
|
||||||
|
if (viewFind) viewCnt = viewFind.process;
|
||||||
|
await TGLogger.Script("[米游币任务]获取帖子列表");
|
||||||
|
const listResp = await getRecentForumPostList(26, 2, 2, undefined, 20);
|
||||||
|
for (const post of listResp.list) {
|
||||||
|
if (!isShare) {
|
||||||
|
await TGLogger.Script(`[米游币任务]正在分享帖子${post.post.post_id}`);
|
||||||
|
const shareResp = await apiHubReq.post.share(post.post.post_id, ck);
|
||||||
|
if (shareResp.retcode === 0) {
|
||||||
|
await TGLogger.Script("[米游币任务]分享成功");
|
||||||
|
isShare = true;
|
||||||
|
}
|
||||||
|
await TGLogger.Script(`[米游币任务]分享失败:${shareResp.retcode} ${shareResp.message}`);
|
||||||
|
}
|
||||||
|
if (likeCnt < 5 || viewCnt < 3) {
|
||||||
|
await TGLogger.Script(`[米游币任务]正在浏览帖子${post.post.post_id}`);
|
||||||
|
const detailResp = await getPostFull(Number(post.post.post_id), ckPost);
|
||||||
|
if ("retcode" in detailResp) {
|
||||||
|
await TGLogger.Script(
|
||||||
|
`[米游币任务]获取帖子${post.post.post_id}失败:${detailResp.retcode} ${detailResp.message}`,
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
viewCnt++;
|
||||||
|
if (likeCnt < 5) {
|
||||||
|
const isLike = post.self_operation.upvote_type === 1;
|
||||||
|
if (isLike) {
|
||||||
|
await TGLogger.Script(`[米游币任务]帖子${post.post.post_id}已点赞,跳过`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await TGLogger.Script(`[米游币任务]正在点赞帖子${post.post.post_id}`);
|
||||||
|
const likeResp = await apiHubReq.post.like(post.post.post_id, ckPost);
|
||||||
|
if (likeResp.retcode === 0) {
|
||||||
|
await TGLogger.Script("[米游币任务]点赞成功");
|
||||||
|
likeCnt++;
|
||||||
|
} else {
|
||||||
|
await TGLogger.Script(`[米游币任务]点赞失败:${likeResp.retcode} ${likeResp.message}`);
|
||||||
|
}
|
||||||
|
await TGLogger.Script(`[米游币任务]正在取消点赞帖子${post.post.post_id}`);
|
||||||
|
const unlikeResp = await apiHubReq.post.like(post.post.post_id, ckPost, true);
|
||||||
|
if (unlikeResp.retcode === 0) {
|
||||||
|
await TGLogger.Script("[米游币任务]取消点赞成功");
|
||||||
|
} else {
|
||||||
|
await TGLogger.Script(
|
||||||
|
`[米游币任务]取消点赞失败:${unlikeResp.retcode} ${unlikeResp.message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isShare && likeCnt >= 5 && viewCnt >= 3) {
|
||||||
|
await TGLogger.Script("[米游币任务]所有任务已完成");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await TGLogger.Script("[米游币任务]任务执行完毕,即将刷新任务状态");
|
||||||
|
await refreshState(ck);
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshState(ck: Record<string, string>): Promise<void> {
|
||||||
|
await TGLogger.Script("[米游币任务]刷新任务状态");
|
||||||
|
if (missionList.value.length === 0) {
|
||||||
|
await TGLogger.Script("[米游币任务]未检测到任务列表,正在获取");
|
||||||
|
const listResp = await apiHubReq.mission.list(ck);
|
||||||
|
if (listResp.retcode !== 0) {
|
||||||
|
await TGLogger.Script(
|
||||||
|
`[米游币任务]获取任务列表失败:${listResp.retcode} ${listResp.message}`,
|
||||||
|
);
|
||||||
|
showSnackbar.error(`[${listResp.retcode}] ${listResp.message}`);
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
missionList.value = listResp.data.missions;
|
||||||
|
await TGLogger.Script("[米游币任务]获取任务列表成功");
|
||||||
|
}
|
||||||
|
await TGLogger.Script("[米游币任务]正在获取任务状态");
|
||||||
|
const stateResp = await apiHubReq.mission.state(ck);
|
||||||
|
if (stateResp.retcode !== 0) {
|
||||||
|
await TGLogger.Script(
|
||||||
|
`[米游币任务]获取任务状态失败:${stateResp.retcode} ${stateResp.message}`,
|
||||||
|
);
|
||||||
|
showSnackbar.error(`[${stateResp.retcode}] ${stateResp.message}`);
|
||||||
|
await TGLogger.ScriptSep("米游币任务", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await TGLogger.Script("[米游币任务]获取任务状态成功");
|
||||||
|
todayPoints.value = stateResp.data.already_received_points;
|
||||||
|
totalPoints.value = stateResp.data.today_total_points;
|
||||||
|
await TGLogger.Script("[米游币任务]合并任务数据");
|
||||||
|
mergeMission(missionList.value, stateResp.data.states);
|
||||||
|
await TGLogger.Script("[米游币任务]任务数据合并完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
async function autoSign(ck: Record<string, string>): Promise<void> {
|
||||||
|
const signFind = parseMissions.value.find((i) => i.key === "continuous_sign");
|
||||||
|
if (!signFind) {
|
||||||
|
await TGLogger.Script("[米游币任务]未找到打卡任务");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (signFind.status) {
|
||||||
|
await TGLogger.Script("[米游币任务]今日已打卡");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await TGLogger.Script("[米游币任务]正在执行打卡");
|
||||||
|
const resp = await apiHubReq.sign(ck);
|
||||||
|
if (resp.retcode !== 0) {
|
||||||
|
await TGLogger.Script(`[米游币任务]打卡失败:${resp.retcode} ${resp.message}`);
|
||||||
|
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await TGLogger.Script("[米游币任务]打卡成功");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tusm-box {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--box-bg-1);
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid var(--common-shadow-2);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
color: var(--box-text-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tusm-top {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tusm-title {
|
||||||
|
font-family: var(--font-title);
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tusm-acts {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tusm-btn {
|
||||||
|
background: var(--tgc-btn-1);
|
||||||
|
color: var(--btn-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tusm-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mission-item {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px;
|
||||||
|
background: var(--box-bg-2);
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--box-text-2);
|
||||||
|
|
||||||
|
.left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
:first-child {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
101
src/components/userScripts/tus-output.vue
Normal file
101
src/components/userScripts/tus-output.vue
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tuso-box">
|
||||||
|
<div class="tuso-top">
|
||||||
|
<div class="tuso-title">输出日志</div>
|
||||||
|
<div class="tuso-top-acts">
|
||||||
|
<v-btn class="tuso-btn" @click="clearLog()">清空</v-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tuso-mid" ref="logRef">
|
||||||
|
<div class="tuso-log" v-for="log in logs" :key="log">{{ log }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { event } from "@tauri-apps/api";
|
||||||
|
import type { Event, UnlistenFn } from "@tauri-apps/api/event";
|
||||||
|
import { nextTick, onMounted, onUnmounted, ref, useTemplateRef } from "vue";
|
||||||
|
|
||||||
|
let logListener: UnlistenFn | null = null;
|
||||||
|
const logs = ref<Array<string>>([]);
|
||||||
|
const logEl = useTemplateRef<HTMLDivElement>("logRef");
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
logListener = await event.listen<string>("userScriptLog", async (e: Event<string>) => {
|
||||||
|
logs.value.push(e.payload);
|
||||||
|
await nextTick();
|
||||||
|
logEl.value?.scrollTo({ top: logEl.value.scrollHeight, behavior: "smooth" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function clearLog(): void {
|
||||||
|
logs.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (logListener !== null) {
|
||||||
|
logListener();
|
||||||
|
logListener = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tuso-box {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
margin-left: auto;
|
||||||
|
width: 800px;
|
||||||
|
min-width: 800px;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--box-bg-1);
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid var(--common-shadow-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuso-top {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuso-title {
|
||||||
|
color: var(--common-text-title);
|
||||||
|
font-family: var(--font-title);
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuso-top-acts {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuso-btn {
|
||||||
|
background: var(--tgc-btn-1);
|
||||||
|
color: var(--btn-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuso-mid {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--box-bg-2);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuso-log {
|
||||||
|
position: relative;
|
||||||
|
height: 24px;
|
||||||
|
min-height: 24px;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,5 +1,263 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="user-scripts-page"></div>
|
<v-app-bar>
|
||||||
|
<template #prepend>
|
||||||
|
<div class="us-top-title">
|
||||||
|
<img alt="icon" src="/source/UI/toolbox.webp" />
|
||||||
|
<span>实用脚本</span>
|
||||||
|
<v-select
|
||||||
|
class="us-top-select"
|
||||||
|
variant="outlined"
|
||||||
|
v-model="curAccount"
|
||||||
|
:items="accounts"
|
||||||
|
item-title="uid"
|
||||||
|
:hide-details="true"
|
||||||
|
title="账号UID"
|
||||||
|
>
|
||||||
|
<template #selection="{ item }">
|
||||||
|
<div class="select-main">
|
||||||
|
<img alt="icon" :src="item.raw.brief.avatar" />
|
||||||
|
<div class="content">
|
||||||
|
<span>{{ item.raw.brief.nickname }}</span>
|
||||||
|
<span>UID:{{ item.raw.uid }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #item="{ props, item }">
|
||||||
|
<div class="select-item" v-bind="props">
|
||||||
|
<img alt="icon" :src="item.raw.brief.avatar" />
|
||||||
|
<div class="content">
|
||||||
|
<span>{{ item.raw.brief.nickname }}</span>
|
||||||
|
<span>UID:{{ item.raw.uid }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="append">
|
||||||
|
<v-icon v-if="item.raw.uid === uid" color="green" title="当前登录账号">
|
||||||
|
mdi-account-check
|
||||||
|
</v-icon>
|
||||||
|
<v-icon
|
||||||
|
v-else
|
||||||
|
size="small"
|
||||||
|
icon="mdi-account-convert"
|
||||||
|
title="切换用户"
|
||||||
|
@click="loadAccount(item.raw.uid)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-select>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #append>
|
||||||
|
<span class="top-hint" @click="tryCkVerify()" title="点击验证"
|
||||||
|
>需要验证码登录所需cookie!!!</span
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</v-app-bar>
|
||||||
|
<div class="us-page-container">
|
||||||
|
<!-- 左侧脚本列表 -->
|
||||||
|
<div class="us-scripts">
|
||||||
|
<div class="us-title">脚本列表</div>
|
||||||
|
<TusMission />
|
||||||
|
</div>
|
||||||
|
<!-- 右侧脚本输出 -->
|
||||||
|
<TusOutput />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup></script>
|
<script lang="ts" setup>
|
||||||
<style lang="scss" scoped></style>
|
import showDialog from "@comp/func/dialog.js";
|
||||||
|
import showLoading from "@comp/func/loading.js";
|
||||||
|
import showSnackbar from "@comp/func/snackbar.js";
|
||||||
|
import TusMission from "@comp/userScripts/tus-mission.vue";
|
||||||
|
import TusOutput from "@comp/userScripts/tus-output.vue";
|
||||||
|
import TSUserAccount from "@Sqlite/modules/userAccount.js";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
import { onMounted, shallowRef } from "vue";
|
||||||
|
|
||||||
|
import { useUserStore } from "@/store/modules/user.js";
|
||||||
|
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||||
|
|
||||||
|
const { uid, briefInfo, cookie, account } = storeToRefs(useUserStore());
|
||||||
|
const accounts = shallowRef<Array<TGApp.App.Account.User>>([]);
|
||||||
|
const curAccount = shallowRef<TGApp.App.Account.User>();
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
accounts.value = await TSUserAccount.account.getAllAccount();
|
||||||
|
curAccount.value = accounts.value.find((i) => i.uid === uid.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadAccount(ac: string): Promise<void> {
|
||||||
|
if (uid.value && ac === uid.value) {
|
||||||
|
showSnackbar.warn("该账户已经登录,无需切换");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const accountGet = await TSUserAccount.account.getAccount(ac);
|
||||||
|
if (!accountGet) {
|
||||||
|
showSnackbar.warn(`未找到${uid}的账号信息,请重新登录`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uid.value = ac;
|
||||||
|
briefInfo.value = accountGet.brief;
|
||||||
|
cookie.value = accountGet.cookie;
|
||||||
|
const gameAccount = await TSUserAccount.game.getCurAccount(ac);
|
||||||
|
if (!gameAccount) {
|
||||||
|
showSnackbar.warn(`未找到${uid}的游戏账号信息,请尝试刷新`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
account.value = gameAccount;
|
||||||
|
showSnackbar.success(`成功切换到用户${uid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function tryCkVerify(): Promise<void> {
|
||||||
|
if (!cookie.value) {
|
||||||
|
showSnackbar.warn("当前账号未登录,请先登录");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const check = await showDialog.check("确定验证?", "将通过执行米社社区打卡以验证ck有效性");
|
||||||
|
if (!check) {
|
||||||
|
showSnackbar.cancel("已取消验证");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await showLoading.start("正在验证CK有效性");
|
||||||
|
const ck = {
|
||||||
|
stoken: cookie.value.stoken,
|
||||||
|
stuid: cookie.value.stuid,
|
||||||
|
mid: cookie.value.mid,
|
||||||
|
};
|
||||||
|
const resp = await apiHubReq.sign(ck);
|
||||||
|
await showLoading.update(`[${resp.retcode}] ${resp.message}`);
|
||||||
|
if (resp.retcode === -100) {
|
||||||
|
showSnackbar.error("CK验证失败,请通过验证码登录重新获取CK");
|
||||||
|
await showLoading.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await showLoading.end();
|
||||||
|
showSnackbar.success("CK验证成功");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.us-top-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 10px;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: var(--common-text-title);
|
||||||
|
font-family: var(--font-title);
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.us-top-select {
|
||||||
|
width: 250px;
|
||||||
|
max-width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-main {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
column-gap: 4px;
|
||||||
|
height: 24px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
:first-child {
|
||||||
|
font-family: var(--font-title);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:last-child {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-item {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
column-gap: 4px;
|
||||||
|
padding: 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
:first-child {
|
||||||
|
font-family: var(--font-title);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:last-child {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.append {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-hint {
|
||||||
|
position: relative;
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 20px;
|
||||||
|
color: var(--tgc-pink-1);
|
||||||
|
font-family: var(--font-title);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.us-page-container {
|
||||||
|
display: flex;
|
||||||
|
height: calc(100vh - 100px);
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
column-gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.us-scripts {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
overflow-y: auto;
|
||||||
|
row-gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.us-title {
|
||||||
|
position: relative;
|
||||||
|
margin-right: auto;
|
||||||
|
color: var(--common-text-title);
|
||||||
|
font-family: var(--font-title);
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* @file utils/TGLogger.ts
|
* @file utils/TGLogger.ts
|
||||||
* @description 日志工具
|
* @description 日志工具
|
||||||
* @since Beta v0.6.8
|
* @since Beta v0.6.10/v0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { attachConsole, error, info, warn, debug } from "@tauri-apps/plugin-log";
|
import { event } from "@tauri-apps/api";
|
||||||
|
import { attachConsole, debug, error, info, warn } from "@tauri-apps/plugin-log";
|
||||||
|
|
||||||
|
import { timestampToDate } from "@/utils/toolFunc.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 日志工具
|
* @description 日志工具
|
||||||
@@ -71,6 +74,32 @@ class Logger {
|
|||||||
if (write) await error(message);
|
if (write) await error(message);
|
||||||
console.error(message);
|
console.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 输出日志-脚本
|
||||||
|
* @since Beta v0.6.10/v0.7.0
|
||||||
|
* @param {string} message 日志信息
|
||||||
|
* @returns {Promise<void>} 无返回值
|
||||||
|
*/
|
||||||
|
async Script(message: string): Promise<void> {
|
||||||
|
const timeNow = timestampToDate(new Date().getTime());
|
||||||
|
const msg = `[${timeNow}]${message}`;
|
||||||
|
await event.emitTo("TeyvatGuide", "userScriptLog", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 输出日志-脚本分隔符
|
||||||
|
* @since Beta v0.6.10/v0.7.0
|
||||||
|
* @param {string} label 标签
|
||||||
|
* @param {boolean} [start] 是否为开始,默认为 true
|
||||||
|
* @returns {Promise<void>} 无返回值
|
||||||
|
*/
|
||||||
|
async ScriptSep(label: string, start: boolean = true): Promise<void> {
|
||||||
|
const midStr = `${label} ${start ? "START" : "END--"}`;
|
||||||
|
const msg = `//--------------------${midStr}--------------------//`;
|
||||||
|
await event.emitTo("TeyvatGuide", "userScriptLog", msg);
|
||||||
|
if (!start) await event.emitTo("TeyvatGuide", "userScriptLog", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TGLogger = Logger.getInstance();
|
const TGLogger = Logger.getInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user