feat: 在账号资源库中展示导入的标签字段
KOC 资源导入模板新增「标签」列,导入后写入 accounts.tags 并在 账号资源库面板以 badge 形式展示,导出时也带回标签列以保证往返一致。 - lib/resource-import.ts: 新增 tags 字段与 HEADER 别名(标签/账号标签/人设标签), 新增 normalizeTags/mergeTags 工具,按顿号规整与合并 - 修复 xlsx 解析器对自闭合空 cell (<c r="G6"/>) 的错位 bug,否则 行内出现空 cell 会让后续 cell 的列引用读到错误 body(如老茄子行标签丢失) - db/schema.ts + lib/mvp-db.ts: accounts 表新增 tags VARCHAR(500) - app/api/resources-import/route.ts: SELECT/INSERT/UPDATE/预览全部带上 tags - app/api/resources-export/route.ts: 导出表加「标签」列 - app/admin-app.tsx + app/globals.css: 资源卡片新增「账号标签」区, 导入预览行展示标签 - public/KOC资源导入模板.xlsx: 模板补「标签(选填)」列与填写说明 - mysql/0005_account_tags.sql: 线上 MySQL 迁移 - tests/resource-import.test.mjs: 补 tags 解析/合并用例
This commit is contained in:
@@ -3,6 +3,7 @@ import test from "node:test";
|
||||
import { buildRecoveryWorkbook } from "../lib/recovery-workbook.ts";
|
||||
import {
|
||||
mergeCooperationSources,
|
||||
mergeTags,
|
||||
normalizeProfileUrl,
|
||||
parseResourceFollowers,
|
||||
parseResourceImportFile,
|
||||
@@ -27,6 +28,7 @@ test("parses CSV resources and normalizes public profile data", () => {
|
||||
followers: 0,
|
||||
followersResolved: false,
|
||||
cooperationSource: "林林KOC社群",
|
||||
tags: "",
|
||||
errors: [],
|
||||
});
|
||||
assert.equal(resourcePlatformUid(rows[0]), "abc123");
|
||||
@@ -115,3 +117,16 @@ test("normalizes profile URLs and merges cooperation sources", () => {
|
||||
"林林社群、木子、历史表格",
|
||||
);
|
||||
});
|
||||
|
||||
test("parses and normalizes the optional tags column", () => {
|
||||
const csv = [
|
||||
"账号链接,标签",
|
||||
'"https://www.xiaohongshu.com/user/profile/abc123","美食探店, 旅游出行, 美食探店"',
|
||||
].join("\n");
|
||||
const [row] = parseResourceImportFile(
|
||||
"resources.csv",
|
||||
new TextEncoder().encode(csv),
|
||||
);
|
||||
assert.equal(row.tags, "美食探店、旅游出行");
|
||||
assert.equal(mergeTags("美食探店", "旅游出行;数码汽车"), "美食探店、旅游出行、数码汽车");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user