init
This commit is contained in:
@@ -52,6 +52,25 @@ const handleCancel = () => {
|
|||||||
showDialog.value = false;
|
showDialog.value = false;
|
||||||
resetForm();
|
resetForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getServerInitials = (name: string): string => {
|
||||||
|
if (!name) return ''
|
||||||
|
const words = name.trim().split(/\s+/)
|
||||||
|
if (words.length >= 2) {
|
||||||
|
return (words[0][0] + words[1][0]).toUpperCase()
|
||||||
|
}
|
||||||
|
return name.slice(0, 2).toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
const getServerColor = (str: string): string => {
|
||||||
|
if (!str) return 'hsl(0, 0%, 50%)'
|
||||||
|
let hash = 0
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
hash = str.charCodeAt(i) + ((hash << 5) - hash)
|
||||||
|
}
|
||||||
|
const hue = Math.abs(hash) % 360
|
||||||
|
return `hsl(${hue}, 60%, 45%)`
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -89,10 +108,12 @@ const handleCancel = () => {
|
|||||||
:to="`/server/${server.id}`"
|
:to="`/server/${server.id}`"
|
||||||
>
|
>
|
||||||
<v-avatar
|
<v-avatar
|
||||||
class="d-block text-center mx-auto mb-9"
|
:style="{ backgroundColor: getServerColor(server.name) }"
|
||||||
color="grey-lighten-1"
|
class="d-flex align-center justify-center mx-auto mb-9 font-weight-bold text-caption text-white"
|
||||||
size="28"
|
size="28"
|
||||||
></v-avatar>
|
>
|
||||||
|
{{ getServerInitials(server.name) }}
|
||||||
|
</v-avatar>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<v-btn
|
<v-btn
|
||||||
@@ -151,7 +172,7 @@ const handleCancel = () => {
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
</v-app>
|
</v-app>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user