report.vue 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294
  1. <template>
  2. <div class="layout">
  3. <!-- 添加密码修改弹窗组件 -->
  4. <ChangePasswordDialog
  5. v-model:visible="showPasswordDialog"
  6. />
  7. <div class="header">
  8. <div class="user-profile-bar">
  9. <div class="logo">
  10. <img
  11. src="../assets/logos.JPG"
  12. alt="logo"
  13. class="logo-img"
  14. />
  15. <!-- <span>Raycos Tech</span> -->
  16. </div>
  17. <div class="user-info-bar">
  18. <div class="user-info" @click="toggleDropdown">
  19. <div class="user-name">商户名称:{{ userInfo.merchant?.merchant_name || '未登录用户' }}</div>
  20. <div class="user-name">当前用户:{{ userInfo.username || '未登录用户' }}</div>
  21. <!-- <div class="user-role">{{ userInfo.role || '未设置角色' }}</div> -->
  22. </div>
  23. <div class="avatar" @click="toggleDropdown">
  24. <img src="../assets/avter.png" alt="用户头像" />
  25. </div>
  26. </div>
  27. <!-- Logo :draggable="false"-->
  28. <!-- 下拉菜单 -->
  29. <div class="dropdown-menu" v-show="showDropdown">
  30. <div class="dropdown-item" @click="handleModifyPassword">
  31. <i class="fas fa-key"></i>
  32. 修改密码
  33. </div>
  34. <div class="dropdown-item" @click="handleCreateInvitation">
  35. <i class="fas fa-user-plus"></i>
  36. 创建邀请
  37. </div>
  38. <div class="dropdown-item" @click="handleLogout">
  39. <i class="fas fa-sign-out-alt"></i>
  40. 退出登录
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div
  46. class="collapse-left-button"
  47. :class="{ 'menu-collapsed': isMenuCollapsed }"
  48. @click="toggleMenu"
  49. >
  50. <img
  51. :src="isMenuCollapsed ? rightIcon : leftIcon"
  52. alt="toggle"
  53. class="collapse-icon"
  54. />
  55. </div>
  56. <div class="menu" :class="{ collapsed: isMenuCollapsed }">
  57. <!-- 添加收缩按钮 -->
  58. <!-- New Conversation 按钮 -->
  59. <button class="new-conversation-btn" @click="addNewConversation">
  60. <img class="tab-icon" src="../assets/svg/plus.svg" alt="" />
  61. <span>New Conversation</span>
  62. </button>
  63. <!-- 会话列表 -->
  64. <div class="conversation-list">
  65. <div
  66. v-for="conversation in conversations"
  67. :key="conversation.id"
  68. :class="[
  69. 'conversation-item',
  70. { active: currentConversationId === conversation.id },
  71. ]"
  72. @click="switchConversation(conversation.id)"
  73. >
  74. {{ conversation.title }}
  75. </div>
  76. </div>
  77. <!-- 添加模型配置和语音配置的容器 -->
  78. <div class="config-container">
  79. <KnowledgeConfig />
  80. <ModelConfig />
  81. <VoiceConfig />
  82. </div>
  83. </div>
  84. <div class="chat">
  85. <!-- 欢迎消息 -->
  86. <div v-if="messages.length === 0" class="welcome-section">
  87. <!-- Do you want 部分 -->
  88. <div class="suggestion-section">
  89. <h3>嗨,我是你的智能助手</h3>
  90. <div class="cards-container">
  91. <div class="suggestion-card">
  92. <div class="card-header">
  93. <img
  94. src="../assets/svg/hot-for-ux.svg"
  95. alt="hot topics"
  96. class="tab-icon"
  97. />
  98. <h4>推荐问题</h4>
  99. </div>
  100. <p class="card-subtitle">为您精选的热门问题</p>
  101. <div class="suggestion-items">
  102. <!-- Combine both QA pairs and guides -->
  103. <div
  104. v-for="(item, index) in [
  105. ...currentQaPairs,
  106. ...currentDesignGuides,
  107. ]"
  108. :key="index"
  109. class="suggestion-item"
  110. @click="handleQaClick(item)"
  111. >
  112. {{ item.question }}
  113. </div>
  114. </div>
  115. </div>
  116. <!-- Hot Topics 卡片 --><!-- Design Guide 卡片 -->
  117. <!-- <div class="suggestion-card">
  118. <div class="card-header">
  119. <img
  120. src="../assets/svg/hot-for-ux.svg"
  121. alt="hot topics"
  122. class="tab-icon"
  123. />
  124. <h4>知识库相关问题:</h4>
  125. </div>
  126. <p class="card-subtitle">我们可以这样向知识库提问</p>
  127. <div class="suggestion-items">
  128. <div
  129. v-for="(qa, index) in currentQaPairs"
  130. :key="index"
  131. class="suggestion-item"
  132. @click="handleQaClick(qa)"
  133. >
  134. {{ qa.question }}
  135. </div>
  136. </div>
  137. </div>
  138. <div class="suggestion-card">
  139. <div class="card-header">
  140. <img
  141. src="../assets/svg/read.svg"
  142. alt="hot topics"
  143. class="tab-icon"
  144. />
  145. <h4>网上热搜问答</h4>
  146. </div>
  147. <p class="card-subtitle">搜索网上的热门回答</p>
  148. <div class="suggestion-items">
  149. <div
  150. v-for="(guide, index) in currentDesignGuides"
  151. :key="index"
  152. class="suggestion-item"
  153. @click="handleQaClick(guide)"
  154. >
  155. {{ guide.question }}
  156. </div>
  157. </div>
  158. </div> -->
  159. </div>
  160. </div>
  161. </div>
  162. <!-- 修改消息列表部分 -->
  163. <div v-else class="message-list" ref="messageList">
  164. <div
  165. v-for="message in messages"
  166. :key="message.id"
  167. :class="[
  168. 'message-item',
  169. message.role === 'user' ? 'user' : 'assistant',
  170. ]"
  171. >
  172. <div class="message-bubble">
  173. <div class="message-content">
  174. <template v-if="message.role === 'user' && message.files">
  175. <div
  176. v-for="file in message.files"
  177. :key="file.name"
  178. class="file-message"
  179. >
  180. <!-- 图片文件显示 -->
  181. <template v-if="isImageFile(file)">
  182. <div class="image-preview">
  183. <img :src="file.url" class="preview-image" />
  184. </div>
  185. </template>
  186. <!-- 视频文件显示 -->
  187. <template v-else-if="isVideoFile(file)">
  188. <div class="video-preview">
  189. <video
  190. controls
  191. class="preview-video"
  192. :src="file.url"
  193. preload="metadata"
  194. >
  195. Your browser does not support the video tag.
  196. </video>
  197. </div>
  198. </template>
  199. <!-- 文档文件显示 -->
  200. <template v-else>
  201. <div class="file-info-display">
  202. <img :src="getFileIcon(file)" class="file-type-icon" />
  203. <div class="file-details">
  204. <span class="file-name" :title="file.name">{{
  205. file.name
  206. }}</span>
  207. <span class="file-size">{{ file.size }}</span>
  208. </div>
  209. </div>
  210. </template>
  211. </div>
  212. </template>
  213. <div
  214. class="message-text"
  215. v-if="message.role === 'assistant'"
  216. v-html="renderMarkdown(message.displayContent)"
  217. ></div>
  218. <div v-else>{{ message.content }}</div>
  219. <!-- 音频控制按钮 -->
  220. <div
  221. v-if="message.role === 'assistant'"
  222. class="audio-controls"
  223. >
  224. <button class="audio-btn" @click="handleAudioClick(message)">
  225. <!-- 只在当前消息正在播放时显示波形动画 -->
  226. <div
  227. v-if="currentPlayingId === message.id"
  228. class="wave-animation"
  229. >
  230. <span class="wave-bar"></span>
  231. <span class="wave-bar"></span>
  232. <span class="wave-bar"></span>
  233. <span class="wave-bar"></span>
  234. </div>
  235. <!-- 其他情况显示播放图标 -->
  236. <img v-else :src="playIcon" alt="播放" class="audio-icon" />
  237. </button>
  238. </div>
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. <!-- 输入框 -->
  244. <div class="input-container">
  245. <!-- 搜索开关组 -->
  246. <div class="search-toggles" :class="{ 'compact': isCompact }">
  247. <div class="search-toggle-item">
  248. <div class="toggle-content">
  249. <GlobalOutlined />
  250. <span class="toggle-text" v-show="!isCompact">互联网</span>
  251. <div class="toggle-switch">
  252. <input
  253. type="checkbox"
  254. id="webSearchToggle"
  255. v-model="enableWebSearch"
  256. @change="handleWebSearchToggle"
  257. :disabled="attachedFiles.length > 0"
  258. class="toggle-input"
  259. />
  260. <label
  261. for="webSearchToggle"
  262. class="toggle-label"
  263. :class="{ disabled: attachedFiles.length > 0 }"
  264. >
  265. <span class="toggle-slider"></span>
  266. </label>
  267. </div>
  268. </div>
  269. </div>
  270. <div class="search-toggle-item">
  271. <div class="toggle-content">
  272. <DatabaseOutlined />
  273. <span class="toggle-text" v-show="!isCompact">知识库</span>
  274. <div class="toggle-switch">
  275. <input
  276. type="checkbox"
  277. id="knowledgeSearchToggle"
  278. v-model="enableKnowledgeSearch"
  279. @change="handleKnowledgeToggle"
  280. class="toggle-input"
  281. />
  282. <label
  283. for="knowledgeSearchToggle"
  284. class="toggle-label"
  285. >
  286. <span class="toggle-slider"></span>
  287. </label>
  288. </div>
  289. </div>
  290. </div>
  291. <div class="search-toggle-item">
  292. <div class="toggle-content">
  293. <!-- <SelectOutlined /> -->
  294. <!-- <span class="toggle-text">模型选择</span> -->
  295. <select
  296. class="model-select"
  297. :value="selectedModel"
  298. @change="handleModelChange($event.target.value)"
  299. :disabled="isLoadingModels"
  300. >
  301. <option v-if="isLoadingModels" value="">加载中...</option>
  302. <option v-else-if="models.length === 0" value="">无可用模型</option>
  303. <option
  304. v-for="model in models"
  305. :key="model.id"
  306. :value="model.id"
  307. >
  308. {{ model.name }}
  309. </option>
  310. </select>
  311. </div>
  312. </div>
  313. </div>
  314. <!-- 添加附件面板 -->
  315. <div v-if="showAttachments" class="attachments-panel">
  316. <div class="panel-content">
  317. <div class="attachments-header">
  318. <span>Attachments</span>
  319. <button class="close-btn" @click="toggleAttachments">
  320. <img src="../assets/svg/close.svg" alt="" />
  321. </button>
  322. </div>
  323. <div
  324. v-if="attachedFiles.length === 0"
  325. style="display: flex; justify-content: center"
  326. >
  327. <div
  328. class="upload-area"
  329. :class="{ 'has-files': attachedFiles.length > 0 }"
  330. @click="triggerFileInput"
  331. @drop.prevent="handleFileDrop"
  332. @dragover.prevent
  333. @dragenter.prevent
  334. >
  335. <!-- 移除条件判断,让整个区域始终可点击 -->
  336. <template v-if="isUploading">
  337. <div class="upload-loading">
  338. <div class="loading-spinner"></div>
  339. <div class="upload-text">Uploading...</div>
  340. </div>
  341. </template>
  342. <template v-else>
  343. <img
  344. src="../assets/svg/upload.svg"
  345. alt="upload"
  346. class="upload-icon"
  347. />
  348. <div class="upload-text">Upload files</div>
  349. <div class="upload-hint">
  350. Click or drag files to this area to upload
  351. </div>
  352. </template>
  353. <input
  354. type="file"
  355. ref="fileInput"
  356. style="display: none"
  357. @change="handleFileUpload"
  358. multiple
  359. />
  360. </div>
  361. </div>
  362. <!-- 上传内容列表 -->
  363. <div v-if="attachedFiles.length !== 0">
  364. <div class="file-list">
  365. <div
  366. v-for="file in attachedFiles"
  367. :key="file.name"
  368. class="file-item"
  369. :class="{ 'is-image': isImageFile(file) }"
  370. >
  371. <div :class="isImageFile(file) ? 'file-wrapper' : ''">
  372. <!-- 添加文件 loading 状态 -->
  373. <div v-if="file.isUploading" class="file-loading">
  374. <div class="loading-spinner"></div>
  375. </div>
  376. <!-- 其他文件显示逻辑保持不变 -->
  377. <img
  378. v-else-if="isImageFile(file)"
  379. :src="file.url"
  380. alt="file"
  381. class="file-icon"
  382. />
  383. <video
  384. v-else-if="isVideoFile(file)"
  385. :src="file.url"
  386. class="file-icon"
  387. preload="metadata"
  388. >
  389. Your browser does not support the video tag.
  390. </video>
  391. <img
  392. v-else
  393. :src="getFileIcon(file)"
  394. alt="file"
  395. :class="
  396. isImageFile(file) || isVideoFile(file)
  397. ? 'file-icon'
  398. : ''
  399. "
  400. />
  401. <button
  402. class="remove-btn"
  403. @click.stop="removeFile(file)"
  404. v-if="!file.isUploading"
  405. >
  406. ×
  407. </button>
  408. </div>
  409. <div class="file-info" v-if="!isImageFile(file)">
  410. <span class="file-name">{{ file.name }}</span>
  411. <span class="file-size">{{ file.sizeFormatted }}</span>
  412. </div>
  413. </div>
  414. <button class="add-more-btn" @click.stop="triggerFileInput">
  415. <img src="../assets/svg/plus.svg" alt="add" />
  416. </button>
  417. </div>
  418. <input
  419. type="file"
  420. ref="fileInput"
  421. style="display: none"
  422. @change="handleFileUpload"
  423. multiple
  424. />
  425. </div>
  426. <!-- <div v-if="attachedFiles.length" class="attached-files">
  427. <div
  428. v-for="file in attachedFiles"
  429. :key="file.name"
  430. class="file-item"
  431. >
  432. <FileOutlined />
  433. <span>{{ file.name }}</span>
  434. <button class="remove-btn" @click="removeFile(file)">
  435. </button>
  436. </div>
  437. </div> -->
  438. </div>
  439. </div>
  440. <!-- 输入框部分 -->
  441. <div class="input-wrapper">
  442. <button class="attachment-btn" @click="toggleAttachments">
  443. <img
  444. src="../assets/svg/attachment.svg"
  445. alt="attachment"
  446. class="tab-icon"
  447. />
  448. </button>
  449. <input
  450. type="text"
  451. class="message-input"
  452. v-model="inputContent"
  453. @keyup.enter="sendMessage"
  454. placeholder="Type a message..."
  455. /><!-- @input="handleInputChange" -->
  456. <button
  457. class="send-btn"
  458. @click="sendMessage"
  459. :disabled="!inputContent && attachedFiles.length === 0"
  460. >
  461. <img src="../assets/svg/up.svg" alt="send" />
  462. </button>
  463. </div>
  464. </div>
  465. </div>
  466. <div
  467. class="right_menu"
  468. :class="{
  469. collapsed: !isRightMenuVisible
  470. }"
  471. :style="{ width: rightMenuWidth + 'px' }"
  472. >
  473. <!-- 修改收缩按钮的位置和样式 -->
  474. <div
  475. class="collapse-button"
  476. :class="{
  477. 'menu-expanded': !isRightMenuCollapsed,
  478. 'menu-collapsed': isRightMenuCollapsed
  479. }"
  480. @click="toggleRightMenu"
  481. >
  482. <img
  483. :src="isRightMenuCollapsed ? leftIcon : rightIcon"
  484. alt="toggle"
  485. class="collapse-icon"
  486. />
  487. </div>
  488. <!-- 添加拖动条 -->
  489. <div
  490. class="resize-handle"
  491. @mousedown="startResize"
  492. @touchstart="startResize"
  493. ></div>
  494. <!-- 修改折叠按钮的样式和行为 -->
  495. <!-- <div
  496. class="collapse-button"
  497. :class="{ 'menu-expanded': !isRightMenuCollapsed }"
  498. :style="!isRightMenuCollapsed ? { left: `-20px` } : {}"
  499. @click="toggleRightMenu"
  500. >
  501. <img
  502. :src="isRightMenuCollapsed ? leftIcon : rightIcon"
  503. alt="toggle"
  504. class="collapse-icon"
  505. />
  506. </div> -->
  507. <div class="right-menu-content">
  508. <!-- 添加 Tab 切换 -->
  509. <div class="right-menu-tabs">
  510. <div
  511. class="tab-item"
  512. :class="{ active: activeTab === 'search' }"
  513. @click="activeTab = 'search'"
  514. >
  515. <FileSearchOutlined />
  516. <span>搜索</span>
  517. </div>
  518. <div
  519. class="tab-item"
  520. :class="{ active: activeTab === 'knowledge' }"
  521. @click="activeTab = 'knowledge'"
  522. >
  523. <DatabaseOutlined />
  524. <span>知识库</span>
  525. </div>
  526. <div
  527. class="tab-item"
  528. :class="{ active: activeTab === 'preview' }"
  529. @click="activeTab = 'preview'"
  530. >
  531. <FileOutlined />
  532. <span>文档预览</span>
  533. </div>
  534. </div>
  535. <!-- 搜索面板 -->
  536. <div v-show="activeTab === 'search'" class="panel-container">
  537. <div class="search-header">
  538. <span>搜索结果</span>
  539. <div class="web-search-toggle">
  540. <input
  541. type="checkbox"
  542. id="searchToggle"
  543. v-model="enableWebSearch"
  544. class="toggle-input"
  545. />
  546. <label for="searchToggle" class="toggle-label">
  547. {{ enableWebSearch ? '搜索已开启' : '搜索已关闭' }}
  548. </label>
  549. </div>
  550. </div>
  551. <!-- v-if="enableWebSearch" -->
  552. <SearchResults
  553. :searchResults="searchResults"
  554. :loading="isSearchLoading"
  555. :total="searchTotal"
  556. :enableWebSearch="enableWebSearch"
  557. :message="currentSearchQuery"
  558. @update:enableWebSearch="handleSearchToggle"
  559. />
  560. </div>
  561. <!-- 文档预览面板 -->
  562. <div v-show="activeTab === 'preview'" class="panel-container">
  563. <div class="preview-header">
  564. <span>文档预览</span>
  565. </div>
  566. <DocumentPreview
  567. :documents="attachedFiles"
  568. @select="handleDocumentSelect"
  569. />
  570. </div>
  571. <!-- 添加知识库结果面板 -->
  572. <div v-show="activeTab === 'knowledge'" class="panel-container">
  573. <div class="search-header">
  574. <span>知识库搜索结果</span>
  575. </div>
  576. <!-- v-if="enableKnowledgeSearch" -->
  577. <KnowledgeResults
  578. :searchResults="knowledgeResults"
  579. :loading="isKnowledgeLoading"
  580. :total="knowledgeTotal"
  581. :message="currentSearchQuery"
  582. />
  583. </div>
  584. </div>
  585. </div>
  586. </div>
  587. </template>
  588. <script setup>
  589. import { ref, reactive, nextTick, onUnmounted, onMounted, computed } from "vue";
  590. import {
  591. PlusOutlined,
  592. FireOutlined,
  593. ReadOutlined,
  594. HeartOutlined,
  595. SmileOutlined,
  596. CommentOutlined,
  597. CloudUploadOutlined,
  598. PaperClipOutlined,
  599. ShareAltOutlined,
  600. EllipsisOutlined,
  601. CloseOutlined,
  602. FileOutlined,
  603. ArrowUpOutlined,
  604. UploadOutlined,
  605. FileSearchOutlined,
  606. GlobalOutlined,
  607. DatabaseOutlined,
  608. FolderOutlined,
  609. SelectOutlined,
  610. } from "@ant-design/icons-vue";
  611. import leftIcon from "../assets/svg/left.svg";
  612. import rightIcon from "../assets/svg/right.svg";
  613. import plusIcon from "../assets/svg/plus.svg";
  614. import hotForUxIcon from "../assets/svg/hot-for-ux.svg";
  615. import readIcon from "../assets/svg/read.svg";
  616. import attachmentIcon from "../assets/svg/attachment.svg";
  617. import uploadIcon from "../assets/svg/upload.svg";
  618. import closeIcon from "../assets/svg/close.svg";
  619. import upIcon from "../assets/svg/up.svg";
  620. import wordIcon from "../assets/svg/word.svg";
  621. import pauseIcon from "../assets/svg/pause.svg";
  622. import playIcon from "../assets/svg/play.svg";
  623. import axios from "axios";
  624. import { useStore } from "vuex";
  625. import MarkdownIt from "markdown-it";
  626. import ModelConfig from "../components/ModelConfig/index.vue";
  627. import SearchResults from "../components/SearchResults/index.vue";
  628. import VoiceConfig from "../components/VoiceConfig/index.vue";
  629. import KnowledgeConfig from "../components/KnowledgeConfig/index.vue";
  630. import ExportButton from "../components/ExportButton/index.vue";
  631. import dayjs from 'dayjs';
  632. import DocumentPreview from "../components/DocumentPreview/index.vue";
  633. import KnowledgeResults from "../components/KnowledgeResults/index.vue";
  634. import ChangePasswordDialog from '../components/ChangePasswordDialog.vue'
  635. import { useRouter } from 'vue-router'
  636. import { message } from 'ant-design-vue';
  637. // 初始化 markdown-it
  638. const md = new MarkdownIt({
  639. html: true,
  640. linkify: true,
  641. typographer: true,
  642. });
  643. // 响应式状态
  644. const headerOpen = ref(false);
  645. const inputContent = ref("");
  646. const showAttachments = ref(false);
  647. const isRightMenuCollapsed = ref(false);
  648. const fileInput = ref(null);
  649. const attachedFiles = ref([]);
  650. const messages = ref([]);
  651. const isLoading = ref(false);
  652. const currentConversationId = ref(1);
  653. const conversationCounter = ref(1);
  654. const messageList = ref(null);
  655. const store = useStore();
  656. const router = useRouter()
  657. // 会话数据
  658. const conversations = ref([
  659. {
  660. id: 1,
  661. title: "当前会话",
  662. messages: [],
  663. },
  664. ]);
  665. // 添加打字效果相关的状态
  666. const typingSpeed = 50; // 打字速度(毫秒/字符)
  667. const isTyping = ref(false);
  668. // 添加音频播放相关的响应式变量
  669. const audioPlayer = ref(null);
  670. const isPlaying = ref(false);
  671. // 添加当前播放消息的 ID
  672. const currentPlayingId = ref(null);
  673. const currentAudioSource = ref(null);
  674. // 添加新的响应式变量
  675. const isUploading = ref(false);
  676. // 添加新的响应式状态
  677. const documentSummary = ref(null);
  678. const isLoadingSummary = ref(false);
  679. const currentQaPairs = ref([]);
  680. const currentDesignGuides = ref([]);
  681. let rotationInterval = null;
  682. // 添加新的响应式状态
  683. const searchResults = ref([]);
  684. const isSearchLoading = ref(false);
  685. const searchTotal = ref(0);
  686. // 添加互联网搜索开关状态
  687. const enableWebSearch = ref(true);
  688. // 添加新的响应式变量
  689. const isMenuCollapsed = ref(false);
  690. // 添加移动端检测
  691. const isMobile = ref(false);
  692. //知识库搜索
  693. const enableKnowledgeSearch = ref(false);
  694. const knowledgeResults = ref([]);
  695. const knowledgeTotal = ref(0);
  696. const isKnowledgeLoading = ref(false);
  697. // 检测设备类型
  698. const checkMobile = () => {
  699. isMobile.value = window.innerWidth <= 768;
  700. };
  701. onUnmounted(() => {
  702. window.removeEventListener('resize', checkMobile);
  703. });
  704. const showDropdown = ref(false);
  705. const toggleDropdown = () => {
  706. console.log(showDropdown.value);
  707. showDropdown.value = !showDropdown.value;
  708. };
  709. // 添加遮罩层点击处理
  710. const handleOverlayClick = () => {
  711. if (isMobile.value) {
  712. isMenuCollapsed.value = true;
  713. isRightMenuCollapsed.value = true;
  714. document.body.style.overflow = 'auto';
  715. }
  716. };
  717. // 修改菜单切换逻辑
  718. const toggleMenu = () => {
  719. isMenuCollapsed.value = !isMenuCollapsed.value;
  720. if (isMobile.value) {
  721. document.body.style.overflow = isMenuCollapsed.value ? 'auto' : 'hidden';
  722. if (!isMenuCollapsed.value) {
  723. isRightMenuCollapsed.value = true; // 确保右侧菜单关闭
  724. }
  725. }
  726. // 更新聊天区域的位置
  727. if (document.querySelector('.chat')) {
  728. document.querySelector('.chat').style.left = isMenuCollapsed.value ? '0' : '260px';
  729. }
  730. };
  731. // 修改右侧菜单切换逻辑
  732. const toggleRightMenu = () => {
  733. isRightMenuCollapsed.value = !isRightMenuCollapsed.value;
  734. if (isRightMenuCollapsed.value) {
  735. // 收起菜单时的处理
  736. if (document.querySelector('.chat')) {
  737. document.querySelector('.chat').style.right = '0';
  738. }
  739. } else {
  740. enableWebSearch.value = true;
  741. // 展开菜单时的处理
  742. if (document.querySelector('.chat')) {
  743. document.querySelector('.chat').style.right = `${rightMenuWidth.value}px`;
  744. }
  745. }
  746. if (isMobile.value) {
  747. document.body.style.overflow = isRightMenuCollapsed.value ? 'auto' : 'hidden';
  748. if (!isRightMenuCollapsed.value) {
  749. isMenuCollapsed.value = true;
  750. }
  751. }
  752. };
  753. // 修改自动展开右侧菜单的方法
  754. const expandRightMenu = () => {
  755. isRightMenuCollapsed.value = false;
  756. if (document.querySelector('.chat')) {
  757. document.querySelector('.chat').style.right = `${rightMenuWidth.value}px`;
  758. }
  759. };
  760. // 修改获取文档摘要的方法
  761. const fetchDocumentSummary = async () => {
  762. isLoadingSummary.value = true;
  763. try {
  764. const response = await axios.get(
  765. `${import.meta.env.VITE_BASE_AI_API}/api/document/summary`,
  766. {
  767. headers: {
  768. 'Authorization': `JWT ${localStorage.getItem('token')}`
  769. }
  770. }
  771. );
  772. console.log("API Response:", response.data);
  773. if (response.data.code === 200) {
  774. documentSummary.value = response.data.data.items;
  775. console.log("Document Summary:", documentSummary.value);
  776. startRotation();
  777. }
  778. } catch (error) {
  779. console.error("获取文档摘要失败:", error);
  780. } finally {
  781. isLoadingSummary.value = false;
  782. }
  783. };
  784. // 修改轮换显示逻辑
  785. const startRotation = () => {
  786. if (rotationInterval) {
  787. clearInterval(rotationInterval);
  788. }
  789. const updateItems = () => {
  790. if (!documentSummary.value?.length) {
  791. console.log("No document summary data available");
  792. return;
  793. }
  794. // 处理第一项数据(Hot Topics)
  795. try {
  796. const hotTopicsData = documentSummary.value[0];
  797. if (hotTopicsData?.questions) {
  798. const parsedQaPairs =
  799. /* JSON.parse( */ hotTopicsData.questions; /* .replace(/'/g, '"')); */
  800. const formattedQaPairs = parsedQaPairs.map((question) => ({
  801. question,
  802. }));
  803. // 随机选择3个问题
  804. const shuffled = [...formattedQaPairs].sort(() => 0.5 - Math.random());
  805. currentQaPairs.value = shuffled.slice(0, 3);
  806. }
  807. } catch (error) {
  808. console.error("解析 Hot Topics 失败:", error);
  809. }
  810. // 处理第二项数据(Design Guide)
  811. try {
  812. const designGuideData = documentSummary.value[1];
  813. if (designGuideData?.questions) {
  814. const parsedGuides =
  815. /* JSON.parse( */ designGuideData.questions; /* .replace(/'/g, '"')); */
  816. const formattedGuides = parsedGuides.map((question) => ({ question }));
  817. // 随机选择3个指南
  818. const shuffled = [...formattedGuides].sort(() => 0.5 - Math.random());
  819. currentDesignGuides.value = shuffled.slice(0, 3);
  820. }
  821. } catch (error) {
  822. console.error("解析 Design Guide 失败:", error);
  823. }
  824. };
  825. // 初始更新
  826. updateItems();
  827. // 每5秒更新一次
  828. rotationInterval = setInterval(updateItems, 5000);
  829. };
  830. // 处理QA点击事件
  831. const handleQaClick = (qa) => {
  832. console.log("QA clicked:", qa); // 添加日志
  833. if (qa?.question) {
  834. inputContent.value = qa.question;
  835. sendMessage();
  836. }
  837. };
  838. // 在组件卸载时清理定时器
  839. onUnmounted(() => {
  840. if (rotationInterval) {
  841. clearInterval(rotationInterval);
  842. }
  843. });
  844. // 方法
  845. const toggleAttachments = () => {
  846. showAttachments.value = !showAttachments.value;
  847. };
  848. const removeFile = (file) => {
  849. attachedFiles.value = attachedFiles.value.filter((f) => f !== file);
  850. };
  851. const triggerFileInput = () => {
  852. // 如果正在上传,不触发新的上传
  853. if (isUploading.value) return;
  854. fileInput.value?.click();
  855. };
  856. const uploadFile = async (file) => {
  857. try {
  858. const formData = new FormData();
  859. formData.append("file", file);
  860. const response = await axios.post(
  861. `${import.meta.env.VITE_BASE_AI_API}/upload/file`,
  862. formData,
  863. {
  864. headers: {
  865. "Content-Type": "multipart/form-data",
  866. },
  867. }
  868. );
  869. if (response.data.status === 2000) {
  870. return response.data.data.fileUrl; // 返回文件上传后的URL
  871. } else {
  872. throw new Error(response.data.message || "文件上传失败");
  873. }
  874. } catch (error) {
  875. console.error("文件上传失败:", error);
  876. throw error;
  877. }
  878. };
  879. const handleFileUpload = async (event) => {
  880. const files = Array.from(event.target.files);
  881. if (files.length === 0) return;
  882. // 添加文件大小检查
  883. const MAX_VIDEO_SIZE = 10 * 1024 * 1024; // 10MB in bytes
  884. const invalidFiles = files.filter((file) => {
  885. if (isVideoFile(file) && file.size > MAX_VIDEO_SIZE) {
  886. return true;
  887. }
  888. return false;
  889. });
  890. if (invalidFiles.length > 0) {
  891. // 如果有超出大小限制的视频文件,显示错误提示
  892. alert("Video files must not exceed 10MB");
  893. event.target.value = ""; // 清空input
  894. return;
  895. }
  896. isUploading.value = true;
  897. try {
  898. for (const file of files) {
  899. // 创建一个带有上传状态的文件对象
  900. const fileWithStatus = {
  901. name: file.name,
  902. size: file.size,
  903. sizeFormatted: formatFileSize(file.size),
  904. type: file.type,
  905. isUploading: true,
  906. };
  907. // 先添加到文件列表中
  908. attachedFiles.value.push(fileWithStatus);
  909. try {
  910. const url = await uploadFile(file);
  911. // 直接修改数组中的对象
  912. const index = attachedFiles.value.findIndex(
  913. (f) => f.name === file.name
  914. );
  915. if (index !== -1) {
  916. // 使用数组替换方式更新,确保响应式更新
  917. attachedFiles.value.splice(index, 1, {
  918. ...fileWithStatus,
  919. url,
  920. isUploading: false,
  921. });
  922. }
  923. } catch (error) {
  924. // 如果上传失败,从列表中移除该文件
  925. attachedFiles.value = attachedFiles.value.filter(
  926. (f) => f.name !== file.name
  927. );
  928. console.error("单个文件上传失败:", error);
  929. }
  930. }
  931. } catch (error) {
  932. console.error("文件上传失败:", error);
  933. } finally {
  934. isUploading.value = false;
  935. event.target.value = ""; // 清空input以允许重复上传相同文件
  936. // 修改文件上传后的处理逻辑
  937. if (attachedFiles.value.length > 0) {
  938. // 仅切换到预览标签页,不自动展开右侧菜单
  939. activeTab.value = 'preview';
  940. /* expandRightMenu(); */
  941. }
  942. }
  943. if (files.length > 0 && enableWebSearch.value) {
  944. enableWebSearch.value = false; // 如果有文件上传,自动关闭互联网搜索
  945. }
  946. };
  947. const formatFileSize = (bytes) => {
  948. if (!bytes || isNaN(bytes)) return "0 B";
  949. const k = 1024;
  950. const sizes = ["B", "KB", "MB", "GB"];
  951. const i = Math.floor(Math.log(bytes) / Math.log(k));
  952. return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
  953. };
  954. const getFileIcon = (file) => {
  955. // 如果文件已经有 URL 且是图片类型,返回 URL
  956. if (file.url && isImageFile(file)) {
  957. return file.url;
  958. }
  959. // 其他所有情况返回文档图标
  960. return wordIcon;
  961. };
  962. const isImageFile = (file) => {
  963. const imageTypes = ["jpg", "jpeg", "png", "gif", "webp"];
  964. const ext = file.name?.split(".")?.pop()?.toLowerCase() || "";
  965. return imageTypes.includes(ext);
  966. };
  967. const isVideoFile = (file) => {
  968. const videoTypes = ["mp4", "webm", "ogg"];
  969. const ext = file.name?.split(".")?.pop()?.toLowerCase() || "";
  970. return videoTypes.includes(ext);
  971. };
  972. const getFileType = (file) => {
  973. const ext = file.name.split(".").pop().toLowerCase();
  974. const imageTypes = ["jpg", "jpeg", "png", "gif", "webp"];
  975. const videoTypes = ["mp4", "webm", "ogg"];
  976. if (imageTypes.includes(ext)) return "image";
  977. if (videoTypes.includes(ext)) return "video";
  978. return "document";
  979. };
  980. // 添加滚动到底部的方法
  981. const scrollToBottom = () => {
  982. if (messageList.value) {
  983. nextTick(() => {
  984. messageList.value.scrollTop = messageList.value.scrollHeight;
  985. });
  986. }
  987. };
  988. // 添加 session_id 的响应式引用
  989. const session_id = ref("");
  990. // 修改发送消息方法
  991. const sendMessage = async () => {
  992. // 检查登录状态
  993. const token = localStorage.getItem('token');
  994. if (!token) {
  995. router.push('/login');
  996. return;
  997. }
  998. if (
  999. (!inputContent.value.trim() && attachedFiles.value.length === 0) ||
  1000. isTyping.value
  1001. )
  1002. return;
  1003. // 保存当前输入内容
  1004. const currentMessage = inputContent.value.trim();
  1005. // 立即清空输入框
  1006. inputContent.value = '';
  1007. // 根据开启的搜索类型执行相应的搜索
  1008. if (enableWebSearch.value) {
  1009. currentSearchQuery.value = currentMessage;
  1010. /* // 执行互联网搜索
  1011. sendMessageS(currentMessage).catch((error) => {
  1012. console.error("Web search failed:", error);
  1013. }); */
  1014. } else if (enableKnowledgeSearch.value) {
  1015. currentSearchQuery.value = currentMessage;
  1016. // 执行知识库搜索
  1017. handleKnowledgeSearch({
  1018. query: currentMessage,
  1019. page: 1,
  1020. pageSize: 20
  1021. });
  1022. }
  1023. // 构建消息内容,包含文件信息
  1024. let messageContent = currentMessage;
  1025. // 收集文件URLs
  1026. const imageUrls = [];
  1027. const videoUrls = [];
  1028. const documentUrls = [];
  1029. attachedFiles.value.forEach((file) => {
  1030. const fileType = getFileType(file);
  1031. if (fileType === "image") {
  1032. imageUrls.push(file.url);
  1033. } else if (fileType === "video") {
  1034. videoUrls.push(file.url);
  1035. } else {
  1036. documentUrls.push(file.url);
  1037. }
  1038. });
  1039. // 添加用户消息
  1040. const userMessage = {
  1041. id: Date.now(),
  1042. role: "user",
  1043. content: messageContent,
  1044. displayContent: messageContent,
  1045. files: attachedFiles.value.map((file) => ({
  1046. name: file.name,
  1047. size: file.sizeFormatted,
  1048. type: file.type,
  1049. url: file.url,
  1050. })),
  1051. };
  1052. messages.value.push(userMessage);
  1053. scrollToBottom();
  1054. // 添加临时AI消息
  1055. const tempAiMessage = {
  1056. id: Date.now() + 1,
  1057. role: "assistant",
  1058. content: "Thinking...",
  1059. displayContent: "Thinking...",
  1060. isLoading: true,
  1061. };
  1062. messages.value.push(tempAiMessage);
  1063. scrollToBottom();
  1064. try {
  1065. // 根据开关状态选择不同的 API 端点
  1066. const apiEndpoint = enableWebSearch.value
  1067. ? `${import.meta.env.VITE_BASE_AI_API}/api/chat/web-search-llm/`
  1068. : `${import.meta.env.VITE_BASE_AI_API}/api/chat/online/multimodal`;
  1069. const response = await axios.post(apiEndpoint, {
  1070. message: currentMessage,
  1071. chat_config_id: "2",
  1072. user_id: "13365429324",
  1073. session_id: session_id.value,
  1074. source: "pc",
  1075. image_urls: imageUrls,
  1076. video_urls: videoUrls,
  1077. documents: documentUrls,
  1078. merchant_id:JSON.parse(localStorage.getItem('userInfo')).merchant.merchant_id,
  1079. model_type: selectedModelInfo.value.type,
  1080. model_name: selectedModelInfo.value.name
  1081. },
  1082. {
  1083. headers: {
  1084. 'Authorization': `JWT ${localStorage.getItem('token')}`
  1085. }
  1086. }
  1087. );
  1088. // 移除临时消息
  1089. messages.value = messages.value.filter(
  1090. (msg) => msg.id !== tempAiMessage.id
  1091. );
  1092. // 统一处理响应数据
  1093. const responseData = enableWebSearch.value ? response.data.data : response.data;
  1094. const messageContent = enableWebSearch.value ? responseData.answer : responseData.choices[0].message.content;
  1095. const audioInfo = enableWebSearch.value ? responseData.audio_info?.audio : responseData.audio_info?.audio;
  1096. const sessionId = enableWebSearch.value ? responseData.session_id : responseData.session_id;
  1097. // 更新 session_id
  1098. if (sessionId) {
  1099. session_id.value = sessionId;
  1100. }
  1101. // 创建新的AI消息
  1102. const aiMessage = reactive({
  1103. id: Date.now() + 2,
  1104. role: "assistant",
  1105. content: messageContent,
  1106. displayContent: "",
  1107. audioData: audioInfo || null,
  1108. });
  1109. messages.value.push(aiMessage);
  1110. // 如果有音频数据,自动播放
  1111. if (aiMessage.audioData && !isPlaying.value) {
  1112. await playAudioMessage(aiMessage.audioData, aiMessage.id);
  1113. }
  1114. // 显示打字效果
  1115. await typeMessage(aiMessage);
  1116. } catch (error) {
  1117. console.error("发送消息失败:", error);
  1118. messages.value = messages.value.filter(
  1119. (msg) => msg.id !== tempAiMessage.id
  1120. );
  1121. messages.value.push({
  1122. id: Date.now() + 2,
  1123. role: "assistant",
  1124. content: "Sorry, there was an error processing your request.",
  1125. displayContent: "Sorry, there was an error processing your request.",
  1126. });
  1127. } finally {
  1128. isTyping.value = false;
  1129. await nextTick();
  1130. scrollToBottom();
  1131. }
  1132. };
  1133. // 修改 sendMessageS 方法
  1134. const sendMessageS = async (query) => {
  1135. isSearchLoading.value = true;
  1136. try {
  1137. const response = await axios.post(
  1138. `${import.meta.env.VITE_BASE_AI_API}/api/web-search-results/`,
  1139. {
  1140. query: query,
  1141. num_results: 20,
  1142. page: 1,
  1143. page_size: 20,
  1144. engine: "tavily",
  1145. }
  1146. );
  1147. if (response.data && response.data.code === 200) {
  1148. searchResults.value = response.data.data.results || [];
  1149. searchTotal.value = response.data.data.total_results || 0;
  1150. }
  1151. } catch (error) {
  1152. console.error("Web search failed:", error);
  1153. searchResults.value = [];
  1154. searchTotal.value = 0;
  1155. } finally {
  1156. isSearchLoading.value = false;
  1157. }
  1158. };
  1159. // 修改打字效果方法
  1160. const typeMessage = async (message) => {
  1161. if (!message || !message.content) {
  1162. console.error("Invalid message or content is missing");
  1163. return;
  1164. }
  1165. return new Promise((resolve) => {
  1166. const delay = 30; // 打字延迟时间
  1167. let i = 0;
  1168. message.displayContent = ""; // 确保开始时是空的
  1169. const typeChar = () => {
  1170. if (i < message.content.length) {
  1171. message.displayContent = message.content.substring(0, i + 1);
  1172. i++;
  1173. nextTick(() => {
  1174. scrollToBottom();
  1175. setTimeout(typeChar, delay);
  1176. });
  1177. } else {
  1178. resolve();
  1179. }
  1180. };
  1181. typeChar();
  1182. });
  1183. };
  1184. // 模拟API请求
  1185. const mockApiRequest = async (message) => {
  1186. await new Promise((resolve) => setTimeout(resolve, 1000));
  1187. return `This is a response to: ${message}`;
  1188. };
  1189. // 会话管理
  1190. const addNewConversation = () => {
  1191. conversationCounter.value++;
  1192. const newConversation = {
  1193. id: Date.now(),
  1194. title: `New Conversation ${conversationCounter.value}`,
  1195. messages: [],
  1196. };
  1197. conversations.value.push(newConversation);
  1198. session_id.value = ""; // 重置 session_id
  1199. switchConversation(newConversation.id);
  1200. };
  1201. const switchConversation = (conversationId) => {
  1202. currentConversationId.value = conversationId;
  1203. const conversation = conversations.value.find((c) => c.id === conversationId);
  1204. messages.value = conversation ? conversation.messages : [];
  1205. session_id.value = ""; // 重置 session_id
  1206. };
  1207. const handleFileDrop = async (event) => {
  1208. if (isUploading.value) return;
  1209. const files = Array.from(event.dataTransfer.files);
  1210. if (files.length === 0) return;
  1211. // 添加文件大小检查
  1212. const MAX_VIDEO_SIZE = 10 * 1024 * 1024; // 10MB in bytes
  1213. const invalidFiles = files.filter((file) => {
  1214. if (isVideoFile(file) && file.size > MAX_VIDEO_SIZE) {
  1215. return true;
  1216. }
  1217. return false;
  1218. });
  1219. isUploading.value = true;
  1220. try {
  1221. for (const file of files) {
  1222. const fileWithStatus = {
  1223. name: file.name,
  1224. size: file.size,
  1225. sizeFormatted: formatFileSize(file.size),
  1226. type: file.type,
  1227. isUploading: true,
  1228. };
  1229. attachedFiles.value.push(fileWithStatus);
  1230. try {
  1231. const url = await uploadFile(file);
  1232. // 直接修改数组中的对象
  1233. const index = attachedFiles.value.findIndex(
  1234. (f) => f.name === file.name
  1235. );
  1236. if (index !== -1) {
  1237. // 使用数组替换方式更新,确保响应式更新
  1238. attachedFiles.value.splice(index, 1, {
  1239. ...fileWithStatus,
  1240. url,
  1241. isUploading: false,
  1242. });
  1243. }
  1244. } catch (error) {
  1245. attachedFiles.value = attachedFiles.value.filter(
  1246. (f) => f.name !== file.name
  1247. );
  1248. console.error("单个文件上传失败:", error);
  1249. }
  1250. }
  1251. } catch (error) {
  1252. console.error("文件上传失败:", error);
  1253. } finally {
  1254. isUploading.value = false;
  1255. // 修改文件上传后的处理逻辑
  1256. if (attachedFiles.value.length > 0) {
  1257. // 仅切换到预览标签页,不自动展开右侧菜单
  1258. activeTab.value = 'preview';
  1259. /* expandRightMenu(); */
  1260. }
  1261. }
  1262. if (files.length > 0 && enableWebSearch.value) {
  1263. enableWebSearch.value = false; // 如果有文件上传,自动关闭互联网搜索
  1264. }
  1265. };
  1266. // 添加音频点击处理方法
  1267. const handleAudioClick = (message) => {
  1268. if(message.audioData){
  1269. if (currentPlayingId.value === message.id) {
  1270. stopAudio();
  1271. } else {
  1272. playAudioMessage(message.audioData, message.id);
  1273. }
  1274. }else{
  1275. // 用户消息的文本转语音处理
  1276. if (currentPlayingId.value === message.id) {
  1277. stopAudio();
  1278. } else {
  1279. playUserMessage(message.content, message.id);
  1280. }
  1281. }
  1282. };
  1283. // 添加播放用户消息的方法
  1284. const playUserMessage = async (text, messageId) => {
  1285. try {
  1286. // 如果当前有其他音频在播放,先停止
  1287. if (currentPlayingId.value && currentPlayingId.value !== messageId) {
  1288. stopAudio();
  1289. }
  1290. // 如果已经在播放这条消息,直接返回(这种情况应该不会发生,因为会被上面的 handleAudioClick 处理)
  1291. if (currentPlayingId.value === messageId) {
  1292. return;
  1293. }
  1294. const response = await axios.post(`${import.meta.env.VITE_BASE_AI_API}/api/voices/play_text`, {
  1295. text: text
  1296. }, {
  1297. headers: {
  1298. 'Authorization': `JWT ${localStorage.getItem('token')}`
  1299. },
  1300. });
  1301. if(response.data.code === 200){
  1302. // 创建音频元素
  1303. const audio = new Audio(`${import.meta.env.VITE_BASE_AI_API}${response.data.audio_url}`);
  1304. // 保存当前播放的音频和ID
  1305. currentAudioSource.value = audio;
  1306. currentPlayingId.value = messageId;
  1307. isPlaying.value = true;
  1308. // 播放结束时清理
  1309. audio.onended = () => {
  1310. currentPlayingId.value = null;
  1311. currentAudioSource.value = null;
  1312. isPlaying.value = false;
  1313. };
  1314. // 播放错误时清理
  1315. audio.onerror = (e) => {
  1316. console.error('播放文本失败:', e);
  1317. message.error('播放失败,请稍后重试');
  1318. currentPlayingId.value = null;
  1319. currentAudioSource.value = null;
  1320. isPlaying.value = false;
  1321. };
  1322. // 开始播放
  1323. await audio.play();
  1324. }
  1325. } catch (error) {
  1326. console.error('播放文本失败:', error);
  1327. message.error('播放失败,请稍后重试');
  1328. currentPlayingId.value = null;
  1329. currentAudioSource.value = null;
  1330. isPlaying.value = false;
  1331. }
  1332. };
  1333. // 修改停止播放方法
  1334. const stopAudio = () => {
  1335. if (audioPlayer.value) {
  1336. audioPlayer.value.pause();
  1337. audioPlayer.value.currentTime = 0;
  1338. audioPlayer.value = null;
  1339. }
  1340. if (currentAudioSource.value) {
  1341. currentAudioSource.value.pause();
  1342. currentAudioSource.value.currentTime = 0;
  1343. currentAudioSource.value = null;
  1344. }
  1345. isPlaying.value = false;
  1346. currentPlayingId.value = null;
  1347. };
  1348. // 在组件卸载时清理
  1349. onUnmounted(() => {
  1350. stopAudio();
  1351. });
  1352. // 添加 renderMarkdown 方法
  1353. const renderMarkdown = (content) => {
  1354. if (!content) return "";
  1355. return md.render(content);
  1356. };
  1357. // 添加新的响应式变量
  1358. const rightMenuWidth = ref(450); // 默认宽度
  1359. const minWidth = 0; // 最小宽度
  1360. const maxWidth = 800; // 最大宽度
  1361. // 添加拖动相关方法
  1362. const startResize = (e) => {
  1363. e.preventDefault();
  1364. const startX = e.type === 'mousedown' ? e.clientX : e.touches[0].clientX;
  1365. const startWidth = rightMenuWidth.value;
  1366. const handleMove = (e) => {
  1367. if (isRightMenuCollapsed.value) return;
  1368. const currentX = e.type === 'mousemove' ? e.clientX : e.touches[0].clientX;
  1369. const diff = startX - currentX;
  1370. let newWidth = Math.min(Math.max(startWidth + diff, minWidth), maxWidth);
  1371. rightMenuWidth.value = newWidth;
  1372. // 更新聊天区域的右边距和按钮位置
  1373. if (document.querySelector('.chat')) {
  1374. document.querySelector('.chat').style.right = `${newWidth}px`;
  1375. }
  1376. };
  1377. const handleEnd = () => {
  1378. document.removeEventListener('mousemove', handleMove);
  1379. document.removeEventListener('mouseup', handleEnd);
  1380. document.removeEventListener('touchmove', handleMove);
  1381. document.removeEventListener('touchend', handleEnd);
  1382. };
  1383. document.addEventListener('mousemove', handleMove);
  1384. document.addEventListener('mouseup', handleEnd);
  1385. document.addEventListener('touchmove', handleMove);
  1386. document.addEventListener('touchend', handleEnd);
  1387. };
  1388. // 添加搜索开关状态
  1389. const isSearchEnabled = ref(true);
  1390. // 添加切换搜索方法
  1391. const toggleSearch = () => {
  1392. isSearchEnabled.value = !isSearchEnabled.value;
  1393. };
  1394. // 修改 toggleWebSearch 方法
  1395. const toggleWebSearch = () => {
  1396. enableWebSearch.value = !enableWebSearch.value;
  1397. isSearchEnabled.value = enableWebSearch.value;
  1398. // 只有当当前标签是搜索标签时才折叠面板
  1399. if (!enableWebSearch.value && activeTab.value === 'search') {
  1400. isRightMenuCollapsed.value = true;
  1401. currentSearchQuery.value = '';
  1402. if (document.querySelector('.chat')) {
  1403. document.querySelector('.chat').style.right = '0';
  1404. }
  1405. } else if (enableWebSearch.value && inputContent.value.trim()) {
  1406. isRightMenuCollapsed.value = false;
  1407. currentSearchQuery.value = inputContent.value;
  1408. if (document.querySelector('.chat')) {
  1409. document.querySelector('.chat').style.right = `${rightMenuWidth.value}px`;
  1410. }
  1411. }
  1412. };
  1413. // 添加新的响应式变量
  1414. const currentSearchQuery = ref('');
  1415. // 添加输入变化处理方法
  1416. const handleInputChange = () => {
  1417. if (inputContent.value.trim()) {
  1418. currentSearchQuery.value = inputContent.value;
  1419. // 根据当前选中的搜索类型执行相应的搜索
  1420. if (enableWebSearch.value) {
  1421. /* sendMessageS(inputContent.value).catch((error) => {
  1422. console.error("Web search failed:", error);
  1423. }); */
  1424. } else if (enableKnowledgeSearch.value) {
  1425. handleKnowledgeSearch({
  1426. query: inputContent.value,
  1427. page: 1,
  1428. pageSize: 20
  1429. });
  1430. }
  1431. }
  1432. };
  1433. // 添加处理搜索开关的方法
  1434. const handleSearchToggle = (value) => {
  1435. console.log(enableWebSearch);
  1436. enableWebSearch.value = value;
  1437. if (value) {
  1438. // 开启搜索时,确保右侧面板展开
  1439. expandRightMenu();
  1440. activeTab.value = 'search';
  1441. }
  1442. };
  1443. // 添加新的响应式变量
  1444. const activeTab = ref('search'); // 默认显示搜索面板
  1445. // 处理文档选择
  1446. const handleDocumentSelect = (document) => {
  1447. // 处理文档选择逻辑
  1448. console.log('Selected document:', document);
  1449. };
  1450. // 添加收缩状态控制
  1451. const isCollapsed = ref(false);
  1452. // 监听屏幕宽度变化
  1453. const updateCollapsedState = () => {
  1454. isCollapsed.value = window.innerWidth <= 480;
  1455. };
  1456. onUnmounted(() => {
  1457. window.removeEventListener('resize', updateCollapsedState);
  1458. });
  1459. // 添加收缩状态控制
  1460. const isCompact = ref(false);
  1461. // 监听屏幕宽度变化
  1462. const updateCompactState = () => {
  1463. isCompact.value = window.innerWidth <= 768;
  1464. };
  1465. onUnmounted(() => {
  1466. window.removeEventListener('resize', updateCompactState);
  1467. });
  1468. // 添加计算属性
  1469. const isRightMenuVisible = computed(() => {
  1470. // 移除搜索开关对菜单显示的影响
  1471. return !isRightMenuCollapsed.value;
  1472. /* return (!isRightMenuCollapsed.value && (
  1473. (enableWebSearch.value && activeTab.value === 'search') ||
  1474. (enableKnowledgeSearch.value && activeTab.value === 'knowledge') ||
  1475. (activeTab.value === 'preview' && attachedFiles.value.length > 0)
  1476. )); */
  1477. });
  1478. // 修改知识库搜索开关处理方法
  1479. const handleKnowledgeToggle = (event) => {
  1480. if (event.target.checked) {
  1481. // 开启知识库搜索时关闭互联网搜索
  1482. enableWebSearch.value = false;
  1483. // 切换到知识库标签页
  1484. activeTab.value = 'knowledge';
  1485. // 如果有输入内容,执行知识库搜索
  1486. if (inputContent.value.trim()) {
  1487. handleKnowledgeSearch({
  1488. query: inputContent.value,
  1489. page: 1,
  1490. pageSize: 20
  1491. });
  1492. }
  1493. }
  1494. };
  1495. // 修改知识库搜索方法
  1496. const handleKnowledgeSearch = async (params) => {
  1497. if (!params.query.trim() || !enableKnowledgeSearch.value) return;
  1498. isKnowledgeLoading.value = true;
  1499. try {
  1500. const response = await axios.post(
  1501. `${import.meta.env.VITE_BASE_AI_API}/chataids/mysql_fuzzy_search/`,
  1502. {
  1503. // collection_names: ["25"], // 固定使用 "25" 作为 collection name
  1504. keywords: params.query, // 使用查询关键词
  1505. documents: [], // 保持空数组
  1506. document_ids: [], // 保持空数组
  1507. limit: 5 // 固定返回5条结果
  1508. },
  1509. {
  1510. headers: {
  1511. 'Authorization': `JWT ${localStorage.getItem('token')}`
  1512. }
  1513. }
  1514. );
  1515. console.log(response);
  1516. if (response.data && response.data.status === 200) {
  1517. knowledgeResults.value = response.data.data.data.results || [];
  1518. knowledgeTotal.value = response.data.data.data.total || 0;
  1519. }
  1520. } catch (error) {
  1521. console.error('Knowledge search failed:', error);
  1522. knowledgeResults.value = [];
  1523. knowledgeTotal.value = 0;
  1524. } finally {
  1525. isKnowledgeLoading.value = false;
  1526. }
  1527. }
  1528. // 修改处理互联网搜索开关的方法
  1529. const handleWebSearchToggle = (event) => {
  1530. if (event.target.checked) {
  1531. // 开启互联网搜索时关闭知识库搜索
  1532. enableKnowledgeSearch.value = false;
  1533. // 切换到搜索标签页
  1534. activeTab.value = 'search';
  1535. // 如果有输入内容,执行互联网搜索
  1536. if (inputContent.value.trim()) {
  1537. currentSearchQuery.value = inputContent.value;
  1538. /* sendMessageS(inputContent.value).catch((error) => {
  1539. console.error("Web search failed:", error);
  1540. }); */
  1541. }
  1542. }
  1543. };
  1544. // 添加新的响应式变量
  1545. const API_BASE_URL = import.meta.env.VITE_BASE_AI_API;
  1546. const models = ref([]);
  1547. const selectedModel = ref(null);
  1548. const isLoadingModels = ref(false);
  1549. // 添加计算属性获取选中的模型信息
  1550. const selectedModelInfo = computed(() => {
  1551. if (!selectedModel.value || !models.value.length) return { type: '', name: '' };
  1552. const model = models.value.find(m => m.id === selectedModel.value);
  1553. return {
  1554. type: model?.type || '',
  1555. name: model?.name || ''
  1556. };
  1557. });
  1558. // 添加获取模型列表的方法
  1559. const fetchModels = async () => {
  1560. isLoadingModels.value = true;
  1561. try {
  1562. const response = await fetch(`${API_BASE_URL}/api/models`);
  1563. const data = await response.json();
  1564. console.log(data);
  1565. if (data.code === 2000) {
  1566. // 确保每个模型对象都有必要的字段
  1567. models.value = (data.data.models || []).map(model => ({
  1568. id: model.id,
  1569. name: model.name,
  1570. type: model.type || model.model_type || 'default' // 确保有type字段
  1571. }));
  1572. if (models.value.length > 0) {
  1573. selectedModel.value = models.value[0].id; // 默认选择第一个模型
  1574. }
  1575. }
  1576. } catch (error) {
  1577. console.error('Failed to fetch models:', error);
  1578. } finally {
  1579. isLoadingModels.value = false;
  1580. }
  1581. };
  1582. // 添加模型选择改变的处理方法
  1583. const handleModelChange = (modelId) => {
  1584. selectedModel.value = modelId;
  1585. };
  1586. // 用户信息
  1587. const userInfo = ref({
  1588. name: '',
  1589. role: ''
  1590. });
  1591. const getUserInfo = () => {
  1592. const storedUserInfo = localStorage.getItem('userInfo');
  1593. if (storedUserInfo) {
  1594. userInfo.value = JSON.parse(storedUserInfo);
  1595. }
  1596. }
  1597. // 在组件挂载时获取模型列表
  1598. onMounted(() => {
  1599. updateCompactState();
  1600. window.addEventListener('resize', updateCompactState);
  1601. updateCollapsedState();
  1602. window.addEventListener('resize', updateCollapsedState);
  1603. checkMobile();
  1604. window.addEventListener('resize', checkMobile);
  1605. fetchModels();
  1606. fetchDocumentSummary();
  1607. const storedUserInfo = localStorage.getItem('userInfo');
  1608. if (storedUserInfo) {
  1609. try {
  1610. userInfo.value = JSON.parse(storedUserInfo);
  1611. } catch (error) {
  1612. console.error('解析用户信息失败:', error);
  1613. }
  1614. }
  1615. });
  1616. const showPasswordDialog = ref(false)
  1617. const handleModifyPassword = () => {
  1618. showPasswordDialog.value = true
  1619. showDropdown.value = false // 关闭下拉菜单
  1620. }
  1621. const handleLogout = async () => {
  1622. try {
  1623. // 调用退出登录接口
  1624. await axios.post(`${import.meta.env.VITE_BASE_AI_API}/user/logout`, {}, {
  1625. headers: {
  1626. 'Authorization': `JWT ${localStorage.getItem('token')}`
  1627. }
  1628. });
  1629. // 清除本地存储的信息
  1630. localStorage.removeItem('token');
  1631. localStorage.removeItem('userInfo');
  1632. localStorage.removeItem('permissions');
  1633. localStorage.removeItem('username');
  1634. localStorage.removeItem('mobile');
  1635. // 清除 Vuex store 中的用户信息
  1636. store.commit('app/setUser', {
  1637. user: {},
  1638. permission: [],
  1639. auth: {}
  1640. });
  1641. // 关闭下拉菜单
  1642. showDropdown.value = false;
  1643. // 跳转到登录页面
  1644. router.push('/login');
  1645. } catch (error) {
  1646. console.error('退出登录失败:', error);
  1647. // 即使接口调用失败,也清除本地信息并跳转
  1648. localStorage.clear();
  1649. router.push('/login');
  1650. }
  1651. };
  1652. const handleCreateInvitation = async () => {
  1653. try {
  1654. const response = await axios.post(`${import.meta.env.VITE_BASE_AI_API}/user/create_invitation`, {}, {
  1655. headers: {
  1656. 'Authorization': `JWT ${localStorage.getItem('token')}`
  1657. }
  1658. });
  1659. console.log(response);
  1660. if (response.data.code === 200) {
  1661. message.success('创建邀请成功');
  1662. // 从当前窗口location获取基础URL
  1663. const baseUrl = `${window.location.protocol}//${window.location.host}`;
  1664. // 跳转到完整URL
  1665. window.location.href = `${baseUrl}${response.data.data.invitation_link}`;
  1666. } else {
  1667. message.error(response.data.message || '创建邀请失败');
  1668. }
  1669. } catch (error) {
  1670. console.error('创建邀请失败:', error);
  1671. message.error(error.response?.data?.message || '创建邀请失败,请稍后重试');
  1672. }
  1673. showDropdown.value = false; // 关闭下拉菜单
  1674. };
  1675. /* return {
  1676. loginForm,
  1677. formData,
  1678. rules,
  1679. loading,
  1680. rememberMe,
  1681. loginType,
  1682. countdown,
  1683. handleLogin,
  1684. sendVerificationCode,
  1685. switchToMobileLogin,
  1686. switchToAccountLogin,
  1687. switchToWechatLogin,
  1688. wechatLoginModal,
  1689. wechatQrCode,
  1690. getWechatQrCode,
  1691. handleWechatLoginCancel,
  1692. handleCreateInvitation
  1693. }; */
  1694. // These variables are already declared above
  1695. /* const currentAudioSource = ref(null);
  1696. const currentPlayingId = ref(null); */
  1697. // 添加播放音频消息的方法
  1698. const playAudioMessage = async (audioData, messageId) => {
  1699. try {
  1700. // 如果当前有其他音频在播放,先停止
  1701. if (currentPlayingId.value && currentPlayingId.value !== messageId) {
  1702. stopAudio();
  1703. }
  1704. // 如果已经在播放这条消息,直接返回
  1705. if (currentPlayingId.value === messageId) {
  1706. return;
  1707. }
  1708. // 创建新的音频元素
  1709. const audio = new Audio(audioData);
  1710. // 保存当前播放的音频和ID
  1711. currentAudioSource.value = audio;
  1712. currentPlayingId.value = messageId;
  1713. isPlaying.value = true;
  1714. // 播放结束时清理
  1715. audio.onended = () => {
  1716. currentPlayingId.value = null;
  1717. currentAudioSource.value = null;
  1718. isPlaying.value = false;
  1719. };
  1720. // 播放错误时清理
  1721. audio.onerror = (e) => {
  1722. console.error('播放音频失败:', e);
  1723. message.error('播放失败,请稍后重试');
  1724. currentPlayingId.value = null;
  1725. currentAudioSource.value = null;
  1726. isPlaying.value = false;
  1727. };
  1728. // 开始播放
  1729. await audio.play();
  1730. } catch (error) {
  1731. console.error('播放音频失败:', error);
  1732. message.error('播放失败,请稍后重试');
  1733. currentPlayingId.value = null;
  1734. currentAudioSource.value = null;
  1735. isPlaying.value = false;
  1736. }
  1737. };
  1738. </script>
  1739. <style scoped>
  1740. .layout {
  1741. display: flex;
  1742. width: 100%;
  1743. height: 100vh;
  1744. overflow: hidden;
  1745. position: relative;
  1746. }
  1747. .header {
  1748. position: fixed;
  1749. top: 0;
  1750. left: 0;
  1751. width: 100%;
  1752. height: 64px;
  1753. background: #f7f7f8;
  1754. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  1755. z-index: 999;
  1756. }
  1757. .user-profile-bar {
  1758. margin: 0 auto;
  1759. position: relative;
  1760. display: flex;
  1761. align-items: center;
  1762. justify-content: space-between;
  1763. cursor: pointer;
  1764. }
  1765. .user-info-bar{
  1766. display: flex;
  1767. align-items: center;
  1768. justify-content: flex-end;
  1769. width: 100%;
  1770. height: 100%;
  1771. background-color: #f7f7f8;
  1772. }
  1773. .avatar {
  1774. width: 40px;
  1775. height: 40px;
  1776. border-radius: 50%;
  1777. overflow: hidden;
  1778. margin-right: 12px;
  1779. }
  1780. .avatar img {
  1781. width: 100%;
  1782. height: 100%;
  1783. object-fit: cover;
  1784. }
  1785. .user-info {
  1786. display: flex;
  1787. flex-direction: column;
  1788. margin-right: 15px;
  1789. }
  1790. .user-name {
  1791. font-size: 14px;
  1792. font-weight: 500;
  1793. color: #333;
  1794. }
  1795. .dropdown-menu {
  1796. position: absolute;
  1797. top: 100%;
  1798. right: 0;
  1799. background: white;
  1800. border-radius: 8px;
  1801. box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  1802. min-width: 160px;
  1803. z-index: 1000;
  1804. margin-top: 4px;
  1805. }
  1806. .dropdown-item {
  1807. padding: 12px 16px;
  1808. display: flex;
  1809. align-items: center;
  1810. color: #333;
  1811. transition: background-color 0.2s;
  1812. }
  1813. .dropdown-item:hover {
  1814. background-color: #f5f5f5;
  1815. }
  1816. .dropdown-item i {
  1817. margin-right: 8px;
  1818. font-size: 14px;
  1819. color: #666;
  1820. }
  1821. .menu {
  1822. margin-top: 64px;
  1823. background: #f7f7f8;
  1824. width: 260px;
  1825. height: 93%;
  1826. display: flex;
  1827. flex-direction: column;
  1828. border-right: 1px solid rgba(0, 0, 0, 0.06);
  1829. position: absolute;
  1830. left: 0;
  1831. /* transform: translateX(0); */
  1832. transition: all 0.3s ease;
  1833. z-index: 2;
  1834. }
  1835. .menu.collapsed {
  1836. display: none;
  1837. transform: translateX(-260px);
  1838. width: 0;
  1839. }
  1840. .conversations {
  1841. padding: 0 12px;
  1842. flex: 1;
  1843. overflow-y: auto;
  1844. }
  1845. .chat {
  1846. flex: 1;
  1847. padding: 24px;
  1848. display: flex;
  1849. flex-direction: column;
  1850. gap: 24px;
  1851. overflow-y: auto;
  1852. overflow-x: hidden;
  1853. margin-left: 0;
  1854. margin-right: 0;
  1855. transition: all 0.3s ease;
  1856. position: absolute;
  1857. left: 0;
  1858. right: 0;
  1859. top: 0;
  1860. bottom: 0;
  1861. justify-content: space-between;
  1862. }
  1863. .menu:not(.collapsed) + .chat {
  1864. left: 260px;
  1865. }
  1866. .chat {
  1867. right: 0;
  1868. transition: all 0.3s ease;
  1869. }
  1870. .layout:has(.right_menu:not(.collapsed)) .chat {
  1871. right: 450px;
  1872. }
  1873. .right_menu:not(.collapsed) ~ .chat {
  1874. right: 450px;
  1875. }
  1876. .messages {
  1877. flex: 1;
  1878. overflow-y: auto;
  1879. padding-right: 16px;
  1880. }
  1881. .sender {
  1882. box-shadow: none;
  1883. border: 1px solid #e5e6eb;
  1884. border-radius: 8px;
  1885. padding: 8px;
  1886. }
  1887. .logo {
  1888. height: 64px;
  1889. display: flex;
  1890. align-items: center;
  1891. padding: 0 20px;
  1892. }
  1893. /* .logo-img {
  1894. width: 24px;
  1895. height: 24px;
  1896. } */
  1897. .logo span {
  1898. margin-left: 12px;
  1899. font-size: 16px;
  1900. font-weight: 600;
  1901. color: rgba(0, 0, 0, 0.88);
  1902. }
  1903. .new-conversation-btn {
  1904. margin: 0 12px 12px;
  1905. height: 40px;
  1906. background: rgba(235, 245, 255, 0.7);
  1907. border: none;
  1908. border-radius: 8px;
  1909. color: #1677ff;
  1910. font-size: 14px;
  1911. display: flex;
  1912. align-items: center;
  1913. justify-content: center;
  1914. gap: 8px;
  1915. cursor: pointer;
  1916. transition: background-color 0.2s;
  1917. }
  1918. .new-conversation-btn:hover {
  1919. background: rgba(235, 245, 255, 0.9);
  1920. }
  1921. .conversation-list {
  1922. flex: 1;
  1923. padding: 0 8px;
  1924. overflow-y: auto;
  1925. }
  1926. .conversation-item {
  1927. padding: 12px;
  1928. margin: 4px 0;
  1929. border-radius: 8px;
  1930. color: rgba(0, 0, 0, 0.88);
  1931. font-size: 14px;
  1932. cursor: pointer;
  1933. transition: background-color 0.2s;
  1934. }
  1935. .conversation-item:hover {
  1936. background: rgba(0, 0, 0, 0.04);
  1937. }
  1938. .conversation-item.active {
  1939. background: #fff;
  1940. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  1941. }
  1942. .conversation-list::-webkit-scrollbar {
  1943. width: 4px;
  1944. }
  1945. .conversation-list::-webkit-scrollbar-thumb {
  1946. background: rgba(0, 0, 0, 0.15);
  1947. border-radius: 2px;
  1948. }
  1949. .conversation-list::-webkit-scrollbar-track {
  1950. background: transparent;
  1951. }
  1952. :deep(.welcome-message) {
  1953. background: #fff;
  1954. border-radius: 8px;
  1955. padding: 16px;
  1956. display: flex;
  1957. align-items: flex-start;
  1958. gap: 16px;
  1959. }
  1960. :deep(.welcome-message .title) {
  1961. font-size: 16px;
  1962. font-weight: 500;
  1963. color: rgba(0, 0, 0, 0.88);
  1964. margin-bottom: 4px;
  1965. }
  1966. :deep(.welcome-message .description) {
  1967. color: rgba(0, 0, 0, 0.45);
  1968. font-size: 14px;
  1969. }
  1970. :deep(.prompt-card) {
  1971. background: #f7f8fa;
  1972. border-radius: 8px;
  1973. padding: 16px;
  1974. margin-bottom: 12px;
  1975. }
  1976. :deep(.prompt-card-title) {
  1977. font-size: 16px;
  1978. font-weight: 500;
  1979. margin-bottom: 8px;
  1980. display: flex;
  1981. align-items: center;
  1982. gap: 8px;
  1983. }
  1984. :deep(.prompt-option) {
  1985. background: #f5f5f5;
  1986. padding: 8px 12px;
  1987. border-radius: 4px;
  1988. margin-top: 8px;
  1989. cursor: pointer;
  1990. transition: background 0.3s;
  1991. }
  1992. :deep(.prompt-option:hover) {
  1993. background: #e8e8e8;
  1994. }
  1995. .input-container {
  1996. width: 50%;
  1997. margin: auto auto 0;
  1998. display: flex;
  1999. flex-direction: column;
  2000. gap: 8px;
  2001. }
  2002. .tabs-wrapper {
  2003. display: flex;
  2004. gap: 8px;
  2005. margin-bottom: 4px;
  2006. }
  2007. .tab-item {
  2008. display: flex;
  2009. align-items: center;
  2010. gap: 6px;
  2011. padding: 4px 12px;
  2012. border-radius: 4px;
  2013. cursor: pointer;
  2014. font-size: 14px;
  2015. color: rgba(0, 0, 0, 0.88);
  2016. background: transparent;
  2017. transition: background-color 0.2s;
  2018. }
  2019. .tab-item:hover {
  2020. background: rgba(0, 0, 0, 0.04);
  2021. }
  2022. .tab-item.active {
  2023. background: #f5f5f5;
  2024. }
  2025. .tab-item .anticon {
  2026. font-size: 14px;
  2027. }
  2028. .input-wrapper {
  2029. display: flex;
  2030. align-items: center;
  2031. padding: 8px 12px;
  2032. border: 1px solid #e5e6eb;
  2033. border-radius: 8px;
  2034. background: white;
  2035. }
  2036. .message-input {
  2037. flex: 1;
  2038. border: none;
  2039. outline: none;
  2040. padding: 8px;
  2041. font-size: 14px;
  2042. background: transparent;
  2043. }
  2044. .message-input::placeholder {
  2045. color: rgba(0, 0, 0, 0.45);
  2046. }
  2047. .attachment-btn,
  2048. .send-btn {
  2049. display: flex;
  2050. align-items: center;
  2051. justify-content: center;
  2052. width: 32px;
  2053. height: 32px;
  2054. border: none;
  2055. background: transparent;
  2056. cursor: pointer;
  2057. color: rgba(0, 0, 0, 0.45);
  2058. border-radius: 4px;
  2059. }
  2060. .attachment-btn:hover,
  2061. .send-btn:hover {
  2062. background: rgba(0, 0, 0, 0.04);
  2063. color: rgba(0, 0, 0, 0.88);
  2064. }
  2065. .attachments-panel {
  2066. background: white;
  2067. border-radius: 12px;
  2068. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  2069. overflow: hidden;
  2070. }
  2071. .panel-content {
  2072. background: white;
  2073. }
  2074. .attachments-header {
  2075. padding: 12px 16px;
  2076. border-bottom: 1px solid #f0f0f0;
  2077. display: flex;
  2078. justify-content: space-between;
  2079. align-items: center;
  2080. }
  2081. .attachments-header span {
  2082. font-size: 14px;
  2083. font-weight: 500;
  2084. color: rgba(0, 0, 0, 0.88);
  2085. }
  2086. .close-btn {
  2087. border: none;
  2088. background: transparent;
  2089. cursor: pointer;
  2090. padding: 4px;
  2091. display: flex;
  2092. align-items: center;
  2093. justify-content: center;
  2094. color: rgba(0, 0, 0, 0.45);
  2095. }
  2096. .upload-area {
  2097. padding: 24px;
  2098. border-radius: 8px;
  2099. text-align: center;
  2100. cursor: pointer;
  2101. transition: all 0.3s;
  2102. }
  2103. .upload-area.has-files {
  2104. padding: 12px;
  2105. background: #fff;
  2106. }
  2107. .upload-icon {
  2108. width: 32px;
  2109. height: 32px;
  2110. margin-bottom: 8px;
  2111. }
  2112. .upload-text {
  2113. font-size: 14px;
  2114. color: rgba(0, 0, 0, 0.88);
  2115. margin-bottom: 4px;
  2116. }
  2117. .upload-hint {
  2118. font-size: 12px;
  2119. color: rgba(0, 0, 0, 0.45);
  2120. }
  2121. .file-list {
  2122. display: flex;
  2123. flex-wrap: wrap;
  2124. gap: 8px;
  2125. padding: 10px;
  2126. }
  2127. .file-item {
  2128. position: relative;
  2129. width: 260px;
  2130. padding: 8px 12px;
  2131. margin: 4px 0;
  2132. background: #f5f5f5;
  2133. border-radius: 8px;
  2134. }
  2135. .file-item.is-image {
  2136. width: 68px;
  2137. padding: 0;
  2138. margin: 4px 0;
  2139. }
  2140. .file-wrapper {
  2141. position: relative;
  2142. width: 100%;
  2143. height: 100%;
  2144. }
  2145. .file-icon {
  2146. width: 68px;
  2147. height: 68px;
  2148. object-fit: cover;
  2149. border-radius: 4px;
  2150. }
  2151. .file-wrapper video.file-icon {
  2152. background: #000;
  2153. }
  2154. .remove-btn {
  2155. position: absolute;
  2156. top: -8px;
  2157. right: -8px;
  2158. width: 16px;
  2159. height: 16px;
  2160. padding: 0;
  2161. border: none;
  2162. background: #545454;
  2163. border-radius: 50%;
  2164. cursor: pointer;
  2165. display: flex;
  2166. align-items: center;
  2167. justify-content: center;
  2168. font-size: 14px;
  2169. line-height: 1;
  2170. color: #fff;
  2171. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  2172. }
  2173. .remove-btn:hover {
  2174. opacity: 0.8;
  2175. }
  2176. .file-info {
  2177. margin-top: 8px;
  2178. }
  2179. .file-name {
  2180. display: block;
  2181. max-width: 150px;
  2182. color: rgba(0, 0, 0, 0.88);
  2183. font-size: 14px;
  2184. white-space: nowrap;
  2185. overflow: hidden;
  2186. text-overflow: ellipsis;
  2187. }
  2188. .file-info .file-name {
  2189. max-width: 150px;
  2190. }
  2191. .file-name:hover {
  2192. cursor: pointer;
  2193. }
  2194. .file-size {
  2195. display: block;
  2196. color: rgba(0, 0, 0, 0.45);
  2197. font-size: 12px;
  2198. margin-top: 4px;
  2199. }
  2200. .add-more-btn {
  2201. display: flex;
  2202. align-items: center;
  2203. justify-content: center;
  2204. width: 68px;
  2205. height: 68px;
  2206. border: 1px dashed #d9d9d9;
  2207. border-radius: 6px;
  2208. background: transparent;
  2209. cursor: pointer;
  2210. transition: all 0.3s;
  2211. margin: 4px 0;
  2212. }
  2213. .add-more-btn:hover {
  2214. border-color: #1677ff;
  2215. background: #f0f7ff;
  2216. }
  2217. /* 欢迎区域样式 */
  2218. .welcome-section {
  2219. max-width: 800px;
  2220. margin: 0 auto;
  2221. width: 50%;
  2222. }
  2223. .welcome-header {
  2224. display: flex;
  2225. align-items: flex-start;
  2226. gap: 16px;
  2227. margin-bottom: 24px;
  2228. }
  2229. .avatar {
  2230. width: 40px;
  2231. height: 40px;
  2232. border-radius: 50%;
  2233. }
  2234. .avatar img{
  2235. width: 100%;
  2236. height: 100%;
  2237. border-radius: 50%;
  2238. }
  2239. .welcome-info {
  2240. flex: 1;
  2241. }
  2242. .welcome-info h2 {
  2243. font-size: 20px;
  2244. font-weight: 500;
  2245. color: rgba(0, 0, 0, 0.88);
  2246. margin: 0 0 4px 0;
  2247. }
  2248. .welcome-info p {
  2249. font-size: 14px;
  2250. color: rgba(0, 0, 0, 0.45);
  2251. margin: 0;
  2252. }
  2253. .action-buttons {
  2254. display: flex;
  2255. gap: 8px;
  2256. }
  2257. .icon-btn {
  2258. padding: 8px;
  2259. border: none;
  2260. background: transparent;
  2261. cursor: pointer;
  2262. color: rgba(0, 0, 0, 0.45);
  2263. }
  2264. /* 建议区域样式 */
  2265. .suggestion-section {
  2266. margin-top: 70px;
  2267. }
  2268. .suggestion-section h3 {
  2269. font-size: 14px;
  2270. color: rgba(0, 0, 0, 0.45);
  2271. margin-bottom: 16px;
  2272. }
  2273. .cards-container {
  2274. display: flex;
  2275. gap: 16px;
  2276. }
  2277. .suggestion-card {
  2278. flex: 1;
  2279. border-radius: 8px;
  2280. padding: 16px;
  2281. background: #ffffff; /* 替换 var(--ant-color-bg-container) */
  2282. border-radius: 8px; /* 替换 var(--ant-border-radius-lg) */
  2283. transition: border 0.3s, background 0.3s; /* 替换 var(--ant-motion-duration-slow) */
  2284. border: 1px solid #f0f0f0; /* 替换合的 border 属性 */
  2285. }
  2286. :root {
  2287. --ant-color-bg-container: #ffffff;
  2288. --ant-border-radius-lg: 8px;
  2289. --ant-motion-duration-slow: 0.3s;
  2290. --ant-line-width: 1px;
  2291. --ant-line-type: solid;
  2292. --ant-color-border-secondary: #f0f0f0;
  2293. }
  2294. .card-header {
  2295. display: flex;
  2296. align-items: center;
  2297. gap: 8px;
  2298. margin-bottom: 8px;
  2299. }
  2300. .card-header h4 {
  2301. font-size: 16px;
  2302. font-weight: 500;
  2303. color: rgba(0, 0, 0, 0.88);
  2304. margin: 0;
  2305. }
  2306. .icon.red {
  2307. color: #ff4d4f;
  2308. }
  2309. .icon.blue {
  2310. color: #1890ff;
  2311. }
  2312. .card-subtitle {
  2313. font-size: 14px;
  2314. color: rgba(0, 0, 0, 0.45);
  2315. margin-bottom: 16px;
  2316. }
  2317. .suggestion-items {
  2318. display: flex;
  2319. flex-direction: column;
  2320. gap: 8px;
  2321. }
  2322. .suggestion-item {
  2323. padding: 8px 12px;
  2324. background: #f5f5f5;
  2325. border-radius: 4px;
  2326. font-size: 12px;
  2327. color: rgba(0, 0, 0, 0.88);
  2328. display: flex;
  2329. align-items: center;
  2330. gap: 8px;
  2331. cursor: pointer;
  2332. transition: opacity 0.3s ease;
  2333. }
  2334. .suggestion-item:hover {
  2335. background: #e8e8e8;
  2336. }
  2337. .tab-icon {
  2338. width: 16px;
  2339. }
  2340. .attached-files {
  2341. padding: 16px;
  2342. }
  2343. .file-item {
  2344. display: flex;
  2345. align-items: center;
  2346. gap: 8px;
  2347. padding: 8px;
  2348. border-radius: 4px;
  2349. }
  2350. .file-item:hover {
  2351. background: #f5f5f5;
  2352. }
  2353. .remove-btn {
  2354. margin-left: auto;
  2355. padding: 4px;
  2356. border: none;
  2357. background: transparent;
  2358. cursor: pointer;
  2359. color: rgba(0, 0, 0, 0.45);
  2360. }
  2361. .remove-btn:hover {
  2362. color: rgba(0, 0, 0, 0.88);
  2363. }
  2364. .send-btn:disabled {
  2365. opacity: 0.5;
  2366. cursor: not-allowed;
  2367. }
  2368. .upload-area {
  2369. /* border: 2px dashed #d9d9d9; */
  2370. border-radius: 8px;
  2371. padding: 20px;
  2372. text-align: center;
  2373. cursor: pointer;
  2374. transition: border-color 0.3s;
  2375. }
  2376. /* .upload-area:hover,
  2377. .upload-area.drag-over {
  2378. border-color: #1677ff;
  2379. } */
  2380. .file-item {
  2381. display: flex;
  2382. align-items: center;
  2383. width: 236px;
  2384. height: 68px;
  2385. padding: 0;
  2386. margin: 4px 0;
  2387. background: #f5f5f5;
  2388. border-radius: 4px;
  2389. }
  2390. .file-item .remove-btn {
  2391. margin-left: auto;
  2392. padding: 4px 8px;
  2393. background: transparent;
  2394. border: none;
  2395. cursor: pointer;
  2396. }
  2397. /* 聊天内容显示框 */
  2398. .message-list {
  2399. width: 60%;
  2400. overflow-y: auto;
  2401. overflow-x: hidden;
  2402. padding: 20px;
  2403. display: flex;
  2404. flex-direction: column;
  2405. gap: 16px;
  2406. margin: 30px auto 0;
  2407. }
  2408. .message-item {
  2409. display: flex;
  2410. margin-bottom: 12px;
  2411. }
  2412. /* 用户消息靠右显示 */
  2413. .user {
  2414. display: flex;
  2415. justify-content: flex-end;
  2416. }
  2417. .message-bubble {
  2418. max-width: 80%;
  2419. padding: 12px 16px;
  2420. border-radius: 12px;
  2421. background: #fff;
  2422. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  2423. }
  2424. /* 用户消息的气泡样式 */
  2425. .user .message-bubble {
  2426. background: #fff;
  2427. color: rgba(0, 0, 0, 0.88);
  2428. }
  2429. /* AI消息的气泡样式 */
  2430. .assistant .message-bubble {
  2431. background: #f7f7f8;
  2432. color: rgba(0, 0, 0, 0.88);
  2433. }
  2434. .message-content {
  2435. font-size: 14px;
  2436. line-height: 1.5;
  2437. white-space: pre-wrap;
  2438. word-break: break-word;
  2439. }
  2440. .right_menu {
  2441. /* 修改现有样式 */
  2442. /* position: absolute;
  2443. right: 0; */
  2444. margin-top: 64px;
  2445. height: 93%;
  2446. background: #f7f7f8;
  2447. border-left: 1px solid rgba(0, 0, 0, 0.06);
  2448. transform: translateX(0);
  2449. transition: transform 0.3s ease, width 0.3s ease;
  2450. z-index: 2;
  2451. position: relative;
  2452. }
  2453. .right_menu.collapsed {
  2454. transform: translateX(100%);
  2455. width: 0;
  2456. }
  2457. /* 当右侧菜单展开时,给聊天区域添加右边距 */
  2458. .right_menu:not(.collapsed) + .chat {
  2459. margin-right: 450px;
  2460. }
  2461. .collapse-left-button{
  2462. position: absolute;
  2463. left: 260px;
  2464. top: 50%;
  2465. transform: translateY(-50%);
  2466. width: 20px;
  2467. height: 40px;
  2468. background: #fff;
  2469. border: 1px solid rgba(0, 0, 0, 0.06);
  2470. border-right: none;
  2471. border-radius: 4px 0 0 4px;
  2472. display: flex;
  2473. align-items: center;
  2474. justify-content: center;
  2475. cursor: pointer;
  2476. z-index: 2;
  2477. transition: all 0.3s ease;
  2478. }
  2479. .menu-collapsed {
  2480. left: 0px;
  2481. border-right: 1px solid rgba(0, 0, 0, 0.06);
  2482. border-left: none;
  2483. border-radius: 0 4px 4px 0;
  2484. }
  2485. /* .collapse-button {
  2486. position: absolute;
  2487. left: -20px;
  2488. top: 50%;
  2489. transform: translateY(-50%);
  2490. width: 20px;
  2491. height: 40px;
  2492. background: #fff;
  2493. border: 1px solid rgba(0, 0, 0, 0.06);
  2494. border-right: none;
  2495. border-radius: 4px 0 0 4px;
  2496. display: flex;
  2497. align-items: center;
  2498. justify-content: center;
  2499. cursor: pointer;
  2500. z-index: 3;
  2501. transition: left 0.3s ease;
  2502. } */
  2503. /* .collapse-button.menu-expanded {
  2504. border-right: 1px solid rgba(0, 0, 0, 0.06);
  2505. border-left: none;
  2506. border-radius: 0 4px 4px 0;
  2507. } */
  2508. /* .collapse-button:hover {
  2509. background: #f5f5f5;
  2510. } */
  2511. /* .collapse-icon {
  2512. width: 12px;
  2513. height: 12px;
  2514. } */
  2515. .right-menu-content {
  2516. height: 100%;
  2517. overflow-y: auto;
  2518. }
  2519. .right_menu.collapsed .right-menu-content {
  2520. display: none;
  2521. }
  2522. /* 添加打字效果的光标样式 */
  2523. /* .assistant .message-content {
  2524. position: relative;
  2525. }
  2526. .assistant .message-content::after {
  2527. content: '|';
  2528. position: absolute;
  2529. margin-left: 2px;
  2530. animation: cursor-blink 1s infinite;
  2531. }
  2532. @keyframes cursor-blink {
  2533. 0%, 100% { opacity: 1; }
  2534. 50% { opacity: 0; }
  2535. }*/
  2536. .file-message {
  2537. background: #f7f7f8;
  2538. border-radius: 8px;
  2539. padding: 12px;
  2540. margin-bottom: 8px;
  2541. }
  2542. .file-info-display {
  2543. display: flex;
  2544. align-items: center;
  2545. gap: 12px;
  2546. margin-bottom: 8px;
  2547. }
  2548. .file-type-icon {
  2549. width: 24px;
  2550. height: 24px;
  2551. object-fit: contain;
  2552. }
  2553. .file-details {
  2554. display: flex;
  2555. flex-direction: column;
  2556. }
  2557. /* .file-name {
  2558. font-size: 14px;
  2559. color: rgba(0, 0, 0, 0.88);
  2560. margin-bottom: 4px;
  2561. } */
  2562. .file-size {
  2563. font-size: 12px;
  2564. color: rgba(0, 0, 0, 0.45);
  2565. }
  2566. .file-action {
  2567. font-size: 12px;
  2568. color: rgba(0, 0, 0, 0.45);
  2569. padding-left: 36px;
  2570. }
  2571. /* 修改用户消息气泡样式,确保文件信息正确显示 */
  2572. .user .message-bubble {
  2573. background: #fff;
  2574. color: rgba(0, 0, 0, 0.88);
  2575. }
  2576. .user .file-message {
  2577. background: #f7f7f8;
  2578. }
  2579. /* 图片预览样式 */
  2580. .image-preview {
  2581. position: relative;
  2582. width: 200px;
  2583. border-radius: 8px;
  2584. overflow: hidden;
  2585. background: #fff;
  2586. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  2587. }
  2588. .preview-image {
  2589. width: 100%;
  2590. height: auto;
  2591. display: block;
  2592. }
  2593. .image-info {
  2594. position: absolute;
  2595. bottom: 0;
  2596. left: 0;
  2597. right: 0;
  2598. padding: 8px;
  2599. background: rgba(255, 255, 255, 0.9);
  2600. font-size: 12px;
  2601. color: rgba(0, 0, 0, 0.45);
  2602. text-align: center;
  2603. border-top: 1px solid rgba(0, 0, 0, 0.06);
  2604. }
  2605. /* 文档显示样式保持不变 */
  2606. .file-info-display {
  2607. display: flex;
  2608. align-items: center;
  2609. gap: 12px;
  2610. margin-bottom: 8px;
  2611. }
  2612. .file-type-icon {
  2613. width: 24px;
  2614. height: 24px;
  2615. object-fit: contain;
  2616. }
  2617. .file-details {
  2618. display: flex;
  2619. flex-direction: column;
  2620. }
  2621. /* .file-name {
  2622. font-size: 14px;
  2623. color: rgba(0, 0, 0, 0.88);
  2624. margin-bottom: 4px;
  2625. } */
  2626. .file-size {
  2627. font-size: 12px;
  2628. color: rgba(0, 0, 0, 0.45);
  2629. }
  2630. .file-action {
  2631. font-size: 12px;
  2632. color: rgba(0, 0, 0, 0.45);
  2633. padding-left: 36px;
  2634. }
  2635. /* 添加音频控制相关样式 */
  2636. .audio-controls {
  2637. margin-top: 8px;
  2638. }
  2639. .audio-btn {
  2640. background: transparent;
  2641. border: none;
  2642. padding: 4px 8px;
  2643. cursor: pointer;
  2644. display: flex;
  2645. align-items: center;
  2646. justify-content: center;
  2647. border-radius: 4px;
  2648. transition: background-color 0.2s;
  2649. min-width: 32px;
  2650. height: 32px;
  2651. }
  2652. .audio-btn:hover {
  2653. background: rgba(0, 0, 0, 0.04);
  2654. }
  2655. .audio-icon {
  2656. width: 20px;
  2657. height: 20px;
  2658. }
  2659. /* 音频波形动画样式 */
  2660. .wave-animation {
  2661. display: flex;
  2662. align-items: center;
  2663. height: 20px;
  2664. gap: 2px;
  2665. }
  2666. .wave-bar {
  2667. display: inline-block;
  2668. width: 3px;
  2669. height: 100%;
  2670. background: #1677ff;
  2671. border-radius: 1px;
  2672. animation: wave 1s ease-in-out infinite;
  2673. }
  2674. .wave-bar:nth-child(1) {
  2675. animation-delay: 0s;
  2676. }
  2677. .wave-bar:nth-child(2) {
  2678. animation-delay: 0.2s;
  2679. }
  2680. .wave-bar:nth-child(3) {
  2681. animation-delay: 0.4s;
  2682. }
  2683. .wave-bar:nth-child(4) {
  2684. animation-delay: 0.6s;
  2685. }
  2686. @keyframes wave {
  2687. 0%,
  2688. 100% {
  2689. height: 6px;
  2690. }
  2691. 50% {
  2692. height: 18px;
  2693. }
  2694. }
  2695. .audio-btn {
  2696. background: transparent;
  2697. border: none;
  2698. padding: 4px 8px;
  2699. cursor: pointer;
  2700. display: flex;
  2701. align-items: center;
  2702. justify-content: center;
  2703. border-radius: 4px;
  2704. transition: background-color 0.2s;
  2705. min-width: 32px;
  2706. height: 32px;
  2707. }
  2708. .audio-btn:hover {
  2709. background: rgba(0, 0, 0, 0.04);
  2710. }
  2711. .audio-icon {
  2712. width: 20px;
  2713. height: 20px;
  2714. }
  2715. .message-text {
  2716. margin: 0;
  2717. white-space: normal; /* 确保文本会换行 */
  2718. word-wrap: break-word; /* 长单词或 URL 会被断开以适应容器宽度 */
  2719. overflow: auto;
  2720. font-size: 12px;
  2721. line-height: 20px;
  2722. }
  2723. .message-text ::v-deep p {
  2724. font-size: 12px !important;
  2725. margin: 5px 0 10px;
  2726. padding: 0;
  2727. font-size: inherit;
  2728. line-height: 22px;
  2729. font-weight: inherit;
  2730. }
  2731. .message-text ::v-deep ol {
  2732. padding-bottom: 10px;
  2733. }
  2734. .message-text ::v-deep .source-section h3 {
  2735. margin: 20px 0 3px;
  2736. color: #333;
  2737. font-size: 16px;
  2738. }
  2739. .message-text ::v-deep ol li {
  2740. padding-top: 3px;
  2741. }
  2742. .message-text ::v-deep ol li a {
  2743. font-size: 14px;
  2744. color: #1296db;
  2745. }
  2746. .video-preview {
  2747. position: relative;
  2748. width: 300px;
  2749. border-radius: 8px;
  2750. overflow: hidden;
  2751. background: #fff;
  2752. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  2753. margin-bottom: 8px;
  2754. }
  2755. .preview-video {
  2756. width: 100%;
  2757. height: auto;
  2758. display: block;
  2759. max-height: 300px;
  2760. }
  2761. /* 添加 loading 相关样式 */
  2762. .upload-loading {
  2763. display: flex;
  2764. flex-direction: column;
  2765. align-items: center;
  2766. gap: 12px;
  2767. }
  2768. .loading-spinner {
  2769. width: 24px;
  2770. height: 24px;
  2771. border: 2px solid #f3f3f3;
  2772. border-top: 2px solid #1677ff;
  2773. border-radius: 50%;
  2774. animation: spin 1s linear infinite;
  2775. }
  2776. .file-loading {
  2777. position: absolute;
  2778. top: 0;
  2779. left: 0;
  2780. right: 0;
  2781. bottom: 0;
  2782. background: rgba(255, 255, 255, 0.8);
  2783. display: flex;
  2784. align-items: center;
  2785. justify-content: center;
  2786. z-index: 1;
  2787. }
  2788. @keyframes spin {
  2789. 0% {
  2790. transform: rotate(0deg);
  2791. }
  2792. 100% {
  2793. transform: rotate(360deg);
  2794. }
  2795. }
  2796. /* 上传区域在上传时的样式 */
  2797. .upload-area {
  2798. position: relative;
  2799. cursor: pointer; /* 始终保持指针样式 */
  2800. }
  2801. .upload-area.uploading {
  2802. opacity: 0.7;
  2803. }
  2804. /* 添加配置容器的样式 */
  2805. .config-container {
  2806. margin-top: auto;
  2807. border-top: 1px solid rgba(0, 0, 0, 0.06);
  2808. }
  2809. .web-search-toggle {
  2810. display: flex;
  2811. align-items: center;
  2812. /* margin-left: auto; */
  2813. padding: 0 12px;
  2814. }
  2815. .toggle-input {
  2816. position: relative;
  2817. width: 36px;
  2818. height: 20px;
  2819. margin-right: 8px;
  2820. appearance: none;
  2821. background: #ccc;
  2822. border-radius: 10px;
  2823. cursor: pointer;
  2824. transition: background 0.3s;
  2825. }
  2826. .toggle-input:checked {
  2827. background: #1677ff;
  2828. }
  2829. .toggle-input::before {
  2830. content: "";
  2831. position: absolute;
  2832. top: 2px;
  2833. left: 2px;
  2834. width: 16px;
  2835. height: 16px;
  2836. background: white;
  2837. border-radius: 50%;
  2838. transition: transform 0.3s;
  2839. }
  2840. .toggle-input:checked::before {
  2841. transform: translateX(16px);
  2842. }
  2843. .toggle-label {
  2844. font-size: 14px;
  2845. color: rgba(0, 0, 0, 0.88);
  2846. cursor: pointer;
  2847. }
  2848. .toggle-input:disabled {
  2849. opacity: 0.5;
  2850. cursor: not-allowed;
  2851. }
  2852. .toggle-label.disabled {
  2853. color: rgba(0, 0, 0, 0.45);
  2854. cursor: not-allowed;
  2855. }
  2856. .disabled-hint {
  2857. font-size: 12px;
  2858. color: rgba(0, 0, 0, 0.45);
  2859. margin-left: 4px;
  2860. }
  2861. /* 添加菜单收缩相关样式 */
  2862. .menu {
  2863. /* 现有样式保持不变 */
  2864. transition: width 0.3s ease;
  2865. position: relative;
  2866. }
  2867. .menu.collapsed {
  2868. width: 0;
  2869. padding: 0;
  2870. }
  2871. /* 添加收缩按钮样式 */
  2872. .collapse-button {
  2873. position: absolute;
  2874. top: 50%;
  2875. transform: translateY(-50%);
  2876. width: 20px;
  2877. height: 40px;
  2878. background: #fff;
  2879. border: 1px solid rgba(0, 0, 0, 0.06);
  2880. display: flex;
  2881. align-items: center;
  2882. justify-content: center;
  2883. cursor: pointer;
  2884. z-index: 3;
  2885. transition: right 0.3s ease, left 0.3s ease;
  2886. }
  2887. .collapse-button:hover {
  2888. background: #f5f5f5;
  2889. }
  2890. .collapse-icon {
  2891. width: 12px;
  2892. height: 12px;
  2893. }
  2894. /* 添加响应式布局样式 */
  2895. @media screen and (max-width: 768px) {
  2896. .layout {
  2897. /* 移动端布局调整 */
  2898. flex-direction: column;
  2899. }
  2900. .menu {
  2901. /* 移动端菜单调整 */
  2902. position: fixed;
  2903. width: 100%;
  2904. height: 93%;
  2905. z-index: 1000;
  2906. transform: translateX(-100%);
  2907. }
  2908. .menu.collapsed {
  2909. transform: translateX(-100%);
  2910. }
  2911. .collapse-left-button {
  2912. z-index: 999;
  2913. /* 移动端收缩按钮调整 */
  2914. /* display: none; */
  2915. }
  2916. .chat {
  2917. /* 移动端聊天区域调整 */
  2918. width: 100%;
  2919. margin: 0;
  2920. padding: 16px;
  2921. left: 0 !important;
  2922. right: 0 !important;
  2923. }
  2924. .message-list {
  2925. /* 移动端消息列表调整 */
  2926. width: 100%;
  2927. padding: 10px;
  2928. }
  2929. .input-container {
  2930. /* 移动端输入区域调整 */
  2931. width: 100%;
  2932. padding: 10px;
  2933. }
  2934. .cards-container {
  2935. /* 移动端卡片容器调整 */
  2936. flex-direction: column;
  2937. }
  2938. .suggestion-card {
  2939. /* 移动端建议卡片调整 */
  2940. width: 100%;
  2941. }
  2942. .welcome-section {
  2943. /* 移动端欢迎区域调整 */
  2944. width: 100%;
  2945. padding: 16px;
  2946. }
  2947. .right_menu {
  2948. /* 移动端右侧菜单调整 */
  2949. position: fixed;
  2950. width: 100%;
  2951. height: 100%;
  2952. z-index: 998;
  2953. }
  2954. .right_menu.collapsed {
  2955. transform: translateX(100%);
  2956. }
  2957. /* 移动端文件预览调整 */
  2958. .image-preview,
  2959. .video-preview {
  2960. width: 100%;
  2961. max-width: 300px;
  2962. }
  2963. /* 移动端文件列表调整 */
  2964. .file-list {
  2965. justify-content: center;
  2966. }
  2967. .file-item {
  2968. width: 100%;
  2969. max-width: 300px;
  2970. }
  2971. /* 移动端标签栏调整 */
  2972. .tabs-wrapper {
  2973. flex-wrap: wrap;
  2974. gap: 4px;
  2975. }
  2976. .web-search-toggle {
  2977. width: 100%;
  2978. justify-content: flex-start;
  2979. margin-top: 8px;
  2980. }
  2981. /* 移动端消息气泡调整 */
  2982. .message-bubble {
  2983. max-width: 90%;
  2984. }
  2985. .collapse-button {
  2986. left: -20px !important;
  2987. }
  2988. .collapse-button.menu-expanded {
  2989. left: auto !important;
  2990. right: 0;
  2991. }
  2992. }
  2993. /* 添加移动端手势支持 */
  2994. @media (hover: none) and (pointer: coarse) {
  2995. .menu {
  2996. /* 支持触摸滑动 */
  2997. touch-action: pan-y;
  2998. }
  2999. .message-list {
  3000. /* 支持触摸滚动 */
  3001. -webkit-overflow-scrolling: touch;
  3002. }
  3003. }
  3004. /* 优化移动端字体大小 */
  3005. @media screen and (max-width: 480px) {
  3006. .message-content {
  3007. font-size: 14px;
  3008. }
  3009. .suggestion-item {
  3010. font-size: 13px;
  3011. }
  3012. .file-name {
  3013. font-size: 13px;
  3014. }
  3015. }
  3016. /* 修改现有的响应式样式 */
  3017. @media screen and (max-width: 768px) {
  3018. .layout {
  3019. overflow-x: hidden;
  3020. }
  3021. .chat {
  3022. /* 调整聊天区域以保持一致的宽度 */
  3023. padding: 24px 16px;
  3024. margin: 0;
  3025. width: 100%;
  3026. }
  3027. .message-list {
  3028. /* 保持消息列表的宽度一致 */
  3029. width: 100%;
  3030. max-width: 800px;
  3031. margin: 0 auto;
  3032. padding: 0 10px;
  3033. }
  3034. .input-container {
  3035. /* 保持输入区域的宽度一致 */
  3036. width: 100%;
  3037. max-width: 800px;
  3038. margin: 0 auto;
  3039. padding: 0 10px;
  3040. }
  3041. .welcome-section {
  3042. /* 保持欢迎区域的宽度一致 */
  3043. width: 100%;
  3044. max-width: 800px;
  3045. margin: 0 auto;
  3046. padding: 0 16px;
  3047. }
  3048. .cards-container {
  3049. /* 保持卡片布局 */
  3050. flex-direction: row;
  3051. flex-wrap: wrap;
  3052. gap: 16px;
  3053. }
  3054. .suggestion-card {
  3055. /* 调整卡片大小 */
  3056. flex: 1 1 300px;
  3057. min-width: 300px;
  3058. }
  3059. .message-bubble {
  3060. /* 保持消息气泡的样式 */
  3061. max-width: 80%;
  3062. padding: 12px 16px;
  3063. }
  3064. /* 调整文件预览区域 */
  3065. .image-preview,
  3066. .video-preview {
  3067. width: 200px;
  3068. margin: 0 auto;
  3069. }
  3070. /* 调整文件列表布局 */
  3071. .file-list {
  3072. display: flex;
  3073. flex-wrap: wrap;
  3074. gap: 8px;
  3075. justify-content: flex-start;
  3076. }
  3077. .file-item {
  3078. width: calc(50% - 8px);
  3079. min-width: 200px;
  3080. }
  3081. /* 调整标签栏布局 */
  3082. .tabs-wrapper {
  3083. flex-wrap: nowrap;
  3084. overflow-x: auto;
  3085. -webkit-overflow-scrolling: touch;
  3086. padding-bottom: 8px;
  3087. }
  3088. /* 调整搜索开关位置 */
  3089. .web-search-toggle {
  3090. position: relative;
  3091. width: auto;
  3092. }
  3093. /* 调整菜单样式 */
  3094. .menu {
  3095. position: fixed;
  3096. left: 0;
  3097. top: 0;
  3098. bottom: 0;
  3099. width: 260px;
  3100. transform: translateX(-100%);
  3101. transition: transform 0.3s ease;
  3102. z-index: 1000;
  3103. }
  3104. .menu.collapsed {
  3105. transform: translateX(-100%);
  3106. }
  3107. .menu:not(.collapsed) {
  3108. transform: translateX(0);
  3109. }
  3110. /* 调整右侧菜单样式 */
  3111. /* .right_menu {
  3112. position: fixed;
  3113. right: 0;
  3114. top: 0;
  3115. bottom: 0;
  3116. width: 300px;
  3117. transform: translateX(100%);
  3118. transition: transform 0.3s ease;
  3119. z-index: 998;
  3120. } */
  3121. .right_menu.collapsed {
  3122. transform: translateX(100%);
  3123. }
  3124. .right_menu:not(.collapsed) {
  3125. transform: translateX(0);
  3126. }
  3127. /* 添加遮罩层样式 */
  3128. .menu-overlay {
  3129. position: fixed;
  3130. top: 0;
  3131. left: 0;
  3132. right: 0;
  3133. bottom: 0;
  3134. background: rgba(0, 0, 0, 0.5);
  3135. z-index: 999;
  3136. display: none;
  3137. }
  3138. .menu:not(.collapsed) ~ .menu-overlay,
  3139. .right_menu:not(.collapsed) ~ .menu-overlay {
  3140. display: block;
  3141. }
  3142. }
  3143. /* 添加更细致的断点控制 */
  3144. @media screen and (max-width: 480px) {
  3145. .message-content {
  3146. font-size: 14px;
  3147. line-height: 1.5;
  3148. }
  3149. .suggestion-item {
  3150. font-size: 14px;
  3151. padding: 10px;
  3152. }
  3153. .input-wrapper {
  3154. padding: 8px;
  3155. }
  3156. .message-input {
  3157. font-size: 14px;
  3158. }
  3159. }
  3160. /* 确保滚动流畅 */
  3161. * {
  3162. -webkit-overflow-scrolling: touch;
  3163. }
  3164. /* 防止页面横向滚动 */
  3165. body {
  3166. overflow-x: hidden;
  3167. width: 100%;
  3168. }
  3169. /* 优化触摸体验 */
  3170. button,
  3171. .suggestion-item,
  3172. .conversation-item {
  3173. touch-action: manipulation;
  3174. }
  3175. /* 添加拖动条样式 */
  3176. .resize-handle {
  3177. position: absolute;
  3178. left: -5px;
  3179. top: 0;
  3180. width: 10px;
  3181. height: 100%;
  3182. cursor: col-resize;
  3183. background: transparent;
  3184. z-index: 3;
  3185. }
  3186. .resize-handle:hover {
  3187. background: rgba(0, 0, 0, 0.1);
  3188. }
  3189. /* 确保拖动时不会选中文本 */
  3190. .resize-handle:active {
  3191. user-select: none;
  3192. }
  3193. /* 移动端样式调整 */
  3194. @media screen and (max-width: 768px) {
  3195. .resize-handle {
  3196. display: none;
  3197. }
  3198. .right_menu {
  3199. width: 100% !important;
  3200. }
  3201. }
  3202. .search-header {
  3203. display: flex;
  3204. justify-content: space-between;
  3205. align-items: center;
  3206. padding: 16px;
  3207. border-bottom: 1px solid #f0f0f0;
  3208. }
  3209. .search-header span {
  3210. font-size: 16px;
  3211. font-weight: bold;
  3212. }
  3213. /* 添加开关样式 */
  3214. .web-search-toggle {
  3215. display: flex;
  3216. align-items: center;
  3217. }
  3218. .toggle-input {
  3219. position: relative;
  3220. width: 36px;
  3221. height: 20px;
  3222. margin-right: 8px;
  3223. appearance: none;
  3224. background: #ccc;
  3225. border-radius: 10px;
  3226. cursor: pointer;
  3227. transition: background 0.3s;
  3228. }
  3229. .toggle-input:checked {
  3230. background: #1677ff;
  3231. }
  3232. .toggle-input::before {
  3233. content: "";
  3234. position: absolute;
  3235. top: 2px;
  3236. left: 2px;
  3237. width: 16px;
  3238. height: 16px;
  3239. background: white;
  3240. border-radius: 50%;
  3241. transition: transform 0.3s;
  3242. }
  3243. .toggle-input:checked::before {
  3244. transform: translateX(16px);
  3245. }
  3246. .toggle-label {
  3247. font-size: 14px;
  3248. color: rgba(0, 0, 0, 0.88);
  3249. cursor: pointer;
  3250. }
  3251. /* 添加 Tab 样式 */
  3252. .right-menu-tabs {
  3253. display: flex;
  3254. border-bottom: 1px solid #f0f0f0;
  3255. background: #fff;
  3256. }
  3257. .tab-item {
  3258. flex: 1;
  3259. padding: 12px;
  3260. display: flex;
  3261. align-items: center;
  3262. justify-content: center;
  3263. gap: 8px;
  3264. cursor: pointer;
  3265. transition: all 0.3s;
  3266. border-bottom: 2px solid transparent;
  3267. color: rgba(0, 0, 0, 0.65);
  3268. }
  3269. .tab-item:hover {
  3270. color: #1677ff;
  3271. }
  3272. .tab-item.active {
  3273. color: #1677ff;
  3274. border-bottom-color: #1677ff;
  3275. background: #f6f9fe;
  3276. }
  3277. .panel-container {
  3278. height: calc(100% - 45px); /* 减去 tab 的高度 */
  3279. overflow-y: auto;
  3280. }
  3281. /* 修改右侧菜单内容样式 */
  3282. .right-menu-content {
  3283. height: 100%;
  3284. display: flex;
  3285. flex-direction: column;
  3286. }
  3287. /* 预览面板样式 */
  3288. .preview-header {
  3289. padding: 16px;
  3290. border-bottom: 1px solid #f0f0f0;
  3291. font-size: 16px;
  3292. font-weight: bold;
  3293. }
  3294. .search-toggles {
  3295. display: flex;
  3296. gap: 12px;
  3297. padding: 8px 12px;
  3298. background: rgba(0, 0, 0, 0.02);
  3299. border-radius: 8px;
  3300. margin-bottom: 8px;
  3301. transition: all 0.3s ease;
  3302. &.compact {
  3303. .search-toggle-item {
  3304. padding: 6px;
  3305. min-width: auto;
  3306. width: auto;
  3307. }
  3308. .toggle-content {
  3309. gap: 4px;
  3310. justify-content: center;
  3311. }
  3312. .toggle-text {
  3313. display: none;
  3314. }
  3315. .toggle-switch {
  3316. margin-left: 8px;
  3317. }
  3318. }
  3319. }
  3320. .search-toggle-item {
  3321. position: relative;
  3322. display: flex;
  3323. align-items: center;
  3324. background: #fff;
  3325. border-radius: 6px;
  3326. padding: 6px 12px;
  3327. transition: all 0.3s;
  3328. width: 140px;
  3329. @media screen and (max-width: 768px) {
  3330. width: auto;
  3331. padding: 6px 8px;
  3332. }
  3333. &:hover {
  3334. background: rgba(0, 0, 0, 0.02);
  3335. }
  3336. }
  3337. .toggle-content {
  3338. display: flex;
  3339. align-items: center;
  3340. gap: 8px;
  3341. color: rgba(0, 0, 0, 0.65);
  3342. transition: all 0.3s;
  3343. width: 100%;
  3344. .anticon {
  3345. font-size: 16px;
  3346. flex-shrink: 0;
  3347. }
  3348. .toggle-text {
  3349. font-size: 14px;
  3350. transition: all 0.3s;
  3351. white-space: nowrap;
  3352. color: #000000a6;
  3353. }
  3354. }
  3355. .toggle-switch {
  3356. position: relative;
  3357. display: flex;
  3358. align-items: center;
  3359. }
  3360. .toggle-input {
  3361. position: absolute;
  3362. opacity: 0;
  3363. width: 0;
  3364. height: 0;
  3365. &:checked + .toggle-label {
  3366. .toggle-slider {
  3367. background: #1677ff;
  3368. &:before {
  3369. transform: translateX(16px);
  3370. }
  3371. }
  3372. }
  3373. &:disabled + .toggle-label {
  3374. cursor: not-allowed;
  3375. .toggle-slider {
  3376. background: #d9d9d9;
  3377. &:before {
  3378. background: #f5f5f5;
  3379. }
  3380. }
  3381. }
  3382. }
  3383. .toggle-label {
  3384. display: flex;
  3385. align-items: center;
  3386. cursor: pointer;
  3387. .toggle-slider {
  3388. position: relative;
  3389. width: 36px;
  3390. height: 20px;
  3391. background: #d9d9d9;
  3392. border-radius: 10px;
  3393. transition: all 0.3s;
  3394. &:before {
  3395. content: '';
  3396. position: absolute;
  3397. top: 2px;
  3398. left: 2px;
  3399. width: 16px;
  3400. height: 16px;
  3401. background: white;
  3402. border-radius: 50%;
  3403. transition: transform 0.3s;
  3404. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  3405. }
  3406. }
  3407. &.disabled {
  3408. cursor: not-allowed;
  3409. }
  3410. }
  3411. /* 移动端适配 */
  3412. @media screen and (max-width: 480px) {
  3413. .search-toggles {
  3414. padding: 6px;
  3415. gap: 6px;
  3416. }
  3417. .search-toggle-item {
  3418. padding: 6px;
  3419. }
  3420. .toggle-content {
  3421. gap: 4px;
  3422. }
  3423. }
  3424. @media screen and (max-width: 768px) {
  3425. .search-toggles {
  3426. &:not(.compact) {
  3427. .search-toggle-item {
  3428. padding: 6px 8px;
  3429. }
  3430. .toggle-content {
  3431. gap: 4px;
  3432. }
  3433. .toggle-text {
  3434. font-size: 12px;
  3435. }
  3436. }
  3437. }
  3438. }
  3439. @media screen and (max-width: 480px) {
  3440. .search-toggles {
  3441. padding: 6px;
  3442. gap: 6px;
  3443. &:not(.compact) {
  3444. .toggle-text {
  3445. display: none;
  3446. }
  3447. .search-toggle-item {
  3448. padding: 6px;
  3449. }
  3450. }
  3451. }
  3452. }
  3453. /* 深色模式支持 */
  3454. @media (prefers-color-scheme: dark) {
  3455. .search-toggle-item {
  3456. background: rgba(255, 255, 255, 0.04);
  3457. &:hover {
  3458. background: rgba(255, 255, 255, 0.08);
  3459. }
  3460. }
  3461. .toggle-content {
  3462. color: rgba(255, 255, 255, 0.65);
  3463. }
  3464. .toggle-label {
  3465. .toggle-slider {
  3466. background: #424242;
  3467. &:before {
  3468. background: #8c8c8c;
  3469. }
  3470. }
  3471. }
  3472. .toggle-input:checked + .toggle-label {
  3473. .toggle-slider {
  3474. background: #1677ff;
  3475. &:before {
  3476. background: white;
  3477. }
  3478. }
  3479. }
  3480. .toggle-input:disabled + .toggle-label {
  3481. .toggle-slider {
  3482. background: #1f1f1f;
  3483. &:before {
  3484. background: #434343;
  3485. }
  3486. }
  3487. }
  3488. }
  3489. /* 修改右侧菜单面板样式 */
  3490. .right_menu {
  3491. position: fixed;
  3492. right: 0;
  3493. top: 0;
  3494. bottom: 0;
  3495. width: 450px;
  3496. background: #fff;
  3497. border-left: 1px solid rgba(0, 0, 0, 0.06);
  3498. display: flex;
  3499. flex-direction: column;
  3500. transition: transform 0.3s ease;
  3501. z-index: 998;
  3502. }
  3503. .right_menu.collapsed {
  3504. transform: translateX(100%);
  3505. }
  3506. .right-menu-content {
  3507. height: 100%;
  3508. display: flex;
  3509. flex-direction: column;
  3510. overflow: hidden;
  3511. }
  3512. /* Tab 样式调整 */
  3513. .right-menu-tabs {
  3514. display: flex;
  3515. background: #fff;
  3516. border-bottom: 1px solid #f0f0f0;
  3517. padding: 0;
  3518. height: 46px;
  3519. flex-shrink: 0;
  3520. }
  3521. .tab-item {
  3522. flex: 1;
  3523. display: flex;
  3524. align-items: center;
  3525. justify-content: center;
  3526. gap: 8px;
  3527. padding: 12px;
  3528. color: rgba(0, 0, 0, 0.65);
  3529. cursor: pointer;
  3530. transition: all 0.3s;
  3531. border-bottom: 2px solid transparent;
  3532. font-size: 14px;
  3533. }
  3534. .tab-item.active {
  3535. color: #1677ff;
  3536. border-bottom-color: #1677ff;
  3537. background: rgba(22, 119, 255, 0.04);
  3538. }
  3539. .tab-item:hover {
  3540. color: #1677ff;
  3541. }
  3542. /* 面板容器样式 */
  3543. .panel-container {
  3544. flex: 1;
  3545. overflow-y: auto;
  3546. background: #fff;
  3547. display: flex;
  3548. flex-direction: column;
  3549. }
  3550. /* 搜索头部样式 */
  3551. .search-header {
  3552. padding: 16px;
  3553. border-bottom: 1px solid #f0f0f0;
  3554. display: flex;
  3555. justify-content: space-between;
  3556. align-items: center;
  3557. background: #fff;
  3558. flex-shrink: 0;
  3559. }
  3560. .search-header span {
  3561. font-size: 16px;
  3562. font-weight: 500;
  3563. color: rgba(0, 0, 0, 0.88);
  3564. }
  3565. /* 知识库结果面板样式 */
  3566. .knowledge-results {
  3567. flex: 1;
  3568. padding: 16px;
  3569. overflow-y: auto;
  3570. }
  3571. /* 调整聊天区域的右边距 */
  3572. .chat {
  3573. transition: right 0.3s ease;
  3574. }
  3575. .right_menu:not(.collapsed) ~ .chat {
  3576. right: 450px;
  3577. }
  3578. /* 移动端适配 */
  3579. @media screen and (max-width: 768px) {
  3580. .right_menu {
  3581. width: 93%;
  3582. }
  3583. .right_menu:not(.collapsed) ~ .chat {
  3584. right: 100%;
  3585. }
  3586. .tab-item {
  3587. padding: 8px;
  3588. }
  3589. .tab-item .anticon {
  3590. font-size: 16px;
  3591. }
  3592. .tab-item span {
  3593. font-size: 12px;
  3594. }
  3595. .search-header {
  3596. padding: 12px;
  3597. }
  3598. .search-header span {
  3599. font-size: 14px;
  3600. }
  3601. }
  3602. /* 优化滚动条样式 */
  3603. .panel-container::-webkit-scrollbar {
  3604. width: 4px;
  3605. }
  3606. .panel-container::-webkit-scrollbar-thumb {
  3607. background: rgba(0, 0, 0, 0.1);
  3608. border-radius: 2px;
  3609. }
  3610. .panel-container::-webkit-scrollbar-track {
  3611. background: transparent;
  3612. }
  3613. /* 添加阴影效果 */
  3614. .right_menu {
  3615. box-shadow: -2px 0 8px rgba(0, 0, 0, 0.06);
  3616. }
  3617. /* 优化过渡动画 */
  3618. .right_menu,
  3619. .chat,
  3620. .tab-item,
  3621. .panel-container {
  3622. transition: all 0.3s ease;
  3623. }
  3624. /* 确保内容不会溢出 */
  3625. .right-menu-content {
  3626. max-height: 100%;
  3627. }
  3628. .panel-container {
  3629. max-height: calc(100% - 46px); /* 减去 tab 的高度 */
  3630. }
  3631. /* 菜单展开时的按钮样式 */
  3632. .collapse-button.menu-expanded {
  3633. left: -20px;
  3634. border-right: none;
  3635. border-radius: 4px 0 0 4px;
  3636. }
  3637. /* 菜单收起时的按钮样式 */
  3638. .collapse-button.menu-collapsed {
  3639. left: -20px;
  3640. border-left: none;
  3641. border-radius: 0 4px 4px 0;
  3642. }
  3643. /* 确保右侧菜单收起时按钮仍然可见 */
  3644. .right_menu.collapsed .collapse-button {
  3645. right: auto;
  3646. left: -20px;
  3647. }
  3648. /* 添加模型选择框样式 */
  3649. .model-select {
  3650. background: transparent;
  3651. border: 1px solid #d9d9d9;
  3652. border-radius: 4px;
  3653. padding: 4px 8px;
  3654. font-size: 14px;
  3655. color: rgba(0, 0, 0, 0.88);
  3656. cursor: pointer;
  3657. transition: all 0.3s;
  3658. outline: none;
  3659. margin-left: auto;
  3660. min-width: 120px;
  3661. &:hover {
  3662. border-color: #1677ff;
  3663. }
  3664. &:focus {
  3665. border-color: #1677ff;
  3666. box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
  3667. }
  3668. &:disabled {
  3669. background: #f5f5f5;
  3670. cursor: not-allowed;
  3671. color: rgba(0, 0, 0, 0.25);
  3672. }
  3673. option {
  3674. background: white;
  3675. color: rgba(0, 0, 0, 0.88);
  3676. }
  3677. }
  3678. @media screen and (max-width: 768px) {
  3679. .model-select {
  3680. min-width: 80px;
  3681. font-size: 12px;
  3682. padding: 2px 4px;
  3683. }
  3684. }
  3685. </style>
  3686. <style lang="less" scoped>
  3687. ::v-deep .message-content {
  3688. /* 确保 scoped 样式能够渗透到动态生成的内容 */
  3689. h1,
  3690. h2,
  3691. h3,
  3692. h4,
  3693. h5,
  3694. h6 {
  3695. margin-top: 16px;
  3696. margin-bottom: 8px;
  3697. font-weight: 600;
  3698. }
  3699. p {
  3700. margin-bottom: 8px;
  3701. }
  3702. code {
  3703. background: #f5f5f5;
  3704. padding: 2px 4px;
  3705. border-radius: 4px;
  3706. font-family: monospace;
  3707. }
  3708. pre {
  3709. background: #f5f5f5;
  3710. padding: 16px;
  3711. border-radius: 8px;
  3712. overflow-x: auto;
  3713. }
  3714. ul,
  3715. ol {
  3716. padding-left: 24px;
  3717. margin-bottom: 8px;
  3718. }
  3719. blockquote {
  3720. border-left: 4px solid #ddd;
  3721. padding-left: 16px;
  3722. margin: 8px 0;
  3723. color: rgba(0, 0, 0, 0.65);
  3724. }
  3725. a {
  3726. color: #1677ff;
  3727. text-decoration: none;
  3728. }
  3729. a:hover {
  3730. text-decoration: underline;
  3731. }
  3732. table {
  3733. border-collapse: collapse;
  3734. width: 100%;
  3735. margin-bottom: 16px;
  3736. }
  3737. th,
  3738. td {
  3739. border: 1px solid #ddd;
  3740. padding: 8px;
  3741. text-align: left;
  3742. }
  3743. th {
  3744. background: #f5f5f5;
  3745. }
  3746. }
  3747. .message-actions {
  3748. display: flex;
  3749. justify-content: flex-end;
  3750. margin-top: 8px;
  3751. padding-top: 8px;
  3752. border-top: 1px solid rgba(0, 0, 0, 0.06);
  3753. }
  3754. .message-actions :deep(.export-button) {
  3755. opacity: 0.6;
  3756. transition: opacity 0.2s;
  3757. }
  3758. .message-actions :deep(.export-button:hover) {
  3759. opacity: 1;
  3760. }
  3761. </style>