Files
vmall/apps/admin/pages/login.vue
T
Chengdong Zhang 0d0e10b97b feat(ui): adopt Tailwind v4 design system and archive change
- Add tailwindcss v4 + @tailwindcss/vite to mall, shop-admin, admin
- Add @vmall/shared/theme.css tokens with html[data-accent] presets
- Add @vmall/ui kit (VBtn/VBadge/VField/VInput/VCard/VPanel/VTable/VPage,
  VAccentSwatch, useAccent) as a Nuxt module
- Convert all three apps to kit + utilities; delete ui.css/mall.css and
  every <style scoped>; consoles get accent presets, mall locked to red
- Fix VCard boolean prop default (padding) and PDP/store stale
  useAsyncData keys on param navigation
- Archive adopt-tailwind-design-system; new frontend-ui capability spec
2026-09-22 18:22:50 +08:00

61 lines
2.1 KiB
Vue

<script setup lang="ts">
import type { AuthTokens } from "@vmall/shared";
definePageMeta({ layout: false });
const { $api } = useNuxtApp();
const session = useSessionStore();
const { t } = useI18n();
const email = ref("admin@vmall.local");
const password = ref("admin1234");
const loading = ref(false);
const errorMessage = ref("");
async function submit(): Promise<void> {
if (!email.value.trim() || !password.value) {
errorMessage.value = t("common.required");
return;
}
loading.value = true;
errorMessage.value = "";
try {
const auth: AuthTokens = await $api.login(email.value.trim(), password.value);
if (auth.user.role !== "platform_admin") {
errorMessage.value = t("auth.wrongRole");
return;
}
session.setAuth(auth);
await navigateTo("/");
} catch (error: unknown) {
errorMessage.value = error instanceof Error ? error.message : t("common.error");
} finally {
loading.value = false;
}
}
</script>
<template>
<div class="grid min-h-screen place-items-center bg-bg px-6 py-8 font-sans text-text">
<form class="w-full max-w-[420px]" @submit.prevent="submit">
<VCard>
<p class="mb-2 text-xs font-bold uppercase tracking-[0.08em] text-primary">{{ $t("common.appName") }} · Admin</p>
<h1 class="mb-2 text-xl font-bold">{{ $t("auth.welcome") }}</h1>
<p class="mb-5 text-sm text-muted">{{ $t("admin.dashboardTitle") }}</p>
<VField :label="$t('common.email')">
<VInput id="email" v-model="email" type="email" autocomplete="username" required />
</VField>
<VField :label="$t('common.password')">
<VInput id="password" v-model="password" type="password" autocomplete="current-password" required />
</VField>
<p v-if="errorMessage" class="my-2 text-sm text-danger" role="alert">{{ errorMessage }}</p>
<VBtn class="w-full" variant="primary" type="submit" :disabled="loading">
{{ loading ? $t("common.loading") : $t("common.login") }}
</VBtn>
<p class="mt-4 text-center text-xs text-muted">{{ $t("auth.adminHint") }}</p>
</VCard>
</form>
</div>
</template>