forked from open-webui/open-webui
run npm run format
This commit is contained in:
parent
a0a064f4c8
commit
6bb299ae25
1 changed files with 22 additions and 18 deletions
|
@ -20,29 +20,33 @@
|
||||||
let profileImageInputElement: HTMLInputElement;
|
let profileImageInputElement: HTMLInputElement;
|
||||||
|
|
||||||
const generateInitialsImage = (name) => {
|
const generateInitialsImage = (name) => {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
canvas.width = 100;
|
canvas.width = 100;
|
||||||
canvas.height = 100;
|
canvas.height = 100;
|
||||||
|
|
||||||
ctx.fillStyle = '#F39C12';
|
ctx.fillStyle = '#F39C12';
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
ctx.fillStyle = '#FFFFFF';
|
ctx.fillStyle = '#FFFFFF';
|
||||||
ctx.font = '40px Helvetica';
|
ctx.font = '40px Helvetica';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
const initials = name.split(' ').map(word => word[0]).join('');
|
const initials = name
|
||||||
ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2);
|
.split(' ')
|
||||||
|
.map((word) => word[0])
|
||||||
|
.join('');
|
||||||
|
ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2);
|
||||||
|
|
||||||
return canvas.toDataURL();
|
return canvas.toDataURL();
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
const isInitialsImage: boolean = profileImageUrl === generateInitialsImage($user.name) || profileImageUrl === '';
|
const isInitialsImage: boolean =
|
||||||
if (isInitialsImage && name !== $user.name) {
|
profileImageUrl === generateInitialsImage($user.name) || profileImageUrl === '';
|
||||||
profileImageUrl = generateInitialsImage(name);
|
if (isInitialsImage && name !== $user.name) {
|
||||||
}
|
profileImageUrl = generateInitialsImage(name);
|
||||||
|
}
|
||||||
|
|
||||||
const updatedUser = await updateUserProfile(localStorage.token, name, profileImageUrl).catch(
|
const updatedUser = await updateUserProfile(localStorage.token, name, profileImageUrl).catch(
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|
Loading…
Reference in a new issue