feat: model set avatar

This commit is contained in:
archer
2023-04-28 10:06:14 +08:00
parent 606105d633
commit 08ae4073bd
6 changed files with 61 additions and 8 deletions

View File

@@ -155,7 +155,7 @@ export const splitText = ({
slideLen: number;
}) => {
const textArr =
text.match(/[!?。\n.]+|[^\s]+/g)?.filter((item) => {
text.split(/(?<=[。!?\.!\?\n])/g)?.filter((item) => {
const text = item.replace(/(\\n)/g, '\n').trim();
if (text && text !== '\n') return true;
return false;
@@ -188,3 +188,12 @@ export const splitText = ({
const result = chunks.map((item) => item.arr.join(''));
return result;
};
export const fileToBase64 = (file: File) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
});
};