generated from tailored/router-template
fix
This commit is contained in:
parent
32b6e04d6c
commit
29725a8614
@ -4,7 +4,7 @@ import { Mention } from '@kevisual/xhs/libs/xhs-type/mention.ts';
|
|||||||
const sleep = (ms: number) => {
|
const sleep = (ms: number) => {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
};
|
};
|
||||||
export const splitContent = (content: string, maxLength: number = 300) => {
|
export const splitContent = (content: string, maxLength: number = 270) => {
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
for (let i = 0; i < content.length; i += maxLength) {
|
for (let i = 0; i < content.length; i += maxLength) {
|
||||||
parts.push(content.slice(i, i + maxLength));
|
parts.push(content.slice(i, i + maxLength));
|
||||||
@ -83,7 +83,7 @@ app
|
|||||||
.define(async (ctx) => {
|
.define(async (ctx) => {
|
||||||
const { note_id, comment_id, content } = ctx.query;
|
const { note_id, comment_id, content } = ctx.query;
|
||||||
const client = xhsServices.getClient();
|
const client = xhsServices.getClient();
|
||||||
// content 300个字内,超过cai fen
|
// content 小红书最大 300个字内,超过则分割, 分比300小,比如270
|
||||||
const textArr: string[] = splitContent(content);
|
const textArr: string[] = splitContent(content);
|
||||||
const resArr: any[] = [];
|
const resArr: any[] = [];
|
||||||
for (let text of textArr) {
|
for (let text of textArr) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { splitContent } from '../routes/mentions/mention.ts';
|
import { splitContent } from '../routes/mentions/mention.ts';
|
||||||
|
|
||||||
const content = `这是一个测试内容,长度超过300个字符。34`.repeat(43); // 模拟一个超过300个字符的内容
|
const content = `这是一个测试内容,长度超过300个字符。34`.repeat(43); // 模拟一个超过300个字符的内容
|
||||||
const maxLength = 300;
|
const maxLength = 270; // 设置分割长度为270个字符
|
||||||
const parts = splitContent(content, maxLength);
|
const parts = splitContent(content, maxLength);
|
||||||
console.log('分割后的内容:', parts);
|
console.log('分割后的内容:', parts);
|
||||||
// 输出分割后的内容
|
// 输出分割后的内容
|
||||||
|
Loading…
x
Reference in New Issue
Block a user