hippofish/packages/client/src/reactiveAccount.ts
2024-02-20 17:41:45 +09:00

14 lines
478 B
TypeScript

import { reactive } from "vue";
import type { Account } from "@/account";
const accountData = localStorage.getItem("account");
// TODO: 外部からはreadonlyに
export const $i = accountData
? reactive(JSON.parse(accountData) as Account)
: null;
export const isSignedIn = $i != null;
export const isModerator = $i != null && ($i.isModerator || $i.isAdmin);
export const isEmojiMod = isModerator || $i?.emojiModPerm !== "unauthorized";
export const isAdmin = $i?.isAdmin;