Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
feat(web): port layouts (default, website, error) to Nuxt 4
Acho Arnoldedc3fc939fe6
diff --git a/web/app/layouts/default.vue b/web/app/layouts/default.vuenew file mode 100644index 00000000..2f1d0699--- /dev/null+++ b/web/app/layouts/default.vue@@ -0,0 +1,117 @@+<script setup lang="ts">+import Pusher from "pusher-js";+import { useDisplay } from "vuetify";+import { setAuthHeader } from "~/composables/useApi";+import { getAuth } from "firebase/auth";++const route = useRoute();+const config = useRuntimeConfig();+const { lgAndUp } = useDisplay();+const authStore = useAuthStore();+const phonesStore = usePhonesStore();+const threadsStore = useThreadsStore();+const appStore = useAppStore();++let poller: ReturnType<typeof setInterval> | null = null;+let canPoll = false;++const hasDrawer = computed(() => {+ return ["threads", "threads-id"].includes((route.name as string) ?? "");+});++onMounted(() => {+ setTimeout(() => {+ const pusher = new Pusher(config.public.pusherKey as string, {+ cluster: config.public.pusherCluster as string,+ });++ if (authStore.authUser) {+ const channel = pusher.subscribe(authStore.authUser.id);+ channel.bind("phone.updated", () => {+ canPoll = true;+ });+ }++ startPoller();+ }, 10_000);+});++onBeforeUnmount(() => {+ if (poller) clearInterval(poller);+});++function startPoller() {+ poller = setInterval(async () => {+ if (!canPoll || authStore.authUser == null) return;++ appStore.setPolling(true);++ if (authStore.authUser && phonesStore.owner) {+ const auth = getAuth();+ const token = await auth.currentUser?.getIdToken();+ if (token) setAuthHeader(token);++ await Promise.all([+ phonesStore.loadPhones(true),+ threadsStore.loadThreads(),+ phonesStore.getHeartbeat(),+ ]);+ }++ canPoll = false;+ setTimeout(() => appStore.setPolling(false), 1000);+ }, 10_000);+}+</script>++<template>+ <v-app>+ <v-divider v-if="appStore.isLocal" class="py-1 bg-warning" />+ <v-navigation-drawer v-if="lgAndUp && hasDrawer" :width="400" permanent>+ <template #prepend>+ <v-divider v-if="appStore.isLocal" class="py-1 bg-warning" />+ <MessageThreadHeader />+ <div class="overflow-y-auto v-navigation-drawer__message-thread">+ <MessageThread />+ </div>+ </template>+ </v-navigation-drawer>+ <v-main :class="{ 'has-drawer': hasDrawer && lgAndUp }">+ <Toast />+ <slot v-if="authStore.authStateChanged" />+ <LoadingDashboard v-else />+ </v-main>+ </v-app>+</template>++<style lang="scss">+.v-application {+ .w-full {+ width: 100%;+ }+ .h-full {+ height: 100%;+ }+ .has-drawer {+ .v-snackbar {+ padding-left: 400px;+ }+ }+ .v-navigation-drawer__message-thread {+ height: calc(100vh - 120px);+ &::-webkit-scrollbar {+ width: 8px;+ }+ &::-webkit-scrollbar-track {+ background: #363636;+ }+ &::-webkit-scrollbar-thumb {+ background: #666666;+ border-radius: 8px;+ }+ }+ code.hljs {+ font-size: 16px;+ }+}+</style>diff --git a/web/app/layouts/error.vue b/web/app/layouts/error.vuenew file mode 100644index 00000000..66d4d4fd--- /dev/null+++ b/web/app/layouts/error.vue@@ -0,0 +1,20 @@+<script setup lang="ts">+const props = defineProps<{+ error: {+ statusCode: number;+ message: string;+ };+}>();+</script>++<template>+ <v-app>+ <v-main>+ <v-container class="text-center mt-16">+ <h1 class="text-h1">{{ error.statusCode }}</h1>+ <p class="text-h5 mt-4">{{ error.message }}</p>+ <v-btn color="primary" class="mt-8" to="/">Go Home</v-btn>+ </v-container>+ </v-main>+ </v-app>+</template>diff --git a/web/app/layouts/website.vue b/web/app/layouts/website.vuenew file mode 100644index 00000000..48882305--- /dev/null+++ b/web/app/layouts/website.vue@@ -0,0 +1,274 @@+<script setup lang="ts">+import { useDisplay } from "vuetify";+import {+ mdiGithub,+ mdiCircle,+ mdiTwitter,+ mdiHeart,+ mdiShieldStar,+ mdiLightbulbOn50,+ mdiCreation,+ mdiEyeOffOutline,+ mdiPost,+ mdiCreditCardOutline,+ mdiScaleBalance,+ mdiEmailOutline,+ mdiBookOpenVariant,+} from "@mdi/js";++const router = useRouter();+const route = useRoute();+const { lgAndUp, mdAndUp } = useDisplay();+const authStore = useAuthStore();+const appStore = useAppStore();++function goToPricing() {+ if (route.name === "index") {+ document.getElementById("pricing")?.scrollIntoView({ behavior: "smooth" });+ } else {+ router.push("/#pricing");+ }+}+</script>++<template>+ <v-app>+ <v-app-bar elevation="2" color="#121212" height="70">+ <v-container>+ <v-row>+ <v-col class="w-full d-flex">+ <NuxtLink+ to="/"+ class="text-decoration-none d-flex"+ :class="{ 'mt-5': mdAndUp }"+ >+ <v-avatar :image="'/img/logo.svg'" :size="33" class="mt-1" />+ <h3 v-if="lgAndUp" class="text-h4 ml-1 text-on-surface">+ httpSMS+ </h3>+ </NuxtLink>+ <v-spacer />+ <v-btn+ v-show="lgAndUp"+ size="large"+ variant="text"+ color="primary"+ class="my-5 mr-2"+ @click="goToPricing"+ >+ Pricing+ </v-btn>+ <v-btn+ v-show="lgAndUp"+ size="large"+ variant="text"+ color="primary"+ class="my-5 mr-2"+ :to="{ name: 'blog' }"+ >+ Blog+ </v-btn>+ <v-btn+ v-show="lgAndUp && authStore.authUser === null"+ size="large"+ variant="text"+ color="primary"+ class="my-5 mr-2"+ :to="{ name: 'login' }"+ >+ Login+ </v-btn>+ <v-btn+ v-show="authStore.authUser === null"+ color="primary"+ :class="{ 'mt-5': mdAndUp, 'mt-1': !mdAndUp }"+ :size="lgAndUp ? 'large' : 'default'"+ :to="{ name: 'login' }"+ >+ Get Started+ <span v-show="lgAndUp"> For Free</span>+ </v-btn>+ <v-btn+ v-show="authStore.authUser !== null"+ color="primary"+ :class="{ 'mt-5': mdAndUp, 'mt-1': !mdAndUp }"+ :size="lgAndUp ? 'large' : 'default'"+ :to="{ name: 'threads' }"+ >+ Dashboard+ </v-btn>+ </v-col>+ </v-row>+ </v-container>+ </v-app-bar>+ <v-main>+ <Toast />+ <slot />+ </v-main>+ <v-footer class="pt-4">+ <v-container>+ <v-row>+ <v-col cols="12" md="3">+ <NuxtLink to="/" class="text-decoration-none d-flex">+ <v-avatar :image="'/img/logo.svg'" :size="33" class="mt-1" />+ <h3 class="text-h4 ml-1 text-on-surface">httpSMS</h3>+ </NuxtLink>+ <div class="text-subtitle-2 mb-4 text-medium-emphasis">+ Made With+ <v-icon color="#cf1112" :icon="mdiHeart" /> in Tallinn+ <v-img+ class="d-inline-block"+ width="20"+ src="https://upload.wikimedia.org/wikipedia/commons/8/8f/Flag_of_Estonia.svg"+ />+ </div>+ <p class="mt-n3">+ <v-btn+ href="https://twitter.com/httpsmsHQ"+ icon+ color="#1DA1F2"+ :icon="mdiTwitter"+ />+ <v-btn+ :href="appStore.appData.githubUrl"+ icon+ size="large"+ color="#ffffff"+ :icon="mdiGithub"+ />+ <v-btn+ href="https://discord.gg/kGk8HVqeEZ"+ icon+ size="large"+ color="#5865f2"+ >+ <v-img+ contain+ height="24"+ width="24"+ src="/img/discord-logo-blue.svg"+ />+ </v-btn>+ </p>+ </v-col>+ <v-col cols="12" md="3">+ <h2 class="text-h6 mb-2">Resources</h2>+ <ul style="list-style: none" class="pa-0">+ <li class="mb-2">+ <a+ class="text-on-surface text-decoration-none"+ @click.stop="goToPricing"+ >+ Pricing+ <v-icon size="small" :icon="mdiCreditCardOutline" />+ </a>+ </li>+ <li class="mb-2">+ <a+ href="https://httpsms.lemonsqueezy.com/affiliates"+ class="text-on-surface text-decoration-none"+ >+ Affiliates+ <v-icon color="warning" size="small" :icon="mdiShieldStar" />+ </a>+ </li>+ <li class="mb-2">+ <a+ href="https://status.httpsms.com"+ class="text-on-surface text-decoration-none"+ >+ Site status+ <v-icon color="success" size="x-small" :icon="mdiCircle" />+ </a>+ </li>+ <li class="mb-2">+ <NuxtLink+ class="text-on-surface text-decoration-none"+ to="/blog"+ >+ Blog <v-icon size="small" :icon="mdiPost" />+ </NuxtLink>+ </li>+ </ul>+ </v-col>+ <v-col cols="12" md="3">+ <h2 class="text-h6 mb-2">Developers</h2>+ <ul style="list-style: none" class="pa-0">+ <li class="mb-2">+ <a+ :href="appStore.appData.documentationUrl"+ class="text-on-surface text-decoration-none"+ >+ Documentation+ <v-icon size="small" :icon="mdiBookOpenVariant" />+ </a>+ </li>+ <li class="mb-2">+ <a+ :href="appStore.appData.githubUrl"+ class="text-on-surface text-decoration-none"+ >+ Github <v-icon size="small" :icon="mdiGithub" />+ </a>+ </li>+ <li class="mb-2">+ <a+ href="https://sandbox.httpsms.com"+ class="text-on-surface text-decoration-none"+ >+ Sandbox+ <v-icon size="small" color="pink" :icon="mdiCreation" />+ </a>+ </li>+ <li class="mb-2">+ <a+ href="https://httpsms.featurebase.app"+ class="text-on-surface text-decoration-none"+ >+ Request Feature+ <v-icon+ size="small"+ color="yellow"+ :icon="mdiLightbulbOn50"+ />+ </a>+ </li>+ </ul>+ </v-col>+ <v-col cols="12" md="3">+ <h2 class="text-h6 mb-2">Legal</h2>+ <ul style="list-style: none" class="pa-0">+ <li class="mb-2">+ <NuxtLink+ class="text-on-surface text-decoration-none"+ to="/terms-and-conditions"+ >+ Terms & Conditions+ <v-icon size="small" :icon="mdiScaleBalance" />+ </NuxtLink>+ </li>+ <li class="mb-2">+ <NuxtLink+ class="text-on-surface text-decoration-none"+ to="/privacy-policy"+ >+ Privacy Policy+ <v-icon size="small" :icon="mdiEyeOffOutline" />+ </NuxtLink>+ </li>+ <li class="mt-2">+ <a+ class="text-on-surface text-decoration-none"+ href="mailto:[email protected]"+ >+ Contact Support+ <v-icon size="small" :icon="mdiEmailOutline" />+ </a>+ </li>+ </ul>+ </v-col>+ </v-row>+ </v-container>+ </v-footer>+ </v-app>+</template>