diff --git a/src/components/config/tc-userBadge.vue b/src/components/config/tc-userBadge.vue index 97fd8521..35c3e893 100644 --- a/src/components/config/tc-userBadge.vue +++ b/src/components/config/tc-userBadge.vue @@ -9,8 +9,15 @@ @@ -218,6 +225,33 @@ async function confirmRefreshUser(): Promise { await refreshUser(); } +async function confirmCopyCookie(): Promise { + const res = await showConfirm({ + title: "确认复制 Cookie 吗?", + text: "将会复制当前登录的 Cookie", + }); + if (!res) { + showSnackbar({ + color: "cancel", + text: "已取消复制", + }); + return; + } + if (!userStore.cookie) { + showSnackbar({ + color: "error", + text: "请先登录", + }); + return; + } + const ckText = useUserStore().getAllCookie(); + await navigator.clipboard.writeText(ckText); + showSnackbar({ + text: "已复制 Cookie!", + color: "success", + }); +} + onUnmounted(() => { if (signListener) signListener(); }); diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index b3aa572d..321be45f 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -1,7 +1,7 @@ /** * @file store/modules/user.ts * @description 用户信息模块 - * @since Beta v0.3.9 + * @since Beta v0.5.1 */ import { defineStore } from "pinia"; @@ -28,10 +28,35 @@ export const useUserStore = defineStore( }); const cookie = ref(); + function getAllCookie(): string { + let res = ""; + if (!cookie.value) return res; + if (cookie.value.ltuid && cookie.value.ltuid !== "") { + res += `ltuid=${cookie.value.ltuid};`; + } + if (cookie.value.ltoken && cookie.value.ltoken !== "") { + res += `ltoken=${cookie.value.ltoken};`; + } + if (cookie.value.mid && cookie.value.mid !== "") { + res += `mid=${cookie.value.mid};`; + } + if (cookie.value.cookie_token && cookie.value.cookie_token !== "") { + res += `cookie_token=${cookie.value.cookie_token};`; + } + if (cookie.value.stoken && cookie.value.stoken !== "") { + res += `stoken=${cookie.value.stoken};`; + } + if (cookie.value.account_id && cookie.value.account_id !== "") { + res += `account_id=${cookie.value.account_id};`; + } + return res; + } + return { cookie, briefInfo, account, + getAllCookie, }; }, {