visualize_inspiration_points.py 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669
  1. """
  2. 灵感点分析结果可视化脚本
  3. 读取 how/灵感点 目录下的分析结果,结合作者历史帖子详情,生成可视化HTML页面
  4. """
  5. import json
  6. from pathlib import Path
  7. from typing import Dict, Any, List, Optional
  8. from datetime import datetime
  9. import html as html_module
  10. def load_inspiration_points_data(inspiration_dir: str) -> List[Dict[str, Any]]:
  11. """
  12. 加载所有灵感点的分析结果
  13. Args:
  14. inspiration_dir: 灵感点目录路径
  15. Returns:
  16. 灵感点分析结果列表
  17. """
  18. inspiration_path = Path(inspiration_dir)
  19. results = []
  20. # 遍历所有子目录
  21. for subdir in inspiration_path.iterdir():
  22. if subdir.is_dir():
  23. # 查找 all_summary 文件
  24. summary_files = list(subdir.glob("all_summary_*.json"))
  25. if summary_files:
  26. summary_file = summary_files[0]
  27. try:
  28. with open(summary_file, 'r', encoding='utf-8') as f:
  29. data = json.load(f)
  30. # 加载完整的 step1 和 step2 数据
  31. step1_data = None
  32. step2_data = None
  33. # 直接从当前子目录查找 step1 和 step2 文件
  34. step1_files = list(subdir.glob("all_step1_*.json"))
  35. step2_files = list(subdir.glob("all_step2_*.json"))
  36. if step1_files:
  37. try:
  38. with open(step1_files[0], 'r', encoding='utf-8') as f:
  39. step1_data = json.load(f)
  40. except Exception as e:
  41. print(f"警告: 读取 {step1_files[0]} 失败: {e}")
  42. if step2_files:
  43. try:
  44. with open(step2_files[0], 'r', encoding='utf-8') as f:
  45. step2_data = json.load(f)
  46. except Exception as e:
  47. print(f"警告: 读取 {step2_files[0]} 失败: {e}")
  48. # 加载搜索结果
  49. search_results = {}
  50. search_dir = subdir / "search"
  51. if search_dir.exists() and search_dir.is_dir():
  52. search_files = list(search_dir.glob("all_search_*.json"))
  53. for search_file in search_files:
  54. try:
  55. with open(search_file, 'r', encoding='utf-8') as f:
  56. search_data = json.load(f)
  57. # 从JSON内容中读取真实的keyword,而不是从文件名提取
  58. keyword = search_data.get("search_params", {}).get("keyword", "")
  59. if keyword:
  60. search_results[keyword] = search_data
  61. else:
  62. # 如果JSON中没有keyword,则从文件名提取
  63. keyword = search_file.stem.replace("all_search_", "")
  64. search_results[keyword] = search_data
  65. except Exception as e:
  66. print(f"警告: 读取 {search_file} 失败: {e}")
  67. results.append({
  68. "summary": data,
  69. "step1": step1_data,
  70. "step2": step2_data,
  71. "search_results": search_results,
  72. "inspiration_name": subdir.name
  73. })
  74. except Exception as e:
  75. print(f"警告: 读取 {summary_file} 失败: {e}")
  76. return results
  77. def load_posts_data(posts_dir: str) -> Dict[str, Dict[str, Any]]:
  78. """
  79. 加载所有帖子详情数据
  80. Args:
  81. posts_dir: 帖子目录路径
  82. Returns:
  83. 帖子ID到帖子详情的映射
  84. """
  85. posts_path = Path(posts_dir)
  86. posts_map = {}
  87. for post_file in posts_path.glob("*.json"):
  88. try:
  89. with open(post_file, 'r', encoding='utf-8') as f:
  90. post_data = json.load(f)
  91. post_id = post_data.get("channel_content_id")
  92. if post_id:
  93. posts_map[post_id] = post_data
  94. except Exception as e:
  95. print(f"警告: 读取 {post_file} 失败: {e}")
  96. return posts_map
  97. def generate_post_card_html(post: Dict[str, Any], note_id_prefix: str = "info-post", post_to_mapping_data: Dict[str, Any] = None) -> str:
  98. """
  99. 生成单个帖子卡片HTML(与搜索结果样式一致)
  100. Args:
  101. post: 帖子数据
  102. note_id_prefix: 帖子ID前缀,用于区分不同区域的帖子
  103. post_to_mapping_data: 帖子到分类和点映射数据
  104. Returns:
  105. HTML字符串
  106. """
  107. import html as html_module
  108. import random
  109. title = post.get("title", "")
  110. desc = post.get("body_text", "")
  111. images = post.get("images", [])
  112. like_count = post.get("like_count", 0)
  113. comment_count = post.get("comment_count", 0)
  114. link = post.get("link", "")
  115. author = post.get("channel_account_name", "")
  116. post_id = post.get("channel_content_id", "")
  117. # 生成唯一的note_id
  118. note_id = f"{note_id_prefix}-{random.randint(10000, 99999)}"
  119. # 生成图片轮播HTML
  120. images_html = ""
  121. if images and len(images) > 0:
  122. images_track = "".join([f'<img src="{img}" class="note-image" alt="图片{i+1}">' for i, img in enumerate(images)])
  123. # 图片导航按钮
  124. nav_buttons = ""
  125. if len(images) > 1:
  126. nav_buttons = f'''
  127. <button class="note-carousel-button prev" onclick="event.stopPropagation(); moveNoteImage('{note_id}', -1)">‹</button>
  128. <button class="note-carousel-button next" onclick="event.stopPropagation(); moveNoteImage('{note_id}', 1)">›</button>
  129. '''
  130. images_html = f'''
  131. <div class="note-image-carousel" data-note-id="{note_id}" data-total-images="{len(images)}">
  132. <div class="note-images-track" id="{note_id}-track">
  133. {images_track}
  134. </div>
  135. {nav_buttons}
  136. </div>
  137. '''
  138. else:
  139. # 无图片时显示占位符
  140. images_html = f'''
  141. <div class="note-image-carousel">
  142. <div class="note-images-track">
  143. <div class="note-image" style="display: flex; align-items: center; justify-content: center; background: #f3f4f6; color: #9ca3af;">
  144. 暂无图片
  145. </div>
  146. </div>
  147. </div>
  148. '''
  149. # 准备详情数据
  150. note_data = {
  151. "title": title,
  152. "desc": desc,
  153. "images": images,
  154. "link": link,
  155. "author": author,
  156. "like_count": like_count,
  157. "comment_count": comment_count
  158. }
  159. # 添加灵感点、关键点、目的点到note_data
  160. if post_to_mapping_data and post_id and post_id in post_to_mapping_data:
  161. mapping = post_to_mapping_data[post_id]
  162. note_data["inspiration_points"] = mapping.get("灵感点列表", [])
  163. note_data["key_points"] = mapping.get("关键点列表", [])
  164. note_data["purpose_points"] = mapping.get("目的点列表", [])
  165. import json
  166. note_data_json = json.dumps(note_data, ensure_ascii=False)
  167. note_data_json_escaped = html_module.escape(note_data_json)
  168. # 获取帖子的灵感点、关键点、目的点
  169. points_html = ""
  170. if post_to_mapping_data and post_id and post_id in post_to_mapping_data:
  171. mapping = post_to_mapping_data[post_id]
  172. inspiration_points = mapping.get("灵感点列表", [])
  173. key_points = mapping.get("关键点列表", [])
  174. purpose_points = mapping.get("目的点列表", [])
  175. points_sections = []
  176. # 灵感点
  177. if inspiration_points:
  178. insp_items = "".join([
  179. f'<div class="point-item"><span class="point-name">{html_module.escape(p.get("灵感点", ""))}</span></div>'
  180. for p in inspiration_points[:3] # 最多显示3个
  181. ])
  182. points_sections.append(f'<div class="points-section"><div class="points-label">灵感点</div><div class="points-list">{insp_items}</div></div>')
  183. # 关键点
  184. if key_points:
  185. key_items = "".join([
  186. f'<div class="point-item"><span class="point-name">{html_module.escape(k.get("关键点", ""))}</span></div>'
  187. for k in key_points[:3] # 最多显示3个
  188. ])
  189. points_sections.append(f'<div class="points-section"><div class="points-label">关键点</div><div class="points-list">{key_items}</div></div>')
  190. # 目的点
  191. if purpose_points:
  192. purpose_items = "".join([
  193. f'<div class="point-item"><span class="point-name">{html_module.escape(p.get("目的点", ""))}</span></div>'
  194. for p in purpose_points[:3] # 最多显示3个
  195. ])
  196. points_sections.append(f'<div class="points-section"><div class="points-label">目的点</div><div class="points-list">{purpose_items}</div></div>')
  197. if points_sections:
  198. points_html = f'<div class="note-points">{"".join(points_sections)}</div>'
  199. card_html = f'''
  200. <div class="search-note-item" data-note-data='{note_data_json_escaped}' onclick="showNoteDetail(this)">
  201. {images_html}
  202. <div class="note-content">
  203. <div class="note-title">{html_module.escape(title) if title else "无标题"}</div>
  204. <div class="note-desc">{html_module.escape(desc) if desc else "暂无描述"}</div>
  205. <div class="note-footer">
  206. <div class="note-author">@{html_module.escape(author) if author else "匿名"}</div>
  207. <div class="note-stats">
  208. <span>👍 {like_count if like_count else 0}</span>
  209. {f'<span>💬 {comment_count}</span>' if comment_count else ''}
  210. </div>
  211. </div>
  212. </div>
  213. {f'<div class="note-points-hover">{points_html}</div>' if points_html else ''}
  214. </div>
  215. '''
  216. return card_html
  217. def generate_inspiration_card_html(
  218. inspiration_data: Dict[str, Any],
  219. inspiration_to_post_data: Dict[str, Any] = None,
  220. category_index_data: Dict[str, Any] = None,
  221. post_to_mapping_data: Dict[str, Any] = None
  222. ) -> str:
  223. """
  224. 生成单个灵感点的卡片HTML
  225. Args:
  226. inspiration_data: 灵感点数据
  227. inspiration_to_post_data: 点到帖子映射数据
  228. category_index_data: 分类索引数据
  229. Returns:
  230. HTML字符串
  231. """
  232. summary = inspiration_data.get("summary", {})
  233. step1 = inspiration_data.get("step1", {})
  234. inspiration_name = inspiration_data.get("inspiration_name", "未知灵感")
  235. search_results = inspiration_data.get("search_results", {})
  236. # 提取关键指标
  237. metrics = summary.get("关键指标", {})
  238. step1_score = metrics.get("step1_top1_score", 0)
  239. step1_match_element = metrics.get("step1_top1_匹配要素", "")
  240. # 确定卡片颜色(基于Step1分数)
  241. if step1_score >= 0.7:
  242. border_color = "#10b981"
  243. step1_color = "#10b981"
  244. elif step1_score >= 0.5:
  245. border_color = "#f59e0b"
  246. step1_color = "#f59e0b"
  247. elif step1_score >= 0.3:
  248. border_color = "#3b82f6"
  249. step1_color = "#3b82f6"
  250. else:
  251. border_color = "#ef4444"
  252. step1_color = "#ef4444"
  253. # 转义HTML
  254. inspiration_name_escaped = html_module.escape(inspiration_name)
  255. step1_match_element_escaped = html_module.escape(step1_match_element)
  256. # 获取Step1匹配结果(简要展示)
  257. step1_matches = step1.get("匹配结果列表", []) if step1 else []
  258. step1_match_preview = ""
  259. if step1_matches:
  260. top_match = step1_matches[0]
  261. # 从新的数据结构中提取信息
  262. input_info = top_match.get("输入信息", {})
  263. match_result = top_match.get("匹配结果", {})
  264. element_name = input_info.get("A", "")
  265. match_score = match_result.get("score", 0)
  266. same_parts = match_result.get("相同部分", {})
  267. increment_parts = match_result.get("增量部分", {})
  268. # 生成相同部分和增量部分的HTML
  269. parts_html = ""
  270. if same_parts:
  271. same_items = [f"{html_module.escape(k)}" for k in same_parts.keys()]
  272. parts_html += f'<div class="preview-parts same"><strong>相同:</strong> {", ".join(same_items)}</div>'
  273. if increment_parts:
  274. inc_items = [f"{html_module.escape(k)}" for k in increment_parts.keys()]
  275. parts_html += f'<div class="preview-parts increment"><strong>增量:</strong> {", ".join(inc_items)}</div>'
  276. step1_match_preview = f'''
  277. <div class="match-preview">
  278. <div class="match-preview-header">🎯 Step1 Top1匹配</div>
  279. <div class="match-preview-content">
  280. <span class="match-preview-name">{html_module.escape(element_name)}</span>
  281. <span class="match-preview-score" style="color: {step1_color};">{match_score:.2f}</span>
  282. </div>
  283. {parts_html}
  284. </div>
  285. '''
  286. # 提取 top3 匹配信息
  287. top3_matches = []
  288. if step1:
  289. matches = step1.get("匹配结果列表", [])
  290. for i, match in enumerate(matches[:3]):
  291. input_info = match.get("输入信息", {})
  292. match_result = match.get("匹配结果", {})
  293. element_name = input_info.get("A", "")
  294. match_score = match_result.get("score", 0)
  295. context = input_info.get("A_Context", "")
  296. # 解析层级关系
  297. hierarchy = []
  298. if context:
  299. lines = context.split("\n")
  300. for line in lines:
  301. if ":" in line:
  302. key, value = line.split(":", 1)
  303. key = key.strip()
  304. value = value.strip()
  305. if key in ["所属视角", "一级分类", "二级分类"]:
  306. hierarchy.append(value)
  307. top3_matches.append({
  308. "rank": i + 1,
  309. "name": element_name,
  310. "score": match_score,
  311. "hierarchy": hierarchy
  312. })
  313. # 准备详细数据用于弹窗
  314. detail_data_json = json.dumps(inspiration_data, ensure_ascii=False)
  315. detail_data_json_escaped = html_module.escape(detail_data_json)
  316. # top3 匹配数据
  317. top3_json = json.dumps(top3_matches, ensure_ascii=False)
  318. top3_json_escaped = html_module.escape(top3_json)
  319. # 生成详细HTML并进行HTML转义
  320. detail_html = generate_detail_html(inspiration_data)
  321. detail_html_escaped = html_module.escape(detail_html)
  322. # 生成匹配列表HTML
  323. matches_html = ""
  324. if step1:
  325. step1_matches = step1.get("匹配结果列表", [])
  326. for idx, match in enumerate(step1_matches):
  327. input_info = match.get("输入信息", {})
  328. match_result = match.get("匹配结果", {})
  329. element_name = input_info.get("A", "")
  330. context = input_info.get("A_Context", "")
  331. score = match_result.get("score", 0)
  332. score_explain = match_result.get("score说明", "")
  333. same_parts = match_result.get("相同部分", {})
  334. increment_parts = match_result.get("增量部分", {})
  335. # 解析层级
  336. hierarchy = []
  337. if context:
  338. lines = context.split("\n")
  339. for line in lines:
  340. if ":" in line:
  341. key, value = line.split(":", 1)
  342. key = key.strip()
  343. value = value.strip()
  344. if key in ["所属视角", "一级分类", "二级分类"]:
  345. hierarchy.append(value)
  346. hierarchy_html = " › ".join([html_module.escape(h) for h in hierarchy]) if hierarchy else ""
  347. rank_class = f"rank-{idx + 1}" if idx < 3 else ""
  348. # 相同部分HTML
  349. same_parts_html = ""
  350. if same_parts:
  351. same_items = "".join([f'<div class="part-item"><span class="part-key">{html_module.escape(k)}:</span><span class="part-value">{html_module.escape(v)}</span></div>' for k, v in same_parts.items()])
  352. same_parts_html = f'''
  353. <div class="match-parts same-parts">
  354. <div class="match-parts-title">✅ 相同部分</div>
  355. {same_items}
  356. </div>
  357. '''
  358. # 增量部分HTML
  359. increment_parts_html = ""
  360. if increment_parts:
  361. inc_items = "".join([f'<div class="part-item"><span class="part-key">{html_module.escape(k)}:</span><span class="part-value">{html_module.escape(v)}</span></div>' for k, v in increment_parts.items()])
  362. increment_parts_html = f'''
  363. <div class="match-parts increment-parts">
  364. <div class="match-parts-title">➕ 增量部分</div>
  365. {inc_items}
  366. </div>
  367. '''
  368. # 生成搜索结果HTML(网格展示,图片轮播)
  369. search_html = ""
  370. if element_name in search_results:
  371. search_data = search_results[element_name]
  372. search_params = search_data.get("search_params", {})
  373. notes = search_data.get("notes", [])
  374. notes_count = len(notes)
  375. # 生成搜索参数HTML
  376. search_params_html = ""
  377. if search_params:
  378. keyword = search_params.get("keyword", "")
  379. content_type = search_params.get("content_type", "不限")
  380. sort_type = search_params.get("sort_type", "综合")
  381. publish_time = search_params.get("publish_time", "不限")
  382. search_params_html = f'''
  383. <div class="search-params-section">
  384. <div class="search-params-title">🔍 搜索参数</div>
  385. <div class="search-params-grid">
  386. <div class="search-param-item">
  387. <span class="search-param-label">关键词:</span>
  388. <span class="search-param-value">{html_module.escape(keyword)}</span>
  389. </div>
  390. <div class="search-param-item">
  391. <span class="search-param-label">内容类型:</span>
  392. <span class="search-param-value">{html_module.escape(content_type)}</span>
  393. </div>
  394. <div class="search-param-item">
  395. <span class="search-param-label">排序方式:</span>
  396. <span class="search-param-value">{html_module.escape(sort_type)}</span>
  397. </div>
  398. <div class="search-param-item">
  399. <span class="search-param-label">发布时间:</span>
  400. <span class="search-param-value">{html_module.escape(publish_time)}</span>
  401. </div>
  402. </div>
  403. </div>
  404. '''
  405. # 生成搜索结果统计HTML
  406. search_summary_html = f'''
  407. <div class="search-summary-section">
  408. <div class="search-summary-title">📊 搜索结果</div>
  409. <div class="search-summary-content">
  410. 共找到 <span class="search-result-count">{notes_count}</span> 条相关内容
  411. </div>
  412. </div>
  413. '''
  414. if notes_count > 0:
  415. notes_items = ""
  416. for note_idx, note in enumerate(notes): # 显示所有结果
  417. title = note.get("title", "")
  418. desc = note.get("desc", "")
  419. link = note.get("link", "")
  420. author = note.get("channel_account_name", "")
  421. like_count = note.get("like_count", 0)
  422. comment_count = note.get("comment_count", 0)
  423. images = note.get("images", [])
  424. note_id = f"note-{idx}-{note_idx}"
  425. # 生成图片轮播HTML
  426. images_html = ""
  427. if images and len(images) > 0:
  428. images_track = "".join([f'<img src="{img}" class="note-image" alt="图片{i+1}">' for i, img in enumerate(images)])
  429. # 图片导航按钮和指示点
  430. nav_buttons = ""
  431. dots_html = ""
  432. if len(images) > 1:
  433. nav_buttons = f'''
  434. <button class="note-carousel-button prev" onclick="event.stopPropagation(); moveNoteImage('{note_id}', -1)">‹</button>
  435. <button class="note-carousel-button next" onclick="event.stopPropagation(); moveNoteImage('{note_id}', 1)">›</button>
  436. '''
  437. dots = "".join([f'<div class="note-image-dot{" active" if i == 0 else ""}"></div>' for i in range(len(images))])
  438. dots_html = f'<div class="note-image-dots" id="{note_id}-dots">{dots}</div>'
  439. images_html = f'''
  440. <div class="note-image-carousel" data-note-id="{note_id}" data-total-images="{len(images)}">
  441. <div class="note-images-track" id="{note_id}-track">
  442. {images_track}
  443. </div>
  444. {nav_buttons}
  445. {dots_html}
  446. </div>
  447. '''
  448. else:
  449. # 无图片时显示占位符
  450. images_html = f'''
  451. <div class="note-image-carousel">
  452. <div class="note-images-track">
  453. <div class="note-image" style="display: flex; align-items: center; justify-content: center; background: #f3f4f6; color: #9ca3af;">
  454. 暂无图片
  455. </div>
  456. </div>
  457. </div>
  458. '''
  459. # 准备详情数据
  460. note_data = {
  461. "title": title,
  462. "desc": desc,
  463. "link": link,
  464. "author": author,
  465. "like_count": like_count,
  466. "comment_count": comment_count,
  467. "images": images
  468. }
  469. note_data_json = json.dumps(note_data, ensure_ascii=False)
  470. note_data_escaped = html_module.escape(note_data_json)
  471. notes_items += f'''
  472. <div class="search-note-item" data-note-data='{note_data_escaped}' onclick="showNoteDetail(this)">
  473. {images_html}
  474. <div class="note-content">
  475. <div class="note-title">{html_module.escape(title) if title else "无标题"}</div>
  476. <div class="note-desc">{html_module.escape(desc) if desc else "暂无描述"}</div>
  477. <div class="note-footer">
  478. <div class="note-author">@{html_module.escape(author)}</div>
  479. <div class="note-stats">
  480. <span>👍 {like_count}</span>
  481. <span>💬 {comment_count}</span>
  482. </div>
  483. </div>
  484. </div>
  485. </div>
  486. '''
  487. search_html = f'''
  488. <div class="search-results-section">
  489. {search_params_html}
  490. {search_summary_html}
  491. <div class="search-notes-list">
  492. {notes_items}
  493. </div>
  494. </div>
  495. '''
  496. else:
  497. # 没有搜索结果时也显示参数
  498. search_html = f'''
  499. <div class="search-results-section">
  500. {search_params_html}
  501. {search_summary_html}
  502. </div>
  503. '''
  504. # 只有第一个匹配项默认展开
  505. expanded_class = " expanded" if idx == 0 else ""
  506. # 生成当前匹配项的灵感点和灵感分类详情
  507. match_info_section = ""
  508. if inspiration_to_post_data and category_index_data:
  509. # 获取灵感点数据
  510. inspiration_points = inspiration_to_post_data.get("点到帖子映射", {}).get("灵感点", {})
  511. inspiration_info = inspiration_points.get(inspiration_name, {})
  512. # 获取当前匹配的灵感分类数据
  513. categories = category_index_data.get("灵感分类", {})
  514. category_info = categories.get(element_name, {})
  515. # 生成灵感点详情HTML(左栏)
  516. insp_detail_html = ""
  517. if inspiration_info:
  518. insp_dimension = inspiration_info.get("维度", "")
  519. insp_desc = inspiration_info.get("描述", "")
  520. insp_posts = inspiration_info.get("帖子详情列表", [])
  521. # 生成帖子卡片
  522. insp_posts_html = ""
  523. for post in insp_posts[:6]: # 最多显示6个
  524. insp_posts_html += generate_post_card_html(post, f"match-{idx}-insp-post", post_to_mapping_data)
  525. insp_detail_html = f'''
  526. <div class="info-detail-column">
  527. <div class="info-header">
  528. <span class="info-label">[灵感点]</span>
  529. <span class="info-name">{html_module.escape(inspiration_name)}</span>
  530. </div>
  531. <div class="info-content">
  532. {f'<div class="info-field"><span class="info-field-label">维度:</span><span class="info-field-value">{html_module.escape(insp_dimension)}</span></div>' if insp_dimension else ''}
  533. {f'<div class="info-field"><span class="info-field-label">描述:</span><span class="info-field-value">{html_module.escape(insp_desc)}</span></div>' if insp_desc else ''}
  534. {f'<div class="info-posts"><div class="info-posts-title">相关帖子</div><div class="info-posts-grid">{insp_posts_html}</div></div>' if insp_posts_html else ''}
  535. </div>
  536. </div>
  537. '''
  538. # 生成灵感分类详情HTML(右栏)
  539. cat_detail_html = ""
  540. if category_info:
  541. cat_level = category_info.get("分类层级", "")
  542. cat_definition = category_info.get("分类定义", "")
  543. cat_posts = category_info.get("帖子详情列表", [])
  544. # 生成帖子卡片
  545. cat_posts_html = ""
  546. for post in cat_posts[:6]: # 最多显示6个
  547. cat_posts_html += generate_post_card_html(post, f"match-{idx}-cat-post", post_to_mapping_data)
  548. cat_detail_html = f'''
  549. <div class="info-detail-column">
  550. <div class="info-header">
  551. <span class="info-label">[灵感分类]</span>
  552. <span class="info-name">{html_module.escape(element_name)}</span>
  553. </div>
  554. <div class="info-content">
  555. {f'<div class="info-field"><span class="info-field-label">层级:</span><span class="info-field-value">{html_module.escape(cat_level)}</span></div>' if cat_level else ''}
  556. {f'<div class="info-field"><span class="info-field-label">定义:</span><span class="info-field-value">{html_module.escape(cat_definition)}</span></div>' if cat_definition else ''}
  557. {f'<div class="info-posts"><div class="info-posts-title">相关帖子</div><div class="info-posts-grid">{cat_posts_html}</div></div>' if cat_posts_html else ''}
  558. </div>
  559. </div>
  560. '''
  561. if insp_detail_html or cat_detail_html:
  562. match_info_section = f'''
  563. <div class="inspiration-category-section">
  564. {insp_detail_html}
  565. {cat_detail_html}
  566. </div>
  567. '''
  568. # 步骤1:灵感点匹配灵感分类
  569. step1_html = f'''
  570. <div class="step-section-wrapper step-1-wrapper expanded">
  571. <div class="step-header" onclick="toggleStepWrapper(this)">
  572. <div class="step-header-content">
  573. <span class="step-number-badge">步骤 1</span>
  574. <span class="step-title">灵感点匹配灵感分类</span>
  575. </div>
  576. <div class="step-toggle">▼</div>
  577. </div>
  578. <div class="step-wrapper-content">
  579. <div class="match-analysis-section" id="match-{idx}-step1" data-step-name="灵感点匹配灵感分类">
  580. <div class="match-parts-container">
  581. <div class="match-parts-column">
  582. {same_parts_html}
  583. </div>
  584. <div class="match-parts-column">
  585. {increment_parts_html}
  586. </div>
  587. </div>
  588. {f'<div class="match-explain"><div class="match-explain-title">💡 分数说明</div><div class="match-explain-text">{html_module.escape(score_explain)}</div></div>' if score_explain else ''}
  589. </div>
  590. </div>
  591. </div>
  592. '''
  593. # 步骤2:搜索结果(如果有)
  594. step2_html = ""
  595. if search_html:
  596. step2_html = f'''
  597. <div class="step-section-wrapper step-2-wrapper expanded">
  598. <div class="step-header" onclick="toggleStepWrapper(this)">
  599. <div class="step-header-content">
  600. <span class="step-number-badge">步骤 2</span>
  601. <span class="step-title">搜索</span>
  602. </div>
  603. <div class="step-toggle">▼</div>
  604. </div>
  605. <div class="step-wrapper-content">
  606. <div class="step-section expanded" data-step="2" id="match-{idx}-step2" data-step-name="灵感分类搜索">
  607. <div class="step-section-header" onclick="toggleStep(this)">
  608. <div class="step-section-title">
  609. <span class="step-sub-number">2.1</span>
  610. <span>直接搜索灵感分类</span>
  611. </div>
  612. <div class="step-toggle">▼</div>
  613. </div>
  614. <div class="step-section-content">
  615. {search_html}
  616. </div>
  617. </div>
  618. </div>
  619. </div>
  620. '''
  621. # 创建安全的ID(移除特殊字符)
  622. safe_element_id = ''.join(c if c.isalnum() or c in '_-' else '_' for c in element_name)
  623. matches_html += f'''
  624. <div class="match-item{expanded_class}" data-index="{idx}" id="match-{idx}" data-match-name="{html_module.escape(element_name)}">
  625. <div class="match-main-header" onclick="toggleMainMatch(this)">
  626. <div class="match-header-row">
  627. <div class="match-header-left">
  628. <span class="match-rank {rank_class}">Top {idx + 1}</span>
  629. <span class="detail-label">[灵感点]</span>
  630. <span class="match-title">{html_module.escape(inspiration_name)}</span>
  631. </div>
  632. <div class="match-header-center">
  633. <span class="match-score-label">匹配分数</span>
  634. <span class="match-score-value">{score:.2f}</span>
  635. </div>
  636. <div class="match-header-right">
  637. <span class="detail-label">[灵感分类]</span>
  638. <span class="match-category">{html_module.escape(element_name)}</span>
  639. <span class="match-hierarchy">({hierarchy_html})</span>
  640. </div>
  641. </div>
  642. <div class="match-toggle-main">▼</div>
  643. </div>
  644. <div class="match-main-content">
  645. {match_info_section}
  646. {step1_html}
  647. {step2_html}
  648. </div>
  649. </div>
  650. '''
  651. # 获取top1匹配的灵感分类名称(用于顶部标题)
  652. top1_category_name = ""
  653. if step1:
  654. step1_matches = step1.get("匹配结果列表", [])
  655. if step1_matches:
  656. top_match = step1_matches[0]
  657. input_info = top_match.get("输入信息", {})
  658. top1_category_name = input_info.get("A", "")
  659. html = f'''
  660. <div class="inspiration-detail"
  661. data-inspiration-name="{inspiration_name_escaped}"
  662. data-step1-score="{step1_score}"
  663. data-top3-matches="{top3_json_escaped}">
  664. <div class="breadcrumb-container">
  665. <div class="breadcrumb" id="dynamicBreadcrumb">
  666. <span class="breadcrumb-item"><span class="breadcrumb-label">[灵感点]</span> {inspiration_name_escaped}</span>
  667. </div>
  668. </div>
  669. <div class="inspiration-content-wrapper">
  670. <div class="matches-list">
  671. {matches_html}
  672. </div>
  673. </div>
  674. </div>
  675. '''
  676. return html
  677. def generate_detail_html(inspiration_data: Dict[str, Any]) -> str:
  678. """
  679. 生成灵感点的详细信息HTML
  680. Args:
  681. inspiration_data: 灵感点数据
  682. Returns:
  683. 详细信息的HTML字符串
  684. """
  685. import html as html_module
  686. summary = inspiration_data.get("summary", {})
  687. step1 = inspiration_data.get("step1", {})
  688. step2 = inspiration_data.get("step2", {})
  689. inspiration_name = inspiration_data.get("inspiration_name", "未知灵感")
  690. content = f'''
  691. <div class="modal-header">
  692. <h2 class="modal-title">{html_module.escape(inspiration_name)}</h2>
  693. </div>
  694. '''
  695. # 获取元数据,用于后面的日志链接
  696. metadata = summary.get("元数据", {})
  697. # Step1 详细信息
  698. if step1 and step1.get("灵感"):
  699. inspiration = step1.get("灵感", "")
  700. matches = step1.get("匹配结果列表", [])
  701. content += f'''
  702. <div class="modal-section">
  703. <h3>🎯 Step1: 灵感人设匹配</h3>
  704. <div class="step-content">
  705. <div class="step-field">
  706. <span class="step-field-label">灵感内容:</span>
  707. <span class="step-field-value">{html_module.escape(inspiration)}</span>
  708. </div>
  709. '''
  710. # 显示匹配结果(只显示Top1)
  711. if matches:
  712. content += f'''
  713. <div class="step-field">
  714. <span class="step-field-label">Top1匹配结果:</span>
  715. <div class="matches-list">
  716. '''
  717. for index, match in enumerate(matches[:1]):
  718. input_info = match.get("输入信息", {})
  719. match_result = match.get("匹配结果", {})
  720. element_a = input_info.get("A", "")
  721. context_a = input_info.get("A_Context", "")
  722. score = match_result.get("score", 0)
  723. score_explain = match_result.get("score说明", "")
  724. same_parts = match_result.get("相同部分", {})
  725. increment_parts = match_result.get("增量部分", {})
  726. content += f'''
  727. <div class="match-item">
  728. <div class="match-header">
  729. <span class="match-element-name">{html_module.escape(element_a)}</span>
  730. <span class="match-score">{score:.2f}</span>
  731. </div>
  732. '''
  733. if context_a:
  734. content += f'<div class="match-context"><strong>📍 所属分类:</strong> {html_module.escape(context_a).replace(chr(10), "<br>")}</div>'
  735. if score_explain:
  736. content += f'<div class="match-explain"><strong>💡 分数说明:</strong> {html_module.escape(score_explain)}</div>'
  737. # 相同部分
  738. if same_parts:
  739. content += '''
  740. <div class="match-parts same-parts">
  741. <div class="parts-header">✅ 相同部分</div>
  742. <div class="parts-content">
  743. '''
  744. for key, value in same_parts.items():
  745. content += f'''
  746. <div class="part-item">
  747. <span class="part-key">{html_module.escape(key)}:</span>
  748. <span class="part-value">{html_module.escape(value)}</span>
  749. </div>
  750. '''
  751. content += '''
  752. </div>
  753. </div>
  754. '''
  755. # 增量部分
  756. if increment_parts:
  757. content += '''
  758. <div class="match-parts increment-parts">
  759. <div class="parts-header">➕ 增量部分</div>
  760. <div class="parts-content">
  761. '''
  762. for key, value in increment_parts.items():
  763. content += f'''
  764. <div class="part-item">
  765. <span class="part-key">{html_module.escape(key)}:</span>
  766. <span class="part-value">{html_module.escape(value)}</span>
  767. </div>
  768. '''
  769. content += '''
  770. </div>
  771. </div>
  772. '''
  773. content += '''
  774. </div>
  775. '''
  776. content += '''
  777. </div>
  778. </div>
  779. '''
  780. content += '''
  781. </div>
  782. </div>
  783. '''
  784. # 日志链接
  785. if metadata.get("log_url"):
  786. content += f'''
  787. <div class="modal-link">
  788. <a href="{metadata["log_url"]}" target="_blank" class="modal-link-btn">
  789. 🔗 查看详细日志
  790. </a>
  791. </div>
  792. '''
  793. return content
  794. def generate_detail_modal_content_js() -> str:
  795. """
  796. 生成详情弹窗内容的JavaScript函数
  797. Returns:
  798. JavaScript代码字符串
  799. """
  800. return '''
  801. // 笔记图片当前索引管理
  802. const noteImageStates = {};
  803. // 移动笔记图片
  804. function moveNoteImage(noteId, direction) {
  805. if (!noteImageStates[noteId]) {
  806. noteImageStates[noteId] = 0;
  807. }
  808. const carousel = document.querySelector(`[data-note-id="${noteId}"]`);
  809. if (!carousel) return;
  810. const totalImages = parseInt(carousel.dataset.totalImages);
  811. const track = document.getElementById(noteId + '-track');
  812. if (!track) return;
  813. let newIndex = noteImageStates[noteId] + direction;
  814. if (newIndex < 0) newIndex = 0;
  815. if (newIndex >= totalImages) newIndex = totalImages - 1;
  816. noteImageStates[noteId] = newIndex;
  817. // 移动轨道
  818. track.style.transform = `translateX(-${newIndex * 100}%)`;
  819. // 更新指示点
  820. const dots = document.querySelectorAll(`#${noteId}-dots .note-image-dot`);
  821. dots.forEach((dot, i) => {
  822. dot.classList.toggle('active', i === newIndex);
  823. });
  824. // 更新按钮状态
  825. const prevBtn = carousel.querySelector('.note-carousel-button.prev');
  826. const nextBtn = carousel.querySelector('.note-carousel-button.next');
  827. if (prevBtn) {
  828. prevBtn.classList.toggle('disabled', newIndex === 0);
  829. }
  830. if (nextBtn) {
  831. nextBtn.classList.toggle('disabled', newIndex >= totalImages - 1);
  832. }
  833. }
  834. // 显示笔记详情
  835. function showNoteDetail(element) {
  836. const noteDataStr = element.dataset.noteData;
  837. if (!noteDataStr) return;
  838. try {
  839. const noteData = JSON.parse(noteDataStr);
  840. // 生成图片HTML
  841. let imagesHtml = '';
  842. if (noteData.images && noteData.images.length > 0) {
  843. imagesHtml = noteData.images.map(img =>
  844. `<img src="${img}" class="note-detail-image" alt="图片">`
  845. ).join('');
  846. } else {
  847. imagesHtml = '<div style="text-align: center; color: #9ca3af; padding: 40px;">暂无图片</div>';
  848. }
  849. // 生成灵感点、关键点、目的点HTML
  850. let pointsDetailHtml = '';
  851. const hasPoints = (noteData.inspiration_points && noteData.inspiration_points.length > 0) ||
  852. (noteData.key_points && noteData.key_points.length > 0) ||
  853. (noteData.purpose_points && noteData.purpose_points.length > 0);
  854. if (hasPoints) {
  855. let sections = [];
  856. // 灵感点
  857. if (noteData.inspiration_points && noteData.inspiration_points.length > 0) {
  858. const items = noteData.inspiration_points.map(p =>
  859. `<div class="detail-point-item">
  860. <div class="detail-point-name">${p.灵感点 || ''}</div>
  861. ${p.描述 ? `<div class="detail-point-desc">${p.描述}</div>` : ''}
  862. </div>`
  863. ).join('');
  864. sections.push(`<div class="detail-points-section">
  865. <div class="detail-points-title">💡 灵感点</div>
  866. ${items}
  867. </div>`);
  868. }
  869. // 关键点
  870. if (noteData.key_points && noteData.key_points.length > 0) {
  871. const items = noteData.key_points.map(k =>
  872. `<div class="detail-point-item">
  873. <div class="detail-point-name">${k.关键点 || ''}</div>
  874. ${k.描述 ? `<div class="detail-point-desc">${k.描述}</div>` : ''}
  875. </div>`
  876. ).join('');
  877. sections.push(`<div class="detail-points-section">
  878. <div class="detail-points-title">🔑 关键点</div>
  879. ${items}
  880. </div>`);
  881. }
  882. // 目的点
  883. if (noteData.purpose_points && noteData.purpose_points.length > 0) {
  884. const items = noteData.purpose_points.map(p =>
  885. `<div class="detail-point-item">
  886. <div class="detail-point-name">${p.目的点 || ''}</div>
  887. ${p.描述 ? `<div class="detail-point-desc">${p.描述}</div>` : ''}
  888. </div>`
  889. ).join('');
  890. sections.push(`<div class="detail-points-section">
  891. <div class="detail-points-title">🎯 目的点</div>
  892. ${items}
  893. </div>`);
  894. }
  895. pointsDetailHtml = `<div class="note-detail-points">${sections.join('')}</div>`;
  896. }
  897. const modalHtml = `
  898. <div class="note-detail-content">
  899. <button class="note-detail-close" onclick="closeNoteDetail()">×</button>
  900. <div class="note-detail-header">
  901. <div class="note-detail-title">${noteData.title || '无标题'}</div>
  902. <div class="note-detail-meta">
  903. <span class="note-detail-author">@${noteData.author}</span>
  904. <div class="note-detail-stats">
  905. <span>👍 ${noteData.like_count}</span>
  906. <span>💬 ${noteData.comment_count}</span>
  907. </div>
  908. </div>
  909. </div>
  910. <div class="note-detail-body">
  911. ${noteData.desc ? `<div class="note-detail-desc">${noteData.desc}</div>` : ''}
  912. ${pointsDetailHtml}
  913. <div class="note-detail-images">
  914. ${imagesHtml}
  915. </div>
  916. </div>
  917. <div class="note-detail-footer">
  918. <a href="${noteData.link}" target="_blank" class="note-detail-link">
  919. 在小红书查看完整内容 →
  920. </a>
  921. </div>
  922. </div>
  923. `;
  924. let modal = document.getElementById('noteDetailModal');
  925. if (!modal) {
  926. modal = document.createElement('div');
  927. modal.id = 'noteDetailModal';
  928. modal.className = 'note-detail-modal';
  929. modal.onclick = (e) => {
  930. if (e.target === modal) closeNoteDetail();
  931. };
  932. document.body.appendChild(modal);
  933. }
  934. modal.innerHTML = modalHtml;
  935. modal.classList.add('active');
  936. document.body.style.overflow = 'hidden';
  937. } catch (e) {
  938. console.error('Error parsing note data:', e);
  939. }
  940. }
  941. // 关闭笔记详情
  942. function closeNoteDetail() {
  943. const modal = document.getElementById('noteDetailModal');
  944. if (modal) {
  945. modal.classList.remove('active');
  946. document.body.style.overflow = '';
  947. }
  948. }
  949. // ESC键关闭详情
  950. document.addEventListener('keydown', function(event) {
  951. if (event.key === 'Escape') {
  952. closeNoteDetail();
  953. }
  954. });
  955. // 切换主匹配项的展开/折叠
  956. function toggleMainMatch(element) {
  957. const matchItem = element.closest('.match-item');
  958. matchItem.classList.toggle('expanded');
  959. }
  960. // 切换步骤wrapper的展开/折叠
  961. function toggleStepWrapper(element) {
  962. const stepWrapper = element.closest('.step-section-wrapper');
  963. stepWrapper.classList.toggle('expanded');
  964. }
  965. // 切换步骤的展开/折叠
  966. function toggleStep(element) {
  967. const stepSection = element.closest('.step-section');
  968. stepSection.classList.toggle('expanded');
  969. }
  970. // 切换匹配详情的展开/折叠
  971. function toggleMatchSection(element) {
  972. const matchSection = element.closest('.match-section');
  973. matchSection.classList.toggle('expanded');
  974. }
  975. // 显示指定的灵感详情
  976. function showDetail(index) {
  977. const details = document.querySelectorAll('.inspiration-detail');
  978. details.forEach((detail, i) => {
  979. if (i === index) {
  980. detail.classList.add('active');
  981. // 滚动到顶部
  982. const section = document.querySelector('.inspirations-section');
  983. if (section) {
  984. section.scrollTop = 0;
  985. }
  986. } else {
  987. detail.classList.remove('active');
  988. }
  989. });
  990. }
  991. // 生成导航目录
  992. function generateNavigation() {
  993. const details = document.querySelectorAll('.inspiration-detail');
  994. const navList = document.getElementById('navList');
  995. navList.innerHTML = '';
  996. details.forEach((detail, index) => {
  997. const name = detail.dataset.inspirationName;
  998. const score = parseFloat(detail.dataset.step1Score) || 0;
  999. const top3MatchesStr = detail.dataset.top3Matches;
  1000. let top3Matches = [];
  1001. try {
  1002. top3Matches = JSON.parse(top3MatchesStr);
  1003. } catch(e) {
  1004. console.error('Error parsing top3 matches:', e);
  1005. }
  1006. const navItem = document.createElement('div');
  1007. navItem.className = 'nav-item';
  1008. if (index === 0) navItem.classList.add('active');
  1009. navItem.dataset.cardIndex = index;
  1010. // 生成匹配列表HTML
  1011. let matchesHtml = '';
  1012. if (top3Matches && top3Matches.length > 0) {
  1013. matchesHtml = '<div class="nav-item-matches">';
  1014. top3Matches.forEach((match, i) => {
  1015. // 生成层级路径
  1016. let hierarchyHtml = '';
  1017. if (match.hierarchy && match.hierarchy.length > 0) {
  1018. hierarchyHtml = '<div class="nav-match-hierarchy">';
  1019. match.hierarchy.forEach((level, idx) => {
  1020. if (idx > 0) {
  1021. hierarchyHtml += '<span class="hierarchy-separator">›</span>';
  1022. }
  1023. hierarchyHtml += `<span class="hierarchy-item">${level}</span>`;
  1024. });
  1025. hierarchyHtml += '</div>';
  1026. }
  1027. matchesHtml += `
  1028. <div class="nav-match-item">
  1029. <span class="nav-match-rank rank-${match.rank}">Top${match.rank}</span>
  1030. <div class="nav-match-content">
  1031. <span class="nav-match-name">${match.name}</span>
  1032. ${hierarchyHtml}
  1033. <span class="nav-match-score">${match.score.toFixed(2)}</span>
  1034. </div>
  1035. </div>
  1036. `;
  1037. });
  1038. matchesHtml += '</div>';
  1039. }
  1040. navItem.innerHTML = `
  1041. <div class="nav-item-header">
  1042. <span class="nav-item-name" title="${name}">
  1043. <span class="nav-label">[灵感点]</span>${name}
  1044. </span>
  1045. <span class="nav-item-score">${score.toFixed(2)}</span>
  1046. </div>
  1047. ${matchesHtml}
  1048. `;
  1049. navItem.addEventListener('click', () => {
  1050. // 移除所有active状态
  1051. document.querySelectorAll('.nav-item').forEach(item => {
  1052. item.classList.remove('active');
  1053. });
  1054. // 添加当前active状态
  1055. navItem.classList.add('active');
  1056. // 显示对应详情
  1057. showDetail(index);
  1058. });
  1059. navList.appendChild(navItem);
  1060. });
  1061. // 默认显示第一个详情
  1062. if (details.length > 0) {
  1063. showDetail(0);
  1064. }
  1065. }
  1066. // 更新面包屑
  1067. function updateBreadcrumb(matchName, stepName) {
  1068. const breadcrumb = document.querySelector('.inspiration-detail.active #dynamicBreadcrumb');
  1069. if (!breadcrumb) return;
  1070. const inspirationName = document.querySelector('.inspiration-detail.active').dataset.inspirationName;
  1071. let breadcrumbHtml = `
  1072. <span class="breadcrumb-item"><span class="breadcrumb-label">[灵感点]</span> ${inspirationName}</span>
  1073. `;
  1074. if (matchName) {
  1075. breadcrumbHtml += `
  1076. <span class="breadcrumb-separator">›</span>
  1077. <span class="breadcrumb-item"><span class="breadcrumb-label">[灵感分类]</span> ${matchName}</span>
  1078. `;
  1079. }
  1080. if (stepName) {
  1081. breadcrumbHtml += `
  1082. <span class="breadcrumb-separator">›</span>
  1083. <span class="breadcrumb-item breadcrumb-current">${stepName}</span>
  1084. `;
  1085. }
  1086. breadcrumb.innerHTML = breadcrumbHtml;
  1087. }
  1088. // 监听滚动,更新面包屑
  1089. function setupBreadcrumbObserver() {
  1090. const activeDetail = document.querySelector('.inspiration-detail.active');
  1091. if (!activeDetail) return;
  1092. const contentWrapper = activeDetail.querySelector('.inspiration-content-wrapper');
  1093. if (!contentWrapper) return;
  1094. // 获取所有需要监听的section
  1095. const sections = activeDetail.querySelectorAll('.step-section');
  1096. if (sections.length === 0) return;
  1097. // 创建Intersection Observer
  1098. const observerOptions = {
  1099. root: null,
  1100. rootMargin: '-100px 0px -50% 0px',
  1101. threshold: 0
  1102. };
  1103. const observer = new IntersectionObserver((entries) => {
  1104. entries.forEach(entry => {
  1105. if (entry.isIntersecting) {
  1106. const section = entry.target;
  1107. const matchItem = section.closest('.match-item');
  1108. const matchName = matchItem ? matchItem.dataset.matchName : '';
  1109. const stepName = section.dataset.stepName || '';
  1110. updateBreadcrumb(matchName, stepName);
  1111. }
  1112. });
  1113. }, observerOptions);
  1114. // 观察所有section
  1115. sections.forEach(section => observer.observe(section));
  1116. // 存储observer以便清理
  1117. if (!window.breadcrumbObservers) {
  1118. window.breadcrumbObservers = [];
  1119. }
  1120. window.breadcrumbObservers.push(observer);
  1121. }
  1122. // 页面加载时生成导航
  1123. document.addEventListener('DOMContentLoaded', () => {
  1124. generateNavigation();
  1125. setupBreadcrumbObserver();
  1126. });
  1127. // 当切换灵感点时,重新设置observer
  1128. const originalShowDetail = showDetail;
  1129. showDetail = function(index) {
  1130. // 清理旧的observers
  1131. if (window.breadcrumbObservers) {
  1132. window.breadcrumbObservers.forEach(obs => obs.disconnect());
  1133. window.breadcrumbObservers = [];
  1134. }
  1135. // 调用原始函数
  1136. originalShowDetail(index);
  1137. // 设置新的observer
  1138. setTimeout(() => {
  1139. setupBreadcrumbObserver();
  1140. }, 100);
  1141. };
  1142. '''
  1143. def generate_persona_structure_html(persona_data: Dict[str, Any]) -> str:
  1144. """
  1145. 生成人设结构的树状HTML
  1146. Args:
  1147. persona_data: 人设数据
  1148. Returns:
  1149. 人设结构的HTML字符串
  1150. """
  1151. if not persona_data:
  1152. return '<div class="empty-state">暂无人设数据</div>'
  1153. inspiration_list = persona_data.get("灵感点列表", [])
  1154. if not inspiration_list:
  1155. return '<div class="empty-state">暂无灵感点列表数据</div>'
  1156. html_parts = ['<div class="tree">']
  1157. for perspective_idx, perspective in enumerate(inspiration_list):
  1158. perspective_name = perspective.get("视角名称", "未知视角")
  1159. perspective_desc = perspective.get("视角描述", "")
  1160. pattern_list = perspective.get("模式列表", [])
  1161. # 一级节点:视角
  1162. html_parts.append(f'''
  1163. <ul>
  1164. <li>
  1165. <div class="tree-node level-1">
  1166. <span class="node-icon">📁</span>
  1167. <span class="node-name">{html_module.escape(perspective_name)}</span>
  1168. <span class="node-count">{len(pattern_list)}个分类</span>
  1169. </div>
  1170. ''')
  1171. if perspective_desc:
  1172. html_parts.append(f'''
  1173. <div class="node-desc">{html_module.escape(perspective_desc)}</div>
  1174. ''')
  1175. # 二级节点:分类
  1176. if pattern_list:
  1177. html_parts.append('<ul>')
  1178. for pattern in pattern_list:
  1179. category_name = pattern.get("分类名称", "未知分类")
  1180. core_definition = pattern.get("核心定义", "")
  1181. subcategories = pattern.get("二级细分", [])
  1182. total_posts = sum(len(sub.get("帖子ID列表", [])) for sub in subcategories)
  1183. html_parts.append(f'''
  1184. <li>
  1185. <div class="tree-node level-2">
  1186. <span class="node-icon">📂</span>
  1187. <span class="node-name">{html_module.escape(category_name)}</span>
  1188. <span class="node-count">{total_posts}个帖子</span>
  1189. </div>
  1190. ''')
  1191. if core_definition:
  1192. html_parts.append(f'''
  1193. <div class="node-desc">{html_module.escape(core_definition)}</div>
  1194. ''')
  1195. # 三级节点:细分
  1196. if subcategories:
  1197. html_parts.append('<ul>')
  1198. for subcategory in subcategories:
  1199. sub_name = subcategory.get("分类名称", "未知细分")
  1200. sub_definition = subcategory.get("分类定义", "")
  1201. post_ids = subcategory.get("帖子ID列表", [])
  1202. html_parts.append(f'''
  1203. <li>
  1204. <div class="tree-node level-3">
  1205. <span class="node-icon">📄</span>
  1206. <span class="node-name">{html_module.escape(sub_name)}</span>
  1207. <span class="node-count">{len(post_ids)}个帖子</span>
  1208. </div>
  1209. ''')
  1210. if sub_definition:
  1211. html_parts.append(f'''
  1212. <div class="node-desc">{html_module.escape(sub_definition)}</div>
  1213. ''')
  1214. if post_ids:
  1215. html_parts.append(f'''
  1216. <div class="node-posts">
  1217. <span class="posts-label">📋 帖子ID:</span>
  1218. <span class="posts-ids">{", ".join([html_module.escape(str(pid)) for pid in post_ids[:5]])}</span>
  1219. {f'<span class="posts-more">... 等{len(post_ids)}个</span>' if len(post_ids) > 5 else ''}
  1220. </div>
  1221. ''')
  1222. html_parts.append('</li>')
  1223. html_parts.append('</ul>')
  1224. html_parts.append('</li>')
  1225. html_parts.append('</ul>')
  1226. html_parts.append('</li>')
  1227. html_parts.append('</ul>')
  1228. html_parts.append('</div>')
  1229. return ''.join(html_parts)
  1230. def generate_html(
  1231. inspirations_data: List[Dict[str, Any]],
  1232. posts_map: Dict[str, Dict[str, Any]],
  1233. persona_data: Dict[str, Any],
  1234. output_path: str,
  1235. inspiration_to_post_data: Dict[str, Any] = None,
  1236. category_index_data: Dict[str, Any] = None,
  1237. post_to_mapping_data: Dict[str, Any] = None
  1238. ) -> str:
  1239. """
  1240. 生成完整的可视化HTML
  1241. Args:
  1242. inspirations_data: 灵感点数据列表
  1243. posts_map: 帖子数据映射
  1244. persona_data: 人设数据
  1245. output_path: 输出文件路径
  1246. Returns:
  1247. 输出文件路径
  1248. """
  1249. timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  1250. # 统计信息
  1251. total_count = len(inspirations_data)
  1252. # Step1 统计
  1253. step1_excellent_count = sum(1 for d in inspirations_data
  1254. if d["summary"].get("关键指标", {}).get("step1_top1_score", 0) >= 0.7)
  1255. step1_good_count = sum(1 for d in inspirations_data
  1256. if 0.5 <= d["summary"].get("关键指标", {}).get("step1_top1_score", 0) < 0.7)
  1257. step1_normal_count = sum(1 for d in inspirations_data
  1258. if 0.3 <= d["summary"].get("关键指标", {}).get("step1_top1_score", 0) < 0.5)
  1259. step1_need_opt_count = sum(1 for d in inspirations_data
  1260. if d["summary"].get("关键指标", {}).get("step1_top1_score", 0) < 0.3)
  1261. # 平均分数
  1262. total_step1_score = sum(d["summary"].get("关键指标", {}).get("step1_top1_score", 0)
  1263. for d in inspirations_data)
  1264. avg_step1_score = total_step1_score / total_count if total_count > 0 else 0
  1265. # 按Step1分数排序
  1266. inspirations_data_sorted = sorted(
  1267. inspirations_data,
  1268. key=lambda x: x["summary"].get("关键指标", {}).get("step1_top1_score", 0),
  1269. reverse=True
  1270. )
  1271. # 生成卡片HTML
  1272. cards_html = [
  1273. generate_inspiration_card_html(data, inspiration_to_post_data, category_index_data, post_to_mapping_data)
  1274. for data in inspirations_data_sorted
  1275. ]
  1276. cards_html_str = '\n'.join(cards_html)
  1277. # 生成人设结构HTML
  1278. persona_structure_html = generate_persona_structure_html(persona_data)
  1279. # 生成JavaScript
  1280. detail_modal_js = generate_detail_modal_content_js()
  1281. # 完整HTML
  1282. html_content = f'''<!DOCTYPE html>
  1283. <html lang="zh-CN">
  1284. <head>
  1285. <meta charset="UTF-8">
  1286. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  1287. <title>灵感点分析可视化</title>
  1288. <style>
  1289. * {{
  1290. margin: 0;
  1291. padding: 0;
  1292. box-sizing: border-box;
  1293. }}
  1294. body {{
  1295. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  1296. background: #f5f7fa;
  1297. color: #333;
  1298. line-height: 1.6;
  1299. margin: 0;
  1300. padding: 0;
  1301. overflow: hidden;
  1302. }}
  1303. .container {{
  1304. max-width: 100%;
  1305. height: 100vh;
  1306. margin: 0;
  1307. padding: 0;
  1308. display: flex;
  1309. }}
  1310. .main-content-layout {{
  1311. display: flex;
  1312. width: 100%;
  1313. height: 100vh;
  1314. overflow: hidden;
  1315. }}
  1316. .sidebar-nav {{
  1317. width: 400px;
  1318. background: white;
  1319. padding: 30px 20px;
  1320. box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  1321. overflow-y: auto;
  1322. flex-shrink: 0;
  1323. height: 100vh;
  1324. }}
  1325. .nav-title {{
  1326. font-size: 18px;
  1327. font-weight: 700;
  1328. color: #1a1a1a;
  1329. margin-bottom: 15px;
  1330. padding-bottom: 10px;
  1331. border-bottom: 2px solid #e5e7eb;
  1332. }}
  1333. .nav-list {{
  1334. display: flex;
  1335. flex-direction: column;
  1336. gap: 12px;
  1337. }}
  1338. .nav-item {{
  1339. border-radius: 10px;
  1340. cursor: pointer;
  1341. transition: all 0.3s;
  1342. border: 2px solid #e5e7eb;
  1343. overflow: hidden;
  1344. background: white;
  1345. }}
  1346. .nav-item:hover {{
  1347. border-color: #667eea;
  1348. box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  1349. }}
  1350. .nav-item.active {{
  1351. border-color: #667eea;
  1352. box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25);
  1353. }}
  1354. .nav-item-header {{
  1355. padding: 12px 14px;
  1356. background: #f9fafb;
  1357. display: flex;
  1358. justify-content: space-between;
  1359. align-items: center;
  1360. gap: 8px;
  1361. }}
  1362. .nav-item.active .nav-item-header {{
  1363. background: rgba(102, 126, 234, 0.1);
  1364. }}
  1365. .nav-item-name {{
  1366. flex: 1;
  1367. font-weight: 600;
  1368. font-size: 14px;
  1369. color: #1f2937;
  1370. overflow: hidden;
  1371. text-overflow: ellipsis;
  1372. white-space: nowrap;
  1373. display: flex;
  1374. align-items: center;
  1375. gap: 6px;
  1376. }}
  1377. .nav-item.active .nav-item-name {{
  1378. color: #667eea;
  1379. }}
  1380. .nav-label {{
  1381. display: inline-block;
  1382. font-size: 11px;
  1383. color: #8b5cf6;
  1384. background: #f5f3ff;
  1385. padding: 2px 6px;
  1386. border-radius: 3px;
  1387. font-weight: 500;
  1388. white-space: nowrap;
  1389. flex-shrink: 0;
  1390. }}
  1391. .nav-item-score {{
  1392. font-size: 13px;
  1393. font-weight: 700;
  1394. padding: 4px 10px;
  1395. border-radius: 6px;
  1396. background: #e5e7eb;
  1397. color: #6b7280;
  1398. }}
  1399. .nav-item.active .nav-item-score {{
  1400. background: #667eea;
  1401. color: white;
  1402. }}
  1403. .nav-item-matches {{
  1404. padding: 10px 14px;
  1405. background: white;
  1406. border-top: 1px solid #e5e7eb;
  1407. }}
  1408. .nav-match-item {{
  1409. padding: 8px 0;
  1410. font-size: 12px;
  1411. color: #6b7280;
  1412. display: flex;
  1413. align-items: flex-start;
  1414. gap: 6px;
  1415. }}
  1416. .nav-match-item:not(:last-child) {{
  1417. border-bottom: 1px dashed #e5e7eb;
  1418. }}
  1419. .nav-match-rank {{
  1420. font-weight: 700;
  1421. color: #9ca3af;
  1422. min-width: 20px;
  1423. flex-shrink: 0;
  1424. }}
  1425. .nav-match-rank.rank-1 {{
  1426. color: #f59e0b;
  1427. }}
  1428. .nav-match-rank.rank-2 {{
  1429. color: #c0c0c0;
  1430. }}
  1431. .nav-match-rank.rank-3 {{
  1432. color: #cd7f32;
  1433. }}
  1434. .nav-match-content {{
  1435. flex: 1;
  1436. line-height: 1.6;
  1437. min-width: 0;
  1438. }}
  1439. .nav-match-name {{
  1440. color: #1f2937;
  1441. font-weight: 600;
  1442. display: block;
  1443. margin-bottom: 4px;
  1444. }}
  1445. .nav-match-hierarchy {{
  1446. font-size: 11px;
  1447. color: #9ca3af;
  1448. display: flex;
  1449. align-items: center;
  1450. gap: 4px;
  1451. flex-wrap: wrap;
  1452. margin-bottom: 3px;
  1453. }}
  1454. .hierarchy-item {{
  1455. display: inline-flex;
  1456. align-items: center;
  1457. gap: 4px;
  1458. }}
  1459. .hierarchy-separator {{
  1460. color: #d1d5db;
  1461. }}
  1462. .nav-match-score {{
  1463. color: #667eea;
  1464. font-weight: 700;
  1465. font-size: 13px;
  1466. }}
  1467. .inspirations-section {{
  1468. flex: 1;
  1469. height: 100vh;
  1470. overflow-y: auto;
  1471. background: #f5f7fa;
  1472. position: relative;
  1473. }}
  1474. .breadcrumb-container {{
  1475. position: sticky;
  1476. top: 0;
  1477. left: 0;
  1478. right: 0;
  1479. background: white;
  1480. border-bottom: 1px solid #e5e7eb;
  1481. padding: 15px 30px;
  1482. z-index: 100;
  1483. box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  1484. }}
  1485. .breadcrumb {{
  1486. display: flex;
  1487. align-items: center;
  1488. gap: 8px;
  1489. font-size: 14px;
  1490. color: #6b7280;
  1491. }}
  1492. .breadcrumb-item {{
  1493. display: flex;
  1494. align-items: center;
  1495. gap: 8px;
  1496. }}
  1497. .breadcrumb-separator {{
  1498. color: #d1d5db;
  1499. }}
  1500. .breadcrumb-current {{
  1501. color: #111827;
  1502. font-weight: 600;
  1503. }}
  1504. .breadcrumb-label {{
  1505. display: inline-block;
  1506. font-size: 12px;
  1507. color: #6366f1;
  1508. background: #eef2ff;
  1509. padding: 2px 8px;
  1510. border-radius: 4px;
  1511. font-weight: 500;
  1512. margin-right: 4px;
  1513. }}
  1514. .inspiration-content-wrapper {{
  1515. padding: 30px 40px;
  1516. }}
  1517. .inspirations-grid {{
  1518. display: none;
  1519. }}
  1520. .inspiration-display {{
  1521. width: 100%;
  1522. }}
  1523. .inspiration-detail {{
  1524. display: none;
  1525. }}
  1526. .inspiration-detail.active {{
  1527. display: block;
  1528. }}
  1529. .detail-header {{
  1530. background: white;
  1531. border-radius: 12px;
  1532. padding: 25px 30px;
  1533. margin-bottom: 15px;
  1534. box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  1535. border: 1px solid #e5e7eb;
  1536. }}
  1537. .detail-title-row {{
  1538. display: flex;
  1539. justify-content: space-between;
  1540. align-items: center;
  1541. margin-bottom: 15px;
  1542. }}
  1543. .detail-title-left, .detail-title-right {{
  1544. display: flex;
  1545. align-items: center;
  1546. gap: 10px;
  1547. }}
  1548. .detail-label {{
  1549. font-size: 12px;
  1550. color: #5b21b6;
  1551. background: rgba(109, 40, 217, 0.15);
  1552. padding: 3px 10px;
  1553. border-radius: 4px;
  1554. font-weight: 500;
  1555. }}
  1556. .detail-category {{
  1557. font-size: 18px;
  1558. font-weight: 600;
  1559. color: #374151;
  1560. }}
  1561. .detail-title {{
  1562. font-size: 24px;
  1563. font-weight: 700;
  1564. color: #111827;
  1565. margin-bottom: 12px;
  1566. }}
  1567. .detail-score-section {{
  1568. display: flex;
  1569. align-items: center;
  1570. gap: 12px;
  1571. }}
  1572. .detail-score-label {{
  1573. font-size: 13px;
  1574. color: #6b7280;
  1575. font-weight: 500;
  1576. }}
  1577. .detail-score-value {{
  1578. font-size: 20px;
  1579. font-weight: 700;
  1580. color: #374151;
  1581. }}
  1582. .card-header {{
  1583. display: flex;
  1584. justify-content: space-between;
  1585. align-items: flex-start;
  1586. margin-bottom: 20px;
  1587. gap: 12px;
  1588. }}
  1589. .inspiration-name {{
  1590. font-size: 28px;
  1591. font-weight: 800;
  1592. color: #1a1a1a;
  1593. line-height: 1.4;
  1594. flex: 1;
  1595. }}
  1596. .grade-badge {{
  1597. background: #10b981;
  1598. color: white;
  1599. padding: 6px 14px;
  1600. border-radius: 20px;
  1601. font-size: 12px;
  1602. font-weight: 700;
  1603. white-space: nowrap;
  1604. }}
  1605. .score-section {{
  1606. display: flex;
  1607. align-items: center;
  1608. gap: 25px;
  1609. margin-bottom: 20px;
  1610. padding: 20px;
  1611. background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  1612. border-radius: 12px;
  1613. }}
  1614. .score-item {{
  1615. display: flex;
  1616. flex-direction: column;
  1617. align-items: center;
  1618. gap: 8px;
  1619. flex: 1;
  1620. }}
  1621. .main-score {{
  1622. display: flex;
  1623. flex-direction: column;
  1624. align-items: center;
  1625. gap: 8px;
  1626. }}
  1627. .score-circle {{
  1628. width: 90px;
  1629. height: 90px;
  1630. border-radius: 50%;
  1631. border: 6px solid #10b981;
  1632. display: flex;
  1633. align-items: center;
  1634. justify-content: center;
  1635. background: white;
  1636. }}
  1637. .score-value {{
  1638. font-size: 26px;
  1639. font-weight: 800;
  1640. color: #10b981;
  1641. }}
  1642. .score-label {{
  1643. font-size: 12px;
  1644. color: #6b7280;
  1645. font-weight: 600;
  1646. }}
  1647. .sub-scores {{
  1648. flex: 1;
  1649. display: flex;
  1650. flex-direction: column;
  1651. gap: 12px;
  1652. }}
  1653. .sub-score-item {{
  1654. display: flex;
  1655. justify-content: space-between;
  1656. align-items: center;
  1657. padding: 10px 15px;
  1658. background: white;
  1659. border-radius: 8px;
  1660. }}
  1661. .sub-score-label {{
  1662. font-size: 13px;
  1663. color: #6b7280;
  1664. font-weight: 600;
  1665. }}
  1666. .sub-score-value {{
  1667. font-size: 18px;
  1668. font-weight: 700;
  1669. color: #2563eb;
  1670. }}
  1671. .metrics-section {{
  1672. display: flex;
  1673. flex-direction: column;
  1674. gap: 10px;
  1675. margin-bottom: 15px;
  1676. }}
  1677. .metric-item {{
  1678. display: flex;
  1679. align-items: center;
  1680. gap: 8px;
  1681. font-size: 13px;
  1682. color: #4b5563;
  1683. }}
  1684. .metric-icon {{
  1685. font-size: 16px;
  1686. }}
  1687. .metric-label {{
  1688. font-weight: 600;
  1689. }}
  1690. .metric-value {{
  1691. color: #1f2937;
  1692. }}
  1693. .match-preview {{
  1694. background: #f9fafb;
  1695. padding: 12px;
  1696. border-radius: 8px;
  1697. margin-bottom: 10px;
  1698. border-left: 3px solid #8b5cf6;
  1699. }}
  1700. .match-preview-header {{
  1701. font-size: 12px;
  1702. font-weight: 600;
  1703. color: #6b7280;
  1704. margin-bottom: 6px;
  1705. }}
  1706. .match-preview-content {{
  1707. display: flex;
  1708. justify-content: space-between;
  1709. align-items: center;
  1710. }}
  1711. .match-preview-name {{
  1712. font-size: 13px;
  1713. color: #1f2937;
  1714. flex: 1;
  1715. }}
  1716. .match-preview-score {{
  1717. font-size: 16px;
  1718. font-weight: 700;
  1719. }}
  1720. .preview-parts {{
  1721. margin-top: 8px;
  1722. padding: 8px 10px;
  1723. border-radius: 6px;
  1724. font-size: 12px;
  1725. line-height: 1.6;
  1726. }}
  1727. .preview-parts.same {{
  1728. background: #f0fdf4;
  1729. color: #15803d;
  1730. border-left: 3px solid #10b981;
  1731. }}
  1732. .preview-parts.increment {{
  1733. background: #fff7ed;
  1734. color: #92400e;
  1735. border-left: 3px solid #f59e0b;
  1736. margin-top: 6px;
  1737. }}
  1738. .preview-parts strong {{
  1739. font-weight: 700;
  1740. margin-right: 6px;
  1741. }}
  1742. .score-divider {{
  1743. width: 1px;
  1744. height: 40px;
  1745. background: #e5e7eb;
  1746. }}
  1747. .inspiration-category-section {{
  1748. display: grid;
  1749. grid-template-columns: 1fr 1fr;
  1750. gap: 25px;
  1751. margin-bottom: 0;
  1752. }}
  1753. .info-detail-column {{
  1754. background: #fafbfc;
  1755. border-radius: 10px;
  1756. border: 1px solid #e5e7eb;
  1757. overflow: hidden;
  1758. }}
  1759. .info-header {{
  1760. padding: 15px 20px;
  1761. border-bottom: 1px solid #e5e7eb;
  1762. background: #f9fafb;
  1763. display: flex;
  1764. align-items: center;
  1765. gap: 10px;
  1766. }}
  1767. .info-label {{
  1768. font-size: 11px;
  1769. color: #8b5cf6;
  1770. background: #f5f3ff;
  1771. padding: 2px 6px;
  1772. border-radius: 3px;
  1773. font-weight: 500;
  1774. }}
  1775. .info-name {{
  1776. font-size: 16px;
  1777. font-weight: 600;
  1778. color: #111827;
  1779. }}
  1780. .info-content {{
  1781. padding: 20px;
  1782. }}
  1783. .info-field {{
  1784. margin-bottom: 12px;
  1785. line-height: 1.6;
  1786. }}
  1787. .info-field-label {{
  1788. font-weight: 600;
  1789. color: #374151;
  1790. margin-right: 6px;
  1791. }}
  1792. .info-field-value {{
  1793. color: #6b7280;
  1794. }}
  1795. .info-posts {{
  1796. margin-top: 20px;
  1797. }}
  1798. .info-posts-title {{
  1799. font-size: 14px;
  1800. font-weight: 600;
  1801. color: #374151;
  1802. margin-bottom: 12px;
  1803. }}
  1804. .info-posts-grid {{
  1805. display: flex;
  1806. gap: 15px;
  1807. overflow-x: auto;
  1808. overflow-y: hidden;
  1809. padding-bottom: 10px;
  1810. scroll-behavior: smooth;
  1811. }}
  1812. .info-posts-grid::-webkit-scrollbar {{
  1813. height: 6px;
  1814. }}
  1815. .info-posts-grid::-webkit-scrollbar-track {{
  1816. background: #f3f4f6;
  1817. border-radius: 3px;
  1818. }}
  1819. .info-posts-grid::-webkit-scrollbar-thumb {{
  1820. background: #d1d5db;
  1821. border-radius: 3px;
  1822. }}
  1823. .info-posts-grid::-webkit-scrollbar-thumb:hover {{
  1824. background: #9ca3af;
  1825. }}
  1826. .info-posts-grid .search-note-item {{
  1827. flex: 0 0 280px;
  1828. min-width: 280px;
  1829. }}
  1830. .matches-list {{
  1831. display: flex;
  1832. flex-direction: column;
  1833. gap: 15px;
  1834. }}
  1835. .match-item {{
  1836. background: white;
  1837. border-radius: 12px;
  1838. overflow: hidden;
  1839. box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  1840. transition: all 0.3s;
  1841. margin-bottom: 20px;
  1842. }}
  1843. .match-item:hover {{
  1844. box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  1845. }}
  1846. .match-main-header {{
  1847. background: linear-gradient(135deg, #a5b4fc 0%, #c4b5fd 100%);
  1848. border-bottom: none;
  1849. padding: 16px 20px;
  1850. cursor: pointer;
  1851. display: flex;
  1852. justify-content: space-between;
  1853. align-items: center;
  1854. }}
  1855. .match-main-header:hover {{
  1856. background: linear-gradient(135deg, #8b9cfc 0%, #b39dfc 100%);
  1857. }}
  1858. .match-header-row {{
  1859. flex: 1;
  1860. display: flex;
  1861. justify-content: space-between;
  1862. align-items: center;
  1863. gap: 20px;
  1864. }}
  1865. .match-header-left, .match-header-right {{
  1866. display: flex;
  1867. align-items: center;
  1868. gap: 10px;
  1869. flex: 1;
  1870. }}
  1871. .match-header-center {{
  1872. display: flex;
  1873. flex-direction: column;
  1874. align-items: center;
  1875. gap: 4px;
  1876. padding: 0 20px;
  1877. }}
  1878. .match-score-label {{
  1879. font-size: 11px;
  1880. color: #4c1d95;
  1881. text-transform: uppercase;
  1882. }}
  1883. .match-score-value {{
  1884. font-size: 20px;
  1885. font-weight: 700;
  1886. color: #5b21b6;
  1887. }}
  1888. .match-title {{
  1889. color: #3730a3;
  1890. font-size: 16px;
  1891. font-weight: 700;
  1892. }}
  1893. .match-category {{
  1894. color: #3730a3;
  1895. font-size: 16px;
  1896. font-weight: 700;
  1897. }}
  1898. .match-hierarchy {{
  1899. color: #4c1d95;
  1900. font-size: 13px;
  1901. }}
  1902. .match-toggle-main {{
  1903. color: #5b21b6;
  1904. font-size: 20px;
  1905. transition: transform 0.3s;
  1906. flex-shrink: 0;
  1907. }}
  1908. .match-item.expanded .match-toggle-main {{
  1909. transform: rotate(180deg);
  1910. }}
  1911. .match-main-content {{
  1912. max-height: 0;
  1913. overflow: hidden;
  1914. transition: max-height 0.3s ease;
  1915. }}
  1916. .match-item.expanded .match-main-content {{
  1917. max-height: 10000px;
  1918. }}
  1919. .match-main-content .inspiration-category-section {{
  1920. margin: 25px;
  1921. margin-bottom: 0;
  1922. }}
  1923. .step-section-wrapper {{
  1924. margin: 20px 25px;
  1925. border: 2px solid #e5e7eb;
  1926. border-radius: 12px;
  1927. overflow: hidden;
  1928. background: white;
  1929. }}
  1930. .step-1-wrapper {{
  1931. border-color: #fbbf24;
  1932. }}
  1933. .step-2-wrapper {{
  1934. border-color: #34d399;
  1935. }}
  1936. .step-header {{
  1937. background: linear-gradient(135deg, #fbbf24 0%, #fcd34d 100%);
  1938. padding: 16px 25px;
  1939. display: flex;
  1940. justify-content: space-between;
  1941. align-items: center;
  1942. cursor: pointer;
  1943. transition: all 0.3s;
  1944. }}
  1945. .step-header:hover {{
  1946. background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  1947. }}
  1948. .step-2-wrapper .step-header {{
  1949. background: linear-gradient(135deg, #34d399 0%, #6ee7b7 100%);
  1950. }}
  1951. .step-2-wrapper .step-header:hover {{
  1952. background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  1953. }}
  1954. .step-header-content {{
  1955. display: flex;
  1956. align-items: center;
  1957. gap: 12px;
  1958. }}
  1959. .step-header .step-toggle {{
  1960. font-size: 20px;
  1961. color: #78350f;
  1962. transition: transform 0.3s;
  1963. }}
  1964. .step-2-wrapper .step-header .step-toggle {{
  1965. color: #065f46;
  1966. }}
  1967. .step-section-wrapper.expanded > .step-header .step-toggle {{
  1968. transform: rotate(180deg);
  1969. }}
  1970. .step-wrapper-content {{
  1971. max-height: 0;
  1972. overflow: hidden;
  1973. transition: max-height 0.3s ease;
  1974. }}
  1975. .step-section-wrapper.expanded .step-wrapper-content {{
  1976. max-height: 10000px;
  1977. }}
  1978. .step-number-badge {{
  1979. background: rgba(255, 255, 255, 0.5);
  1980. color: #78350f;
  1981. padding: 6px 14px;
  1982. border-radius: 20px;
  1983. font-size: 13px;
  1984. font-weight: 700;
  1985. letter-spacing: 0.5px;
  1986. }}
  1987. .step-2-wrapper .step-number-badge {{
  1988. color: #065f46;
  1989. }}
  1990. .step-title {{
  1991. color: #78350f;
  1992. font-size: 16px;
  1993. font-weight: 700;
  1994. }}
  1995. .step-2-wrapper .step-title {{
  1996. color: #065f46;
  1997. }}
  1998. .match-analysis-section {{
  1999. padding: 25px;
  2000. }}
  2001. .match-header {{
  2002. padding: 20px;
  2003. cursor: pointer;
  2004. display: flex;
  2005. justify-content: space-between;
  2006. align-items: center;
  2007. gap: 15px;
  2008. background: #fafafa;
  2009. transition: background 0.3s;
  2010. border-bottom: 1px solid #e5e7eb;
  2011. }}
  2012. .match-header:hover {{
  2013. background: #f5f5f5;
  2014. }}
  2015. .match-section.expanded .match-header {{
  2016. background: rgba(102, 126, 234, 0.05);
  2017. }}
  2018. .match-header-left {{
  2019. flex: 1;
  2020. min-width: 0;
  2021. }}
  2022. .match-rank {{
  2023. display: inline-block;
  2024. padding: 3px 10px;
  2025. border-radius: 4px;
  2026. font-size: 11px;
  2027. font-weight: 600;
  2028. background: rgba(91, 33, 182, 0.15);
  2029. color: #5b21b6;
  2030. }}
  2031. .match-element-name {{
  2032. font-size: 18px;
  2033. font-weight: 700;
  2034. color: #1f2937;
  2035. display: block;
  2036. margin-bottom: 6px;
  2037. }}
  2038. .match-context {{
  2039. font-size: 13px;
  2040. color: #6b7280;
  2041. display: flex;
  2042. align-items: center;
  2043. gap: 6px;
  2044. }}
  2045. .match-context-separator {{
  2046. color: #d1d5db;
  2047. }}
  2048. .match-header-right {{
  2049. display: flex;
  2050. align-items: center;
  2051. gap: 15px;
  2052. flex-shrink: 0;
  2053. }}
  2054. .match-score {{
  2055. font-size: 24px;
  2056. font-weight: 800;
  2057. color: #667eea;
  2058. }}
  2059. .match-toggle {{
  2060. width: 32px;
  2061. height: 32px;
  2062. border-radius: 8px;
  2063. background: #e5e7eb;
  2064. display: flex;
  2065. align-items: center;
  2066. justify-content: center;
  2067. transition: all 0.3s;
  2068. font-size: 18px;
  2069. color: #6b7280;
  2070. }}
  2071. .match-item.expanded .match-toggle {{
  2072. background: #667eea;
  2073. color: white;
  2074. transform: rotate(180deg);
  2075. }}
  2076. .match-section {{
  2077. border-bottom: 1px solid #e5e7eb;
  2078. }}
  2079. .match-section:last-child {{
  2080. border-bottom: none;
  2081. }}
  2082. .step-section-header {{
  2083. padding: 18px 25px;
  2084. background: #f9fafb;
  2085. cursor: pointer;
  2086. display: flex;
  2087. justify-content: space-between;
  2088. align-items: center;
  2089. border-bottom: 1px solid #e5e7eb;
  2090. }}
  2091. .step-section-header:hover {{
  2092. background: #f3f4f6;
  2093. }}
  2094. .step-section-title {{
  2095. font-size: 15px;
  2096. font-weight: 600;
  2097. color: #374151;
  2098. display: flex;
  2099. align-items: center;
  2100. gap: 10px;
  2101. }}
  2102. .step-sub-number {{
  2103. display: inline-flex;
  2104. align-items: center;
  2105. justify-content: center;
  2106. min-width: 38px;
  2107. padding: 4px 10px;
  2108. background: #10b981;
  2109. color: white;
  2110. border-radius: 6px;
  2111. font-size: 12px;
  2112. font-weight: 700;
  2113. }}
  2114. .step-number {{
  2115. display: inline-flex;
  2116. align-items: center;
  2117. justify-content: center;
  2118. width: 20px;
  2119. height: 20px;
  2120. background: #e5e7eb;
  2121. color: #6b7280;
  2122. border-radius: 50%;
  2123. font-size: 11px;
  2124. font-weight: 600;
  2125. }}
  2126. .step-toggle {{
  2127. font-size: 18px;
  2128. color: #6b7280;
  2129. transition: transform 0.3s;
  2130. }}
  2131. .step-section.expanded .step-toggle {{
  2132. transform: rotate(180deg);
  2133. }}
  2134. .step-section-content {{
  2135. max-height: 0;
  2136. overflow: hidden;
  2137. transition: max-height 0.3s ease;
  2138. }}
  2139. .step-section.expanded .step-section-content {{
  2140. max-height: 5000px;
  2141. }}
  2142. .match-content {{
  2143. max-height: 0;
  2144. overflow: hidden;
  2145. transition: max-height 0.3s ease;
  2146. }}
  2147. .match-section.expanded .match-content {{
  2148. max-height: 2000px;
  2149. }}
  2150. .match-content-inner {{
  2151. padding: 20px;
  2152. }}
  2153. .match-explain {{
  2154. background: #fffbeb;
  2155. padding: 16px 20px;
  2156. border-radius: 8px;
  2157. margin-top: 20px;
  2158. border-left: 3px solid #f59e0b;
  2159. }}
  2160. .match-explain-title {{
  2161. font-weight: 600;
  2162. color: #374151;
  2163. margin-bottom: 6px;
  2164. font-size: 13px;
  2165. }}
  2166. .match-explain-text {{
  2167. color: #6b7280;
  2168. font-size: 14px;
  2169. line-height: 1.7;
  2170. }}
  2171. .match-parts-container {{
  2172. display: grid;
  2173. grid-template-columns: 1fr 1fr;
  2174. gap: 25px;
  2175. margin-bottom: 20px;
  2176. }}
  2177. .match-parts-column {{
  2178. min-width: 0;
  2179. }}
  2180. .match-parts {{
  2181. margin-bottom: 0;
  2182. height: 100%;
  2183. background: #f9fafb;
  2184. padding: 16px;
  2185. border-radius: 8px;
  2186. border: 1px solid #e5e7eb;
  2187. }}
  2188. .match-parts-title {{
  2189. font-weight: 700;
  2190. font-size: 14px;
  2191. margin-bottom: 16px;
  2192. color: #374151;
  2193. text-transform: uppercase;
  2194. letter-spacing: 0.5px;
  2195. }}
  2196. .part-item {{
  2197. padding: 10px 0;
  2198. margin-bottom: 8px;
  2199. font-size: 14px;
  2200. border-bottom: 1px solid #e5e7eb;
  2201. }}
  2202. .part-item:last-child {{
  2203. border-bottom: none;
  2204. }}
  2205. .part-key {{
  2206. font-weight: 500;
  2207. color: #374151;
  2208. margin-right: 8px;
  2209. }}
  2210. .part-value {{
  2211. color: #6b7280;
  2212. }}
  2213. .same-parts {{
  2214. background: #ecfdf5;
  2215. border-color: #10b981;
  2216. }}
  2217. .increment-parts {{
  2218. background: #fef3c7;
  2219. border-color: #f59e0b;
  2220. }}
  2221. .search-results-section {{
  2222. padding: 25px;
  2223. }}
  2224. .search-params-section {{
  2225. background: #f0f9ff;
  2226. border: 1px solid #bae6fd;
  2227. border-radius: 8px;
  2228. padding: 20px;
  2229. margin-bottom: 20px;
  2230. }}
  2231. .search-params-title {{
  2232. font-size: 15px;
  2233. font-weight: 700;
  2234. color: #0c4a6e;
  2235. margin-bottom: 16px;
  2236. }}
  2237. .search-params-grid {{
  2238. display: grid;
  2239. grid-template-columns: repeat(2, 1fr);
  2240. gap: 12px;
  2241. }}
  2242. .search-param-item {{
  2243. display: flex;
  2244. align-items: center;
  2245. gap: 8px;
  2246. }}
  2247. .search-param-label {{
  2248. font-size: 13px;
  2249. color: #0369a1;
  2250. font-weight: 600;
  2251. min-width: 80px;
  2252. }}
  2253. .search-param-value {{
  2254. font-size: 13px;
  2255. color: #0c4a6e;
  2256. background: #e0f2fe;
  2257. padding: 4px 12px;
  2258. border-radius: 4px;
  2259. }}
  2260. .search-summary-section {{
  2261. background: #ecfdf5;
  2262. border: 1px solid #a7f3d0;
  2263. border-radius: 8px;
  2264. padding: 16px 20px;
  2265. margin-bottom: 20px;
  2266. }}
  2267. .search-summary-title {{
  2268. font-size: 15px;
  2269. font-weight: 700;
  2270. color: #065f46;
  2271. margin-bottom: 8px;
  2272. }}
  2273. .search-summary-content {{
  2274. font-size: 14px;
  2275. color: #047857;
  2276. }}
  2277. .search-result-count {{
  2278. font-size: 18px;
  2279. font-weight: 700;
  2280. color: #059669;
  2281. margin: 0 4px;
  2282. }}
  2283. .search-notes-list {{
  2284. display: grid;
  2285. grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  2286. gap: 20px;
  2287. }}
  2288. .search-note-item {{
  2289. background: white;
  2290. border-radius: 12px;
  2291. overflow: hidden;
  2292. box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  2293. border: 1px solid #e5e7eb;
  2294. transition: all 0.3s;
  2295. }}
  2296. .search-note-item:hover {{
  2297. box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
  2298. border-color: #667eea;
  2299. }}
  2300. .note-image-carousel {{
  2301. position: relative;
  2302. width: 100%;
  2303. min-height: 200px;
  2304. max-height: 400px;
  2305. background: #f3f4f6;
  2306. overflow: hidden;
  2307. display: flex;
  2308. align-items: center;
  2309. justify-content: center;
  2310. }}
  2311. .note-images-track {{
  2312. display: flex;
  2313. width: 100%;
  2314. height: 100%;
  2315. transition: transform 0.4s ease;
  2316. }}
  2317. .note-image {{
  2318. flex: 0 0 100%;
  2319. width: 100%;
  2320. height: auto;
  2321. max-height: 400px;
  2322. object-fit: contain;
  2323. }}
  2324. .note-carousel-button {{
  2325. position: absolute;
  2326. top: 50%;
  2327. transform: translateY(-50%);
  2328. width: 32px;
  2329. height: 32px;
  2330. background: rgba(255, 255, 255, 0.9);
  2331. border: none;
  2332. border-radius: 50%;
  2333. display: flex;
  2334. align-items: center;
  2335. justify-content: center;
  2336. cursor: pointer;
  2337. transition: all 0.3s;
  2338. z-index: 10;
  2339. font-size: 16px;
  2340. color: #6b7280;
  2341. opacity: 0;
  2342. }}
  2343. .search-note-item:hover .note-carousel-button {{
  2344. opacity: 1;
  2345. }}
  2346. .note-carousel-button:hover {{
  2347. background: #667eea;
  2348. color: white;
  2349. }}
  2350. .note-carousel-button.disabled {{
  2351. opacity: 0 !important;
  2352. }}
  2353. .note-carousel-button.prev {{
  2354. left: 10px;
  2355. }}
  2356. .note-carousel-button.next {{
  2357. right: 10px;
  2358. }}
  2359. .note-image-dots {{
  2360. position: absolute;
  2361. bottom: 10px;
  2362. left: 50%;
  2363. transform: translateX(-50%);
  2364. display: flex;
  2365. gap: 6px;
  2366. z-index: 10;
  2367. }}
  2368. .note-image-dot {{
  2369. width: 6px;
  2370. height: 6px;
  2371. border-radius: 50%;
  2372. background: rgba(255, 255, 255, 0.6);
  2373. transition: all 0.3s;
  2374. }}
  2375. .note-image-dot.active {{
  2376. background: white;
  2377. width: 20px;
  2378. border-radius: 3px;
  2379. }}
  2380. .note-content {{
  2381. padding: 15px;
  2382. }}
  2383. .note-title {{
  2384. font-size: 15px;
  2385. font-weight: 600;
  2386. color: #1f2937;
  2387. margin-bottom: 8px;
  2388. overflow: hidden;
  2389. text-overflow: ellipsis;
  2390. display: -webkit-box;
  2391. -webkit-line-clamp: 2;
  2392. -webkit-box-orient: vertical;
  2393. line-height: 1.4;
  2394. }}
  2395. .note-desc {{
  2396. font-size: 13px;
  2397. color: #6b7280;
  2398. line-height: 1.6;
  2399. margin-bottom: 12px;
  2400. overflow: hidden;
  2401. text-overflow: ellipsis;
  2402. display: -webkit-box;
  2403. -webkit-line-clamp: 2;
  2404. -webkit-box-orient: vertical;
  2405. }}
  2406. .note-footer {{
  2407. display: flex;
  2408. justify-content: space-between;
  2409. align-items: center;
  2410. padding-top: 12px;
  2411. border-top: 1px solid #f3f4f6;
  2412. }}
  2413. .note-author {{
  2414. font-size: 12px;
  2415. font-weight: 600;
  2416. color: #6b7280;
  2417. overflow: hidden;
  2418. text-overflow: ellipsis;
  2419. white-space: nowrap;
  2420. max-width: 150px;
  2421. }}
  2422. .note-points-hover {{
  2423. position: absolute;
  2424. bottom: 100%;
  2425. left: 0;
  2426. right: 0;
  2427. background: white;
  2428. border: 1px solid #e5e7eb;
  2429. border-radius: 8px;
  2430. box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  2431. padding: 12px;
  2432. margin-bottom: 8px;
  2433. opacity: 0;
  2434. visibility: hidden;
  2435. transition: opacity 0.2s, visibility 0.2s;
  2436. z-index: 10;
  2437. max-height: 300px;
  2438. overflow-y: auto;
  2439. }}
  2440. .search-note-item {{
  2441. position: relative;
  2442. }}
  2443. .search-note-item:hover .note-points-hover {{
  2444. opacity: 1;
  2445. visibility: visible;
  2446. }}
  2447. .note-points {{
  2448. /* 用于详情弹窗中的样式 */
  2449. }}
  2450. .points-section {{
  2451. margin-bottom: 8px;
  2452. }}
  2453. .points-section:last-child {{
  2454. margin-bottom: 0;
  2455. }}
  2456. .points-label {{
  2457. font-size: 11px;
  2458. font-weight: 600;
  2459. color: #6b7280;
  2460. margin-bottom: 4px;
  2461. }}
  2462. .points-list {{
  2463. display: flex;
  2464. flex-wrap: wrap;
  2465. gap: 4px;
  2466. }}
  2467. .point-item {{
  2468. display: inline-block;
  2469. }}
  2470. .point-name {{
  2471. display: inline-block;
  2472. font-size: 11px;
  2473. color: #4b5563;
  2474. background: #f3f4f6;
  2475. padding: 2px 6px;
  2476. border-radius: 3px;
  2477. }}
  2478. .note-stats {{
  2479. display: flex;
  2480. gap: 10px;
  2481. font-size: 12px;
  2482. color: #9ca3af;
  2483. }}
  2484. .note-link {{
  2485. display: block;
  2486. text-align: center;
  2487. padding: 8px;
  2488. margin-top: 10px;
  2489. background: rgba(102, 126, 234, 0.1);
  2490. color: #667eea;
  2491. text-decoration: none;
  2492. border-radius: 6px;
  2493. font-size: 13px;
  2494. font-weight: 600;
  2495. transition: all 0.3s;
  2496. }}
  2497. .note-link:hover {{
  2498. background: #667eea;
  2499. color: white;
  2500. }}
  2501. /* 笔记详情Modal样式 */
  2502. .note-detail-modal {{
  2503. display: none;
  2504. position: fixed;
  2505. top: 0;
  2506. left: 0;
  2507. width: 100%;
  2508. height: 100%;
  2509. background: rgba(0, 0, 0, 0.8);
  2510. z-index: 9999;
  2511. overflow-y: auto;
  2512. padding: 40px 20px;
  2513. }}
  2514. .note-detail-modal.active {{
  2515. display: flex;
  2516. align-items: flex-start;
  2517. justify-content: center;
  2518. }}
  2519. .note-detail-content {{
  2520. background: white;
  2521. border-radius: 16px;
  2522. max-width: 1200px;
  2523. width: 100%;
  2524. position: relative;
  2525. margin: auto;
  2526. }}
  2527. .note-detail-close {{
  2528. position: absolute;
  2529. top: 20px;
  2530. right: 20px;
  2531. width: 40px;
  2532. height: 40px;
  2533. background: white;
  2534. border: none;
  2535. border-radius: 50%;
  2536. font-size: 24px;
  2537. cursor: pointer;
  2538. display: flex;
  2539. align-items: center;
  2540. justify-content: center;
  2541. box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  2542. transition: all 0.3s;
  2543. z-index: 10;
  2544. }}
  2545. .note-detail-close:hover {{
  2546. background: #ef4444;
  2547. color: white;
  2548. transform: rotate(90deg);
  2549. }}
  2550. .note-detail-header {{
  2551. padding: 30px;
  2552. border-bottom: 1px solid #e5e7eb;
  2553. }}
  2554. .note-detail-title {{
  2555. font-size: 24px;
  2556. font-weight: 800;
  2557. color: #1f2937;
  2558. margin-bottom: 15px;
  2559. }}
  2560. .note-detail-meta {{
  2561. display: flex;
  2562. align-items: center;
  2563. gap: 20px;
  2564. font-size: 14px;
  2565. color: #6b7280;
  2566. }}
  2567. .note-detail-author {{
  2568. font-weight: 600;
  2569. color: #1f2937;
  2570. }}
  2571. .note-detail-stats {{
  2572. display: flex;
  2573. gap: 15px;
  2574. }}
  2575. .note-detail-body {{
  2576. padding: 30px;
  2577. }}
  2578. .note-detail-desc {{
  2579. font-size: 15px;
  2580. line-height: 1.8;
  2581. color: #4b5563;
  2582. margin-bottom: 30px;
  2583. }}
  2584. .note-detail-points {{
  2585. margin-bottom: 30px;
  2586. background: #f9fafb;
  2587. border-radius: 8px;
  2588. padding: 20px;
  2589. }}
  2590. .detail-points-section {{
  2591. margin-bottom: 20px;
  2592. }}
  2593. .detail-points-section:last-child {{
  2594. margin-bottom: 0;
  2595. }}
  2596. .detail-points-title {{
  2597. font-size: 16px;
  2598. font-weight: 600;
  2599. color: #111827;
  2600. margin-bottom: 12px;
  2601. }}
  2602. .detail-point-item {{
  2603. background: white;
  2604. padding: 12px 15px;
  2605. border-radius: 6px;
  2606. margin-bottom: 10px;
  2607. border-left: 3px solid #e5e7eb;
  2608. }}
  2609. .detail-point-item:last-child {{
  2610. margin-bottom: 0;
  2611. }}
  2612. .detail-point-name {{
  2613. font-size: 14px;
  2614. font-weight: 600;
  2615. color: #374151;
  2616. margin-bottom: 4px;
  2617. }}
  2618. .detail-point-desc {{
  2619. font-size: 13px;
  2620. line-height: 1.6;
  2621. color: #6b7280;
  2622. }}
  2623. .note-detail-images {{
  2624. display: grid;
  2625. grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  2626. gap: 15px;
  2627. }}
  2628. .note-detail-image {{
  2629. width: 100%;
  2630. border-radius: 8px;
  2631. cursor: pointer;
  2632. transition: all 0.3s;
  2633. }}
  2634. .note-detail-image:hover {{
  2635. transform: scale(1.05);
  2636. box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  2637. }}
  2638. .note-detail-footer {{
  2639. padding: 20px 30px;
  2640. border-top: 1px solid #e5e7eb;
  2641. display: flex;
  2642. justify-content: center;
  2643. }}
  2644. .note-detail-link {{
  2645. display: inline-block;
  2646. padding: 12px 32px;
  2647. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  2648. color: white;
  2649. text-decoration: none;
  2650. border-radius: 10px;
  2651. font-weight: 600;
  2652. transition: all 0.3s;
  2653. }}
  2654. .note-detail-link:hover {{
  2655. transform: translateY(-2px);
  2656. box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  2657. }}
  2658. /* Modal样式 */
  2659. .modal-overlay {{
  2660. display: none;
  2661. position: fixed;
  2662. top: 0;
  2663. left: 0;
  2664. right: 0;
  2665. bottom: 0;
  2666. background: rgba(0, 0, 0, 0.8);
  2667. z-index: 1000;
  2668. align-items: center;
  2669. justify-content: center;
  2670. padding: 20px;
  2671. overflow-y: auto;
  2672. }}
  2673. .modal-overlay.active {{
  2674. display: flex;
  2675. }}
  2676. .modal-content {{
  2677. background: white;
  2678. border-radius: 16px;
  2679. max-width: 1200px;
  2680. width: 100%;
  2681. max-height: 90vh;
  2682. overflow-y: auto;
  2683. position: relative;
  2684. }}
  2685. .modal-close {{
  2686. position: sticky;
  2687. top: 0;
  2688. right: 0;
  2689. background: white;
  2690. border: none;
  2691. font-size: 32px;
  2692. color: #6b7280;
  2693. cursor: pointer;
  2694. padding: 15px 20px;
  2695. z-index: 10;
  2696. text-align: right;
  2697. border-bottom: 1px solid #e5e7eb;
  2698. }}
  2699. .modal-close:hover {{
  2700. color: #1f2937;
  2701. }}
  2702. .modal-body {{
  2703. padding: 30px;
  2704. }}
  2705. .modal-header {{
  2706. margin-bottom: 25px;
  2707. padding-bottom: 20px;
  2708. border-bottom: 2px solid #e5e7eb;
  2709. }}
  2710. .modal-title {{
  2711. font-size: 28px;
  2712. font-weight: 800;
  2713. color: #1a1a1a;
  2714. }}
  2715. .modal-section {{
  2716. margin-bottom: 30px;
  2717. }}
  2718. .modal-section h3 {{
  2719. font-size: 20px;
  2720. font-weight: 700;
  2721. color: #374151;
  2722. margin-bottom: 15px;
  2723. padding-bottom: 10px;
  2724. border-bottom: 2px solid #f3f4f6;
  2725. }}
  2726. .info-grid {{
  2727. display: grid;
  2728. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  2729. gap: 15px;
  2730. }}
  2731. .info-item {{
  2732. background: #f9fafb;
  2733. padding: 12px 16px;
  2734. border-radius: 8px;
  2735. border-left: 3px solid #8b5cf6;
  2736. }}
  2737. .info-label {{
  2738. font-weight: 600;
  2739. color: #6b7280;
  2740. font-size: 13px;
  2741. margin-right: 8px;
  2742. }}
  2743. .info-value {{
  2744. color: #1f2937;
  2745. font-size: 14px;
  2746. }}
  2747. .metrics-grid {{
  2748. display: grid;
  2749. grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  2750. gap: 15px;
  2751. }}
  2752. .metric-box {{
  2753. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  2754. padding: 20px;
  2755. border-radius: 12px;
  2756. text-align: center;
  2757. color: white;
  2758. }}
  2759. .metric-box.wide {{
  2760. grid-column: span 2;
  2761. }}
  2762. .metric-box-label {{
  2763. font-size: 13px;
  2764. opacity: 0.9;
  2765. margin-bottom: 8px;
  2766. font-weight: 600;
  2767. }}
  2768. .metric-box-value {{
  2769. font-size: 28px;
  2770. font-weight: 700;
  2771. }}
  2772. .metric-box-value.small {{
  2773. font-size: 16px;
  2774. }}
  2775. .step-content {{
  2776. background: #f9fafb;
  2777. padding: 20px;
  2778. border-radius: 12px;
  2779. }}
  2780. .step-field {{
  2781. margin-bottom: 20px;
  2782. }}
  2783. .step-field-label {{
  2784. font-weight: 700;
  2785. color: #374151;
  2786. font-size: 14px;
  2787. margin-bottom: 8px;
  2788. display: block;
  2789. }}
  2790. .step-field-value {{
  2791. color: #1f2937;
  2792. font-size: 15px;
  2793. line-height: 1.7;
  2794. }}
  2795. .matches-list {{
  2796. display: flex;
  2797. flex-direction: column;
  2798. gap: 15px;
  2799. margin-top: 10px;
  2800. }}
  2801. .match-item {{
  2802. background: white;
  2803. padding: 18px;
  2804. border-radius: 10px;
  2805. border-left: 5px solid #3b82f6;
  2806. }}
  2807. .match-item.top1 {{
  2808. border-left-color: #fbbf24;
  2809. background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, white 100%);
  2810. }}
  2811. .match-item.top2 {{
  2812. border-left-color: #c0c0c0;
  2813. background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 50%, white 100%);
  2814. }}
  2815. .match-item.top3 {{
  2816. border-left-color: #cd7f32;
  2817. background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 50%, white 100%);
  2818. }}
  2819. .match-header {{
  2820. display: flex;
  2821. justify-content: space-between;
  2822. align-items: center;
  2823. margin-bottom: 12px;
  2824. gap: 10px;
  2825. }}
  2826. .match-rank {{
  2827. font-size: 18px;
  2828. font-weight: 800;
  2829. color: #6b7280;
  2830. }}
  2831. .match-element-name {{
  2832. flex: 1;
  2833. font-size: 16px;
  2834. font-weight: 700;
  2835. color: #1f2937;
  2836. }}
  2837. .match-score {{
  2838. font-size: 22px;
  2839. font-weight: 800;
  2840. color: #2563eb;
  2841. background: white;
  2842. padding: 6px 14px;
  2843. border-radius: 8px;
  2844. }}
  2845. .match-detail {{
  2846. background: rgba(255, 255, 255, 0.7);
  2847. padding: 10px;
  2848. border-radius: 6px;
  2849. margin-bottom: 10px;
  2850. font-size: 13px;
  2851. color: #4b5563;
  2852. }}
  2853. .match-reason {{
  2854. color: #1f2937;
  2855. font-size: 14px;
  2856. line-height: 1.7;
  2857. }}
  2858. .increment-matches {{
  2859. display: flex;
  2860. flex-direction: column;
  2861. gap: 12px;
  2862. margin-top: 10px;
  2863. }}
  2864. .increment-item {{
  2865. background: white;
  2866. padding: 15px;
  2867. border-radius: 8px;
  2868. border-left: 4px solid #10b981;
  2869. }}
  2870. .increment-header {{
  2871. display: flex;
  2872. justify-content: space-between;
  2873. align-items: center;
  2874. margin-bottom: 10px;
  2875. }}
  2876. .increment-words {{
  2877. font-weight: 700;
  2878. color: #1f2937;
  2879. font-size: 15px;
  2880. }}
  2881. .increment-score {{
  2882. font-size: 20px;
  2883. font-weight: 800;
  2884. color: #10b981;
  2885. }}
  2886. .increment-reason {{
  2887. color: #4b5563;
  2888. font-size: 13px;
  2889. line-height: 1.6;
  2890. }}
  2891. .empty-state {{
  2892. text-align: center;
  2893. padding: 40px;
  2894. color: #9ca3af;
  2895. font-size: 14px;
  2896. }}
  2897. .modal-link {{
  2898. margin-top: 25px;
  2899. padding-top: 20px;
  2900. border-top: 2px solid #e5e7eb;
  2901. text-align: center;
  2902. }}
  2903. .modal-link-btn {{
  2904. display: inline-flex;
  2905. align-items: center;
  2906. gap: 10px;
  2907. padding: 12px 24px;
  2908. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  2909. color: white;
  2910. text-decoration: none;
  2911. border-radius: 10px;
  2912. font-size: 15px;
  2913. font-weight: 600;
  2914. transition: all 0.3s;
  2915. }}
  2916. .modal-link-btn:hover {{
  2917. transform: translateY(-2px);
  2918. box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  2919. }}
  2920. .timestamp {{
  2921. text-align: center;
  2922. color: white;
  2923. font-size: 13px;
  2924. margin-top: 30px;
  2925. opacity: 0.8;
  2926. }}
  2927. .match-context {{
  2928. background: #f3f4f6;
  2929. padding: 8px 12px;
  2930. border-radius: 6px;
  2931. margin: 8px 0;
  2932. font-size: 12px;
  2933. color: #6b7280;
  2934. line-height: 1.6;
  2935. }}
  2936. .match-explain {{
  2937. background: #fef3c7;
  2938. padding: 10px 12px;
  2939. border-radius: 6px;
  2940. margin: 10px 0;
  2941. font-size: 13px;
  2942. color: #92400e;
  2943. line-height: 1.7;
  2944. border-left: 3px solid #f59e0b;
  2945. }}
  2946. .match-parts {{
  2947. margin: 12px 0;
  2948. border-radius: 8px;
  2949. overflow: hidden;
  2950. }}
  2951. .match-parts.same-parts {{
  2952. background: #f0fdf4;
  2953. border: 2px solid #10b981;
  2954. }}
  2955. .match-parts.increment-parts {{
  2956. background: #fff7ed;
  2957. border: 2px solid #f59e0b;
  2958. }}
  2959. .parts-header {{
  2960. font-weight: 700;
  2961. padding: 10px 12px;
  2962. font-size: 13px;
  2963. }}
  2964. .same-parts .parts-header {{
  2965. background: #dcfce7;
  2966. color: #15803d;
  2967. }}
  2968. .increment-parts .parts-header {{
  2969. background: #fed7aa;
  2970. color: #92400e;
  2971. }}
  2972. .parts-content {{
  2973. padding: 8px 12px;
  2974. }}
  2975. .part-item {{
  2976. padding: 6px 0;
  2977. border-bottom: 1px solid rgba(0,0,0,0.05);
  2978. font-size: 13px;
  2979. line-height: 1.6;
  2980. }}
  2981. .part-item:last-child {{
  2982. border-bottom: none;
  2983. }}
  2984. .part-key {{
  2985. font-weight: 600;
  2986. color: #374151;
  2987. margin-right: 6px;
  2988. }}
  2989. .part-value {{
  2990. color: #1f2937;
  2991. }}
  2992. .increment-context {{
  2993. background: #fef3c7;
  2994. padding: 10px 12px;
  2995. border-radius: 6px;
  2996. margin: 10px 0;
  2997. font-size: 12px;
  2998. color: #92400e;
  2999. line-height: 1.6;
  3000. border-left: 3px solid #f59e0b;
  3001. }}
  3002. @media (max-width: 768px) {{
  3003. .main-content-layout {{
  3004. flex-direction: column;
  3005. }}
  3006. .sidebar-nav {{
  3007. position: relative;
  3008. width: 100%;
  3009. max-height: 300px;
  3010. }}
  3011. .inspirations-grid {{
  3012. grid-template-columns: 1fr;
  3013. }}
  3014. .header h1 {{
  3015. font-size: 32px;
  3016. }}
  3017. .stats-overview {{
  3018. grid-template-columns: repeat(2, 1fr);
  3019. }}
  3020. }}
  3021. </style>
  3022. </head>
  3023. <body>
  3024. <div class="container">
  3025. <div class="main-content-layout">
  3026. <div class="sidebar-nav">
  3027. <div class="nav-title">📑 灵感点列表</div>
  3028. <div class="nav-list" id="navList">
  3029. <!-- 目录将通过JS动态生成 -->
  3030. </div>
  3031. </div>
  3032. <div class="inspirations-section">
  3033. <div class="inspiration-display">
  3034. {cards_html_str}
  3035. </div>
  3036. </div>
  3037. </div>
  3038. <!-- Modal -->
  3039. <div id="detailModal" class="modal-overlay" onclick="closeModalOnOverlay(event)">
  3040. <div class="modal-content">
  3041. <button class="modal-close" onclick="closeModal()">&times;</button>
  3042. <div class="modal-body" id="modalBody">
  3043. <!-- Content will be inserted here -->
  3044. </div>
  3045. </div>
  3046. </div>
  3047. </div>
  3048. <script>
  3049. {detail_modal_js}
  3050. </script>
  3051. </body>
  3052. </html>'''
  3053. # 写入文件
  3054. output_file = Path(output_path)
  3055. output_file.parent.mkdir(parents=True, exist_ok=True)
  3056. with open(output_file, 'w', encoding='utf-8') as f:
  3057. f.write(html_content)
  3058. return str(output_file.absolute())
  3059. def load_persona_data(persona_path: str) -> Dict[str, Any]:
  3060. """
  3061. 加载人设数据
  3062. Args:
  3063. persona_path: 人设JSON文件路径
  3064. Returns:
  3065. 人设数据字典
  3066. """
  3067. try:
  3068. with open(persona_path, 'r', encoding='utf-8') as f:
  3069. return json.load(f)
  3070. except Exception as e:
  3071. print(f"警告: 读取人设文件失败: {e}")
  3072. return {}
  3073. def main():
  3074. """主函数"""
  3075. import sys
  3076. import os
  3077. # 配置路径(使用当前脚本的相对路径)
  3078. script_dir = os.path.dirname(os.path.abspath(__file__))
  3079. base_dir = os.path.join(script_dir, "data/阿里多多酱")
  3080. inspiration_dir = os.path.join(base_dir, "out/人设_1110/how/灵感点")
  3081. posts_dir = os.path.join(base_dir, "作者历史帖子")
  3082. persona_path = os.path.join(base_dir, "out/人设_1110/人设.json")
  3083. inspiration_to_post_path = os.path.join(base_dir, "out/人设_1110/点到帖子映射.json")
  3084. category_index_path = os.path.join(base_dir, "out/人设_1110/分类索引_完整.json")
  3085. post_to_mapping_path = os.path.join(base_dir, "out/人设_1110/帖子到分类和点映射.json")
  3086. output_path = os.path.join(base_dir, "out/人设_1110/how/灵感点可视化.html")
  3087. print("=" * 60)
  3088. print("灵感点分析可视化脚本")
  3089. print("=" * 60)
  3090. # 加载数据
  3091. print("\n📂 正在加载灵感点数据...")
  3092. inspirations_data = load_inspiration_points_data(inspiration_dir)
  3093. print(f"✅ 成功加载 {len(inspirations_data)} 个灵感点")
  3094. print("\n📂 正在加载帖子数据...")
  3095. posts_map = load_posts_data(posts_dir)
  3096. print(f"✅ 成功加载 {len(posts_map)} 个帖子")
  3097. print("\n📂 正在加载人设数据...")
  3098. persona_data = load_persona_data(persona_path)
  3099. print(f"✅ 成功加载人设数据")
  3100. print("\n📂 正在加载点到帖子映射数据...")
  3101. with open(inspiration_to_post_path, 'r', encoding='utf-8') as f:
  3102. inspiration_to_post_data = json.load(f)
  3103. print(f"✅ 成功加载点到帖子映射数据")
  3104. print("\n📂 正在加载分类索引数据...")
  3105. with open(category_index_path, 'r', encoding='utf-8') as f:
  3106. category_index_data = json.load(f)
  3107. print(f"✅ 成功加载分类索引数据")
  3108. print("\n📂 正在加载帖子到分类和点映射数据...")
  3109. with open(post_to_mapping_path, 'r', encoding='utf-8') as f:
  3110. post_to_mapping_data = json.load(f)
  3111. print(f"✅ 成功加载帖子到分类和点映射数据")
  3112. # 生成HTML
  3113. print("\n🎨 正在生成可视化HTML...")
  3114. result_path = generate_html(
  3115. inspirations_data,
  3116. posts_map,
  3117. persona_data,
  3118. output_path,
  3119. inspiration_to_post_data,
  3120. category_index_data,
  3121. post_to_mapping_data
  3122. )
  3123. print(f"\n✅ 可视化文件已生成!")
  3124. print(f"📄 文件路径: {result_path}")
  3125. print(f"\n💡 在浏览器中打开该文件即可查看可视化结果")
  3126. print("=" * 60)
  3127. if __name__ == "__main__":
  3128. main()