| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162 |
- """
- 灵感点分析结果可视化脚本
- 读取 how/灵感点 目录下的分析结果,结合作者历史帖子详情,生成可视化HTML页面
- """
- import json
- from pathlib import Path
- from typing import Dict, Any, List, Optional
- from datetime import datetime
- import html as html_module
- def load_inspiration_points_data(inspiration_dir: str) -> List[Dict[str, Any]]:
- """
- 加载所有灵感点的分析结果
- Args:
- inspiration_dir: 灵感点目录路径
- Returns:
- 灵感点分析结果列表
- """
- inspiration_path = Path(inspiration_dir)
- results = []
- # 遍历所有子目录
- for subdir in inspiration_path.iterdir():
- if subdir.is_dir():
- # 查找 all_summary 文件
- summary_files = list(subdir.glob("all_summary_*.json"))
- if summary_files:
- summary_file = summary_files[0]
- try:
- with open(summary_file, 'r', encoding='utf-8') as f:
- data = json.load(f)
- # 加载完整的 step1 和 step2 数据
- step1_data = None
- step2_data = None
- # 直接从当前子目录查找 step1 和 step2 文件
- step1_files = list(subdir.glob("all_step1_*.json"))
- step2_files = list(subdir.glob("all_step2_*.json"))
- if step1_files:
- try:
- with open(step1_files[0], 'r', encoding='utf-8') as f:
- step1_data = json.load(f)
- except Exception as e:
- print(f"警告: 读取 {step1_files[0]} 失败: {e}")
- if step2_files:
- try:
- with open(step2_files[0], 'r', encoding='utf-8') as f:
- step2_data = json.load(f)
- except Exception as e:
- print(f"警告: 读取 {step2_files[0]} 失败: {e}")
- # 加载搜索结果和匹配分数
- search_results = {}
- search_dir = subdir / "search"
- if search_dir.exists() and search_dir.is_dir():
- search_files = list(search_dir.glob("all_search_*.json"))
- for search_file in search_files:
- try:
- with open(search_file, 'r', encoding='utf-8') as f:
- search_data = json.load(f)
- # 从JSON内容中读取真实的keyword,而不是从文件名提取
- keyword = search_data.get("search_params", {}).get("keyword", "")
- if keyword:
- # 尝试加载对应的匹配结果文件
- match_file = search_dir / "all_step4_搜索结果匹配_gemini-2.5-pro.json"
- match_data = None
- if match_file.exists():
- try:
- with open(match_file, 'r', encoding='utf-8') as mf:
- match_data = json.load(mf)
- except Exception as e:
- print(f"警告: 读取匹配文件 {match_file} 失败: {e}")
- search_results[keyword] = {
- "search_data": search_data,
- "match_data": match_data
- }
- else:
- # 如果JSON中没有keyword,则从文件名提取
- keyword = search_file.stem.replace("all_search_", "")
- search_results[keyword] = {
- "search_data": search_data,
- "match_data": None
- }
- except Exception as e:
- print(f"警告: 读取 {search_file} 失败: {e}")
- results.append({
- "summary": data,
- "step1": step1_data,
- "step2": step2_data,
- "search_results": search_results,
- "inspiration_name": subdir.name
- })
- except Exception as e:
- print(f"警告: 读取 {summary_file} 失败: {e}")
- return results
- def load_posts_data(posts_dir: str) -> Dict[str, Dict[str, Any]]:
- """
- 加载所有帖子详情数据
- Args:
- posts_dir: 帖子目录路径
- Returns:
- 帖子ID到帖子详情的映射
- """
- posts_path = Path(posts_dir)
- posts_map = {}
- for post_file in posts_path.glob("*.json"):
- try:
- with open(post_file, 'r', encoding='utf-8') as f:
- post_data = json.load(f)
- post_id = post_data.get("channel_content_id")
- if post_id:
- posts_map[post_id] = post_data
- except Exception as e:
- print(f"警告: 读取 {post_file} 失败: {e}")
- return posts_map
- def generate_post_card_html(post: Dict[str, Any], note_id_prefix: str = "info-post", post_to_mapping_data: Dict[str, Any] = None) -> str:
- """
- 生成单个帖子卡片HTML(与搜索结果样式一致)
- Args:
- post: 帖子数据
- note_id_prefix: 帖子ID前缀,用于区分不同区域的帖子
- post_to_mapping_data: 帖子到分类和点映射数据
- Returns:
- HTML字符串
- """
- import html as html_module
- import random
- title = post.get("title", "")
- desc = post.get("body_text", "")
- images = post.get("images", [])
- like_count = post.get("like_count", 0)
- comment_count = post.get("comment_count", 0)
- link = post.get("link", "")
- author = post.get("channel_account_name", "")
- post_id = post.get("channel_content_id", "")
- publish_time = post.get("publish_time", "")
- # 生成唯一的note_id
- note_id = f"{note_id_prefix}-{random.randint(10000, 99999)}"
- # 生成图片轮播HTML
- images_html = ""
- if images and len(images) > 0:
- images_track = "".join([f'<img src="{img}" class="note-image" alt="图片{i+1}">' for i, img in enumerate(images)])
- # 图片导航按钮
- nav_buttons = ""
- if len(images) > 1:
- nav_buttons = f'''
- <button class="note-carousel-button prev" onclick="event.stopPropagation(); moveNoteImage('{note_id}', -1)">‹</button>
- <button class="note-carousel-button next" onclick="event.stopPropagation(); moveNoteImage('{note_id}', 1)">›</button>
- '''
- images_html = f'''
- <div class="note-image-carousel" data-note-id="{note_id}" data-total-images="{len(images)}">
- <div class="note-images-track" id="{note_id}-track">
- {images_track}
- </div>
- {nav_buttons}
- </div>
- '''
- else:
- # 无图片时显示占位符
- images_html = f'''
- <div class="note-image-carousel">
- <div class="note-images-track">
- <div class="note-image" style="display: flex; align-items: center; justify-content: center; background: #f3f4f6; color: #9ca3af;">
- 暂无图片
- </div>
- </div>
- </div>
- '''
- # 准备详情数据
- note_data = {
- "title": title,
- "desc": desc,
- "images": images,
- "link": link,
- "author": author,
- "like_count": like_count,
- "comment_count": comment_count
- }
- # 添加灵感点、关键点、目的点到note_data
- if post_to_mapping_data and post_id and post_id in post_to_mapping_data:
- mapping = post_to_mapping_data[post_id]
- note_data["inspiration_points"] = mapping.get("灵感点列表", [])
- note_data["key_points"] = mapping.get("关键点列表", [])
- note_data["purpose_points"] = mapping.get("目的点列表", [])
- import json
- note_data_json = json.dumps(note_data, ensure_ascii=False)
- note_data_json_escaped = html_module.escape(note_data_json)
- # 获取帖子的灵感点、关键点、目的点
- points_html = ""
- if post_to_mapping_data and post_id and post_id in post_to_mapping_data:
- mapping = post_to_mapping_data[post_id]
- inspiration_points = mapping.get("灵感点列表", [])
- key_points = mapping.get("关键点列表", [])
- purpose_points = mapping.get("目的点列表", [])
- points_sections = []
- # 灵感点
- if inspiration_points:
- insp_items = "".join([
- f'<div class="point-item"><span class="point-name">{html_module.escape(p.get("灵感点", ""))}</span></div>'
- for p in inspiration_points[:3] # 最多显示3个
- ])
- points_sections.append(f'<div class="points-section"><div class="points-label">灵感点</div><div class="points-list">{insp_items}</div></div>')
- # 关键点
- if key_points:
- key_items = "".join([
- f'<div class="point-item"><span class="point-name">{html_module.escape(k.get("关键点", ""))}</span></div>'
- for k in key_points[:3] # 最多显示3个
- ])
- points_sections.append(f'<div class="points-section"><div class="points-label">关键点</div><div class="points-list">{key_items}</div></div>')
- # 目的点
- if purpose_points:
- purpose_items = "".join([
- f'<div class="point-item"><span class="point-name">{html_module.escape(p.get("目的点", ""))}</span></div>'
- for p in purpose_points[:3] # 最多显示3个
- ])
- points_sections.append(f'<div class="points-section"><div class="points-label">目的点</div><div class="points-list">{purpose_items}</div></div>')
- if points_sections:
- points_html = f'<div class="note-points">{"".join(points_sections)}</div>'
- # 生成发布日期HTML
- publish_date_html = ""
- if publish_time:
- publish_date_html = f'<div class="note-publish-date">📅 {html_module.escape(publish_time)}</div>'
- card_html = f'''
- <div class="search-note-item" data-note-data='{note_data_json_escaped}' onclick="showNoteDetail(this)">
- {images_html}
- <div class="note-content">
- <div class="note-title">{html_module.escape(title) if title else "无标题"}</div>
- <div class="note-desc">{html_module.escape(desc) if desc else "暂无描述"}</div>
- {publish_date_html}
- <div class="note-footer">
- <div class="note-author">@{html_module.escape(author) if author else "匿名"}</div>
- <div class="note-stats">
- <span>👍 {like_count if like_count else 0}</span>
- {f'<span>💬 {comment_count}</span>' if comment_count else ''}
- </div>
- </div>
- </div>
- {f'<div class="note-points-hover">{points_html}</div>' if points_html else ''}
- </div>
- '''
- return card_html
- def generate_inspiration_card_html(
- inspiration_data: Dict[str, Any],
- inspiration_to_post_data: Dict[str, Any] = None,
- category_index_data: Dict[str, Any] = None,
- post_to_mapping_data: Dict[str, Any] = None
- ) -> str:
- """
- 生成单个灵感点的卡片HTML
- Args:
- inspiration_data: 灵感点数据
- inspiration_to_post_data: 点到帖子映射数据
- category_index_data: 分类索引数据
- Returns:
- HTML字符串
- """
- summary = inspiration_data.get("summary", {})
- step1 = inspiration_data.get("step1", {})
- inspiration_name = inspiration_data.get("inspiration_name", "未知灵感")
- search_results = inspiration_data.get("search_results", {})
- # 提取关键指标
- metrics = summary.get("关键指标", {})
- step1_score = metrics.get("step1_top1_score", 0)
- step1_match_element = metrics.get("step1_top1_匹配要素", "")
- # 确定卡片颜色(基于Step1分数)
- if step1_score >= 0.7:
- border_color = "#10b981"
- step1_color = "#10b981"
- elif step1_score >= 0.5:
- border_color = "#f59e0b"
- step1_color = "#f59e0b"
- elif step1_score >= 0.3:
- border_color = "#3b82f6"
- step1_color = "#3b82f6"
- else:
- border_color = "#ef4444"
- step1_color = "#ef4444"
- # 转义HTML
- inspiration_name_escaped = html_module.escape(inspiration_name)
- step1_match_element_escaped = html_module.escape(step1_match_element)
- # 获取Step1匹配结果(简要展示)
- step1_matches = step1.get("匹配结果列表", []) if step1 else []
- step1_match_preview = ""
- if step1_matches:
- top_match = step1_matches[0]
- # 从新的数据结构中提取信息
- input_info = top_match.get("输入信息", {})
- match_result = top_match.get("匹配结果", {})
- element_name = input_info.get("A", "")
- match_score = match_result.get("score", 0)
- same_parts = match_result.get("相同部分", {}) or {}
- increment_parts = match_result.get("增量部分", {}) or {}
- # 生成相同部分和增量部分的HTML
- parts_html = ""
- if same_parts:
- same_items = [f"{html_module.escape(k)}" for k in same_parts.keys()]
- parts_html += f'<div class="preview-parts same"><strong>相同:</strong> {", ".join(same_items)}</div>'
- if increment_parts:
- inc_items = [f"{html_module.escape(k)}" for k in increment_parts.keys()]
- parts_html += f'<div class="preview-parts increment"><strong>增量:</strong> {", ".join(inc_items)}</div>'
- step1_match_preview = f'''
- <div class="match-preview">
- <div class="match-preview-header">🎯 Step1 Top1匹配</div>
- <div class="match-preview-content">
- <span class="match-preview-name">{html_module.escape(element_name)}</span>
- <span class="match-preview-score" style="color: {step1_color};">{match_score:.2f}</span>
- </div>
- {parts_html}
- </div>
- '''
- # 提取 top3 匹配信息
- top3_matches = []
- if step1:
- matches = step1.get("匹配结果列表", [])
- for i, match in enumerate(matches[:3]):
- input_info = match.get("输入信息", {})
- match_result = match.get("匹配结果", {})
- element_name = input_info.get("A", "")
- match_score = match_result.get("score", 0)
- context = input_info.get("A_Context", "")
- # 解析层级关系
- hierarchy = []
- if context:
- lines = context.split("\n")
- for line in lines:
- if ":" in line:
- key, value = line.split(":", 1)
- key = key.strip()
- value = value.strip()
- if key in ["所属视角", "一级分类", "二级分类"]:
- hierarchy.append(value)
- top3_matches.append({
- "rank": i + 1,
- "name": element_name,
- "score": match_score,
- "hierarchy": hierarchy
- })
- # 准备详细数据用于弹窗
- detail_data_json = json.dumps(inspiration_data, ensure_ascii=False)
- detail_data_json_escaped = html_module.escape(detail_data_json)
- # top3 匹配数据
- top3_json = json.dumps(top3_matches, ensure_ascii=False)
- top3_json_escaped = html_module.escape(top3_json)
- # 生成详细HTML并进行HTML转义
- detail_html = generate_detail_html(inspiration_data)
- detail_html_escaped = html_module.escape(detail_html)
- # 生成匹配列表HTML
- matches_html = ""
- if step1:
- step1_matches = step1.get("匹配结果列表", [])
- for idx, match in enumerate(step1_matches):
- input_info = match.get("输入信息", {})
- match_result = match.get("匹配结果", {})
- element_name = input_info.get("A", "")
- context = input_info.get("A_Context", "")
- score = match_result.get("score", 0)
- score_explain = match_result.get("score说明", "") or ""
- same_parts = match_result.get("相同部分", {}) or {}
- increment_parts = match_result.get("增量部分", {}) or {}
- # 为搜索结果容器生成唯一ID
- safe_insp_name = ''.join(c if c.isalnum() else '_' for c in inspiration_name)
- unique_match_id = f"{safe_insp_name}-match-{idx}"
- # 解析层级
- hierarchy = []
- if context:
- lines = context.split("\n")
- for line in lines:
- if ":" in line:
- key, value = line.split(":", 1)
- key = key.strip()
- value = value.strip()
- if key in ["所属视角", "一级分类", "二级分类"]:
- hierarchy.append(value)
- hierarchy_html = " › ".join([html_module.escape(h) for h in hierarchy]) if hierarchy else ""
- rank_class = f"rank-{idx + 1}" if idx < 3 else ""
- # 相同部分HTML
- same_parts_html = ""
- if same_parts:
- 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()])
- same_parts_html = f'''
- <div class="match-parts same-parts">
- <div class="match-parts-title">✅ 相同部分</div>
- {same_items}
- </div>
- '''
- # 增量部分HTML
- increment_parts_html = ""
- if increment_parts:
- 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()])
- increment_parts_html = f'''
- <div class="match-parts increment-parts">
- <div class="match-parts-title">➕ 增量部分</div>
- {inc_items}
- </div>
- '''
- # 生成搜索结果HTML(网格展示,图片轮播)
- search_html = ""
- if element_name in search_results:
- result_obj = search_results[element_name]
- search_data = result_obj.get("search_data", {})
- match_data = result_obj.get("match_data", None)
- search_params = search_data.get("search_params", {})
- notes = search_data.get("notes", [])
- notes_count = len(notes)
- # 构建匹配分数字典 {channel_content_id: match_info}
- match_scores = {}
- if match_data and "匹配结果列表" in match_data:
- for match_item in match_data["匹配结果列表"]:
- business_info = match_item.get("业务信息", {})
- input_info = match_item.get("输入信息", {})
- content_id = business_info.get("channel_content_id", "")
- if content_id:
- match_scores[content_id] = {
- "score": match_item.get("匹配结果", {}).get("score", 0),
- "score说明": match_item.get("匹配结果", {}).get("score说明", "") or "",
- "相同部分": match_item.get("匹配结果", {}).get("相同部分", {}) or {},
- "增量部分": match_item.get("匹配结果", {}).get("增量部分", {}) or {},
- "输入B": input_info.get("B", "") or "",
- "输入A": input_info.get("A", "") or "",
- "B_Context": input_info.get("B_Context", "") or "",
- "A_Context": input_info.get("A_Context", "") or ""
- }
- # 为notes添加匹配分数、原始索引,并准备排序
- notes_with_scores = []
- for original_idx, note in enumerate(notes):
- note_id = note.get("channel_content_id", "")
- score_info = match_scores.get(note_id, None)
- notes_with_scores.append({
- "note": note,
- "score_info": score_info,
- "original_index": original_idx, # 原始搜索结果位置(0-based)
- "page": (original_idx // 20) + 1, # 第几页(假设每页20条)
- "position_in_page": (original_idx % 20) + 1 # 页内位置
- })
- # 默认按分数降序排序(没有分数的放到最后)
- notes_with_scores.sort(key=lambda x: x["score_info"]["score"] if x["score_info"] else -1, reverse=True)
- # 生成搜索参数HTML
- search_params_html = ""
- if search_params:
- keyword = search_params.get("keyword", "")
- content_type = search_params.get("content_type", "不限")
- sort_type = search_params.get("sort_type", "综合")
- publish_time = search_params.get("publish_time", "不限")
- search_params_html = f'''
- <div class="search-params-section">
- <div class="search-params-title">🔍 搜索参数</div>
- <div class="search-params-grid">
- <div class="search-param-item">
- <span class="search-param-label">关键词:</span>
- <span class="search-param-value">{html_module.escape(keyword)}</span>
- </div>
- <div class="search-param-item">
- <span class="search-param-label">内容类型:</span>
- <span class="search-param-value">{html_module.escape(content_type)}</span>
- </div>
- <div class="search-param-item">
- <span class="search-param-label">排序方式:</span>
- <span class="search-param-value">{html_module.escape(sort_type)}</span>
- </div>
- <div class="search-param-item">
- <span class="search-param-label">发布时间:</span>
- <span class="search-param-value">{html_module.escape(publish_time)}</span>
- </div>
- </div>
- </div>
- '''
- # 生成搜索结果统计HTML(带排序按钮)
- search_summary_html = f'''
- <div class="search-summary-section">
- <div class="search-summary-header">
- <div class="search-summary-left">
- <div class="search-summary-title">📊 搜索结果</div>
- <div class="search-summary-content">
- 共找到 <span class="search-result-count">{notes_count}</span> 条相关内容
- </div>
- </div>
- <div class="search-sort-buttons">
- <span class="search-sort-label">排序:</span>
- <button class="search-sort-btn active" data-sort="score" onclick="sortSearchResults(this, '{unique_match_id}-search-results')">匹配分数</button>
- <button class="search-sort-btn" data-sort="original" onclick="sortSearchResults(this, '{unique_match_id}-search-results')">原始顺序</button>
- <button class="search-sort-btn" data-sort="likes" onclick="sortSearchResults(this, '{unique_match_id}-search-results')">点赞数</button>
- </div>
- </div>
- </div>
- '''
- if notes_count > 0:
- notes_items = ""
- for note_idx, item in enumerate(notes_with_scores): # 使用包含元数据的列表
- note = item["note"]
- score_info = item["score_info"]
- original_index = item["original_index"]
- page = item["page"]
- position_in_page = item["position_in_page"]
- title = note.get("title", "")
- desc = note.get("desc", "")
- link = note.get("link", "")
- author = note.get("channel_account_name", "")
- like_count = note.get("like_count", 0)
- comment_count = note.get("comment_count", 0)
- images = note.get("images", [])
- content_id = note.get("channel_content_id", "")
- publish_time = note.get("publish_time", "")
- note_id = f"note-{idx}-{note_idx}"
- # 生成图片轮播HTML
- images_html = ""
- if images and len(images) > 0:
- images_track = "".join([f'<img src="{img}" class="note-image" alt="图片{i+1}">' for i, img in enumerate(images)])
- # 图片导航按钮和指示点
- nav_buttons = ""
- dots_html = ""
- if len(images) > 1:
- nav_buttons = f'''
- <button class="note-carousel-button prev" onclick="event.stopPropagation(); moveNoteImage('{note_id}', -1)">‹</button>
- <button class="note-carousel-button next" onclick="event.stopPropagation(); moveNoteImage('{note_id}', 1)">›</button>
- '''
- dots = "".join([f'<div class="note-image-dot{" active" if i == 0 else ""}"></div>' for i in range(len(images))])
- dots_html = f'<div class="note-image-dots" id="{note_id}-dots">{dots}</div>'
- images_html = f'''
- <div class="note-image-carousel" data-note-id="{note_id}" data-total-images="{len(images)}">
- <div class="note-images-track" id="{note_id}-track">
- {images_track}
- </div>
- {nav_buttons}
- {dots_html}
- </div>
- '''
- else:
- # 无图片时显示占位符
- images_html = f'''
- <div class="note-image-carousel">
- <div class="note-images-track">
- <div class="note-image" style="display: flex; align-items: center; justify-content: center; background: #f3f4f6; color: #9ca3af;">
- 暂无图片
- </div>
- </div>
- </div>
- '''
- # 准备详情数据
- note_data = {
- "title": title,
- "desc": desc,
- "link": link,
- "author": author,
- "like_count": like_count,
- "comment_count": comment_count,
- "images": images
- }
- note_data_json = json.dumps(note_data, ensure_ascii=False)
- note_data_escaped = html_module.escape(note_data_json)
- # 生成匹配分数HTML
- score_badge_html = ""
- score_detail_html = ""
- if score_info:
- note_score = score_info["score"]
- note_score_explain = score_info.get("score说明", "") or ""
- note_same_parts = score_info.get("相同部分", {}) or {}
- note_increment_parts = score_info.get("增量部分", {}) or {}
- input_b = score_info.get("输入B", "") or ""
- input_a = score_info.get("输入A", "") or ""
- b_context = score_info.get("B_Context", "") or ""
- a_context = score_info.get("A_Context", "") or ""
- # 分数详情JSON
- score_detail_data = {
- "score": note_score,
- "score说明": note_score_explain,
- "相同部分": note_same_parts,
- "增量部分": note_increment_parts,
- "输入B": input_b,
- "输入A": input_a,
- "B_Context": b_context,
- "A_Context": a_context
- }
- score_detail_json = json.dumps(score_detail_data, ensure_ascii=False)
- score_detail_escaped = html_module.escape(score_detail_json)
- score_badge_html = f'''
- <div class="note-score-badge" onclick="event.stopPropagation(); showScoreDetail(this)" data-score-detail='{score_detail_escaped}'>
- <span class="score-label">匹配分数</span>
- <span class="score-value">{note_score:.2f}</span>
- </div>
- '''
- # 生成发布日期HTML
- publish_date_html = ""
- if publish_time:
- publish_date_html = f'<div class="note-publish-date">📅 {html_module.escape(publish_time)}</div>'
- # 计算匹配分数(用于排序)
- sort_score = score_info["score"] if score_info else -1
- notes_items += f'''
- <div class="search-note-item"
- data-note-data='{note_data_escaped}'
- data-original-index="{original_index}"
- data-score="{sort_score}"
- data-likes="{like_count}"
- onclick="showNoteDetail(this)">
- {score_badge_html}
- {images_html}
- <div class="note-content">
- <div class="note-title">{html_module.escape(title) if title else "无标题"}</div>
- <div class="note-desc">{html_module.escape(desc) if desc else "暂无描述"}</div>
- {publish_date_html}
- <div class="note-footer">
- <div class="note-author">@{html_module.escape(author)}</div>
- <div class="note-position">P{page}-{position_in_page}</div>
- <div class="note-stats">
- <span>👍 {like_count}</span>
- <span>💬 {comment_count}</span>
- </div>
- </div>
- </div>
- </div>
- '''
- search_html = f'''
- <div class="search-results-section">
- {search_params_html}
- {search_summary_html}
- <div class="search-notes-list" id="{unique_match_id}-search-results">
- {notes_items}
- </div>
- </div>
- '''
- else:
- # 没有搜索结果时也显示参数
- search_html = f'''
- <div class="search-results-section">
- {search_params_html}
- {search_summary_html}
- </div>
- '''
- # 只有第一个匹配项默认展开
- expanded_class = " expanded" if idx == 0 else ""
- # 生成当前匹配项的灵感点和灵感分类详情
- match_info_section = ""
- if inspiration_to_post_data and category_index_data:
- # 获取灵感点数据
- inspiration_points = inspiration_to_post_data.get("点到帖子映射", {}).get("灵感点", {})
- inspiration_info = inspiration_points.get(inspiration_name, {})
- # 获取当前匹配的灵感分类数据
- categories = category_index_data.get("灵感分类", {})
- category_info = categories.get(element_name, {})
- # 生成灵感点详情HTML(左栏)
- insp_detail_html = ""
- if inspiration_info:
- insp_dimension = inspiration_info.get("维度", "")
- insp_desc = inspiration_info.get("描述", "")
- insp_posts = inspiration_info.get("帖子详情列表", [])
- # 生成帖子卡片
- insp_posts_html = ""
- for post in insp_posts[:6]: # 最多显示6个
- insp_posts_html += generate_post_card_html(post, f"{unique_match_id}-insp-post", post_to_mapping_data)
- insp_detail_html = f'''
- <div class="info-detail-column">
- <div class="info-header">
- <span class="info-label">[灵感点]</span>
- <span class="info-name">{html_module.escape(inspiration_name)}</span>
- </div>
- <div class="info-content">
- {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 ''}
- {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 ''}
- {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 ''}
- </div>
- </div>
- '''
- # 生成灵感分类详情HTML(右栏)
- cat_detail_html = ""
- if category_info:
- cat_level = category_info.get("分类层级", "")
- cat_definition = category_info.get("分类定义", "")
- cat_posts = category_info.get("帖子详情列表", [])
- # 生成帖子卡片
- cat_posts_html = ""
- for post in cat_posts[:6]: # 最多显示6个
- cat_posts_html += generate_post_card_html(post, f"{unique_match_id}-cat-post", post_to_mapping_data)
- cat_detail_html = f'''
- <div class="info-detail-column">
- <div class="info-header">
- <span class="info-label">[灵感分类]</span>
- <span class="info-name">{html_module.escape(element_name)}</span>
- </div>
- <div class="info-content">
- {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 ''}
- {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 ''}
- {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 ''}
- </div>
- </div>
- '''
- if insp_detail_html or cat_detail_html:
- match_info_section = f'''
- <div class="inspiration-category-section">
- {insp_detail_html}
- {cat_detail_html}
- </div>
- '''
- # 步骤1:灵感点匹配灵感分类
- step1_html = f'''
- <div class="step-section-wrapper step-1-wrapper expanded">
- <div class="step-header" onclick="toggleStepWrapper(this)">
- <div class="step-header-content">
- <span class="step-number-badge">步骤 1</span>
- <span class="step-title">灵感点匹配灵感分类</span>
- </div>
- <div class="step-toggle">▼</div>
- </div>
- <div class="step-wrapper-content">
- <div class="match-analysis-section" id="{unique_match_id}-step1" data-step-name="灵感点匹配灵感分类">
- <div class="match-parts-container">
- <div class="match-parts-column">
- {same_parts_html}
- </div>
- <div class="match-parts-column">
- {increment_parts_html}
- </div>
- </div>
- {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 ''}
- </div>
- </div>
- </div>
- '''
- # 步骤2:搜索结果(如果有)
- step2_html = ""
- if search_html:
- step2_html = f'''
- <div class="step-section-wrapper step-2-wrapper expanded">
- <div class="step-header" onclick="toggleStepWrapper(this)">
- <div class="step-header-content">
- <span class="step-number-badge">步骤 2</span>
- <span class="step-title">搜索</span>
- </div>
- <div class="step-toggle">▼</div>
- </div>
- <div class="step-wrapper-content">
- <div class="step-section expanded" data-step="2" id="{unique_match_id}-step2" data-step-name="灵感分类搜索">
- <div class="step-section-header" onclick="toggleStep(this)">
- <div class="step-section-title">
- <span class="step-sub-number">2.1</span>
- <span>直接搜索灵感分类</span>
- </div>
- <div class="step-toggle">▼</div>
- </div>
- <div class="step-section-content">
- {search_html}
- </div>
- </div>
- </div>
- </div>
- '''
- # 创建安全的ID(移除特殊字符)
- safe_element_id = ''.join(c if c.isalnum() or c in '_-' else '_' for c in element_name)
- matches_html += f'''
- <div class="match-item{expanded_class}" data-index="{idx}" id="{unique_match_id}" data-match-name="{html_module.escape(element_name)}">
- <div class="match-main-header" onclick="toggleMainMatch(this)">
- <div class="match-header-row">
- <div class="match-header-left">
- <span class="match-rank {rank_class}">Top {idx + 1}</span>
- <span class="detail-label">[灵感点]</span>
- <span class="match-title">{html_module.escape(inspiration_name)}</span>
- </div>
- <div class="match-header-center">
- <span class="match-score-label">匹配分数</span>
- <span class="match-score-value">{score:.2f}</span>
- </div>
- <div class="match-header-right">
- <span class="detail-label">[灵感分类]</span>
- <span class="match-category">{html_module.escape(element_name)}</span>
- </div>
- </div>
- <div class="match-toggle-main">▼</div>
- </div>
- <div class="match-main-content">
- {match_info_section}
- {step1_html}
- {step2_html}
- </div>
- </div>
- '''
- # 获取top1匹配的灵感分类名称(用于顶部标题)
- top1_category_name = ""
- if step1:
- step1_matches = step1.get("匹配结果列表", [])
- if step1_matches:
- top_match = step1_matches[0]
- input_info = top_match.get("输入信息", {})
- top1_category_name = input_info.get("A", "")
- html = f'''
- <div class="inspiration-detail"
- data-inspiration-name="{inspiration_name_escaped}"
- data-step1-score="{step1_score}"
- data-top3-matches="{top3_json_escaped}">
- <div class="breadcrumb-container">
- <div class="breadcrumb" id="dynamicBreadcrumb">
- <span class="breadcrumb-item"><span class="breadcrumb-label">[灵感点]</span> {inspiration_name_escaped}</span>
- </div>
- </div>
- <div class="inspiration-content-wrapper">
- <div class="matches-list">
- {matches_html}
- </div>
- </div>
- </div>
- '''
- return html
- def generate_detail_html(inspiration_data: Dict[str, Any]) -> str:
- """
- 生成灵感点的详细信息HTML
- Args:
- inspiration_data: 灵感点数据
- Returns:
- 详细信息的HTML字符串
- """
- import html as html_module
- summary = inspiration_data.get("summary", {})
- step1 = inspiration_data.get("step1", {})
- step2 = inspiration_data.get("step2", {})
- inspiration_name = inspiration_data.get("inspiration_name", "未知灵感")
- content = f'''
- <div class="modal-header">
- <h2 class="modal-title">{html_module.escape(inspiration_name)}</h2>
- </div>
- '''
- # 获取元数据,用于后面的日志链接
- metadata = summary.get("元数据", {})
- # Step1 详细信息
- if step1 and step1.get("灵感"):
- inspiration = step1.get("灵感", "")
- matches = step1.get("匹配结果列表", [])
- content += f'''
- <div class="modal-section">
- <h3>🎯 Step1: 灵感人设匹配</h3>
- <div class="step-content">
- <div class="step-field">
- <span class="step-field-label">灵感内容:</span>
- <span class="step-field-value">{html_module.escape(inspiration)}</span>
- </div>
- '''
- # 显示匹配结果(只显示Top1)
- if matches:
- content += f'''
- <div class="step-field">
- <span class="step-field-label">Top1匹配结果:</span>
- <div class="matches-list">
- '''
- for index, match in enumerate(matches[:1]):
- input_info = match.get("输入信息", {})
- match_result = match.get("匹配结果", {})
- element_a = input_info.get("A", "")
- context_a = input_info.get("A_Context", "")
- score = match_result.get("score", 0)
- score_explain = match_result.get("score说明", "") or ""
- same_parts = match_result.get("相同部分", {}) or {}
- increment_parts = match_result.get("增量部分", {}) or {}
- content += f'''
- <div class="match-item">
- <div class="match-header">
- <span class="match-element-name">{html_module.escape(element_a)}</span>
- <span class="match-score">{score:.2f}</span>
- </div>
- '''
- if context_a:
- content += f'<div class="match-context"><strong>📍 所属分类:</strong> {html_module.escape(context_a).replace(chr(10), "<br>")}</div>'
- if score_explain:
- content += f'<div class="match-explain"><strong>💡 分数说明:</strong> {html_module.escape(score_explain)}</div>'
- # 相同部分
- if same_parts:
- content += '''
- <div class="match-parts same-parts">
- <div class="parts-header">✅ 相同部分</div>
- <div class="parts-content">
- '''
- for key, value in same_parts.items():
- content += f'''
- <div class="part-item">
- <span class="part-key">{html_module.escape(key)}:</span>
- <span class="part-value">{html_module.escape(value)}</span>
- </div>
- '''
- content += '''
- </div>
- </div>
- '''
- # 增量部分
- if increment_parts:
- content += '''
- <div class="match-parts increment-parts">
- <div class="parts-header">➕ 增量部分</div>
- <div class="parts-content">
- '''
- for key, value in increment_parts.items():
- content += f'''
- <div class="part-item">
- <span class="part-key">{html_module.escape(key)}:</span>
- <span class="part-value">{html_module.escape(value)}</span>
- </div>
- '''
- content += '''
- </div>
- </div>
- '''
- content += '''
- </div>
- '''
- content += '''
- </div>
- </div>
- '''
- content += '''
- </div>
- </div>
- '''
- # 日志链接
- if metadata.get("log_url"):
- content += f'''
- <div class="modal-link">
- <a href="{metadata["log_url"]}" target="_blank" class="modal-link-btn">
- 🔗 查看详细日志
- </a>
- </div>
- '''
- return content
- def generate_detail_modal_content_js() -> str:
- """
- 生成详情弹窗内容的JavaScript函数
- Returns:
- JavaScript代码字符串
- """
- return '''
- // 笔记图片当前索引管理
- const noteImageStates = {};
- // 移动笔记图片
- function moveNoteImage(noteId, direction) {
- if (!noteImageStates[noteId]) {
- noteImageStates[noteId] = 0;
- }
- const carousel = document.querySelector(`[data-note-id="${noteId}"]`);
- if (!carousel) return;
- const totalImages = parseInt(carousel.dataset.totalImages);
- const track = document.getElementById(noteId + '-track');
- if (!track) return;
- let newIndex = noteImageStates[noteId] + direction;
- if (newIndex < 0) newIndex = 0;
- if (newIndex >= totalImages) newIndex = totalImages - 1;
- noteImageStates[noteId] = newIndex;
- // 移动轨道
- track.style.transform = `translateX(-${newIndex * 100}%)`;
- // 更新指示点
- const dots = document.querySelectorAll(`#${noteId}-dots .note-image-dot`);
- dots.forEach((dot, i) => {
- dot.classList.toggle('active', i === newIndex);
- });
- // 更新按钮状态
- const prevBtn = carousel.querySelector('.note-carousel-button.prev');
- const nextBtn = carousel.querySelector('.note-carousel-button.next');
- if (prevBtn) {
- prevBtn.classList.toggle('disabled', newIndex === 0);
- }
- if (nextBtn) {
- nextBtn.classList.toggle('disabled', newIndex >= totalImages - 1);
- }
- }
- // 显示笔记详情
- function showNoteDetail(element) {
- const noteDataStr = element.dataset.noteData;
- if (!noteDataStr) return;
- try {
- const noteData = JSON.parse(noteDataStr);
- // 生成图片HTML
- let imagesHtml = '';
- if (noteData.images && noteData.images.length > 0) {
- imagesHtml = noteData.images.map(img =>
- `<img src="${img}" class="note-detail-image" alt="图片">`
- ).join('');
- } else {
- imagesHtml = '<div style="text-align: center; color: #9ca3af; padding: 40px;">暂无图片</div>';
- }
- // 生成灵感点、关键点、目的点HTML
- let pointsDetailHtml = '';
- const hasPoints = (noteData.inspiration_points && noteData.inspiration_points.length > 0) ||
- (noteData.key_points && noteData.key_points.length > 0) ||
- (noteData.purpose_points && noteData.purpose_points.length > 0);
- if (hasPoints) {
- let sections = [];
- // 灵感点
- if (noteData.inspiration_points && noteData.inspiration_points.length > 0) {
- const items = noteData.inspiration_points.map(p =>
- `<div class="detail-point-item">
- <div class="detail-point-name">${p.灵感点 || ''}</div>
- ${p.描述 ? `<div class="detail-point-desc">${p.描述}</div>` : ''}
- </div>`
- ).join('');
- sections.push(`<div class="detail-points-section">
- <div class="detail-points-title">💡 灵感点</div>
- ${items}
- </div>`);
- }
- // 关键点
- if (noteData.key_points && noteData.key_points.length > 0) {
- const items = noteData.key_points.map(k =>
- `<div class="detail-point-item">
- <div class="detail-point-name">${k.关键点 || ''}</div>
- ${k.描述 ? `<div class="detail-point-desc">${k.描述}</div>` : ''}
- </div>`
- ).join('');
- sections.push(`<div class="detail-points-section">
- <div class="detail-points-title">🔑 关键点</div>
- ${items}
- </div>`);
- }
- // 目的点
- if (noteData.purpose_points && noteData.purpose_points.length > 0) {
- const items = noteData.purpose_points.map(p =>
- `<div class="detail-point-item">
- <div class="detail-point-name">${p.目的点 || ''}</div>
- ${p.描述 ? `<div class="detail-point-desc">${p.描述}</div>` : ''}
- </div>`
- ).join('');
- sections.push(`<div class="detail-points-section">
- <div class="detail-points-title">🎯 目的点</div>
- ${items}
- </div>`);
- }
- pointsDetailHtml = `<div class="note-detail-points">${sections.join('')}</div>`;
- }
- const modalHtml = `
- <div class="note-detail-content">
- <button class="note-detail-close" onclick="closeNoteDetail()">×</button>
- <div class="note-detail-header">
- <div class="note-detail-title">${noteData.title || '无标题'}</div>
- <div class="note-detail-meta">
- <span class="note-detail-author">@${noteData.author}</span>
- <div class="note-detail-stats">
- <span>👍 ${noteData.like_count}</span>
- <span>💬 ${noteData.comment_count}</span>
- </div>
- </div>
- </div>
- <div class="note-detail-body">
- ${noteData.desc ? `<div class="note-detail-desc">${noteData.desc}</div>` : ''}
- ${pointsDetailHtml}
- <div class="note-detail-images">
- ${imagesHtml}
- </div>
- </div>
- <div class="note-detail-footer">
- <a href="${noteData.link}" target="_blank" class="note-detail-link">
- 在小红书查看完整内容 →
- </a>
- </div>
- </div>
- `;
- let modal = document.getElementById('noteDetailModal');
- if (!modal) {
- modal = document.createElement('div');
- modal.id = 'noteDetailModal';
- modal.className = 'note-detail-modal';
- modal.onclick = (e) => {
- if (e.target === modal) closeNoteDetail();
- };
- document.body.appendChild(modal);
- }
- modal.innerHTML = modalHtml;
- modal.classList.add('active');
- document.body.style.overflow = 'hidden';
- } catch (e) {
- console.error('Error parsing note data:', e);
- }
- }
- // 关闭笔记详情
- function closeNoteDetail() {
- const modal = document.getElementById('noteDetailModal');
- if (modal) {
- modal.classList.remove('active');
- document.body.style.overflow = '';
- }
- }
- // 显示分数详情
- function showScoreDetail(element) {
- const scoreDetailStr = element.dataset.scoreDetail;
- if (!scoreDetailStr) return;
- try {
- const scoreData = JSON.parse(scoreDetailStr);
- const modal = document.getElementById('scoreDetailModal');
- const modalBody = document.getElementById('scoreModalBody');
- // 生成相同部分HTML
- let samePartsHTML = '';
- if (scoreData.相同部分 && Object.keys(scoreData.相同部分).length > 0) {
- const sameItems = Object.entries(scoreData.相同部分).map(([key, value]) =>
- `<div class="score-part-item"><span class="score-part-key">${key}:</span><span class="score-part-value">${value}</span></div>`
- ).join('');
- samePartsHTML = `
- <div class="score-parts same-parts">
- <div class="score-parts-title">✅ 相同部分</div>
- ${sameItems}
- </div>
- `;
- }
- // 生成增量部分HTML
- let incrementPartsHTML = '';
- if (scoreData.增量部分 && Object.keys(scoreData.增量部分).length > 0) {
- const incItems = Object.entries(scoreData.增量部分).map(([key, value]) =>
- `<div class="score-part-item"><span class="score-part-key">${key}:</span><span class="score-part-value">${value}</span></div>`
- ).join('');
- incrementPartsHTML = `
- <div class="score-parts increment-parts">
- <div class="score-parts-title">➕ 增量部分</div>
- ${incItems}
- </div>
- `;
- }
- // 生成分数说明HTML
- let explainHTML = '';
- if (scoreData.score说明) {
- explainHTML = `
- <div class="score-detail-explain">
- <div class="score-explain-title">💡 分数说明</div>
- <div class="score-explain-text">${scoreData.score说明}</div>
- </div>
- `;
- }
- // 生成输入信息HTML
- let inputInfoHTML = '';
- if (scoreData.输入B || scoreData.输入A) {
- inputInfoHTML = `
- <div class="score-input-info">
- <div class="score-input-title">📝 输入信息</div>
- ${scoreData.输入B ? `
- <div class="score-input-item">
- <div class="score-input-label">输入B(灵感点):</div>
- <div class="score-input-value">${scoreData.输入B}</div>
- </div>
- ` : ''}
- ${scoreData.B_Context ? `
- <div class="score-input-item">
- <div class="score-input-label">B_Context:</div>
- <div class="score-input-value">${scoreData.B_Context}</div>
- </div>
- ` : ''}
- ${scoreData.输入A ? `
- <div class="score-input-item">
- <div class="score-input-label">输入A(帖子标题):</div>
- <div class="score-input-value">${scoreData.输入A}</div>
- </div>
- ` : ''}
- ${scoreData.A_Context ? `
- <div class="score-input-item">
- <div class="score-input-label">A_Context(帖子内容摘要):</div>
- <div class="score-input-value">${scoreData.A_Context}</div>
- </div>
- ` : ''}
- </div>
- `;
- }
- modalBody.innerHTML = `
- <div class="score-detail-container">
- <h2 class="score-detail-title">匹配分数详情</h2>
- <div class="score-detail-score">
- <span class="score-detail-label">匹配分数:</span>
- <span class="score-detail-value">${scoreData.score.toFixed(2)}</span>
- </div>
- ${inputInfoHTML}
- ${explainHTML}
- <div class="score-parts-container">
- ${samePartsHTML}
- ${incrementPartsHTML}
- </div>
- </div>
- `;
- modal.classList.add('active');
- document.body.style.overflow = 'hidden';
- } catch (e) {
- console.error('Failed to parse score detail:', e);
- }
- }
- // 关闭分数详情
- function closeScoreDetail() {
- const modal = document.getElementById('scoreDetailModal');
- if (modal) {
- modal.classList.remove('active');
- document.body.style.overflow = '';
- }
- }
- // 点击Modal背景关闭分数详情
- function closeScoreDetailModal(event) {
- if (event.target.id === 'scoreDetailModal') {
- closeScoreDetail();
- }
- }
- // 搜索结果排序
- function sortSearchResults(button, containerId) {
- const sortType = button.dataset.sort;
- const container = document.getElementById(containerId);
- if (!container) return;
- // 更新按钮状态
- const allButtons = button.parentElement.querySelectorAll('.search-sort-btn');
- allButtons.forEach(btn => btn.classList.remove('active'));
- button.classList.add('active');
- // 获取所有搜索结果卡片
- const items = Array.from(container.querySelectorAll('.search-note-item'));
- // 根据排序类型排序
- items.sort((a, b) => {
- if (sortType === 'score') {
- const scoreA = parseFloat(a.dataset.score) || -1;
- const scoreB = parseFloat(b.dataset.score) || -1;
- return scoreB - scoreA; // 降序
- } else if (sortType === 'original') {
- const indexA = parseInt(a.dataset.originalIndex) || 0;
- const indexB = parseInt(b.dataset.originalIndex) || 0;
- return indexA - indexB; // 升序
- } else if (sortType === 'likes') {
- const likesA = parseInt(a.dataset.likes) || 0;
- const likesB = parseInt(b.dataset.likes) || 0;
- return likesB - likesA; // 降序
- }
- return 0;
- });
- // 重新排列DOM
- items.forEach(item => container.appendChild(item));
- }
- // ESC键关闭详情
- document.addEventListener('keydown', function(event) {
- if (event.key === 'Escape') {
- closeNoteDetail();
- closeScoreDetail();
- }
- });
- // 切换主匹配项的展开/折叠
- function toggleMainMatch(element) {
- const matchItem = element.closest('.match-item');
- matchItem.classList.toggle('expanded');
- }
- // 切换步骤wrapper的展开/折叠
- function toggleStepWrapper(element) {
- const stepWrapper = element.closest('.step-section-wrapper');
- stepWrapper.classList.toggle('expanded');
- }
- // 切换步骤的展开/折叠
- function toggleStep(element) {
- const stepSection = element.closest('.step-section');
- stepSection.classList.toggle('expanded');
- }
- // 切换匹配详情的展开/折叠
- function toggleMatchSection(element) {
- const matchSection = element.closest('.match-section');
- matchSection.classList.toggle('expanded');
- }
- // 显示指定的灵感详情
- function showDetail(index) {
- const details = document.querySelectorAll('.inspiration-detail');
- details.forEach((detail, i) => {
- if (i === index) {
- detail.classList.add('active');
- // 滚动到顶部
- const section = document.querySelector('.inspirations-section');
- if (section) {
- section.scrollTop = 0;
- }
- } else {
- detail.classList.remove('active');
- }
- });
- }
- // 生成导航目录
- function generateNavigation() {
- const details = document.querySelectorAll('.inspiration-detail');
- const navList = document.getElementById('navList');
- navList.innerHTML = '';
- details.forEach((detail, index) => {
- const name = detail.dataset.inspirationName;
- const score = parseFloat(detail.dataset.step1Score) || 0;
- const top3MatchesStr = detail.dataset.top3Matches;
- let top3Matches = [];
- try {
- top3Matches = JSON.parse(top3MatchesStr);
- } catch(e) {
- console.error('Error parsing top3 matches:', e);
- }
- const navItem = document.createElement('div');
- navItem.className = 'nav-item';
- if (index === 0) navItem.classList.add('active');
- navItem.dataset.cardIndex = index;
- // 生成匹配列表HTML - 精简版:只显示[灵感分类]名称 score
- let matchesHtml = '';
- if (top3Matches && top3Matches.length > 0) {
- matchesHtml = '<div class="nav-item-matches">';
- top3Matches.forEach((match, i) => {
- matchesHtml += `
- <div class="nav-match-item-compact">
- <span class="nav-match-label">[灵感分类]</span>
- <span class="nav-match-name-compact">${match.name}</span>
- <span class="nav-match-score-compact">${match.score.toFixed(2)}</span>
- </div>
- `;
- });
- matchesHtml += '</div>';
- }
- navItem.innerHTML = `
- <div class="nav-item-header">
- <span class="nav-item-name" title="${name}">
- <span class="nav-label">[灵感点]</span>${name}
- </span>
- <span class="nav-item-score">${score.toFixed(2)}</span>
- </div>
- ${matchesHtml}
- `;
- navItem.addEventListener('click', () => {
- // 移除所有active状态
- document.querySelectorAll('.nav-item').forEach(item => {
- item.classList.remove('active');
- });
- // 添加当前active状态
- navItem.classList.add('active');
- // 显示对应详情
- showDetail(index);
- });
- navList.appendChild(navItem);
- });
- // 默认显示第一个详情
- if (details.length > 0) {
- showDetail(0);
- }
- }
- // 更新面包屑
- function updateBreadcrumb(matchName, stepName) {
- const breadcrumb = document.querySelector('.inspiration-detail.active #dynamicBreadcrumb');
- if (!breadcrumb) return;
- const inspirationName = document.querySelector('.inspiration-detail.active').dataset.inspirationName;
- let breadcrumbHtml = `
- <span class="breadcrumb-item"><span class="breadcrumb-label">[灵感点]</span> ${inspirationName}</span>
- `;
- if (matchName) {
- breadcrumbHtml += `
- <span class="breadcrumb-separator">›</span>
- <span class="breadcrumb-item"><span class="breadcrumb-label">[灵感分类]</span> ${matchName}</span>
- `;
- }
- if (stepName) {
- breadcrumbHtml += `
- <span class="breadcrumb-separator">›</span>
- <span class="breadcrumb-item breadcrumb-current">${stepName}</span>
- `;
- }
- breadcrumb.innerHTML = breadcrumbHtml;
- }
- // 监听滚动,更新面包屑
- function setupBreadcrumbObserver() {
- const activeDetail = document.querySelector('.inspiration-detail.active');
- if (!activeDetail) return;
- const contentWrapper = activeDetail.querySelector('.inspiration-content-wrapper');
- if (!contentWrapper) return;
- // 获取所有需要监听的section
- const sections = activeDetail.querySelectorAll('.step-section');
- if (sections.length === 0) return;
- // 创建Intersection Observer
- const observerOptions = {
- root: null,
- rootMargin: '-100px 0px -50% 0px',
- threshold: 0
- };
- const observer = new IntersectionObserver((entries) => {
- entries.forEach(entry => {
- if (entry.isIntersecting) {
- const section = entry.target;
- const matchItem = section.closest('.match-item');
- const matchName = matchItem ? matchItem.dataset.matchName : '';
- const stepName = section.dataset.stepName || '';
- updateBreadcrumb(matchName, stepName);
- }
- });
- }, observerOptions);
- // 观察所有section
- sections.forEach(section => observer.observe(section));
- // 存储observer以便清理
- if (!window.breadcrumbObservers) {
- window.breadcrumbObservers = [];
- }
- window.breadcrumbObservers.push(observer);
- }
- // 页面加载时生成导航
- document.addEventListener('DOMContentLoaded', () => {
- generateNavigation();
- setupBreadcrumbObserver();
- });
- // 当切换灵感点时,重新设置observer
- const originalShowDetail = showDetail;
- showDetail = function(index) {
- // 清理旧的observers
- if (window.breadcrumbObservers) {
- window.breadcrumbObservers.forEach(obs => obs.disconnect());
- window.breadcrumbObservers = [];
- }
- // 调用原始函数
- originalShowDetail(index);
- // 设置新的observer
- setTimeout(() => {
- setupBreadcrumbObserver();
- }, 100);
- };
- '''
- def generate_persona_structure_html(persona_data: Dict[str, Any]) -> str:
- """
- 生成人设结构的树状HTML
- Args:
- persona_data: 人设数据
- Returns:
- 人设结构的HTML字符串
- """
- if not persona_data:
- return '<div class="empty-state">暂无人设数据</div>'
- inspiration_list = persona_data.get("灵感点列表", [])
- if not inspiration_list:
- return '<div class="empty-state">暂无灵感点列表数据</div>'
- html_parts = ['<div class="tree">']
- for perspective_idx, perspective in enumerate(inspiration_list):
- perspective_name = perspective.get("视角名称", "未知视角")
- perspective_desc = perspective.get("视角描述", "")
- pattern_list = perspective.get("模式列表", [])
- # 一级节点:视角
- html_parts.append(f'''
- <ul>
- <li>
- <div class="tree-node level-1">
- <span class="node-icon">📁</span>
- <span class="node-name">{html_module.escape(perspective_name)}</span>
- <span class="node-count">{len(pattern_list)}个分类</span>
- </div>
- ''')
- if perspective_desc:
- html_parts.append(f'''
- <div class="node-desc">{html_module.escape(perspective_desc)}</div>
- ''')
- # 二级节点:分类
- if pattern_list:
- html_parts.append('<ul>')
- for pattern in pattern_list:
- category_name = pattern.get("分类名称", "未知分类")
- core_definition = pattern.get("核心定义", "")
- subcategories = pattern.get("二级细分", [])
- total_posts = sum(len(sub.get("帖子ID列表", [])) for sub in subcategories)
- html_parts.append(f'''
- <li>
- <div class="tree-node level-2">
- <span class="node-icon">📂</span>
- <span class="node-name">{html_module.escape(category_name)}</span>
- <span class="node-count">{total_posts}个帖子</span>
- </div>
- ''')
- if core_definition:
- html_parts.append(f'''
- <div class="node-desc">{html_module.escape(core_definition)}</div>
- ''')
- # 三级节点:细分
- if subcategories:
- html_parts.append('<ul>')
- for subcategory in subcategories:
- sub_name = subcategory.get("分类名称", "未知细分")
- sub_definition = subcategory.get("分类定义", "")
- post_ids = subcategory.get("帖子ID列表", [])
- html_parts.append(f'''
- <li>
- <div class="tree-node level-3">
- <span class="node-icon">📄</span>
- <span class="node-name">{html_module.escape(sub_name)}</span>
- <span class="node-count">{len(post_ids)}个帖子</span>
- </div>
- ''')
- if sub_definition:
- html_parts.append(f'''
- <div class="node-desc">{html_module.escape(sub_definition)}</div>
- ''')
- if post_ids:
- html_parts.append(f'''
- <div class="node-posts">
- <span class="posts-label">📋 帖子ID:</span>
- <span class="posts-ids">{", ".join([html_module.escape(str(pid)) for pid in post_ids[:5]])}</span>
- {f'<span class="posts-more">... 等{len(post_ids)}个</span>' if len(post_ids) > 5 else ''}
- </div>
- ''')
- html_parts.append('</li>')
- html_parts.append('</ul>')
- html_parts.append('</li>')
- html_parts.append('</ul>')
- html_parts.append('</li>')
- html_parts.append('</ul>')
- html_parts.append('</div>')
- return ''.join(html_parts)
- def generate_html(
- inspirations_data: List[Dict[str, Any]],
- posts_map: Dict[str, Dict[str, Any]],
- persona_data: Dict[str, Any],
- output_path: str,
- inspiration_to_post_data: Dict[str, Any] = None,
- category_index_data: Dict[str, Any] = None,
- post_to_mapping_data: Dict[str, Any] = None
- ) -> str:
- """
- 生成完整的可视化HTML
- Args:
- inspirations_data: 灵感点数据列表
- posts_map: 帖子数据映射
- persona_data: 人设数据
- output_path: 输出文件路径
- Returns:
- 输出文件路径
- """
- timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- # 统计信息
- total_count = len(inspirations_data)
- # Step1 统计
- step1_excellent_count = sum(1 for d in inspirations_data
- if d["summary"].get("关键指标", {}).get("step1_top1_score", 0) >= 0.7)
- step1_good_count = sum(1 for d in inspirations_data
- if 0.5 <= d["summary"].get("关键指标", {}).get("step1_top1_score", 0) < 0.7)
- step1_normal_count = sum(1 for d in inspirations_data
- if 0.3 <= d["summary"].get("关键指标", {}).get("step1_top1_score", 0) < 0.5)
- step1_need_opt_count = sum(1 for d in inspirations_data
- if d["summary"].get("关键指标", {}).get("step1_top1_score", 0) < 0.3)
- # 平均分数
- total_step1_score = sum(d["summary"].get("关键指标", {}).get("step1_top1_score", 0)
- for d in inspirations_data)
- avg_step1_score = total_step1_score / total_count if total_count > 0 else 0
- # 按Step1分数排序
- inspirations_data_sorted = sorted(
- inspirations_data,
- key=lambda x: x["summary"].get("关键指标", {}).get("step1_top1_score", 0),
- reverse=True
- )
- # 生成卡片HTML
- cards_html = [
- generate_inspiration_card_html(data, inspiration_to_post_data, category_index_data, post_to_mapping_data)
- for data in inspirations_data_sorted
- ]
- cards_html_str = '\n'.join(cards_html)
- # 生成人设结构HTML
- persona_structure_html = generate_persona_structure_html(persona_data)
- # 生成JavaScript
- detail_modal_js = generate_detail_modal_content_js()
- # 完整HTML
- html_content = f'''<!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>灵感点分析可视化</title>
- <style>
- * {{
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }}
- body {{
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
- background: #f5f7fa;
- color: #333;
- line-height: 1.6;
- margin: 0;
- padding: 0;
- overflow: hidden;
- }}
- .container {{
- max-width: 100%;
- height: 100vh;
- margin: 0;
- padding: 0;
- display: flex;
- }}
- .main-content-layout {{
- display: flex;
- width: 100%;
- height: 100vh;
- overflow: hidden;
- }}
- .sidebar-nav {{
- width: 400px;
- background: white;
- padding: 30px 20px;
- box-shadow: 2px 0 10px rgba(0,0,0,0.1);
- overflow-y: auto;
- flex-shrink: 0;
- height: 100vh;
- }}
- .nav-title {{
- font-size: 18px;
- font-weight: 700;
- color: #1a1a1a;
- margin-bottom: 15px;
- padding-bottom: 10px;
- border-bottom: 2px solid #e5e7eb;
- }}
- .nav-list {{
- display: flex;
- flex-direction: column;
- gap: 12px;
- }}
- .nav-item {{
- border-radius: 10px;
- cursor: pointer;
- transition: all 0.3s;
- border: 2px solid #e5e7eb;
- overflow: hidden;
- background: white;
- }}
- .nav-item:hover {{
- border-color: #667eea;
- box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
- }}
- .nav-item.active {{
- border-color: #667eea;
- box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25);
- }}
- .nav-item-header {{
- padding: 12px 14px;
- background: #f9fafb;
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 8px;
- }}
- .nav-item.active .nav-item-header {{
- background: rgba(102, 126, 234, 0.1);
- }}
- .nav-item-name {{
- flex: 1;
- font-weight: 600;
- font-size: 14px;
- color: #1f2937;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- display: flex;
- align-items: center;
- gap: 6px;
- }}
- .nav-item.active .nav-item-name {{
- color: #667eea;
- }}
- .nav-label {{
- display: inline-block;
- font-size: 11px;
- color: #8b5cf6;
- background: #f5f3ff;
- padding: 2px 6px;
- border-radius: 3px;
- font-weight: 500;
- white-space: nowrap;
- flex-shrink: 0;
- }}
- .nav-item-score {{
- font-size: 13px;
- font-weight: 700;
- padding: 4px 10px;
- border-radius: 6px;
- background: #e5e7eb;
- color: #6b7280;
- }}
- .nav-item.active .nav-item-score {{
- background: #667eea;
- color: white;
- }}
- .nav-item-matches {{
- padding: 10px 14px;
- background: white;
- border-top: 1px solid #e5e7eb;
- }}
- .nav-match-item-compact {{
- padding: 6px 0;
- font-size: 12px;
- display: flex;
- align-items: center;
- gap: 6px;
- line-height: 1.4;
- }}
- .nav-match-item-compact:not(:last-child) {{
- border-bottom: 1px dashed #e5e7eb;
- }}
- .nav-match-label {{
- color: #10b981;
- font-weight: 600;
- font-size: 11px;
- flex-shrink: 0;
- }}
- .nav-match-name-compact {{
- color: #1f2937;
- font-weight: 500;
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }}
- .nav-match-score-compact {{
- color: #667eea;
- font-weight: 700;
- font-size: 12px;
- flex-shrink: 0;
- }}
- .inspirations-section {{
- flex: 1;
- height: 100vh;
- overflow-y: auto;
- background: #f5f7fa;
- position: relative;
- }}
- .breadcrumb-container {{
- position: sticky;
- top: 0;
- left: 0;
- right: 0;
- background: white;
- border-bottom: 1px solid #e5e7eb;
- padding: 15px 30px;
- z-index: 100;
- box-shadow: 0 1px 3px rgba(0,0,0,0.05);
- }}
- .breadcrumb {{
- display: flex;
- align-items: center;
- gap: 8px;
- font-size: 14px;
- color: #6b7280;
- }}
- .breadcrumb-item {{
- display: flex;
- align-items: center;
- gap: 8px;
- }}
- .breadcrumb-separator {{
- color: #d1d5db;
- }}
- .breadcrumb-current {{
- color: #111827;
- font-weight: 600;
- }}
- .breadcrumb-label {{
- display: inline-block;
- font-size: 12px;
- color: #6366f1;
- background: #eef2ff;
- padding: 2px 8px;
- border-radius: 4px;
- font-weight: 500;
- margin-right: 4px;
- }}
- .inspiration-content-wrapper {{
- padding: 30px 40px;
- }}
- .inspirations-grid {{
- display: none;
- }}
- .inspiration-display {{
- width: 100%;
- }}
- .inspiration-detail {{
- display: none;
- }}
- .inspiration-detail.active {{
- display: block;
- }}
- .detail-header {{
- background: white;
- border-radius: 12px;
- padding: 25px 30px;
- margin-bottom: 15px;
- box-shadow: 0 1px 3px rgba(0,0,0,0.06);
- border: 1px solid #e5e7eb;
- }}
- .detail-title-row {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 15px;
- }}
- .detail-title-left, .detail-title-right {{
- display: flex;
- align-items: center;
- gap: 10px;
- }}
- .detail-label {{
- font-size: 12px;
- color: #5b21b6;
- background: rgba(109, 40, 217, 0.15);
- padding: 3px 10px;
- border-radius: 4px;
- font-weight: 500;
- }}
- .detail-category {{
- font-size: 18px;
- font-weight: 600;
- color: #374151;
- }}
- .detail-title {{
- font-size: 24px;
- font-weight: 700;
- color: #111827;
- margin-bottom: 12px;
- }}
- .detail-score-section {{
- display: flex;
- align-items: center;
- gap: 12px;
- }}
- .detail-score-label {{
- font-size: 13px;
- color: #6b7280;
- font-weight: 500;
- }}
- .detail-score-value {{
- font-size: 20px;
- font-weight: 700;
- color: #374151;
- }}
- .card-header {{
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- margin-bottom: 20px;
- gap: 12px;
- }}
- .inspiration-name {{
- font-size: 28px;
- font-weight: 800;
- color: #1a1a1a;
- line-height: 1.4;
- flex: 1;
- }}
- .grade-badge {{
- background: #10b981;
- color: white;
- padding: 6px 14px;
- border-radius: 20px;
- font-size: 12px;
- font-weight: 700;
- white-space: nowrap;
- }}
- .score-section {{
- display: flex;
- align-items: center;
- gap: 25px;
- margin-bottom: 20px;
- padding: 20px;
- background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
- border-radius: 12px;
- }}
- .score-item {{
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 8px;
- flex: 1;
- }}
- .main-score {{
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 8px;
- }}
- .score-circle {{
- width: 90px;
- height: 90px;
- border-radius: 50%;
- border: 6px solid #10b981;
- display: flex;
- align-items: center;
- justify-content: center;
- background: white;
- }}
- .score-value {{
- font-size: 26px;
- font-weight: 800;
- color: #10b981;
- }}
- .score-label {{
- font-size: 12px;
- color: #6b7280;
- font-weight: 600;
- }}
- .sub-scores {{
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 12px;
- }}
- .sub-score-item {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 10px 15px;
- background: white;
- border-radius: 8px;
- }}
- .sub-score-label {{
- font-size: 13px;
- color: #6b7280;
- font-weight: 600;
- }}
- .sub-score-value {{
- font-size: 18px;
- font-weight: 700;
- color: #2563eb;
- }}
- .metrics-section {{
- display: flex;
- flex-direction: column;
- gap: 10px;
- margin-bottom: 15px;
- }}
- .metric-item {{
- display: flex;
- align-items: center;
- gap: 8px;
- font-size: 13px;
- color: #4b5563;
- }}
- .metric-icon {{
- font-size: 16px;
- }}
- .metric-label {{
- font-weight: 600;
- }}
- .metric-value {{
- color: #1f2937;
- }}
- .match-preview {{
- background: #f9fafb;
- padding: 12px;
- border-radius: 8px;
- margin-bottom: 10px;
- border-left: 3px solid #8b5cf6;
- }}
- .match-preview-header {{
- font-size: 12px;
- font-weight: 600;
- color: #6b7280;
- margin-bottom: 6px;
- }}
- .match-preview-content {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- }}
- .match-preview-name {{
- font-size: 13px;
- color: #1f2937;
- flex: 1;
- }}
- .match-preview-score {{
- font-size: 16px;
- font-weight: 700;
- }}
- .preview-parts {{
- margin-top: 8px;
- padding: 8px 10px;
- border-radius: 6px;
- font-size: 12px;
- line-height: 1.6;
- }}
- .preview-parts.same {{
- background: #f0fdf4;
- color: #15803d;
- border-left: 3px solid #10b981;
- }}
- .preview-parts.increment {{
- background: #fff7ed;
- color: #92400e;
- border-left: 3px solid #f59e0b;
- margin-top: 6px;
- }}
- .preview-parts strong {{
- font-weight: 700;
- margin-right: 6px;
- }}
- .score-divider {{
- width: 1px;
- height: 40px;
- background: #e5e7eb;
- }}
- .inspiration-category-section {{
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 25px;
- margin-bottom: 0;
- }}
- .info-detail-column {{
- background: #fafbfc;
- border-radius: 10px;
- border: 1px solid #e5e7eb;
- overflow: hidden;
- }}
- .info-header {{
- padding: 15px 20px;
- border-bottom: 1px solid #e5e7eb;
- background: #f9fafb;
- display: flex;
- align-items: center;
- gap: 10px;
- }}
- .info-label {{
- font-size: 11px;
- color: #8b5cf6;
- background: #f5f3ff;
- padding: 2px 6px;
- border-radius: 3px;
- font-weight: 500;
- }}
- .info-name {{
- font-size: 16px;
- font-weight: 600;
- color: #111827;
- }}
- .info-content {{
- padding: 20px;
- }}
- .info-field {{
- margin-bottom: 12px;
- line-height: 1.6;
- }}
- .info-field-label {{
- font-weight: 600;
- color: #374151;
- margin-right: 6px;
- }}
- .info-field-value {{
- color: #6b7280;
- }}
- .info-posts {{
- margin-top: 20px;
- }}
- .info-posts-title {{
- font-size: 14px;
- font-weight: 600;
- color: #374151;
- margin-bottom: 12px;
- }}
- .info-posts-grid {{
- display: flex;
- gap: 15px;
- overflow-x: auto;
- overflow-y: hidden;
- padding-bottom: 10px;
- scroll-behavior: smooth;
- }}
- .info-posts-grid::-webkit-scrollbar {{
- height: 6px;
- }}
- .info-posts-grid::-webkit-scrollbar-track {{
- background: #f3f4f6;
- border-radius: 3px;
- }}
- .info-posts-grid::-webkit-scrollbar-thumb {{
- background: #d1d5db;
- border-radius: 3px;
- }}
- .info-posts-grid::-webkit-scrollbar-thumb:hover {{
- background: #9ca3af;
- }}
- .info-posts-grid .search-note-item {{
- flex: 0 0 260px;
- min-width: 260px;
- }}
- .matches-list {{
- display: flex;
- flex-direction: column;
- gap: 15px;
- }}
- .match-item {{
- background: white;
- border-radius: 12px;
- overflow: hidden;
- box-shadow: 0 2px 8px rgba(0,0,0,0.06);
- transition: all 0.3s;
- margin-bottom: 20px;
- }}
- .match-item:hover {{
- box-shadow: 0 4px 16px rgba(0,0,0,0.1);
- }}
- .match-main-header {{
- background: linear-gradient(135deg, #a5b4fc 0%, #c4b5fd 100%);
- border-bottom: none;
- padding: 16px 20px;
- cursor: pointer;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }}
- .match-main-header:hover {{
- background: linear-gradient(135deg, #8b9cfc 0%, #b39dfc 100%);
- }}
- .match-header-row {{
- flex: 1;
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 20px;
- }}
- .match-header-left, .match-header-right {{
- display: flex;
- align-items: center;
- gap: 10px;
- flex: 1;
- }}
- .match-header-center {{
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 4px;
- padding: 0 20px;
- }}
- .match-score-label {{
- font-size: 11px;
- color: #4c1d95;
- text-transform: uppercase;
- }}
- .match-score-value {{
- font-size: 20px;
- font-weight: 700;
- color: #5b21b6;
- }}
- .match-title {{
- color: #3730a3;
- font-size: 16px;
- font-weight: 700;
- }}
- .match-category {{
- color: #3730a3;
- font-size: 16px;
- font-weight: 700;
- }}
- .match-hierarchy {{
- color: #4c1d95;
- font-size: 13px;
- }}
- .match-toggle-main {{
- color: #5b21b6;
- font-size: 20px;
- transition: transform 0.3s;
- flex-shrink: 0;
- }}
- .match-item.expanded .match-toggle-main {{
- transform: rotate(180deg);
- }}
- .match-main-content {{
- max-height: 0;
- overflow: hidden;
- transition: max-height 0.3s ease;
- }}
- .match-item.expanded .match-main-content {{
- max-height: 10000px;
- }}
- .match-main-content .inspiration-category-section {{
- margin: 25px;
- margin-bottom: 0;
- }}
- .step-section-wrapper {{
- margin: 20px 25px;
- border: 2px solid #e5e7eb;
- border-radius: 12px;
- overflow: hidden;
- background: white;
- }}
- .step-1-wrapper {{
- border-color: #fbbf24;
- }}
- .step-2-wrapper {{
- border-color: #34d399;
- }}
- .step-header {{
- background: linear-gradient(135deg, #fbbf24 0%, #fcd34d 100%);
- padding: 16px 25px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- cursor: pointer;
- transition: all 0.3s;
- }}
- .step-header:hover {{
- background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
- }}
- .step-2-wrapper .step-header {{
- background: linear-gradient(135deg, #34d399 0%, #6ee7b7 100%);
- }}
- .step-2-wrapper .step-header:hover {{
- background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
- }}
- .step-header-content {{
- display: flex;
- align-items: center;
- gap: 12px;
- }}
- .step-header .step-toggle {{
- font-size: 20px;
- color: #78350f;
- transition: transform 0.3s;
- }}
- .step-2-wrapper .step-header .step-toggle {{
- color: #065f46;
- }}
- .step-section-wrapper.expanded > .step-header .step-toggle {{
- transform: rotate(180deg);
- }}
- .step-wrapper-content {{
- max-height: 0;
- overflow: hidden;
- transition: max-height 0.3s ease;
- }}
- .step-section-wrapper.expanded .step-wrapper-content {{
- max-height: 30000px;
- }}
- .step-number-badge {{
- background: rgba(255, 255, 255, 0.5);
- color: #78350f;
- padding: 6px 14px;
- border-radius: 20px;
- font-size: 13px;
- font-weight: 700;
- letter-spacing: 0.5px;
- }}
- .step-2-wrapper .step-number-badge {{
- color: #065f46;
- }}
- .step-title {{
- color: #78350f;
- font-size: 16px;
- font-weight: 700;
- }}
- .step-2-wrapper .step-title {{
- color: #065f46;
- }}
- .match-analysis-section {{
- padding: 25px;
- }}
- .match-header {{
- padding: 20px;
- cursor: pointer;
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 15px;
- background: #fafafa;
- transition: background 0.3s;
- border-bottom: 1px solid #e5e7eb;
- }}
- .match-header:hover {{
- background: #f5f5f5;
- }}
- .match-section.expanded .match-header {{
- background: rgba(102, 126, 234, 0.05);
- }}
- .match-header-left {{
- flex: 1;
- min-width: 0;
- }}
- .match-rank {{
- display: inline-block;
- padding: 3px 10px;
- border-radius: 4px;
- font-size: 11px;
- font-weight: 600;
- background: rgba(91, 33, 182, 0.15);
- color: #5b21b6;
- }}
- .match-element-name {{
- font-size: 18px;
- font-weight: 700;
- color: #1f2937;
- display: block;
- margin-bottom: 6px;
- }}
- .match-context {{
- font-size: 13px;
- color: #6b7280;
- display: flex;
- align-items: center;
- gap: 6px;
- }}
- .match-context-separator {{
- color: #d1d5db;
- }}
- .match-header-right {{
- display: flex;
- align-items: center;
- gap: 15px;
- flex-shrink: 0;
- }}
- .match-score {{
- font-size: 24px;
- font-weight: 800;
- color: #667eea;
- }}
- .match-toggle {{
- width: 32px;
- height: 32px;
- border-radius: 8px;
- background: #e5e7eb;
- display: flex;
- align-items: center;
- justify-content: center;
- transition: all 0.3s;
- font-size: 18px;
- color: #6b7280;
- }}
- .match-item.expanded .match-toggle {{
- background: #667eea;
- color: white;
- transform: rotate(180deg);
- }}
- .match-section {{
- border-bottom: 1px solid #e5e7eb;
- }}
- .match-section:last-child {{
- border-bottom: none;
- }}
- .step-section-header {{
- padding: 18px 25px;
- background: #f9fafb;
- cursor: pointer;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid #e5e7eb;
- }}
- .step-section-header:hover {{
- background: #f3f4f6;
- }}
- .step-section-title {{
- font-size: 15px;
- font-weight: 600;
- color: #374151;
- display: flex;
- align-items: center;
- gap: 10px;
- }}
- .step-sub-number {{
- display: inline-flex;
- align-items: center;
- justify-content: center;
- min-width: 38px;
- padding: 4px 10px;
- background: #10b981;
- color: white;
- border-radius: 6px;
- font-size: 12px;
- font-weight: 700;
- }}
- .step-number {{
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 20px;
- height: 20px;
- background: #e5e7eb;
- color: #6b7280;
- border-radius: 50%;
- font-size: 11px;
- font-weight: 600;
- }}
- .step-toggle {{
- font-size: 18px;
- color: #6b7280;
- transition: transform 0.3s;
- }}
- .step-section.expanded .step-toggle {{
- transform: rotate(180deg);
- }}
- .step-section-content {{
- max-height: 0;
- overflow: hidden;
- transition: max-height 0.3s ease;
- }}
- .step-section.expanded .step-section-content {{
- max-height: 20000px;
- }}
- .match-content {{
- max-height: 0;
- overflow: hidden;
- transition: max-height 0.3s ease;
- }}
- .match-section.expanded .match-content {{
- max-height: 2000px;
- }}
- .match-content-inner {{
- padding: 20px;
- }}
- .match-explain {{
- background: #fffbeb;
- padding: 16px 20px;
- border-radius: 8px;
- margin-top: 20px;
- border-left: 3px solid #f59e0b;
- }}
- .match-explain-title {{
- font-weight: 600;
- color: #374151;
- margin-bottom: 6px;
- font-size: 13px;
- }}
- .match-explain-text {{
- color: #6b7280;
- font-size: 14px;
- line-height: 1.7;
- }}
- .match-parts-container {{
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 25px;
- margin-bottom: 20px;
- }}
- .match-parts-column {{
- min-width: 0;
- }}
- .match-parts {{
- margin-bottom: 0;
- height: 100%;
- background: #f9fafb;
- padding: 16px;
- border-radius: 8px;
- border: 1px solid #e5e7eb;
- }}
- .match-parts-title {{
- font-weight: 700;
- font-size: 14px;
- margin-bottom: 16px;
- color: #374151;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- }}
- .part-item {{
- padding: 10px 0;
- margin-bottom: 8px;
- font-size: 14px;
- border-bottom: 1px solid #e5e7eb;
- }}
- .part-item:last-child {{
- border-bottom: none;
- }}
- .part-key {{
- font-weight: 500;
- color: #374151;
- margin-right: 8px;
- }}
- .part-value {{
- color: #6b7280;
- }}
- .same-parts {{
- background: #ecfdf5;
- border-color: #10b981;
- }}
- .increment-parts {{
- background: #fef3c7;
- border-color: #f59e0b;
- }}
- .search-results-section {{
- padding: 25px;
- }}
- .search-params-section {{
- background: #f0f9ff;
- border: 1px solid #bae6fd;
- border-radius: 8px;
- padding: 20px;
- margin-bottom: 20px;
- }}
- .search-params-title {{
- font-size: 15px;
- font-weight: 700;
- color: #0c4a6e;
- margin-bottom: 16px;
- }}
- .search-params-grid {{
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 12px;
- }}
- .search-param-item {{
- display: flex;
- align-items: center;
- gap: 8px;
- }}
- .search-param-label {{
- font-size: 13px;
- color: #0369a1;
- font-weight: 600;
- min-width: 80px;
- }}
- .search-param-value {{
- font-size: 13px;
- color: #0c4a6e;
- background: #e0f2fe;
- padding: 4px 12px;
- border-radius: 4px;
- }}
- .search-summary-section {{
- background: #ecfdf5;
- border: 1px solid #a7f3d0;
- border-radius: 8px;
- padding: 16px 20px;
- margin-bottom: 20px;
- }}
- .search-summary-header {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 20px;
- }}
- .search-summary-left {{
- flex: 1;
- }}
- .search-summary-title {{
- font-size: 15px;
- font-weight: 700;
- color: #065f46;
- margin-bottom: 8px;
- }}
- .search-summary-content {{
- font-size: 14px;
- color: #047857;
- }}
- .search-result-count {{
- font-size: 18px;
- font-weight: 700;
- color: #059669;
- margin: 0 4px;
- }}
- .search-sort-buttons {{
- display: flex;
- align-items: center;
- gap: 8px;
- }}
- .search-sort-label {{
- font-size: 13px;
- color: #047857;
- font-weight: 600;
- }}
- .search-sort-btn {{
- background: white;
- border: 1px solid #a7f3d0;
- color: #065f46;
- padding: 6px 12px;
- border-radius: 6px;
- font-size: 12px;
- font-weight: 600;
- cursor: pointer;
- transition: all 0.2s;
- }}
- .search-sort-btn:hover {{
- background: #d1fae5;
- border-color: #6ee7b7;
- }}
- .search-sort-btn.active {{
- background: #059669;
- color: white;
- border-color: #059669;
- }}
- .note-position {{
- font-size: 11px;
- color: #9ca3af;
- font-weight: 600;
- }}
- .search-notes-list {{
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
- gap: 16px;
- }}
- .search-note-item {{
- background: white;
- border-radius: 12px;
- overflow: hidden;
- box-shadow: 0 2px 8px rgba(0,0,0,0.08);
- border: 1px solid #e5e7eb;
- transition: all 0.3s;
- position: relative;
- }}
- .search-note-item:hover {{
- box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
- border-color: #667eea;
- }}
- .note-score-badge {{
- position: absolute;
- top: 12px;
- right: 12px;
- background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
- padding: 8px 14px;
- border-radius: 8px;
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 2px;
- cursor: pointer;
- z-index: 5;
- box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
- transition: all 0.3s;
- }}
- .note-score-badge:hover {{
- transform: scale(1.05);
- box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
- }}
- .note-score-badge .score-label {{
- font-size: 10px;
- color: rgba(255, 255, 255, 0.9);
- text-transform: uppercase;
- letter-spacing: 0.5px;
- }}
- .note-score-badge .score-value {{
- font-size: 18px;
- font-weight: 700;
- color: white;
- }}
- .note-image-carousel {{
- position: relative;
- width: 100%;
- min-height: 200px;
- max-height: 400px;
- background: #f3f4f6;
- overflow: hidden;
- display: flex;
- align-items: center;
- justify-content: center;
- }}
- .note-images-track {{
- display: flex;
- width: 100%;
- height: 100%;
- transition: transform 0.4s ease;
- }}
- .note-image {{
- flex: 0 0 100%;
- width: 100%;
- height: auto;
- max-height: 400px;
- object-fit: contain;
- }}
- .note-carousel-button {{
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- width: 32px;
- height: 32px;
- background: rgba(255, 255, 255, 0.9);
- border: none;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- transition: all 0.3s;
- z-index: 10;
- font-size: 16px;
- color: #6b7280;
- opacity: 0;
- }}
- .search-note-item:hover .note-carousel-button {{
- opacity: 1;
- }}
- .note-carousel-button:hover {{
- background: #667eea;
- color: white;
- }}
- .note-carousel-button.disabled {{
- opacity: 0 !important;
- }}
- .note-carousel-button.prev {{
- left: 10px;
- }}
- .note-carousel-button.next {{
- right: 10px;
- }}
- .note-image-dots {{
- position: absolute;
- bottom: 10px;
- left: 50%;
- transform: translateX(-50%);
- display: flex;
- gap: 6px;
- z-index: 10;
- }}
- .note-image-dot {{
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.6);
- transition: all 0.3s;
- }}
- .note-image-dot.active {{
- background: white;
- width: 20px;
- border-radius: 3px;
- }}
- .note-content {{
- padding: 15px;
- }}
- .note-title {{
- font-size: 15px;
- font-weight: 600;
- color: #1f2937;
- margin-bottom: 8px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- line-height: 1.4;
- }}
- .note-desc {{
- font-size: 13px;
- color: #6b7280;
- line-height: 1.6;
- margin-bottom: 12px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }}
- .note-publish-date {{
- font-size: 12px;
- color: #9ca3af;
- margin-bottom: 12px;
- display: flex;
- align-items: center;
- gap: 4px;
- }}
- .note-footer {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-top: 12px;
- border-top: 1px solid #f3f4f6;
- }}
- .note-author {{
- font-size: 12px;
- font-weight: 600;
- color: #6b7280;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 150px;
- }}
- .note-points-hover {{
- position: absolute;
- bottom: 100%;
- left: 0;
- right: 0;
- background: white;
- border: 1px solid #e5e7eb;
- border-radius: 8px;
- box-shadow: 0 4px 12px rgba(0,0,0,0.15);
- padding: 12px;
- margin-bottom: 8px;
- opacity: 0;
- visibility: hidden;
- transition: opacity 0.2s, visibility 0.2s;
- z-index: 10;
- max-height: 300px;
- overflow-y: auto;
- }}
- .search-note-item {{
- position: relative;
- }}
- .search-note-item:hover .note-points-hover {{
- opacity: 1;
- visibility: visible;
- }}
- .note-points {{
- /* 用于详情弹窗中的样式 */
- }}
- .points-section {{
- margin-bottom: 8px;
- }}
- .points-section:last-child {{
- margin-bottom: 0;
- }}
- .points-label {{
- font-size: 11px;
- font-weight: 600;
- color: #6b7280;
- margin-bottom: 4px;
- }}
- .points-list {{
- display: flex;
- flex-wrap: wrap;
- gap: 4px;
- }}
- .point-item {{
- display: inline-block;
- }}
- .point-name {{
- display: inline-block;
- font-size: 11px;
- color: #4b5563;
- background: #f3f4f6;
- padding: 2px 6px;
- border-radius: 3px;
- }}
- .note-stats {{
- display: flex;
- gap: 10px;
- font-size: 12px;
- color: #9ca3af;
- }}
- .note-link {{
- display: block;
- text-align: center;
- padding: 8px;
- margin-top: 10px;
- background: rgba(102, 126, 234, 0.1);
- color: #667eea;
- text-decoration: none;
- border-radius: 6px;
- font-size: 13px;
- font-weight: 600;
- transition: all 0.3s;
- }}
- .note-link:hover {{
- background: #667eea;
- color: white;
- }}
- /* 笔记详情Modal样式 */
- .note-detail-modal {{
- display: none;
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, 0.8);
- z-index: 9999;
- overflow-y: auto;
- padding: 40px 20px;
- }}
- .note-detail-modal.active {{
- display: flex;
- align-items: flex-start;
- justify-content: center;
- }}
- .note-detail-content {{
- background: white;
- border-radius: 16px;
- max-width: 1200px;
- width: 100%;
- position: relative;
- margin: auto;
- }}
- .note-detail-close {{
- position: absolute;
- top: 20px;
- right: 20px;
- width: 40px;
- height: 40px;
- background: white;
- border: none;
- border-radius: 50%;
- font-size: 24px;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- box-shadow: 0 2px 8px rgba(0,0,0,0.2);
- transition: all 0.3s;
- z-index: 10;
- }}
- .note-detail-close:hover {{
- background: #ef4444;
- color: white;
- transform: rotate(90deg);
- }}
- .note-detail-header {{
- padding: 30px;
- border-bottom: 1px solid #e5e7eb;
- }}
- .note-detail-title {{
- font-size: 24px;
- font-weight: 800;
- color: #1f2937;
- margin-bottom: 15px;
- }}
- .note-detail-meta {{
- display: flex;
- align-items: center;
- gap: 20px;
- font-size: 14px;
- color: #6b7280;
- }}
- .note-detail-author {{
- font-weight: 600;
- color: #1f2937;
- }}
- .note-detail-stats {{
- display: flex;
- gap: 15px;
- }}
- .note-detail-body {{
- padding: 30px;
- }}
- .note-detail-desc {{
- font-size: 15px;
- line-height: 1.8;
- color: #4b5563;
- margin-bottom: 30px;
- }}
- .note-detail-points {{
- margin-bottom: 30px;
- background: #f9fafb;
- border-radius: 8px;
- padding: 20px;
- }}
- .detail-points-section {{
- margin-bottom: 20px;
- }}
- .detail-points-section:last-child {{
- margin-bottom: 0;
- }}
- .detail-points-title {{
- font-size: 16px;
- font-weight: 600;
- color: #111827;
- margin-bottom: 12px;
- }}
- .detail-point-item {{
- background: white;
- padding: 12px 15px;
- border-radius: 6px;
- margin-bottom: 10px;
- border-left: 3px solid #e5e7eb;
- }}
- .detail-point-item:last-child {{
- margin-bottom: 0;
- }}
- .detail-point-name {{
- font-size: 14px;
- font-weight: 600;
- color: #374151;
- margin-bottom: 4px;
- }}
- .detail-point-desc {{
- font-size: 13px;
- line-height: 1.6;
- color: #6b7280;
- }}
- .note-detail-images {{
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
- gap: 15px;
- }}
- .note-detail-image {{
- width: 100%;
- border-radius: 8px;
- cursor: pointer;
- transition: all 0.3s;
- }}
- .note-detail-image:hover {{
- transform: scale(1.05);
- box-shadow: 0 8px 24px rgba(0,0,0,0.2);
- }}
- .note-detail-footer {{
- padding: 20px 30px;
- border-top: 1px solid #e5e7eb;
- display: flex;
- justify-content: center;
- }}
- .note-detail-link {{
- display: inline-block;
- padding: 12px 32px;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: white;
- text-decoration: none;
- border-radius: 10px;
- font-weight: 600;
- transition: all 0.3s;
- }}
- .note-detail-link:hover {{
- transform: translateY(-2px);
- box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
- }}
- /* Modal样式 */
- .modal-overlay {{
- display: none;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.8);
- z-index: 1000;
- align-items: center;
- justify-content: center;
- padding: 20px;
- overflow-y: auto;
- }}
- .modal-overlay.active {{
- display: flex;
- }}
- .modal-content {{
- background: white;
- border-radius: 16px;
- max-width: 1200px;
- width: 100%;
- max-height: 90vh;
- overflow-y: auto;
- position: relative;
- }}
- .modal-close {{
- position: sticky;
- top: 0;
- right: 0;
- background: white;
- border: none;
- font-size: 32px;
- color: #6b7280;
- cursor: pointer;
- padding: 15px 20px;
- z-index: 10;
- text-align: right;
- border-bottom: 1px solid #e5e7eb;
- }}
- .modal-close:hover {{
- color: #1f2937;
- }}
- .modal-body {{
- padding: 30px;
- }}
- /* 分数详情Modal样式 */
- .score-detail-content {{
- max-width: 800px;
- }}
- .score-detail-container {{
- padding: 10px;
- }}
- .score-detail-title {{
- font-size: 24px;
- font-weight: 700;
- color: #1f2937;
- margin-bottom: 20px;
- padding-bottom: 15px;
- border-bottom: 2px solid #e5e7eb;
- }}
- .score-detail-score {{
- background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
- padding: 20px;
- border-radius: 12px;
- margin-bottom: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 10px;
- }}
- .score-detail-label {{
- font-size: 16px;
- color: rgba(255, 255, 255, 0.9);
- font-weight: 600;
- }}
- .score-detail-value {{
- font-size: 32px;
- font-weight: 700;
- color: white;
- }}
- .score-detail-explain {{
- background: #fffbeb;
- padding: 16px 20px;
- border-radius: 8px;
- margin-bottom: 20px;
- border-left: 3px solid #f59e0b;
- }}
- .score-input-info {{
- background: #f0f9ff;
- padding: 16px 20px;
- border-radius: 8px;
- margin-bottom: 20px;
- border-left: 3px solid #3b82f6;
- }}
- .score-input-title {{
- font-weight: 700;
- font-size: 14px;
- margin-bottom: 12px;
- color: #1e40af;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- }}
- .score-input-item {{
- margin-bottom: 12px;
- padding-bottom: 12px;
- border-bottom: 1px solid #bfdbfe;
- }}
- .score-input-item:last-child {{
- margin-bottom: 0;
- padding-bottom: 0;
- border-bottom: none;
- }}
- .score-input-label {{
- font-weight: 600;
- font-size: 13px;
- color: #1e40af;
- margin-bottom: 4px;
- }}
- .score-input-value {{
- font-size: 14px;
- color: #374151;
- line-height: 1.6;
- white-space: pre-wrap;
- word-break: break-word;
- }}
- .score-parts-container {{
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 20px;
- }}
- .score-parts {{
- background: #f9fafb;
- padding: 16px;
- border-radius: 8px;
- border: 1px solid #e5e7eb;
- }}
- .score-parts.same-parts {{
- background: #ecfdf5;
- border-color: #10b981;
- }}
- .score-parts.increment-parts {{
- background: #fef3c7;
- border-color: #f59e0b;
- }}
- .score-parts-title {{
- font-weight: 700;
- font-size: 14px;
- margin-bottom: 16px;
- color: #374151;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- }}
- .score-part-item {{
- padding: 10px 0;
- margin-bottom: 8px;
- font-size: 14px;
- border-bottom: 1px solid #e5e7eb;
- }}
- .score-part-item:last-child {{
- border-bottom: none;
- }}
- .score-part-key {{
- font-weight: 500;
- color: #374151;
- margin-right: 8px;
- }}
- .score-part-value {{
- color: #6b7280;
- }}
- .modal-header {{
- margin-bottom: 25px;
- padding-bottom: 20px;
- border-bottom: 2px solid #e5e7eb;
- }}
- .modal-title {{
- font-size: 28px;
- font-weight: 800;
- color: #1a1a1a;
- }}
- .modal-section {{
- margin-bottom: 30px;
- }}
- .modal-section h3 {{
- font-size: 20px;
- font-weight: 700;
- color: #374151;
- margin-bottom: 15px;
- padding-bottom: 10px;
- border-bottom: 2px solid #f3f4f6;
- }}
- .info-grid {{
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
- gap: 15px;
- }}
- .info-item {{
- background: #f9fafb;
- padding: 12px 16px;
- border-radius: 8px;
- border-left: 3px solid #8b5cf6;
- }}
- .info-label {{
- font-weight: 600;
- color: #6b7280;
- font-size: 13px;
- margin-right: 8px;
- }}
- .info-value {{
- color: #1f2937;
- font-size: 14px;
- }}
- .metrics-grid {{
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: 15px;
- }}
- .metric-box {{
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- padding: 20px;
- border-radius: 12px;
- text-align: center;
- color: white;
- }}
- .metric-box.wide {{
- grid-column: span 2;
- }}
- .metric-box-label {{
- font-size: 13px;
- opacity: 0.9;
- margin-bottom: 8px;
- font-weight: 600;
- }}
- .metric-box-value {{
- font-size: 28px;
- font-weight: 700;
- }}
- .metric-box-value.small {{
- font-size: 16px;
- }}
- .step-content {{
- background: #f9fafb;
- padding: 20px;
- border-radius: 12px;
- }}
- .step-field {{
- margin-bottom: 20px;
- }}
- .step-field-label {{
- font-weight: 700;
- color: #374151;
- font-size: 14px;
- margin-bottom: 8px;
- display: block;
- }}
- .step-field-value {{
- color: #1f2937;
- font-size: 15px;
- line-height: 1.7;
- }}
- .matches-list {{
- display: flex;
- flex-direction: column;
- gap: 15px;
- margin-top: 10px;
- }}
- .match-item {{
- background: white;
- padding: 18px;
- border-radius: 10px;
- border-left: 5px solid #3b82f6;
- }}
- .match-item.top1 {{
- border-left-color: #fbbf24;
- background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, white 100%);
- }}
- .match-item.top2 {{
- border-left-color: #c0c0c0;
- background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 50%, white 100%);
- }}
- .match-item.top3 {{
- border-left-color: #cd7f32;
- background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 50%, white 100%);
- }}
- .match-header {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 12px;
- gap: 10px;
- }}
- .match-rank {{
- font-size: 18px;
- font-weight: 800;
- color: #6b7280;
- }}
- .match-element-name {{
- flex: 1;
- font-size: 16px;
- font-weight: 700;
- color: #1f2937;
- }}
- .match-score {{
- font-size: 22px;
- font-weight: 800;
- color: #2563eb;
- background: white;
- padding: 6px 14px;
- border-radius: 8px;
- }}
- .match-detail {{
- background: rgba(255, 255, 255, 0.7);
- padding: 10px;
- border-radius: 6px;
- margin-bottom: 10px;
- font-size: 13px;
- color: #4b5563;
- }}
- .match-reason {{
- color: #1f2937;
- font-size: 14px;
- line-height: 1.7;
- }}
- .increment-matches {{
- display: flex;
- flex-direction: column;
- gap: 12px;
- margin-top: 10px;
- }}
- .increment-item {{
- background: white;
- padding: 15px;
- border-radius: 8px;
- border-left: 4px solid #10b981;
- }}
- .increment-header {{
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10px;
- }}
- .increment-words {{
- font-weight: 700;
- color: #1f2937;
- font-size: 15px;
- }}
- .increment-score {{
- font-size: 20px;
- font-weight: 800;
- color: #10b981;
- }}
- .increment-reason {{
- color: #4b5563;
- font-size: 13px;
- line-height: 1.6;
- }}
- .empty-state {{
- text-align: center;
- padding: 40px;
- color: #9ca3af;
- font-size: 14px;
- }}
- .modal-link {{
- margin-top: 25px;
- padding-top: 20px;
- border-top: 2px solid #e5e7eb;
- text-align: center;
- }}
- .modal-link-btn {{
- display: inline-flex;
- align-items: center;
- gap: 10px;
- padding: 12px 24px;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- color: white;
- text-decoration: none;
- border-radius: 10px;
- font-size: 15px;
- font-weight: 600;
- transition: all 0.3s;
- }}
- .modal-link-btn:hover {{
- transform: translateY(-2px);
- box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
- }}
- .timestamp {{
- text-align: center;
- color: white;
- font-size: 13px;
- margin-top: 30px;
- opacity: 0.8;
- }}
- .match-context {{
- background: #f3f4f6;
- padding: 8px 12px;
- border-radius: 6px;
- margin: 8px 0;
- font-size: 12px;
- color: #6b7280;
- line-height: 1.6;
- }}
- .match-explain {{
- background: #fef3c7;
- padding: 10px 12px;
- border-radius: 6px;
- margin: 10px 0;
- font-size: 13px;
- color: #92400e;
- line-height: 1.7;
- border-left: 3px solid #f59e0b;
- }}
- .match-parts {{
- margin: 12px 0;
- border-radius: 8px;
- overflow: hidden;
- }}
- .match-parts.same-parts {{
- background: #f0fdf4;
- border: 2px solid #10b981;
- }}
- .match-parts.increment-parts {{
- background: #fff7ed;
- border: 2px solid #f59e0b;
- }}
- .parts-header {{
- font-weight: 700;
- padding: 10px 12px;
- font-size: 13px;
- }}
- .same-parts .parts-header {{
- background: #dcfce7;
- color: #15803d;
- }}
- .increment-parts .parts-header {{
- background: #fed7aa;
- color: #92400e;
- }}
- .parts-content {{
- padding: 8px 12px;
- }}
- .part-item {{
- padding: 6px 0;
- border-bottom: 1px solid rgba(0,0,0,0.05);
- font-size: 13px;
- line-height: 1.6;
- }}
- .part-item:last-child {{
- border-bottom: none;
- }}
- .part-key {{
- font-weight: 600;
- color: #374151;
- margin-right: 6px;
- }}
- .part-value {{
- color: #1f2937;
- }}
- .increment-context {{
- background: #fef3c7;
- padding: 10px 12px;
- border-radius: 6px;
- margin: 10px 0;
- font-size: 12px;
- color: #92400e;
- line-height: 1.6;
- border-left: 3px solid #f59e0b;
- }}
- @media (max-width: 768px) {{
- .main-content-layout {{
- flex-direction: column;
- }}
- .sidebar-nav {{
- position: relative;
- width: 100%;
- max-height: 300px;
- }}
- .inspirations-grid {{
- grid-template-columns: 1fr;
- }}
- .header h1 {{
- font-size: 32px;
- }}
- .stats-overview {{
- grid-template-columns: repeat(2, 1fr);
- }}
- }}
- </style>
- </head>
- <body>
- <div class="container">
- <div class="main-content-layout">
- <div class="sidebar-nav">
- <div class="nav-title">📑 灵感点列表</div>
- <div class="nav-list" id="navList">
- <!-- 目录将通过JS动态生成 -->
- </div>
- </div>
- <div class="inspirations-section">
- <div class="inspiration-display">
- {cards_html_str}
- </div>
- </div>
- </div>
- <!-- Modal -->
- <div id="detailModal" class="modal-overlay" onclick="closeModalOnOverlay(event)">
- <div class="modal-content">
- <button class="modal-close" onclick="closeModal()">×</button>
- <div class="modal-body" id="modalBody">
- <!-- Content will be inserted here -->
- </div>
- </div>
- </div>
- <!-- Score Detail Modal -->
- <div id="scoreDetailModal" class="modal-overlay" onclick="closeScoreDetailModal(event)">
- <div class="modal-content score-detail-content">
- <button class="modal-close" onclick="closeScoreDetail()">×</button>
- <div class="modal-body" id="scoreModalBody">
- <!-- Score detail content will be inserted here -->
- </div>
- </div>
- </div>
- </div>
- <script>
- {detail_modal_js}
- </script>
- </body>
- </html>'''
- # 写入文件
- output_file = Path(output_path)
- output_file.parent.mkdir(parents=True, exist_ok=True)
- with open(output_file, 'w', encoding='utf-8') as f:
- f.write(html_content)
- return str(output_file.absolute())
- def load_persona_data(persona_path: str) -> Dict[str, Any]:
- """
- 加载人设数据
- Args:
- persona_path: 人设JSON文件路径
- Returns:
- 人设数据字典
- """
- try:
- with open(persona_path, 'r', encoding='utf-8') as f:
- return json.load(f)
- except Exception as e:
- print(f"警告: 读取人设文件失败: {e}")
- return {}
- def main():
- """主函数"""
- import sys
- import os
- # 配置路径(使用当前脚本的相对路径)
- script_dir = os.path.dirname(os.path.abspath(__file__))
- base_dir = os.path.join(script_dir, "data/阿里多多酱")
- inspiration_dir = os.path.join(base_dir, "out/人设_1110/how/灵感点")
- posts_dir = os.path.join(base_dir, "作者历史帖子")
- persona_path = os.path.join(base_dir, "out/人设_1110/人设.json")
- inspiration_to_post_path = os.path.join(base_dir, "out/人设_1110/点到帖子映射.json")
- category_index_path = os.path.join(base_dir, "out/人设_1110/分类索引_完整.json")
- post_to_mapping_path = os.path.join(base_dir, "out/人设_1110/帖子到分类和点映射.json")
- output_path = os.path.join(base_dir, "out/人设_1110/how/灵感点可视化.html")
- print("=" * 60)
- print("灵感点分析可视化脚本")
- print("=" * 60)
- # 加载数据
- print("\n📂 正在加载灵感点数据...")
- inspirations_data = load_inspiration_points_data(inspiration_dir)
- print(f"✅ 成功加载 {len(inspirations_data)} 个灵感点")
- print("\n📂 正在加载帖子数据...")
- posts_map = load_posts_data(posts_dir)
- print(f"✅ 成功加载 {len(posts_map)} 个帖子")
- print("\n📂 正在加载人设数据...")
- persona_data = load_persona_data(persona_path)
- print(f"✅ 成功加载人设数据")
- print("\n📂 正在加载点到帖子映射数据...")
- with open(inspiration_to_post_path, 'r', encoding='utf-8') as f:
- inspiration_to_post_data = json.load(f)
- print(f"✅ 成功加载点到帖子映射数据")
- print("\n📂 正在加载分类索引数据...")
- with open(category_index_path, 'r', encoding='utf-8') as f:
- category_index_data = json.load(f)
- print(f"✅ 成功加载分类索引数据")
- print("\n📂 正在加载帖子到分类和点映射数据...")
- with open(post_to_mapping_path, 'r', encoding='utf-8') as f:
- post_to_mapping_data = json.load(f)
- print(f"✅ 成功加载帖子到分类和点映射数据")
- # 生成HTML
- print("\n🎨 正在生成可视化HTML...")
- result_path = generate_html(
- inspirations_data,
- posts_map,
- persona_data,
- output_path,
- inspiration_to_post_data,
- category_index_data,
- post_to_mapping_data
- )
- print(f"\n✅ 可视化文件已生成!")
- print(f"📄 文件路径: {result_path}")
- print(f"\n💡 在浏览器中打开该文件即可查看可视化结果")
- print("=" * 60)
- if __name__ == "__main__":
- main()
|