hippofish/packages/client/src/scripts/please-login.ts
2024-03-07 11:06:45 +09:00

28 lines
578 B
TypeScript

import { defineAsyncComponent } from "vue";
import { isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { popup } from "@/os";
import { vibrate } from "@/scripts/vibrate";
export function pleaseLogin(path?: string) {
if (isSignedIn) return;
vibrate(100);
popup(
defineAsyncComponent(() => import("@/components/MkSigninDialog.vue")),
{
autoSet: true,
message: i18n.ts.signinRequired,
},
{
cancelled: () => {
if (path) {
window.location.href = path;
}
},
},
"closed",
);
if (!path) throw new Error("Sign-in required.");
}