feat: 服装分类

This commit is contained in:
2026-05-21 13:44:57 +08:00
parent 5476a1f69d
commit 81b907562e
8 changed files with 321 additions and 61 deletions

View File

@@ -0,0 +1,71 @@
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import i18n from '@/lang'
type Translate = (key: string) => string
const clothesCategoryConfigs = [
{
key: 'blouses',
value: 'blouses'
},
{
key: 'dress',
value: 'dress'
},
{
key: 'trousers',
value: 'trousers'
},
{
key: 'skirt',
value: 'skirt'
},
{
key: 'tops',
value: 'tops'
},
{
key: 'bottoms',
value: 'bottoms'
},
{
key: 'outwear',
value: 'outwear'
},
{
key: 'others',
value: 'others'
}
] as const
export type ClothesCategoryValue = (typeof clothesCategoryConfigs)[number]['value']
export interface ClothesCategory {
name: string
label: string
value: ClothesCategoryValue
}
export const createClothesCategories = (t: Translate = i18n.global.t): ClothesCategory[] =>
clothesCategoryConfigs.map(({ key, value }) => ({
name: t(`ClothesCategories.${key}`),
label: t(`ClothesCategories.${key}`),
value
}))
export const ClothesCategories: ClothesCategory[] = clothesCategoryConfigs.map(({ key, value }) => ({
get name() {
return i18n.global.t(`ClothesCategories.${key}`)
},
get label() {
return i18n.global.t(`ClothesCategories.${key}`)
},
value
}))
export const useClothesCategories = () => {
const { t } = useI18n({ useScope: 'global' })
return computed(() => createClothesCategories(t))
}