添加内容过滤功能

This commit is contained in:
张成
2026-02-14 13:56:54 +08:00
parent 64f0267457
commit baa60bbfcb
6 changed files with 171 additions and 147 deletions

View File

@@ -94,6 +94,19 @@ export function toast(message) {
Taro.showToast({ title: message, icon: "none" });
}
/** 从接口/请求错误中取出后端返回的文案,用于保存失败等场景的 toast */
export function getBackendErrorMsg(error: any, fallback = "操作失败"): string {
if (error == null) return fallback;
const msg =
error?.message ||
(typeof error?.error === "string" ? error.error : error?.error?.message) ||
error?.data?.message ||
error?.data?.msg ||
"";
const s = String(msg).trim();
return s || fallback;
}
// 将·作为连接符插入到标签文本之间
export function insertDotInTags(tags: string[]) {
if (!tags) return [];