|
@@ -463,6 +463,12 @@ export function removeRichTextValue(data) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 将给定的字符串按设置的字符个数分段
|
|
|
|
+ * @param {string} content 字符串内容
|
|
|
|
+ * @param {number} countPerGroup 每段字符最大个数
|
|
|
|
+ * @returns 分段数组
|
|
|
|
+ */
|
|
export function splitContent(content, countPerGroup) {
|
|
export function splitContent(content, countPerGroup) {
|
|
if (!countPerGroup) return content;
|
|
if (!countPerGroup) return content;
|
|
const gCount = Math.ceil(content.length / countPerGroup);
|
|
const gCount = Math.ceil(content.length / countPerGroup);
|
|
@@ -474,3 +480,16 @@ export function splitContent(content, countPerGroup) {
|
|
}
|
|
}
|
|
return groups;
|
|
return groups;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 获取远程json文件的内容
|
|
|
|
+ * @param {string} url json文件远程地址
|
|
|
|
+ */
|
|
|
|
+export async function getJsonDataFormUrl(url) {
|
|
|
|
+ const response = await fetch(url);
|
|
|
|
+ if (!response.ok) {
|
|
|
|
+ throw new Error(`fetch error! response.status: ${response.status}`);
|
|
|
|
+ }
|
|
|
|
+ const data = await response.json();
|
|
|
|
+ return data;
|
|
|
|
+}
|