mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 07:10:16 +08:00
feat: finish basic functions
This commit is contained in:
11
app/utils.ts
Normal file
11
app/utils.ts
Normal 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("");
|
||||
}
|
Reference in New Issue
Block a user