Files
vmall/apps/shop-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

48 lines
1.6 KiB
Vue

<script setup lang="ts">
const { $api } = useNuxtApp();
const session = useSessionStore();
const { t: translate } = useI18n();
const email = ref("");
const password = ref("");
const error = ref("");
const busy = ref(false);
async function submit(): Promise<void> {
error.value = "";
busy.value = true;
try {
const auth = await $api.login(email.value.trim(), password.value);
if (auth.user.role !== "shop_owner" && auth.user.role !== "shop_staff") {
error.value = translate("auth.shopRoleError");
return;
}
session.setAuth(auth);
await navigateTo("/");
} catch (err: unknown) {
error.value = err instanceof Error ? err.message : translate("common.error");
} finally {
busy.value = false;
}
}
</script>
<template>
<main class="grid min-h-screen place-items-center bg-bg px-4 font-sans text-text">
<VCard class="w-full max-w-[420px]">
<form @submit.prevent="submit">
<h1 class="mb-5 text-xl font-bold text-text">{{ $t("auth.welcome") }}</h1>
<div v-if="error" class="my-2 text-sm text-danger" role="alert">{{ error }}</div>
<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>
<VBtn variant="primary" type="submit" :disabled="busy">
{{ busy ? $t("common.loading") : $t("common.login") }}
</VBtn>
</form>
</VCard>
</main>
</template>