feat: finish basic functions

This commit is contained in:
Yidadaa
2023-03-11 02:25:33 +08:00
parent 9912762157
commit 2c9baa4e2c
17 changed files with 2234 additions and 189 deletions

11
app/utils.ts Normal file
View File

@@ -0,0 +1,11 @@
export function trimTopic(topic: string) {
const s = topic.split("").slice(0, 20);
let lastChar = s.at(-1); // 获取 s 的最后一个字符
let pattern = /[,。!?、]/; // 定义匹配中文标点符号的正则表达式
while (lastChar && pattern.test(lastChar!)) {
s.pop();
lastChar = s.at(-1);
}
return s.join("");
}