🚸 支持删除无用账户,重构游戏账号表格

This commit is contained in:
目棃
2025-03-11 10:54:34 +08:00
parent c0d9830670
commit 9d212a5b87
4 changed files with 77 additions and 13 deletions

View File

@@ -20,7 +20,17 @@
</v-icon>
<v-icon v-else color="var(--tgc-od-white)">mdi-checkbox-blank-outline</v-icon>
<div class="tuss-account">
<img :src="item.info.icon" alt="icon" />
<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)"
title="删除账户"
>
<v-icon size="12" color="var(--tgc-od-red)">mdi-delete</v-icon>
</div>
</div>
<span>{{ item.account.gameUid }} {{ item.account.regionName }}</span>
</div>
<div class="tuss-stat">
@@ -43,6 +53,7 @@
</template>
<script setup lang="ts">
import TMiImg from "@comp/app/t-mi-img.vue";
import showDialog from "@comp/func/dialog.js";
import showGeetest from "@comp/func/geetest.js";
import showSnackbar from "@comp/func/snackbar.js";
import TSUserAccount from "@Sqlite/modules/userAccount.js";
@@ -114,6 +125,24 @@ async function loadData(): Promise<void> {
}
}
async function deleteAccount(item: SignAccount): Promise<void> {
if (item.account.gameBiz === "hk4e_cn") {
showSnackbar.warn("原神账户不可删除");
return;
}
const idx = signAccounts.value.findIndex((i) => i === item);
if (idx === -1) return;
const infoStr = `${item.info.title}-${item.account.regionName}-${item.account.gameUid}`;
const check = await showDialog.check(`确定删除?`, `${infoStr}\n删除后仅能通过刷新游戏账号恢复`);
if (!check) {
showSnackbar.cancel(`已取消删除${infoStr}`);
return;
}
await TSUserAccount.game.deleteAccount(item.account);
signAccounts.value.splice(idx, 1);
showSnackbar.success(`已删除${infoStr}`);
}
async function tryRefresh(): Promise<void> {
if (loadScript.value) {
showSnackbar.warn("任务正在执行中,请稍后再试");
@@ -231,9 +260,6 @@ async function trySign(ac: SignAccount[], ck: TGApp.App.Account.Cookie): Promise
);
continue;
}
await TGLogger.Script(
`[签到任务]${item.info.title}-${item.account.regionName}-${item.account.gameUid}签到`,
);
let check = false;
let challenge: string | undefined = undefined;
while (!check) {
@@ -354,11 +380,33 @@ async function trySign(ac: SignAccount[], ck: TGApp.App.Account.Cookie): Promise
align-items: center;
justify-content: center;
column-gap: 4px;
}
.tuss-icon {
position: relative;
width: 48px;
height: 48px;
border-radius: 4px;
overflow: hidden;
img {
border-radius: 4px;
width: 48px;
height: 48px;
width: 100%;
height: 100%;
}
.delete {
position: absolute;
bottom: 0;
left: 0;
width: 16px;
height: 16px;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(5px);
border-top-right-radius: 8px;
cursor: pointer;
}
}