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
This commit is contained in:
Chengdong Zhang
2026-09-22 18:22:50 +08:00
parent 4d2ee3b0bf
commit 0d0e10b97b
101 changed files with 2833 additions and 7207 deletions
+54 -127
View File
@@ -180,137 +180,64 @@ onMounted(async () => {
</script>
<template>
<div class="page">
<h1 class="page-title">{{ $t("shop.couponList") }}</h1>
<div v-if="error" class="error-text" role="alert">{{ error }}</div>
<div v-if="message" class="muted" role="status">{{ message }}</div>
<VPage :title="$t('shop.couponList')">
<div v-if="error" class="my-2 text-sm text-danger" role="alert">{{ error }}</div>
<div v-if="message" class="my-2 text-sm text-muted" role="status">{{ message }}</div>
<section class="card">
<h2>{{ editingId ? $t("shop.editCoupon") : $t("shop.newCoupon") }}</h2>
<div class="form-grid">
<label>
<span>{{ $t("shop.couponTitleEn") }}</span>
<input v-model="form.titleEn" class="input" type="text" />
</label>
<label>
<span>{{ $t("shop.couponTitleZh") }}</span>
<input v-model="form.titleZh" class="input" type="text" />
</label>
<label>
<span>{{ $t("shop.couponAmount") }}</span>
<input v-model.number="form.amountMinor" class="input" type="number" min="1" step="1" />
</label>
<label>
<span>{{ $t("shop.couponThreshold") }}</span>
<input v-model.number="form.thresholdMinor" class="input" type="number" min="0" step="1" />
</label>
<label>
<span>{{ $t("shop.couponCurrency") }}</span>
<select v-model="form.currency" class="input">
<VCard class="mb-5">
<h2 class="mb-4 text-base font-semibold">{{ editingId ? $t("shop.editCoupon") : $t("shop.newCoupon") }}</h2>
<div class="my-3 grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(220px,1fr))]">
<VField :label="$t('shop.couponTitleEn')"><VInput v-model="form.titleEn" type="text" /></VField>
<VField :label="$t('shop.couponTitleZh')"><VInput v-model="form.titleZh" type="text" /></VField>
<VField :label="$t('shop.couponAmount')"><VInput v-model.number="form.amountMinor" type="number" min="1" step="1" /></VField>
<VField :label="$t('shop.couponThreshold')"><VInput v-model.number="form.thresholdMinor" type="number" min="0" step="1" /></VField>
<VField :label="$t('shop.couponCurrency')">
<select v-model="form.currency" class="w-full rounded-md border border-border bg-surface px-3 py-2 text-sm text-text focus:border-primary focus:outline-2 focus:outline-primary/30">
<option v-for="c in currencies" :key="c.code" :value="c.code">{{ c.code }}</option>
</select>
</label>
<label>
<span>{{ $t("shop.couponStock") }}</span>
<input v-model.number="form.stock" class="input" type="number" min="0" step="1" />
</label>
<label>
<span>{{ $t("shop.couponStartsAt") }}</span>
<input v-model="form.startsAt" class="input" type="datetime-local" />
</label>
<label>
<span>{{ $t("shop.couponEndsAt") }}</span>
<input v-model="form.endsAt" class="input" type="datetime-local" />
</label>
<label class="checkbox">
<input v-model="form.enabled" type="checkbox" />
<span>{{ $t("shop.couponEnabled") }}</span>
</label>
</VField>
<VField :label="$t('shop.couponStock')"><VInput v-model.number="form.stock" type="number" min="0" step="1" /></VField>
<VField :label="$t('shop.couponStartsAt')"><VInput v-model="form.startsAt" type="datetime-local" /></VField>
<VField :label="$t('shop.couponEndsAt')"><VInput v-model="form.endsAt" type="datetime-local" /></VField>
<label class="flex items-center gap-2 text-sm font-medium text-text"><input v-model="form.enabled" type="checkbox" class="h-4 w-4 accent-primary" /><span>{{ $t("shop.couponEnabled") }}</span></label>
</div>
<div class="form-actions">
<button class="btn primary" :disabled="saving" @click="submit">
{{ editingId ? $t("shop.updateCoupon") : $t("shop.createCoupon") }}
</button>
<button v-if="editingId" class="btn" type="button" @click="resetForm">
{{ $t("common.cancel") }}
</button>
<div class="flex gap-2">
<VBtn variant="primary" :disabled="saving" @click="submit">{{ editingId ? $t("shop.updateCoupon") : $t("shop.createCoupon") }}</VBtn>
<VBtn v-if="editingId" type="button" @click="resetForm">{{ $t("common.cancel") }}</VBtn>
</div>
</section>
</VCard>
<p v-if="loading" class="muted">{{ $t("common.loading") }}</p>
<div v-else-if="!templates.length" class="card muted">{{ $t("common.empty") }}</div>
<div v-else class="table-wrap">
<table class="table">
<thead>
<tr>
<th>{{ $t("shop.couponTitleEn") }}</th>
<th>{{ $t("shop.couponAmount") }}</th>
<th>{{ $t("shop.couponThreshold") }}</th>
<th>{{ $t("shop.couponStock") }}</th>
<th>{{ $t("shop.couponStartsAt") }}</th>
<th>{{ $t("shop.couponEndsAt") }}</th>
<th>{{ $t("common.status") }}</th>
<th>{{ $t("common.actions") }}</th>
</tr>
</thead>
<tbody>
<tr v-for="template in templates" :key="template.id">
<td>{{ template.title[locale] ?? template.title.en }}</td>
<td>{{ fmt(template.amount_minor, template.currency) }}</td>
<td>{{ fmt(template.threshold_minor, template.currency) }}</td>
<td>{{ template.stock }}</td>
<td>{{ template.starts_at.slice(0, 10) }}</td>
<td>{{ template.ends_at.slice(0, 10) }}</td>
<td>
<span class="badge" :class="template.enabled ? 'green' : 'red'">
{{ template.enabled ? $t("shop.enabledOn") : $t("shop.enabledOff") }}
</span>
</td>
<td class="actions">
<button class="btn sm" :disabled="actionId === template.id" @click="edit(template)">
{{ $t("shop.edit") }}
</button>
<button class="btn sm" :disabled="actionId === template.id" @click="toggleEnabled(template)">
{{ template.enabled ? $t("shop.enabledOff") : $t("shop.enabledOn") }}
</button>
<button class="btn sm" :disabled="actionId === template.id" @click="remove(template)">
{{ $t("common.delete") }}
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p v-if="loading" class="text-muted">{{ $t("common.loading") }}</p>
<VCard v-else-if="!templates.length" class="text-muted">{{ $t("common.empty") }}</VCard>
<VTable v-else>
<thead>
<tr>
<th>{{ $t("shop.couponTitleEn") }}</th>
<th>{{ $t("shop.couponAmount") }}</th>
<th>{{ $t("shop.couponThreshold") }}</th>
<th>{{ $t("shop.couponStock") }}</th>
<th>{{ $t("shop.couponStartsAt") }}</th>
<th>{{ $t("shop.couponEndsAt") }}</th>
<th>{{ $t("common.status") }}</th>
<th>{{ $t("common.actions") }}</th>
</tr>
</thead>
<tbody>
<tr v-for="template in templates" :key="template.id">
<td>{{ template.title[locale] ?? template.title.en }}</td>
<td>{{ fmt(template.amount_minor, template.currency) }}</td>
<td>{{ fmt(template.threshold_minor, template.currency) }}</td>
<td>{{ template.stock }}</td>
<td>{{ template.starts_at.slice(0, 10) }}</td>
<td>{{ template.ends_at.slice(0, 10) }}</td>
<td><VBadge :tone="template.enabled ? 'green' : 'red'">{{ template.enabled ? $t("shop.enabledOn") : $t("shop.enabledOff") }}</VBadge></td>
<td class="flex flex-wrap gap-1.5">
<VBtn size="sm" :disabled="actionId === template.id" @click="edit(template)">{{ $t("shop.edit") }}</VBtn>
<VBtn size="sm" :disabled="actionId === template.id" @click="toggleEnabled(template)">{{ template.enabled ? $t("shop.enabledOff") : $t("shop.enabledOn") }}</VBtn>
<VBtn size="sm" :disabled="actionId === template.id" @click="remove(template)">{{ $t("common.delete") }}</VBtn>
</td>
</tr>
</tbody>
</VTable>
</VPage>
</template>
<style scoped>
.form-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 12px;
margin: 12px 0;
}
.form-grid label {
display: flex;
flex-direction: column;
gap: 4px;
font-size: 13px;
}
.form-grid .checkbox {
flex-direction: row;
align-items: center;
gap: 8px;
}
.form-actions {
display: flex;
gap: 8px;
}
.table-wrap {
overflow-x: auto;
}
.actions {
display: flex;
gap: 6px;
}
</style>