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
+73 -188
View File
@@ -232,211 +232,96 @@ onMounted(async () => {
</script>
<template>
<div class="page">
<h1 class="page-title">{{ $t("shop.flashSaleList") }}</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.flashSaleList')">
<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 create-card">
<h2>{{ editingSessionId ? $t("shop.editFlashSale") : $t("shop.newFlashSale") }}</h2>
<div class="form-grid">
<label>
<span>{{ $t("shop.flashLabelEn") }}</span>
<input v-model="sessionForm.labelEn" class="input" type="text" />
</label>
<label>
<span>{{ $t("shop.flashLabelZh") }}</span>
<input v-model="sessionForm.labelZh" class="input" type="text" />
</label>
<label>
<span>{{ $t("shop.flashStartsAt") }}</span>
<input v-model="sessionForm.startsAt" class="input" type="datetime-local" />
</label>
<label>
<span>{{ $t("shop.flashEndsAt") }}</span>
<input v-model="sessionForm.endsAt" class="input" type="datetime-local" />
</label>
<label class="checkbox">
<input v-model="sessionForm.enabled" type="checkbox" />
<span>{{ $t("shop.flashEnabled") }}</span>
</label>
<VCard class="mb-5">
<h2 class="mb-4 text-base font-semibold">{{ editingSessionId ? $t("shop.editFlashSale") : $t("shop.newFlashSale") }}</h2>
<div class="my-3 grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(220px,1fr))]">
<VField :label="$t('shop.flashLabelEn')"><VInput v-model="sessionForm.labelEn" type="text" /></VField>
<VField :label="$t('shop.flashLabelZh')"><VInput v-model="sessionForm.labelZh" type="text" /></VField>
<VField :label="$t('shop.flashStartsAt')"><VInput v-model="sessionForm.startsAt" type="datetime-local" /></VField>
<VField :label="$t('shop.flashEndsAt')"><VInput v-model="sessionForm.endsAt" type="datetime-local" /></VField>
<label class="flex items-center gap-2 text-sm font-medium text-text"><input v-model="sessionForm.enabled" type="checkbox" class="h-4 w-4 accent-primary" /><span>{{ $t("shop.flashEnabled") }}</span></label>
</div>
<div class="form-actions">
<button class="btn primary" :disabled="saving" @click="saveSession">
{{ editingSessionId ? $t("shop.updateFlashSale") : $t("shop.createFlashSale") }}
</button>
<button v-if="editingSessionId" class="btn" type="button" @click="resetSessionForm">
{{ $t("common.cancel") }}
</button>
<div class="flex gap-2">
<VBtn variant="primary" :disabled="saving" @click="saveSession">{{ editingSessionId ? $t("shop.updateFlashSale") : $t("shop.createFlashSale") }}</VBtn>
<VBtn v-if="editingSessionId" type="button" @click="resetSessionForm">{{ $t("common.cancel") }}</VBtn>
</div>
</section>
</VCard>
<p v-if="loading" class="muted">{{ $t("common.loading") }}</p>
<div v-else-if="!sessions.length" class="card muted">{{ $t("common.empty") }}</div>
<p v-if="loading" class="text-muted">{{ $t("common.loading") }}</p>
<VCard v-else-if="!sessions.length" class="text-muted">{{ $t("common.empty") }}</VCard>
<template v-else>
<section v-for="session in sessions" :key="session.id" class="card session-card">
<header class="session-head">
<div>
<VCard v-for="session in sessions" :key="session.id" class="mb-4">
<header class="flex flex-wrap items-center justify-between gap-3">
<div class="flex flex-wrap items-center gap-2">
<strong>{{ session.label[locale] ?? session.label.en }}</strong>
<span class="muted">
{{ session.starts_at.slice(0, 10) }} → {{ session.ends_at.slice(0, 10) }}
</span>
<span class="badge" :class="session.enabled ? 'green' : 'red'">
{{ session.enabled ? $t("shop.enabledOn") : $t("shop.enabledOff") }}
</span>
<span class="text-sm text-muted">{{ session.starts_at.slice(0, 10) }} → {{ session.ends_at.slice(0, 10) }}</span>
<VBadge :tone="session.enabled ? 'green' : 'red'">{{ session.enabled ? $t("shop.enabledOn") : $t("shop.enabledOff") }}</VBadge>
</div>
<div class="action-row">
<button class="btn sm" :disabled="actionId === session.id" @click="editSession(session)">
{{ $t("shop.edit") }}
</button>
<button class="btn sm" :disabled="actionId === session.id" @click="startAddItem(session)">
{{ $t("shop.newFlashItem") }}
</button>
<button class="btn sm" :disabled="actionId === session.id" @click="removeSession(session)">
{{ $t("common.delete") }}
</button>
<div class="flex gap-1.5">
<VBtn size="sm" :disabled="actionId === session.id" @click="editSession(session)">{{ $t("shop.edit") }}</VBtn>
<VBtn size="sm" :disabled="actionId === session.id" @click="startAddItem(session)">{{ $t("shop.newFlashItem") }}</VBtn>
<VBtn size="sm" :disabled="actionId === session.id" @click="removeSession(session)">{{ $t("common.delete") }}</VBtn>
</div>
</header>
<h3 class="sub-title">{{ $t("shop.flashItems") }}</h3>
<div v-if="!session.items.length" class="muted">{{ $t("shop.noFlashItems") }}</div>
<div v-else class="table-wrap">
<table class="table">
<thead>
<tr>
<th>{{ $t("shop.flashSku") }}</th>
<th>{{ $t("shop.flashSalePrice") }}</th>
<th>{{ $t("shop.flashOriginalPrice") }}</th>
<th>{{ $t("shop.flashRemaining") }}</th>
<th>{{ $t("shop.flashSold") }}</th>
<th>{{ $t("shop.flashPerCustomerLimit") }}</th>
<th>{{ $t("common.actions") }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in session.items" :key="item.id">
<td>{{ item.sku_code }}</td>
<td>{{ fmt(item.sale_price_minor, item.currency) }}</td>
<td>{{ fmt(item.original_price_minor, item.original_currency) }}</td>
<td>{{ item.reserved_stock }}</td>
<td>{{ item.sold_count }}</td>
<td>{{ item.per_customer_limit }}</td>
<td class="action-row">
<button class="btn sm" :disabled="actionId === item.id" @click="editItem(session, item)">
{{ $t("shop.edit") }}
</button>
<button class="btn sm" :disabled="actionId === item.id" @click="removeItem(item)">
{{ $t("common.delete") }}
</button>
</td>
</tr>
</tbody>
</table>
</div>
<h3 class="mb-2 mt-4 text-sm font-semibold">{{ $t("shop.flashItems") }}</h3>
<div v-if="!session.items.length" class="text-muted">{{ $t("shop.noFlashItems") }}</div>
<VTable v-else>
<thead>
<tr>
<th>{{ $t("shop.flashSku") }}</th>
<th>{{ $t("shop.flashSalePrice") }}</th>
<th>{{ $t("shop.flashOriginalPrice") }}</th>
<th>{{ $t("shop.flashRemaining") }}</th>
<th>{{ $t("shop.flashSold") }}</th>
<th>{{ $t("shop.flashPerCustomerLimit") }}</th>
<th>{{ $t("common.actions") }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in session.items" :key="item.id">
<td>{{ item.sku_code }}</td>
<td>{{ fmt(item.sale_price_minor, item.currency) }}</td>
<td>{{ fmt(item.original_price_minor, item.original_currency) }}</td>
<td>{{ item.reserved_stock }}</td>
<td>{{ item.sold_count }}</td>
<td>{{ item.per_customer_limit }}</td>
<td class="flex gap-1.5">
<VBtn size="sm" :disabled="actionId === item.id" @click="editItem(session, item)">{{ $t("shop.edit") }}</VBtn>
<VBtn size="sm" :disabled="actionId === item.id" @click="removeItem(item)">{{ $t("common.delete") }}</VBtn>
</td>
</tr>
</tbody>
</VTable>
<div v-if="itemSessionId === session.id" class="item-form">
<h3 class="sub-title">
{{ editingItemId ? $t("shop.editFlashItem") : $t("shop.newFlashItem") }}
</h3>
<div class="form-grid">
<label>
<span>{{ $t("shop.flashSku") }}</span>
<select v-model="itemForm.skuId" class="input">
<div v-if="itemSessionId === session.id" class="mt-4 border-t border-border pt-3">
<h3 class="mb-2 text-sm font-semibold">{{ editingItemId ? $t("shop.editFlashItem") : $t("shop.newFlashItem") }}</h3>
<div class="my-3 grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(220px,1fr))]">
<VField :label="$t('shop.flashSku')">
<select v-model="itemForm.skuId" 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 value="">{{ $t("shop.flashSelectSku") }}</option>
<option v-for="option in skuOptions" :key="option.id" :value="option.id">
{{ option.label }}
</option>
<option v-for="option in skuOptions" :key="option.id" :value="option.id">{{ option.label }}</option>
</select>
</label>
<label>
<span>{{ $t("shop.flashSalePrice") }}</span>
<input v-model.number="itemForm.salePriceMinor" class="input" type="number" min="1" step="1" />
</label>
<label>
<span>{{ $t("shop.couponCurrency") }}</span>
<select v-model="itemForm.currency" class="input">
</VField>
<VField :label="$t('shop.flashSalePrice')"><VInput v-model.number="itemForm.salePriceMinor" type="number" min="1" step="1" /></VField>
<VField :label="$t('shop.couponCurrency')">
<select v-model="itemForm.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.flashReservedStock") }}</span>
<input v-model.number="itemForm.reservedStock" class="input" type="number" min="0" step="1" />
</label>
<label>
<span>{{ $t("shop.flashPerCustomerLimit") }}</span>
<input v-model.number="itemForm.perCustomerLimit" class="input" type="number" min="1" step="1" />
</label>
</VField>
<VField :label="$t('shop.flashReservedStock')"><VInput v-model.number="itemForm.reservedStock" type="number" min="0" step="1" /></VField>
<VField :label="$t('shop.flashPerCustomerLimit')"><VInput v-model.number="itemForm.perCustomerLimit" type="number" min="1" step="1" /></VField>
</div>
<div class="form-actions">
<button class="btn primary" :disabled="saving" @click="saveItem(session)">
{{ $t("shop.saveFlashItem") }}
</button>
<button class="btn" type="button" @click="itemSessionId = ''; resetItemForm()">
{{ $t("common.cancel") }}
</button>
<div class="flex gap-2">
<VBtn variant="primary" :disabled="saving" @click="saveItem(session)">{{ $t("shop.saveFlashItem") }}</VBtn>
<VBtn type="button" @click="itemSessionId = ''; resetItemForm()">{{ $t("common.cancel") }}</VBtn>
</div>
</div>
</section>
</VCard>
</template>
</div>
</VPage>
</template>
<style scoped>
.create-card {
margin-bottom: 20px;
}
.create-card h2 {
font-size: 16px;
margin: 0 0 16px;
}
.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;
}
.session-card {
margin-bottom: 16px;
}
.session-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.session-head .muted {
margin: 0 10px;
}
.sub-title {
font-size: 14px;
margin: 16px 0 8px;
}
.table-wrap {
overflow-x: auto;
}
.action-row {
display: flex;
gap: 6px;
}
.item-form {
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid var(--mall-line, #eee);
}
</style>