# Market Audience Profile Export Design ## Goal Add a separate CSV export for selected creators that includes the current market export fields plus audience profile data from each creator detail page's "连接用户" tab. ## User-Approved Decisions - Add a new toolbar button named `导出画像CSV`. - Keep the existing `导出CSV` behavior unchanged. - Only allow the new export when at least one creator row is selected. - Do not support "export all" for profile data in this change because detail-page data costs extra API/page loads. - Suggested downloaded filename: `达人连接用户画像_YYYYMMDD_HHmm.csv`. - Export profile distributions as separate structured CSV columns, not as JSON blobs. ## Data Scope Each exported row represents one selected creator. Start with the current market CSV columns, then append audience profile columns for: - 性别分布 - 年龄分布 - 全国省份分布 - 地域占比 TOP10 - 城市等级分布 - 兴趣分布 - 八大人群占比 Fixed distributions should become fixed columns, for example: - `连接用户-男性占比` - `连接用户-女性占比` - `连接用户-18-23占比` - `连接用户-24-30占比` - `省份-广东占比` - `城市等级-一线占比` - `八大人群-精致妈妈占比` Ranked distributions should become name/value column pairs: - `地域TOP1名称` - `地域TOP1占比` - ... - `地域TOP10名称` - `地域TOP10占比` - `兴趣TOP1名称` - `兴趣TOP1占比` - ... - `兴趣TOP10名称` - `兴趣TOP10占比` Add a `画像抓取状态` column so partial failures are visible in CSV output. ## Data Acquisition Use an on-demand detail-page probe. The implementation must first confirm the real data source from an authenticated creator detail page: 1. Prefer Xingtu `/gw/api/...` JSON responses if they expose the required profile data. 2. If the API payload is difficult to locate or unstable, read the detail page's Vue/ECharts state from the page context. 3. Avoid screen/OCR parsing and avoid relying on rendered chart pixels. The export should process selected creators one at a time by default to respect API limits and reduce anti-abuse risk. Cache successful profile results in memory for the current page session. ## UX Toolbar behavior: - Add `导出画像CSV` next to the existing export actions. - Disable the button while any export/submission action is running. - If no creators are selected, show `请先勾选需要导出画像的达人`. - While exporting, show progress such as `画像导出中 3/12...`. - If plugin auth is expired, show `登录已过期,请重新登录`. - If one creator fails, keep the row in the CSV with `画像抓取状态=失败` and leave profile columns empty. - If all creators fail, do not download a CSV and show a failure message. ## Architecture Add the feature as a separate export path instead of extending the existing `导出CSV` action. Reuse current selection state, market record hydration, CSV escaping, and runtime download path. Proposed units: - `audience-profile-client`: load and parse audience profile data for one creator detail page. - `audience-profile-csv`: combine existing market CSV columns with profile-specific columns. - Toolbar additions: add a button and handler for profile export. - Controller additions: filter to selected creators, call the profile client serially, build the CSV, then reuse `onCsvReady`. ## Testing Use TDD. Add focused tests for: - Auth state expired detection and user-facing expired-login text. - Toolbar renders and wires the new `导出画像CSV` button. - New export refuses to run without selected creators. - Profile CSV expands fixed and ranked distributions into separate columns. - Controller exports only selected creators and fetches profiles serially. - Failed creator profile fetches produce a failed row while successful rows still export. Run focused tests first, then full `npm test`, then `npm run build`. ## Out of Scope - Unselected/all-page profile export. - Persistent cross-session profile cache. - Visual dashboard UI for profile data. - Changing batch submission payloads. - OCR or screenshot-based chart extraction.