mirror of
https://github.com/Codennnn/vue-color-avatar.git
synced 2024-12-22 20:22:39 +00:00
feat: add gender feature
This commit is contained in:
parent
c7254cbd6b
commit
3a3f4db9db
@ -111,6 +111,7 @@ function handleGenerate() {
|
|||||||
) {
|
) {
|
||||||
colorfulOption = getSpecialAvatarOption()
|
colorfulOption = getSpecialAvatarOption()
|
||||||
}
|
}
|
||||||
|
colorfulOption.wrapperShape = avatarOption.value.wrapperShape
|
||||||
setAvatarOption(colorfulOption)
|
setAvatarOption(colorfulOption)
|
||||||
showConfetti()
|
showConfetti()
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,6 +40,8 @@ type AvatarWidgets = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AvatarOption {
|
export interface AvatarOption {
|
||||||
|
gender?: Gender
|
||||||
|
|
||||||
wrapperShape?: `${WrapperShape}`
|
wrapperShape?: `${WrapperShape}`
|
||||||
|
|
||||||
background: {
|
background: {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import type { BeardShape, EarringsShape, GlassesShape } from '@/enums'
|
import type { EarringsShape, GlassesShape } from '@/enums'
|
||||||
|
import { BeardShape, Gender, TopsShape } from '@/enums'
|
||||||
import type { AvatarOption, None } from '@/types'
|
import type { AvatarOption, None } from '@/types'
|
||||||
|
|
||||||
import { NONE, SETTINGS, SPECIAL_AVATARS } from './constant'
|
import { NONE, SETTINGS, SPECIAL_AVATARS } from './constant'
|
||||||
@ -32,7 +33,19 @@ export function getRandomAvatarOption(
|
|||||||
presetOption: Partial<AvatarOption> = {},
|
presetOption: Partial<AvatarOption> = {},
|
||||||
useOption: Partial<AvatarOption> = {}
|
useOption: Partial<AvatarOption> = {}
|
||||||
): AvatarOption {
|
): AvatarOption {
|
||||||
|
const gender = getRandomValue(SETTINGS.gender)
|
||||||
|
|
||||||
|
const beardList: BeardShape[] = []
|
||||||
|
let topList: TopsShape[] = [TopsShape.Danny, TopsShape.Wave, TopsShape.Pixie]
|
||||||
|
|
||||||
|
if (gender === Gender.Male) {
|
||||||
|
beardList.push(BeardShape.Scruff)
|
||||||
|
topList = SETTINGS.topsShape.filter((shape) => !topList.includes(shape))
|
||||||
|
}
|
||||||
|
|
||||||
const avatarOption: AvatarOption = {
|
const avatarOption: AvatarOption = {
|
||||||
|
gender,
|
||||||
|
|
||||||
wrapperShape:
|
wrapperShape:
|
||||||
presetOption?.wrapperShape || getRandomValue(SETTINGS.wrapperShape),
|
presetOption?.wrapperShape || getRandomValue(SETTINGS.wrapperShape),
|
||||||
|
|
||||||
@ -47,7 +60,7 @@ export function getRandomAvatarOption(
|
|||||||
shape: getRandomValue(SETTINGS.faceShape),
|
shape: getRandomValue(SETTINGS.faceShape),
|
||||||
},
|
},
|
||||||
tops: {
|
tops: {
|
||||||
shape: getRandomValue(SETTINGS.topsShape, {
|
shape: getRandomValue(topList, {
|
||||||
avoid: [useOption.widgets?.tops?.shape],
|
avoid: [useOption.widgets?.tops?.shape],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -87,7 +100,7 @@ export function getRandomAvatarOption(
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
beard: {
|
beard: {
|
||||||
shape: getRandomValue<BeardShape | None>(SETTINGS.beardShape, {
|
shape: getRandomValue<BeardShape | None>(beardList, {
|
||||||
usually: [NONE],
|
usually: [NONE],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user