| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056 |
- <template>
- <div
- ref="recordRootRef"
- :style="recordRootStyle"
- :class="{ 'text-left': record.isAI, 'text-right': record.isUser, 'text-center': record.isTips }"
- >
- <transition name="slow-fade">
- <QuestionSource
- v-if="record.questionSource && record.questionSource.length"
- :questionFrom="record.questionSource"
- />
- </transition>
- <div
- v-if="businessScopeOutsideRow"
- ref="businessScopeOutsideRef"
- class="business-scope-content-outside"
- >
- <ScopeContent
- :content="businessScopeOutsideRow.content"
- :forcePending="isScopeForcePending"
- :exiting="businessScopeOutsideRow.exiting"
- scope-source="outside"
- @auto-exit="handleScopeAutoExit(businessScopeOutsideRow)"
- />
- </div>
- <Transition name="business-record-body-fade" appear>
- <div
- v-if="shouldRenderBusinessRecordBody"
- class="business-record-body"
- :style="businessRecordBodyStyle"
- :class="{
- 'is-scope-exiting': isScopeExitCompensating,
- 'is-scope-exit-transition-disabled': isScopeExitBodyTransitionDisabled,
- }"
- >
- <div
- v-if="showUserAttachments"
- class="ba-message-attachments"
- :class="{ desktop: !isMobileDevice }"
- >
- <div
- v-for="attachment in userAttachments"
- :key="attachment.id || attachment.url"
- class="ba-message-attachment"
- :class="{ 'is-image': attachment.isImage, 'is-file': !attachment.isImage }"
- >
- <ImageContent
- v-if="attachment.isImage && attachment.url"
- :image-urls="previewableUserAttachmentUrls"
- :preview-index="getUserAttachmentPreviewIndex(attachment)"
- :compact="true"
- :activeReveal="false"
- :showDownloadButton="false"
- />
- <template v-else>
- <div class="ba-message-attachment-icon">{{
- getAttachmentExtension(attachment.name)
- }}</div>
- <div class="ba-message-attachment-info">
- <div class="ba-message-attachment-name">{{ attachment.name }}</div>
- <div class="ba-message-attachment-size">{{
- formatAttachmentSize(attachment.size)
- }}</div>
- </div>
- </template>
- </div>
- </div>
- <div
- v-if="shouldRenderRecordLine"
- :class="{
- 'ba-record-me': record.isUser,
- 'ba-record-ai': record.isAI,
- 'is-loading': isBusinessLoading,
- 'is-interrupted': showInterruptedState,
- 'chat-record-tips': record.isTips,
- 'with-feedback-margin': true,
- 'with-feedback-margin-rated':
- localFeedback === FeedbackType.Like || localFeedback === FeedbackType.Dislike,
- 'full-mode': type == 'full',
- desktop: !isMobileDevice,
- }"
- class="chat-record-line record--business business-record"
- ref="elRef"
- >
- <div class="tips-title" v-if="record.isTips">
- <div class="tips-deco" />
- <div class="tips-deco mirror" />
- 温馨提示
- </div>
- <ReasoningWidget
- v-if="record.isAI && record.reasoningContent !== undefined"
- :reasoningContent="record.reasoningContent"
- :status="reasoningStatus"
- />
- <div class="content" :class="{ isTip: record.isTips }" ref="contentRef">
- <span v-if="showInterruptedState" class="request-interrupted-text">请求已取消</span>
- <DotsAnim v-else-if="showLoadingDots" />
- <template v-else>
- <template
- v-for="(row, index) in visibleInlineDisplayRecordRows"
- :key="row.id || index"
- >
- <TextContent
- :content="row.content"
- v-if="shouldRenderTextContentRow(row)"
- :instant="shouldRenderTextInstantly"
- :blockMarkdown="true"
- :activeTypewriter="shouldDriveTypewriter"
- :paused="false"
- :scopeExitCompensating="isScopeExitCompensating"
- :enableRevealFade="false"
- :initialMinWidth="scopeExitWidth"
- @typingFinished="handleTypingFinished(row.id)"
- @typingStateChange="handleTypingStateChange(row.id, $event)"
- />
- <FormContent :content="row.content" v-if="row.type === RecordRowTypes.Form" />
- <LinkURLContent :content="row.content" v-if="row.type === RecordRowTypes.LinkURL" />
- <ImageContent
- :content="row.content"
- v-if="row.type === RecordRowTypes.ImageContent"
- :activeReveal="shouldDriveTypewriter && !isImageRowFullyRevealed(row)"
- @revealFinished="handleImageRevealFinished(row.id)"
- @revealStateChange="handleImageRevealStateChange(row.id, $event)"
- />
- <OfficeURLContent
- :content="row.content"
- v-if="row.type === RecordRowTypes.OfficeURL"
- />
- <div
- v-if="row.type === RecordRowTypes.Scope"
- class="scope-content-shell"
- :ref="(el) => setScopeRowRef(row, el)"
- >
- <ScopeContent
- :content="row.content"
- :forcePending="isScopeForcePending"
- :exiting="row.exiting"
- scope-source="inline"
- @auto-exit="handleScopeAutoExit(row)"
- />
- </div>
- <PolicyMatch
- v-if="row.type === RecordRowTypes.PolicyTable"
- :policyContent="row.content"
- :recordMode="true"
- :sessionId="policyMatchSessionId"
- />
- <PolicyListUpdatedMatch
- v-if="row.type === RecordRowTypes.PolicyListUpdated"
- :content="row.content"
- :recordMode="true"
- :sessionId="policyMatchSessionId"
- />
- <QuestionCard
- v-if="row.type === RecordRowTypes.QuestionCards"
- :content="row.content"
- :recordMode="true"
- :sessionId="policyMatchSessionId"
- />
- <div
- v-if="row.type === RecordRowTypes.RefLinks && getRefLinkItems(row.content).length"
- class="ba-ref-links-summary"
- :class="{ desktop: !isMobileDevice }"
- >
- <div class="ba-ref-links-summary-title">参考资料</div>
- <div class="ba-ref-links-row">
- <div class="ba-ref-links-chip-list">
- <a
- v-for="(item, refIndex) in getRefLinkItems(row.content)"
- :key="`${item.title}-${refIndex}`"
- class="ba-ref-links-chip"
- :href="item.linkUrl"
- target="_blank"
- rel="noopener noreferrer"
- @click="handleRefLinkChipClick($event, item)"
- >
- <span class="ba-ref-links-chip-index">[{{ refIndex + 1 }}]</span>
- <span class="ba-ref-links-chip-title">{{
- item.title || item.type || "参考资料"
- }}</span>
- </a>
- </div>
- <button
- type="button"
- class="ba-ref-links-more"
- @click.stop="openRefLinksPanel(row.content)"
- >
- 更多
- </button>
- </div>
- </div>
- </template>
- <!-- media display holder -->
- <div
- class="media-row"
- :class="{ 'mt-1': visibleInlineDisplayRecordRows.length === 0 }"
- v-if="headMedia.type"
- >
- <div
- class="media-placeholder head-media"
- @click="
- (e) => {
- openPreview(headMedia, 0, e);
- }
- "
- >
- <img
- :src="headMedia.type === 'image' ? headMedia.url : headMedia.preview"
- @error="handleError"
- />
- <div v-if="headMedia.type === 'video'" class="play-button"></div>
- </div>
- </div>
- <div
- class="rest-media-wrapper"
- :class="{ 'pa-0': restMedia.length == 1 }"
- v-if="restMedia.length"
- >
- <div
- class="media-placeholder"
- :class="{
- several: restMedia.length > 1 && restMedia.length <= 4,
- multi: restMedia.length > 4,
- }"
- v-for="(each, index) in restMedia"
- :key="index"
- @click="
- (e) => {
- openPreview(each, index + 1, e);
- }
- "
- >
- <img
- :src="each.type === 'image' ? each.url : each.preview"
- @error="handleError"
- />
- <div v-if="each.type === 'video'" class="play-button"></div>
- </div>
- </div>
- <!-- media display holder end -->
- </template>
- </div>
- <div class="tips-wrap" v-if="record.isTips">
- <div class="tip" v-for="(item, index) in tips.tipItems" :key="index">
- <div class="title">
- <span class="order">{{ index + 1 }}</span> {{ item.title }}
- </div>
- <div class="content">{{ item.content }}</div>
- </div>
- <div class="tip-footer">{{ tips.tipFooter }}</div>
- </div>
- <BarAnim v-if="state === MessageState.Update" />
- <transition name="slow-fade">
- <References
- v-if="showReferences && record.references && record.references.length"
- :questions="record.references"
- />
- </transition>
- <transition name="slow-fade">
- <RelatedQuestions
- v-if="
- showRelatedQuestions && record.relatedQuestions && record.relatedQuestions.length
- "
- :questions="record.relatedQuestions"
- />
- </transition>
- <div v-if="showSessionReadableLogButton" class="session-readable-log-row">
- <button type="button" class="session-readable-log-btn" @click="openSessionReadableLog">
- 打开日志
- </button>
- </div>
- </div>
- <transition name="slow-fade">
- <FeedbackWidget
- v-if="shouldRenderFeedback"
- :id="record.id"
- :feedback="localFeedback"
- :content="copyableContent"
- @change="handleFeedbackChange"
- />
- </transition>
- </div>
- </Transition>
- </div>
- <Teleport to="body">
- <div v-if="refLinksPanelVisible" class="ref-links-viewer-modal">
- <transition name="ref-links-panel">
- <div v-if="refLinksPanelVisible" class="ref-links-viewer-content">
- <div class="ref-links-viewer-header">
- <div class="ref-links-viewer-title">参考资料</div>
- <button type="button" class="ref-links-viewer-close" @click.stop="closeRefLinksPanel">
- <svg
- width="14"
- height="14"
- viewBox="0 0 14 14"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M1 1L13 13M13 1L1 13"
- stroke="currentColor"
- stroke-width="1.5"
- stroke-linecap="round"
- stroke-linejoin="round"
- />
- </svg>
- </button>
- </div>
- <div class="ref-links-viewer-list">
- <div
- v-for="(item, index) in activeRefLinks"
- :key="`${item.title}-${index}`"
- class="ref-links-card"
- >
- <div class="ref-links-card-head">
- <div class="ref-links-card-title">{{ item.title || "参考资料" }}</div>
- <div v-if="item.type" class="ref-links-card-tag">{{ item.type }}</div>
- </div>
- <!-- 来源元信息:发布机构 / 发布或更新时间(见接口文档 §9 source 统一字段) -->
- <div v-if="getRefLinkMeta(item)" class="ref-links-card-content">
- {{ getRefLinkMeta(item) }}
- </div>
- <div v-if="item.content" class="ref-links-card-content">{{ item.content }}</div>
- <a
- v-if="item.linkUrl"
- class="ref-links-card-link"
- :href="item.linkUrl"
- target="_blank"
- rel="noopener noreferrer"
- >
- 查看详情
- <svg
- width="12"
- height="12"
- viewBox="0 0 12 12"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M1.33333 12C0.966667 12 0.652778 11.8694 0.391667 11.6083C0.130556 11.3472 0 11.0333 0 10.6667V1.33333C0 0.966667 0.130556 0.652778 0.391667 0.391667C0.652778 0.130556 0.966667 0 1.33333 0H6V1.33333H1.33333V10.6667H10.6667V6H12V10.6667C12 11.0333 11.8694 11.3472 11.6083 11.6083C11.3472 11.8694 11.0333 12 10.6667 12H1.33333ZM4.46667 8.46667L3.53333 7.53333L9.73333 1.33333H7.33333V0H12V4.66667H10.6667V2.26667L4.46667 8.46667Z"
- fill="#3525CD"
- />
- </svg>
- </a>
- </div>
- </div>
- </div>
- </transition>
- </div>
- </Teleport>
- <DislikeDialog v-model:visible="showDislikeDialog" @confirm="handleDislikeConfirm" />
- <Toast :message="toastMessage" />
- </template>
- <script setup lang="ts">
- import {
- computed,
- inject,
- onBeforeUnmount,
- onMounted,
- nextTick,
- provide,
- ref,
- watch,
- getCurrentInstance,
- } from "vue";
- import { MessageState } from "../stream-message-coordinator";
- import { FeedbackType, From } from "@/types/record";
- import { writeDmsFeedback } from "@/network/api/dms/chat-sessions-dms";
- import DotsAnim from "../Common/DotsAnim.vue";
- import BarAnim from "../Common/BarAnim.vue";
- import FeedbackWidget from "../Common/FeedbackWidget.vue";
- import DislikeDialog from "../Common/DislikeDialog.vue";
- import Toast from "../Common/Toast.vue";
- import QuestionSource from "../Common/QuestionSourceWidget.vue";
- import defaultImage from "@/assets/img_break.svg";
- import { computedOriginContentPosition, getQueryObj, sleep } from "../utils";
- import { isMobile } from "@/utils";
- import ReasoningWidget from "../Common/ReasoningWidget.vue";
- import RelatedQuestions from "../Common/RelatedQuestionsWidget.vue";
- import References from "../Common/References.vue";
- import TextContent from "./TextContent.vue";
- import FormContent from "./FormContent.vue";
- import LinkURLContent from "./LinkURLContent.vue";
- import ImageContent from "./ImageContent.vue";
- import OfficeURLContent from "./OfficeURLContent.vue";
- import ScopeContent from "./ScopeContent.vue";
- import PolicyMatch from "./PolicyMatch.vue";
- import PolicyListUpdatedMatch from "./PolicyListUpdatedMatch.vue";
- import QuestionCard from "./QuestionCard.vue";
- import {
- parseRefLinksContent,
- RecordRowTypes,
- StreamXMLFilter,
- type RefLinkItem,
- } from "@/utils/stream-xml-filter";
- import { jsonrepair } from "jsonrepair";
- import { isInterruptedEmptyScopeMessage } from "@/utils/interrupted-message";
- import {
- splitStreamingTextContentRows,
- trimDisplayTextContentEnd,
- trimDisplayTextContentStart,
- } from "./text-content-utils";
- import {
- isEmptyScopeRow,
- isRemovableEmptyScopeStatusRow,
- isRemovableScopePreludeTextRow,
- mergeScopeRecordRow,
- resolveBusinessScopeOutsideRow,
- shouldForcePendingScope,
- } from "@/utils/scope-record-rows";
- import { createModalMutex, MODAL_MUTEX_KEY } from "../business-assistant/modal-mutex";
- enum RecordRowStates {
- Pending = "pending",
- Displaying = "displaying",
- Displayed = "displayed",
- }
- // 定义 displayRecordRow 类型
- type DisplayRecordRow = {
- id: number;
- type: RecordRowTypes;
- state: RecordRowStates;
- content: string;
- [key: string]: any;
- };
- interface Props {
- aspect?: string;
- record?: any;
- content?: string;
- options?: { option: string }[];
- theme?: any;
- state?: MessageState | string | number;
- rect?: {
- top: number;
- height: number;
- };
- type?: string;
- human?: any;
- isLastRecord?: boolean;
- sessionViewedBefore?: boolean;
- sessionId?: string;
- enableFeedback?: boolean;
- }
- const props = withDefaults(defineProps<Props>(), {
- aspect: "16/9",
- rect: () => ({
- top: 0,
- height: 0,
- }),
- type: "default",
- });
- const emit = defineEmits([
- "changeIdleState",
- "feedback",
- "displayContentChange",
- "displayMediaChange",
- "refreshScroll",
- "scopeExitStateChange",
- "scopeHeightLockChange",
- "typewriterStateChange",
- ]);
- const policyMatchSessionId = computed(
- () => props.record?.session || props.sessionId || globalThis.currentSession || ""
- );
- const recordRootRef = ref<HTMLElement | null>(null);
- const businessScopeOutsideRef = ref<HTMLElement | null>(null);
- const textAnimWrapper = ref();
- const showTextAnim = ref(false);
- const localFeedback = ref<FeedbackType>(FeedbackType.None);
- const showDislikeDialog = ref(false);
- const toastMessage = ref("");
- let pendingDislikeRecordId: string | number | null = null;
- let toastTimer: ReturnType<typeof setTimeout> | undefined;
- const isFormQueryMode = getQueryObj("mode") === "form";
- const showRelatedQuestions = ref(false);
- const showReferences = ref(false);
- const refLinksPanelVisible = ref(false);
- const activeRefLinks = ref<RefLinkItem[]>([]);
- // 互斥面板管理
- const businessRecordInstanceId = `BR-${Math.random().toString(36).slice(2, 7)}`;
- const refLinksModalId = Symbol(`${businessRecordInstanceId}:ref-links`);
- const modalMutex = inject(MODAL_MUTEX_KEY, null) ?? createModalMutex();
- provide(MODAL_MUTEX_KEY, modalMutex);
- let unregisterRefLinksModal: (() => void) | undefined;
- function showToast(message: string) {
- toastMessage.value = message;
- if (toastTimer) clearTimeout(toastTimer);
- toastTimer = setTimeout(() => {
- toastMessage.value = "";
- }, 3000);
- }
- function openDislikeDialog(recordId: string | number) {
- pendingDislikeRecordId = recordId;
- showDislikeDialog.value = true;
- }
- // 反馈写入 DMS 的问答记录(栏目 1889 的 c_feedback_*),按 c_record_id 定位那一行。
- // recordId 就是 AI 消息 id,与写入时的 c_record_id 是同一个值(见 chat-sessions-dms.ts)
- function submitLikeFeedback(recordId: string | number) {
- void writeDmsFeedback({
- recordId: String(recordId),
- sessionId: policyMatchSessionId.value,
- status: FeedbackType.Like,
- });
- }
- function cancelFeedback(recordId: string | number) {
- void writeDmsFeedback({
- recordId: String(recordId),
- sessionId: policyMatchSessionId.value,
- status: FeedbackType.None,
- });
- }
- function handleDislikeConfirm(option: string, remark: string) {
- if (pendingDislikeRecordId === null) return;
- void writeDmsFeedback({
- recordId: String(pendingDislikeRecordId),
- sessionId: policyMatchSessionId.value,
- status: FeedbackType.Dislike,
- option,
- remark,
- });
- localFeedback.value = FeedbackType.Dislike;
- pendingDislikeRecordId = null;
- }
- provide("feedbackControl", { openDislikeDialog, submitLikeFeedback, cancelFeedback });
- provide("dislikeDialogControl", { openDislikeDialog });
- provide("toastControl", { showToast });
- const { setFormOptions } = inject("formOptionsControl") as any;
- const instance = getCurrentInstance();
- const $mediaViewer = instance?.proxy?.$mediaViewer as any;
- const record = computed(() => {
- let _record = props.record;
- if (!_record) return {};
- _record.isUser = _record.role === "user" || _record.from === From.User;
- _record.isAI = _record.role === "ai" || _record.from === From.AI;
- _record.isTips = _record.from === From.Tips;
- return _record;
- });
- const xmlFilter = new StreamXMLFilter({
- customProcessor: new Map([
- [
- RecordRowTypes.UIForm,
- (payload: { schema: string; attrs: Record<string, string> }) => {
- setFormOptions({
- visible: true,
- enable: true,
- mode: "form",
- schema: JSON.parse(jsonrepair(payload.schema)) || [],
- title: payload.attrs.title,
- });
- },
- ],
- ]),
- });
- const { stopSpeech, handleEndSpeech } = inject("speechControl") as any;
- let isEffectHumanState: any;
- const mediaList = computed(() => props.record?.mediaList);
- const userAttachments = computed(() => (record.value.isUser ? record.value.attachments || [] : []));
- const previewableUserAttachmentUrls = computed(() =>
- userAttachments.value
- .filter((attachment) => attachment.isImage && attachment.url)
- .map((attachment) => String(attachment.url || "").trim())
- .filter(Boolean)
- );
- const showUserAttachments = computed(() => userAttachments.value.length > 0);
- const displayMediaList = ref<any[]>([]);
- const isMobileDevice = isMobile();
- enum SchedulerTaskState {
- Idle = "idle",
- }
- const getRefLinkItems = (content: string) => parseRefLinksContent(content);
- // 复制按钮只应复制可读正文:去掉 <scope>、<!-- POLICY_TABLE -->、<ref_links>、
- // <question-cards>、<image-scope>(企业微信二维码)等协议标记,
- // 避免复制出一大段 JSON 或图片地址。
- //
- // 注意不能用 getStreamPlainText():它对整段内容做一次性解析,而过滤器在遇到
- // <!-- POLICY_TABLE 时会把同批 buffer 里位于它之前的内容直接当纯文本输出,
- // 导致 scope 标记被当成正文保留下来。这里直接剥离标记,结果与内容分片方式无关。
- const copyableContent = computed(() => {
- const raw = String(record.value.content || props.content || "");
- return raw
- .replace(/<scope\b[^>]*>[\s\S]*?<\/scope>\s*/gi, "")
- .replace(/<ref_links\b[^>]*>[\s\S]*?<\/ref_links>\s*/gi, "")
- .replace(/<question-cards\b[^>]*>[\s\S]*?<\/question-cards>\s*/gi, "")
- .replace(/<image-scope\b[^>]*>[\s\S]*?<\/image-scope>\s*/gi, "")
- .replace(/<!--\s*POLICY_TABLE[\s\S]*?POLICY_TABLE\s*-->\s*/gi, "")
- .replace(/<\/?silence\b[^>]*>/gi, "")
- .replace(/<\/?scope\b[^>]*>/gi, "")
- .replace(/\n{3,}/g, "\n\n")
- .trim();
- });
- // 参考资料卡片的元信息行:发布机构 + 发布/更新时间。
- // 字段来自接口文档 §9「原始 source 对象中的统一字段」,经 originalData 透传。
- const getRefLinkMeta = (item: any) => {
- const data = item?.originalData || {};
- const parts: string[] = [];
- if (data.publisher) {
- parts.push(String(data.publisher));
- }
- const published = data.published_text || data.updated_text;
- if (published) {
- parts.push(/^\d{8}$/.test(String(published))
- ? `${String(published).replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3")} 更新`
- : String(published));
- }
- return parts.join(" · ");
- };
- const handleRefLinkChipClick = (event: MouseEvent, item: RefLinkItem) => {
- if (item.linkUrl) {
- return;
- }
- event.preventDefault();
- };
- const openRefLinksPanel = async (content: string) => {
- const items = getRefLinkItems(content);
- if (!items.length) {
- return;
- }
- const openTicket = modalMutex.requestOpen(refLinksModalId);
- await nextTick();
- if (!modalMutex.isCurrentRequest(refLinksModalId, openTicket)) return;
- activeRefLinks.value = items;
- refLinksPanelVisible.value = true;
- emitRefLinksPanelWidth();
- };
- const closeRefLinksPanel = () => {
- refLinksPanelVisible.value = false;
- modalMutex.release(refLinksModalId);
- emitRefLinksPanelWidth();
- };
- const emitRefLinksPanelWidth = () => {
- document.dispatchEvent(
- new CustomEvent("refLinksPanelWidthChange", {
- detail: { width: refLinksPanelVisible.value ? 480 : 0 },
- })
- );
- };
- watch(
- () => mediaList.value,
- (val) => {
- if (!val || val.length === 0 || timer) {
- return;
- }
- displayMediaList.value = val;
- }
- );
- const headMedia = computed(() => {
- if (!displayMediaList.value || displayMediaList.value.length === 0) {
- return {};
- }
- return displayMediaList.value[0];
- });
- const restMedia = computed(() => {
- if (!displayMediaList.value || displayMediaList.value.length === 0) {
- return [];
- }
- return displayMediaList.value.slice(1);
- });
- const getAttachmentExtension = (name: string) => name.split(".").pop()?.toUpperCase() || "FILE";
- const formatAttachmentSize = (size: number) => {
- if (!Number.isFinite(size) || size <= 0) {
- return "";
- }
- if (size >= 1024 * 1024) {
- return `${(size / 1024 / 1024).toFixed(2)} MB`;
- }
- return `${Math.max(1, Math.round(size / 1024))} KB`;
- };
- const reasoningStatus = computed(() => {
- let status = "";
- if (
- (record.value.state === MessageState.Sending || record.value.state === MessageState.Success) &&
- !record.value.content
- ) {
- status = "thinking";
- } else {
- status = "certain";
- }
- return status;
- });
- const showInterruptedState = computed(() =>
- isInterruptedEmptyScopeMessage({
- ...record.value,
- state: props.state ?? record.value.state,
- })
- );
- const displayContent = ref("");
- const originContent = ref(props.content || "");
- const count = ref(0);
- const mediaCount = ref(0);
- const hasVisibleAnswerContent = ref(false);
- const textRowTypingFinished = ref<Record<number, boolean>>({});
- const textRowTypingActive = ref<Record<number, boolean>>({});
- const imageRowRevealFinished = ref<Record<number, boolean>>({});
- const imageRowRevealActive = ref<Record<number, boolean>>({});
- // displayRecordRows 类型增强
- const displayRecordRows = ref<DisplayRecordRow[]>([]);
- const updateRecordRowIndex = ref(0);
- const activeRecordState = computed(() => props.state ?? record.value.state);
- const isForcePendingState = computed(
- () =>
- String(activeRecordState.value || "")
- .trim()
- .toLowerCase() === "forcepending"
- );
- const hasRecordTextContent = computed(
- () => String(record.value.content || props.content || "").trim().length > 0
- );
- const shouldRenderTextInstantly = computed(() => !record.value.isAI || !!record.value.history);
- const canAnimateAiText = computed(
- () =>
- record.value.isAI &&
- !record.value.history &&
- !!props.isLastRecord &&
- activeRecordState.value !== MessageState.Stop
- );
- const isScopeForcePending = computed(() =>
- shouldForcePendingScope(
- activeRecordState.value,
- hasVisibleAnswerContent.value,
- MessageState.Finish,
- MessageState.Stop
- )
- );
- const isBusinessLoading = computed(() => {
- return (
- record.value.isAI &&
- isForcePendingState.value &&
- !hasRecordTextContent.value &&
- !hasVisibleAnswerContent.value
- );
- });
- const showLoadingDots = computed(() => {
- const hasNoDisplayedContent =
- displayRecordRows.value.length === 0 &&
- !showTextAnim.value &&
- displayMediaList.value.length === 0;
- return hasNoDisplayedContent && isBusinessLoading.value;
- });
- let timer: any;
- let mediaTimer: any;
- let lastRecordResizeObserver: ResizeObserver | null = null;
- let lastObservedRecordHeight = 0;
- const gapTime = 30;
- const scopeExitFadeDurationMs = 300;
- const scopeExitCollapseDurationMs = scopeExitFadeDurationMs;
- let scopeExitTimer: number | null = null;
- let scopeExitRevision = 0;
- const scopeExitDebugStartedAt = performance.now();
- const scopeRowElementMap = new WeakMap<DisplayRecordRow, HTMLElement>();
- const recordHeightLock = ref<number | null>(null);
- const scopeExitHeight = ref(0);
- const scopeExitWidth = ref(0);
- const isScopeExitCompensating = computed(() => scopeExitHeight.value > 0);
- const isScopeExitBodyTransitionDisabled = ref(false);
- const isLastAiStreamingRecord = computed(
- () =>
- props.isLastRecord &&
- record.value.isAI &&
- activeRecordState.value !== MessageState.Finish &&
- activeRecordState.value !== MessageState.Stop
- );
- const scopeExitBodyGapPx = 8;
- const businessRecordBodyStyle = computed(() => ({
- "--scope-exit-offset": `${scopeExitHeight.value + (isScopeExitCompensating.value ? scopeExitBodyGapPx : 0)}px`,
- }));
- const recordRootStyle = computed(() => ({
- width: "100%",
- minHeight: recordHeightLock.value !== null ? `${recordHeightLock.value}px` : undefined,
- overflow: recordHeightLock.value !== null ? "hidden" : undefined,
- }));
- let changeFlag = 1;
- const customFormType = ref("");
- const businessScopeOutsideRow = computed(() => {
- const scopeRow = resolveBusinessScopeOutsideRow({
- variant: "business",
- record: record.value,
- displayRecordRows: displayRecordRows.value,
- hasVisibleAnswerContent: hasVisibleAnswerContent.value,
- activeRecordState: activeRecordState.value,
- finishState: MessageState.Finish,
- stopState: MessageState.Stop,
- allowFallbackPendingScope: !record.value.history,
- });
- if (
- scopeRow &&
- scopeRow.type === RecordRowTypes.Scope &&
- !scopeRow.exiting &&
- (activeRecordState.value === MessageState.Finish ||
- activeRecordState.value === MessageState.Stop)
- ) {
- return null;
- }
- if (record.value.history && hasHistoricalNonScopeContent.value) {
- return null;
- }
- return scopeRow;
- });
- const isOutsideScopeExiting = computed(() => Boolean(businessScopeOutsideRow.value?.exiting));
- const shouldRenderBusinessRecordBody = computed(() => true);
- const handleScopeAutoExit = (scopeRow: DisplayRecordRow | null) => {
- beginScopeExit(scopeRow);
- };
- const hasPolicyTableRow = computed(() =>
- displayRecordRows.value.some(
- (row) =>
- row.type === RecordRowTypes.PolicyTable || row.type === RecordRowTypes.PolicyListUpdated
- )
- );
- const hasHistoricalNonScopeContent = computed(() => {
- if (!record.value.history) {
- return false;
- }
- const rawContent = String(record.value.content || props.content || "");
- const contentWithoutScopes = rawContent
- .replace(/<\/?silence\b[^>]*>/gi, "")
- .replace(/<scope\b[^>]*>[\s\S]*?<\/scope>/gi, "");
- return contentWithoutScopes.trim().length > 0;
- });
- const hasRenderableNonScopeContent = computed(
- () =>
- hasHistoricalNonScopeContent.value ||
- hasInlineRenderableContent.value ||
- showLoadingDots.value ||
- showInterruptedState.value ||
- !!headMedia.value.type ||
- restMedia.value.length > 0 ||
- record.value.isTips ||
- activeRecordState.value === MessageState.Update ||
- showReferences.value ||
- showRelatedQuestions.value ||
- hasPolicyTableRow.value
- );
- const shouldRenderScopeRow = (row: DisplayRecordRow | null | undefined) => {
- if (!row || row.type !== RecordRowTypes.Scope) {
- return false;
- }
- if (record.value.history && hasRenderableNonScopeContent.value) {
- return false;
- }
- if (
- isEmptyScopeRow(row) &&
- (activeRecordState.value === MessageState.Finish ||
- activeRecordState.value === MessageState.Stop) &&
- !row.exiting
- ) {
- return false;
- }
- return (
- row.exiting ||
- (activeRecordState.value !== MessageState.Finish &&
- activeRecordState.value !== MessageState.Stop)
- );
- };
- const shouldRenderTextContentRow = (row: DisplayRecordRow) =>
- row.type === RecordRowTypes.Text && !isScopeExitCompensating.value;
- const visibleDisplayRecordRows = computed(() =>
- displayRecordRows.value.filter(
- (row) => row.type !== RecordRowTypes.Scope || shouldRenderScopeRow(row)
- )
- );
- const inlineDisplayRecordRows = computed(() => {
- const outsideRow = businessScopeOutsideRow.value;
- if (!outsideRow) {
- return visibleDisplayRecordRows.value;
- }
- return visibleDisplayRecordRows.value.filter((row) => row !== outsideRow);
- });
- const isTextRowFullyCompleted = (row: DisplayRecordRow) =>
- // 文本行完成条件只认打字机动画结束事件(textRowTypingFinished[row.id])。
- // 不能依赖 row.state === Displayed:段落边界(breakAfter)会把上一行提前标记为
- // Displayed,但此时打字机可能还没播完最后几个字,会导致下一行提前开始渲染。
- row.type !== RecordRowTypes.Text || textRowTypingFinished.value[row.id] === true;
- const isImageRowFullyRevealed = (row: DisplayRecordRow) =>
- row.type !== RecordRowTypes.ImageContent || imageRowRevealFinished.value[row.id];
- const hasUnfinishedRevealRows = computed(() =>
- inlineDisplayRecordRows.value.some(
- (row) =>
- (row.type === RecordRowTypes.Text && !isTextRowFullyCompleted(row)) ||
- (row.type === RecordRowTypes.ImageContent && !isImageRowFullyRevealed(row))
- )
- );
- const shouldDriveTypewriter = computed(
- () =>
- canAnimateAiText.value &&
- // F073:正文本身是真实增量流式到达的,再逐字重放等于凭空多等一遍 —— 关掉打字机
- // (TextContent 的 `instant || !activeTypewriter` 分支会转成即时渲染)
- !record.value.contentStreaming &&
- (activeRecordState.value !== MessageState.Finish || hasUnfinishedRevealRows.value)
- );
- const isSessionReadableLogButtonEnabled =
- import.meta.env.MODE === "production" || import.meta.env.MODE === "development";
- const showSessionReadableLogButton = computed(
- () =>
- isSessionReadableLogButtonEnabled &&
- globalThis.policyMode !== "zhaoshang" &&
- record.value.isAI &&
- activeRecordState.value === MessageState.Finish
- );
- const shouldWaitForTypewriterCompletion = computed(
- () => canAnimateAiText.value && hasUnfinishedRevealRows.value
- );
- // 反馈组件显示策略:
- // - 非 AI 消息:永不显示
- // - 已评价(赞/踩/未选中):始终显示
- // - 历史会话(sessionViewedBefore)的 AI 消息:始终显示(不需要等动画)
- // - 新消息:等 SSE 流结束 + 打字机/媒体动画都结束才显示
- const shouldRenderFeedback = computed(() => {
- if (!record.value.isAI) return false;
- if (localFeedback.value !== FeedbackType.None) return true;
- if (props.sessionViewedBefore) return true;
- if (activeRecordState.value !== MessageState.Finish) return false;
- // 打字机 / 图片 reveal 还没结束:不显示
- if (shouldWaitForTypewriterCompletion.value) return false;
- // 媒体列表(图片/视频)还在渐进式加载:不显示
- if ((mediaList.value?.length || 0) > displayMediaList.value.length) return false;
- return true;
- });
- const emitTypewriterStateChange = (isTypingActive: boolean) => {
- console.log("[BusinessRecord][typewriter-state]", {
- recordId: record.value.id,
- isLastRecord: props.isLastRecord,
- isAI: record.value.isAI,
- isTypingActive,
- textRowTypingActive: { ...textRowTypingActive.value },
- imageRowRevealActive: { ...imageRowRevealActive.value },
- });
- emit("typewriterStateChange", {
- recordId: record.value.id,
- isTypingActive,
- });
- };
- const syncTypewriterState = () => {
- const isTypingActive = Boolean(
- props.isLastRecord &&
- record.value.isAI &&
- (Object.values(textRowTypingActive.value).some(Boolean) ||
- Object.values(imageRowRevealActive.value).some(Boolean))
- );
- console.log("[BusinessRecord][typewriter-sync]", {
- recordId: record.value.id,
- isLastRecord: props.isLastRecord,
- isAI: record.value.isAI,
- isTypingActive,
- });
- emitTypewriterStateChange(isTypingActive);
- };
- const visibleInlineDisplayRecordRows = computed(() => {
- if (!shouldDriveTypewriter.value && !hasUnfinishedRevealRows.value) {
- return inlineDisplayRecordRows.value;
- }
- const visibleRows: DisplayRecordRow[] = [];
- let revealBlocked = false;
- for (const row of inlineDisplayRecordRows.value) {
- if (revealBlocked) {
- continue;
- }
- if (row.type === RecordRowTypes.Text) {
- visibleRows.push(row);
- if (!isTextRowFullyCompleted(row)) {
- revealBlocked = true;
- }
- continue;
- }
- visibleRows.push(row);
- if (row.type === RecordRowTypes.ImageContent && !isImageRowFullyRevealed(row)) {
- revealBlocked = true;
- }
- }
- return visibleRows;
- });
- const hasInlineRenderableContent = computed(() =>
- inlineDisplayRecordRows.value.some((row) => {
- if (row.type === RecordRowTypes.Text) {
- return String(row.content || "").trim().length > 0;
- }
- return row.type !== RecordRowTypes.Scope && !!row.content;
- })
- );
- const shouldRenderRecordLine = computed(() => {
- if (showInterruptedState.value) {
- return true;
- }
- if (
- record.value.isAI &&
- !hasInlineRenderableContent.value &&
- !businessScopeOutsideRow.value &&
- !hasPolicyTableRow.value
- ) {
- return false;
- }
- if (!businessScopeOutsideRow.value) {
- return true;
- }
- return (
- inlineDisplayRecordRows.value.length > 0 ||
- showLoadingDots.value ||
- showInterruptedState.value ||
- !!headMedia.value.type ||
- restMedia.value.length > 0 ||
- record.value.isTips ||
- activeRecordState.value === MessageState.Update ||
- showReferences.value ||
- showRelatedQuestions.value
- );
- });
- const tips = ref({
- tipItems: [
- {
- title: "携带资料",
- content: "就诊前请准备好身份证件、就诊卡(如有)、以往的病历、检查报告和正在使用的药物清单。",
- },
- {
- title: "体格检查",
- content: "请您明天穿着宽松舒适、无金属的衣物,以便进行体格检查。",
- },
- {
- title: "陪同人员",
- content: "建议您有家人或朋友陪同前来,以确保检查过程的便利和舒适。",
- },
- ],
- tipFooter: "如果您有任何紧急情况或疑问,请联系我们0592-5050505(科室导诊台电话)",
- });
- const clearExistingTimer = () => {
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
- };
- const stripSilenceTags = (input: string) => {
- return String(input || "").replace(/<\/?silence\b[^>]*>/gi, "");
- };
- const processTextSections = (input: string) => {
- recordParser(input);
- };
- const isQuestionAnswersContent = (content: string) => {
- const trimmed = String(content || "").trim();
- if (!trimmed.startsWith("{")) {
- return false;
- }
- try {
- const parsed = JSON.parse(trimmed);
- return !!parsed && Array.isArray(parsed.answers);
- } catch {
- return false;
- }
- };
- const processRecordSections = (input: string) => {
- input = String(input || "");
- if (!input) {
- return;
- }
- if (record.value.isUser && isQuestionAnswersContent(input)) {
- updateLastRecordRow(input, RecordRowTypes.QuestionCards, RecordRowStates.Displayed);
- return;
- }
- const policyStartToken = "<!-- POLICY_TABLE";
- const policyEndToken = "POLICY_TABLE -->";
- let rest = input;
- while (rest.length > 0) {
- const policyStart = rest.indexOf(policyStartToken);
- if (policyStart === -1) {
- processTextSections(rest);
- return;
- }
- const normalText = rest.slice(0, policyStart);
- if (normalText) {
- processTextSections(normalText);
- }
- const policyEnd = rest.indexOf(policyEndToken, policyStart);
- if (policyEnd === -1) {
- recordParser(rest.slice(policyStart));
- return;
- }
- recordParser(rest.slice(policyStart, policyEnd + policyEndToken.length));
- rest = rest.slice(policyEnd + policyEndToken.length);
- }
- };
- /**
- * 诊断(仅非生产):**已经显示过的内容**被改小或被删掉时打一行。
- *
- * 为什么只盯这两种:用户报的「一小段重新渲染」在渲染层只可能来自两类操作 ——
- * ① 整条消息被重置重解析(已有 `[record] 内容被整块重写` 那行)
- * ② 某一行**已经显示过**的内容被改写 / 被删除(就是这里)
- * 纯追加(流式增长)不会重渲任何已有内容,所以完全不必打点(打了每帧都会刷屏)。
- */
- const debugRowMutation = (
- what: string,
- row: DisplayRecordRow | undefined,
- before: string,
- after: string
- ) => {
- if (import.meta.env.MODE === "production") {
- return;
- }
- console.warn(`[record] ${what}`, {
- rowId: row?.id,
- type: row?.type,
- before: String(before ?? "").length,
- after: String(after ?? "").length,
- head: String(before ?? "").slice(0, 40),
- });
- };
- /**
- * 关闭一行文本:去掉尾部空白,并在**真的变短**时打一行诊断
- * —— 变短意味着这一行已经显示过的内容被改写,会重渲(纯追加不会)。
- */
- const closeTextRow = (row: DisplayRecordRow) => {
- const before = row.content;
- const after = trimDisplayTextContentEnd(before);
- if (after !== before) {
- debugRowMutation("行内容被回缩(关闭行时去尾空白)", row, before, after);
- }
- row.content = after;
- };
- const resetDisplayContent = () => {
- if (textAnimWrapper.value) {
- textAnimWrapper.value.innerHTML = "";
- }
- displayContent.value = "";
- displayRecordRows.value = [];
- textRowTypingFinished.value = {};
- textRowTypingActive.value = {};
- imageRowRevealFinished.value = {};
- imageRowRevealActive.value = {};
- hasVisibleAnswerContent.value = false;
- // ⚠️ scope 退场补偿态也要清:`isScopeExitCompensating` 为真时**正文行是隐藏的**
- // (见 shouldRenderTextContentRow),残留会让重写后的正文整段不显示
- clearScopeExitTimer();
- scopeExitHeight.value = 0;
- scopeExitWidth.value = 0;
- recordHeightLock.value = null;
- count.value = 0;
- };
- const clearScopeExitTimer = () => {
- if (scopeExitTimer === null) {
- return;
- }
- window.clearTimeout(scopeExitTimer);
- scopeExitTimer = null;
- };
- const getScopeExitSource = (scopeRow: DisplayRecordRow) =>
- scopeRow === businessScopeOutsideRow.value ? "outside" : "inline";
- const getScopeRowElement = (scopeRow: DisplayRecordRow | null) => {
- if (!scopeRow) {
- return null;
- }
- if (scopeRow === businessScopeOutsideRow.value) {
- return businessScopeOutsideRef.value;
- }
- return scopeRowElementMap.get(scopeRow) || null;
- };
- const getScopeContentWidth = (scopeEl: HTMLElement | null) => {
- const scopeContentEl = scopeEl?.querySelector<HTMLElement>(".scope-content-wrap") || scopeEl;
- const width = scopeContentEl ? Math.ceil(scopeContentEl.getBoundingClientRect().width) : 0;
- return Number.isFinite(width) && width > 0 ? width : 0;
- };
- const setScopeRowRef = (scopeRow: DisplayRecordRow, el: HTMLElement | null) => {
- if (el) {
- scopeRowElementMap.set(scopeRow, el);
- } else {
- scopeRowElementMap.delete(scopeRow);
- }
- };
- const finalizeScopeExit = async (
- exitingRow: DisplayRecordRow,
- scopeSource: string,
- exitHeight: number,
- shouldLockRecordHeight: boolean,
- exitRevision: number
- ) => {
- if (exitRevision !== scopeExitRevision) {
- return;
- }
- const rowIndex = displayRecordRows.value.indexOf(exitingRow);
- if (rowIndex !== -1 && displayRecordRows.value[rowIndex]?.exiting) {
- displayRecordRows.value.splice(rowIndex, 1);
- }
- scopeExitHeight.value = 0;
- scopeExitWidth.value = 0;
- emit("scopeExitStateChange", {
- recordId: record.value.id,
- active: false,
- });
- await nextTick();
- window.requestAnimationFrame(() => {
- if (exitRevision !== scopeExitRevision) {
- return;
- }
- isScopeExitBodyTransitionDisabled.value = false;
- });
- };
- const beginScopeExit = (scopeRow: DisplayRecordRow | null) => {
- if (!scopeRow || scopeRow.type !== RecordRowTypes.Scope || scopeRow.exiting) {
- return;
- }
- if (!String(scopeRow.content || "").includes("</scope>")) {
- return;
- }
- const scopeEl = getScopeRowElement(scopeRow);
- const exitHeight = scopeEl ? Math.ceil(scopeEl.getBoundingClientRect().height) : 0;
- const exitWidth = getScopeContentWidth(scopeEl);
- const shouldLockRecordHeight = props.isLastRecord && exitHeight > 0;
- const scopeSource = getScopeExitSource(scopeRow);
- if (shouldLockRecordHeight && recordHeightLock.value === null) {
- const recordEl = recordRootRef.value;
- recordHeightLock.value = recordEl ? Math.ceil(recordEl.getBoundingClientRect().height) : null;
- }
- scopeRow.exiting = true;
- scopeExitHeight.value = exitHeight;
- scopeExitWidth.value = exitWidth;
- isScopeExitBodyTransitionDisabled.value = true;
- if (import.meta.env.MODE !== "production") {
- // 诊断用:`isScopeExitCompensating` 为真时**所有正文行都不渲染**(见 shouldRenderTextContentRow),
- // 补偿结束再挂回来。如果这一步发生在正文已经流出一段之后,观感就是「一小段正文重渲」。
- // 出问题时看这行的 `已渲染正文行数`:>0 就说明确实有已显示的正文被藏起来又挂回。
- console.warn("[record] scope 退场补偿开始(正文行会暂时隐藏)", {
- exitHeight,
- textRows: displayRecordRows.value.filter((row) => row.type === RecordRowTypes.Text).length,
- policyRows: displayRecordRows.value.filter((row) => row.type === RecordRowTypes.PolicyTable).length,
- });
- }
- emit("scopeHeightLockChange", {
- recordId: record.value.id,
- active: shouldLockRecordHeight && exitHeight > 0,
- height: exitHeight,
- });
- emit("scopeExitStateChange", {
- recordId: record.value.id,
- active: true,
- });
- const exitingRow = scopeRow;
- const exitRevision = ++scopeExitRevision;
- clearScopeExitTimer();
- scopeExitTimer = window.setTimeout(() => {
- scopeExitTimer = null;
- if (exitRevision !== scopeExitRevision) {
- return;
- }
- void finalizeScopeExit(
- exitingRow,
- scopeSource,
- exitHeight,
- shouldLockRecordHeight,
- exitRevision
- );
- }, scopeExitCollapseDurationMs);
- };
- const updateDisplayContent = (newVal: string) => {
- for (let i = 0; i < displayContent.value.length; i++) {
- if (displayContent.value[i] !== newVal[i]) {
- displayContent.value =
- displayContent.value.substring(0, i) + newVal[i] + displayContent.value.substring(i + 1);
- }
- }
- };
- const syncRecordHeightLock = () => {
- if (!isLastAiStreamingRecord.value) {
- return;
- }
- const recordEl = recordRootRef.value;
- if (!recordEl) {
- return;
- }
- const nextHeight = Math.ceil(recordEl.getBoundingClientRect().height);
- if (!Number.isFinite(nextHeight) || nextHeight <= 0) {
- return;
- }
- recordHeightLock.value = Math.max(recordHeightLock.value ?? 0, nextHeight);
- };
- const scopeTitleReg = /title\s*=\s*(['"]?)([^'"\s>]+)\1/i;
- const updateLastRecordRow = (
- text: string,
- type = RecordRowTypes.Text,
- state = RecordRowStates.Displaying
- ) => {
- let lastRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- if (type === RecordRowTypes.Text) {
- text = stripSilenceTags(text);
- if (!lastRow || lastRow.state === RecordRowStates.Displayed || lastRow.type !== type) {
- text = trimDisplayTextContentStart(text);
- }
- if (text.length === 0) {
- return;
- }
- }
- const removeTrailingScopePreludeTextRows = () => {
- while (displayRecordRows.value.length > 0) {
- const trailingRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- if (!isRemovableScopePreludeTextRow(trailingRow)) {
- break;
- }
- debugRowMutation("删除行(scope 前导)", trailingRow, trailingRow.content, "");
- displayRecordRows.value.pop();
- }
- lastRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- };
- const removeTrailingEmptyScopeStatusRows = () => {
- while (displayRecordRows.value.length > 0) {
- const trailingRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- if (!isRemovableEmptyScopeStatusRow(trailingRow)) {
- break;
- }
- if (trailingRow.type === RecordRowTypes.Scope && !trailingRow.exiting) {
- beginScopeExit(trailingRow);
- break;
- }
- debugRowMutation("删除行(空 scope 状态)", trailingRow, trailingRow.content, "");
- displayRecordRows.value.pop();
- }
- lastRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- };
- if (type === RecordRowTypes.Scope) {
- removeTrailingScopePreludeTextRows();
- }
- if (
- type === RecordRowTypes.Scope &&
- mergeScopeRecordRow(displayRecordRows.value, { type, content: text, state })
- ) {
- return;
- }
- // 已经有一个空的 scope 但还在流式更新时,允许直接复用它并替换标题。
- if (
- type === RecordRowTypes.Scope &&
- lastRow &&
- lastRow.type === RecordRowTypes.Scope &&
- isEmptyScopeRow(lastRow)
- ) {
- lastRow.content = text;
- lastRow.state = state;
- return;
- }
- const hasVisibleContent =
- type === RecordRowTypes.Text ? String(text || "").trim().length > 0 : !!text;
- if (type !== RecordRowTypes.Scope && hasVisibleContent) {
- hasVisibleAnswerContent.value = true;
- removeTrailingEmptyScopeStatusRows();
- }
- if (type === RecordRowTypes.Text) {
- const currentTextContent =
- lastRow && lastRow.type === RecordRowTypes.Text && lastRow.state !== RecordRowStates.Displayed
- ? lastRow.content
- : "";
- const segments = splitStreamingTextContentRows(currentTextContent, text);
- if (segments.length === 0) {
- return;
- }
- if (lastRow && lastRow.type === RecordRowTypes.Scope && !lastRow.exiting) {
- beginScopeExit(lastRow);
- }
- for (const segment of segments) {
- lastRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- if (!lastRow || lastRow.state === RecordRowStates.Displayed || lastRow.type !== type) {
- if (lastRow && lastRow.type !== type) {
- if (lastRow.type === RecordRowTypes.Text) {
- closeTextRow(lastRow);
- }
- lastRow.state = RecordRowStates.Displayed;
- }
- displayRecordRows.value.push({
- id: updateRecordRowIndex.value++,
- type: type,
- content: "",
- state: RecordRowStates.Pending,
- });
- lastRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- if (type === RecordRowTypes.Text) {
- textRowTypingFinished.value[lastRow.id] = true;
- }
- }
- const segmentContent =
- lastRow.content.length === 0
- ? trimDisplayTextContentStart(segment.content)
- : segment.content;
- if (segmentContent.length > 0) {
- lastRow.content += segmentContent;
- textRowTypingFinished.value[lastRow.id] = false;
- }
- lastRow.state = state;
- if (segment.breakAfter) {
- closeTextRow(lastRow);
- lastRow.state = RecordRowStates.Displayed;
- }
- }
- return;
- }
- if (!lastRow || lastRow.state === RecordRowStates.Displayed || lastRow.type !== type) {
- if (lastRow && lastRow.type !== type) {
- if (lastRow.type === RecordRowTypes.Text) {
- closeTextRow(lastRow);
- }
- lastRow.state = RecordRowStates.Displayed;
- }
- displayRecordRows.value.push({
- id: updateRecordRowIndex.value++,
- type: type,
- content: "",
- state: RecordRowStates.Pending,
- });
- lastRow = displayRecordRows.value[displayRecordRows.value.length - 1];
- if (type === RecordRowTypes.Text) {
- textRowTypingFinished.value[lastRow.id] = true;
- } else if (type === RecordRowTypes.ImageContent) {
- imageRowRevealFinished.value[lastRow.id] = !shouldDriveTypewriter.value;
- }
- }
- if (type === RecordRowTypes.Text && text.length > 0) {
- textRowTypingFinished.value[lastRow.id] = false;
- }
- lastRow.content = text;
- lastRow.state = state;
- };
- const getLastRecordRow = () => {
- if (displayRecordRows.value.length === 0) {
- return null;
- }
- return displayRecordRows.value[displayRecordRows.value.length - 1];
- };
- // 优化和修正逻辑,确保 <form> 区间处理更严谨
- const handleTimerTick = (val: string) => {
- if (count.value >= val.length) {
- clearExistingTimer();
- if (record.value.state === MessageState.Finish) {
- handleFinishEvent();
- }
- return;
- }
- updateDisplayContent(val);
- // 判断当前字符是否存在,防止越界
- if (typeof val[count.value] !== "undefined") {
- showTextAnim.value = false;
- // 添加当前字符到动画显示区
- addText(val[count.value]);
- // 通知外部内容有变化
- emit("displayContentChange");
- // 计数器自增,准备下一个字符
- count.value++;
- }
- };
- watch(
- () => record.value.content,
- (val) => {
- clearExistingTimer();
- if (!val || showInterruptedState.value) {
- changeFlag++;
- resetDisplayContent();
- return;
- }
- /**
- * ⚠️ 内容**不是纯追加**时必须整体重置再全量解析。
- *
- * 这里的增量解析只吃「比上次多出来的那一段」(`val.slice(count)`),
- * 所以消息内容被**整块重写**(不是往后追加)时,切出来的会是新内容的**中段**——
- * 那段中段会被当正文渲染出来(踩过:参考资料 JSON 的中段变成一坨文本显示在界面上)。
- *
- * 会整块重写的场景(F073 起):
- * - 流式收尾的**卡片重排**(把政策卡片挪到正文之上)
- * - `answer_end` 与增量拼接不一致时的整块重建
- * - 撤草稿(内容被截短回基线)
- * 纯追加(流式 delta / answer_end 的尾缀补齐)仍走增量路径,不重置、不闪。
- */
- if (!val.startsWith(originContent.value)) {
- changeFlag++;
- resetDisplayContent();
- xmlFilter.reset(); // 解析器也是有状态的(buffer / 未闭合标签),一并清
- if (import.meta.env.MODE !== "production") {
- // 诊断用:整块重写会让整条消息重新解析(观感上是"内容被换掉")。
- // 出问题时看这行就知道是哪个长度差触发的。
- console.warn("[record] 内容被整块重写,已重置并全量重解析", {
- before: originContent.value.length,
- after: val.length,
- });
- }
- }
- const diffText = val.slice(count.value);
- processRecordSections(diffText);
- originContent.value = val;
- count.value = val.length;
- timer = setInterval(() => handleTimerTick(val), gapTime);
- }
- );
- /**
- * F073:流式轮收尾(`contentStreaming` 由真变假)时,把**已经在屏幕上的文本行**补记为
- * 「打字完成」—— 它们在流式期间是**即时渲染**的(打字机关着),早就完整显示过了。
- *
- * 不补记的后果(2026-09-21 用户报的两个观感问题都源于此):
- * ① `hasUnfinishedRevealRows` 恒为真 → `shouldDriveTypewriter` 在收尾那一刻翻真
- * ② `visibleInlineDisplayRecordRows` 于是走「阻塞」分支:**最后一条未完成文本行之后的行**
- * (正文之后就是 notices / 参考资料那几行)被从 DOM 里拿掉 → 容器变矮 → 滚动位置被钳制,
- * 视图突然跳一下;随后挂回来时又是**新组件实例**
- * ③ 新实例走 TextContent 的 `watch-initial` → `startTypewriter(0)` 把内容重打一遍,
- * 并上报「打字中」→ 上级据此把视图**拽到最后一条 AI 消息的顶部**("瞬间返回到回答顶部")
- *
- * 非流式轮(mock / 旧后端)从不置 `contentStreaming`,这个 watch 不会触发,行为不变。
- */
- const markStreamedRowsAsTypingFinished = () => {
- let changed = false;
- for (const row of displayRecordRows.value) {
- if (row.type !== RecordRowTypes.Text) continue;
- if (textRowTypingFinished.value[row.id] !== true) {
- textRowTypingFinished.value[row.id] = true;
- changed = true;
- }
- textRowTypingActive.value[row.id] = false;
- }
- if (changed) {
- syncTypewriterState();
- }
- };
- watch(
- () => record.value.contentStreaming,
- (val, oldVal) => {
- if (oldVal && !val) {
- markStreamedRowsAsTypingFinished();
- }
- }
- );
- // 反馈组件显示由 shouldRenderFeedback 控制:历史会话立即展示,
- // 新消息等打字机/媒体动画结束(triggerMediaAndFeedback 内把
- // localFeedback 切到 Unselected)后才展示。
- watch(
- () => record.value.state,
- async (val) => {
- if (val === MessageState.Stop) {
- changeFlag++;
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
- if (mediaTimer) {
- clearInterval(mediaTimer);
- }
- await sleep(200);
- let rawContent = computedOriginContentPosition(
- record.value.originContent,
- displayContent.value
- );
- stopSpeech({ answer: rawContent, record_id: record.value.id });
- } else if (!timer && val === MessageState.Finish) {
- handleFinishEvent();
- }
- }
- );
- const addMediaList = (localMediaList: any[], successCallback: Function) => {
- if (!localMediaList || localMediaList.length === 0) {
- successCallback();
- return;
- }
- if (mediaTimer) {
- clearInterval(mediaTimer);
- }
- mediaTimer = setInterval(() => {
- if (mediaCount.value >= localMediaList.length) {
- clearInterval(mediaTimer);
- successCallback();
- return;
- }
- mediaCount.value++;
- displayMediaList.value = localMediaList.slice(0, mediaCount.value);
- }, gapTime);
- };
- const addText = (text: string) => {
- if (record.value.state === MessageState.Stop) {
- return;
- }
- if (isMobileDevice) {
- displayContent.value += text;
- updateLastRecordRow(text);
- return;
- }
- if (!textAnimWrapper.value) {
- return;
- }
- let textSpan = document.createElement("span");
- let regex = /^[a-zA-Z0-9 ]+$/;
- if (regex.test(text)) {
- textSpan.className = "entry-anim quick";
- } else {
- textSpan.className = "entry-anim";
- }
- textSpan.innerHTML = text;
- textAnimWrapper.value.appendChild(textSpan);
- let currentFlag = changeFlag;
- const onAnimationEnd = () => {
- if (currentFlag !== changeFlag) {
- return;
- }
- textSpan.remove();
- displayContent.value += text;
- updateLastRecordRow(text);
- if (textAnimWrapper.value.innerHTML === "") {
- showTextAnim.value = false;
- }
- };
- setTimeout(onAnimationEnd, 200);
- };
- // Handle TextContent typing finished
- const handleTypingFinished = (rowId: number) => {
- textRowTypingFinished.value[rowId] = true;
- textRowTypingActive.value[rowId] = false;
- console.log("[BusinessRecord][typing-finished]", {
- recordId: record.value.id,
- rowId,
- isLastRecord: props.isLastRecord,
- });
- syncTypewriterState();
- emit("refreshScroll");
- };
- const handleTypingStateChange = (rowId: number, isTypingActive: boolean) => {
- textRowTypingActive.value[rowId] = isTypingActive;
- if (isTypingActive) {
- textRowTypingFinished.value[rowId] = false;
- }
- console.log("[BusinessRecord][typing-state-change]", {
- recordId: record.value.id,
- rowId,
- isTypingActive,
- isLastRecord: props.isLastRecord,
- });
- syncTypewriterState();
- };
- const handleImageRevealFinished = (rowId: number) => {
- imageRowRevealFinished.value[rowId] = true;
- imageRowRevealActive.value[rowId] = false;
- console.log("[BusinessRecord][image-reveal-finished]", {
- recordId: record.value.id,
- rowId,
- isLastRecord: props.isLastRecord,
- });
- syncTypewriterState();
- emit("refreshScroll");
- };
- const handleImageRevealStateChange = (rowId: number, isRevealActive: boolean) => {
- imageRowRevealActive.value[rowId] = isRevealActive;
- if (isRevealActive) {
- imageRowRevealFinished.value[rowId] = false;
- }
- console.log("[BusinessRecord][image-reveal-state-change]", {
- recordId: record.value.id,
- rowId,
- isRevealActive,
- isLastRecord: props.isLastRecord,
- });
- syncTypewriterState();
- };
- const openSessionReadableLog = () => {
- const sessionId = localStorage.getItem("ba_current_session_id");
- if (!sessionId) {
- return;
- }
- const date = new Date().toLocaleDateString("en-CA");
- window.open(
- `https://qingpu-data-api.metamaker.cn/llms/qingpu/debug/session-readable-log?date=${date}&session_id=${sessionId}`
- );
- };
- const observeLastRecordHeight = () => {
- lastRecordResizeObserver?.disconnect();
- lastRecordResizeObserver = null;
- lastObservedRecordHeight = 0;
- const target = recordRootRef.value;
- if (!target || typeof ResizeObserver === "undefined") {
- return;
- }
- lastObservedRecordHeight = target.getBoundingClientRect().height;
- syncRecordHeightLock();
- lastRecordResizeObserver = new ResizeObserver((entries) => {
- const nextHeight = entries[0]?.contentRect.height ?? target.getBoundingClientRect().height;
- if (!props.isLastRecord) {
- lastObservedRecordHeight = nextHeight;
- return;
- }
- syncRecordHeightLock();
- const heightGrowth = nextHeight - lastObservedRecordHeight;
- if (lastObservedRecordHeight > 0 && heightGrowth > 0) {
- emit("refreshScroll", { heightGrowth });
- }
- lastObservedRecordHeight = nextHeight;
- });
- lastRecordResizeObserver.observe(target);
- };
- const handleFinishEvent = () => {
- if (showInterruptedState.value) {
- return;
- }
- handleEndSpeech({
- answer: record.value.originContent,
- record_id: record.value.id,
- });
- const triggerMediaAndFeedback = async () => {
- addMediaList(mediaList.value, async () => {
- if (props.enableFeedback && !isFormQueryMode && localFeedback.value === FeedbackType.None) {
- localFeedback.value = FeedbackType.Unselected;
- }
- if (record.value.references && record.value.references.length) {
- showReferences.value = true;
- }
- if (record.value.relatedQuestions && record.value.relatedQuestions.length) {
- await sleep(500);
- showRelatedQuestions.value = true;
- }
- });
- emit("displayMediaChange");
- };
- const waitAllTypingFinished = () => {
- if (!shouldWaitForTypewriterCompletion.value) {
- triggerMediaAndFeedback();
- return;
- }
- setTimeout(waitAllTypingFinished, 100);
- };
- waitAllTypingFinished();
- };
- watch(
- isLastAiStreamingRecord,
- (isStreaming) => {
- if (!isStreaming) {
- recordHeightLock.value = null;
- return;
- }
- syncRecordHeightLock();
- },
- { immediate: true }
- );
- onMounted(() => {
- unregisterRefLinksModal = modalMutex.register(refLinksModalId, {
- close: closeRefLinksPanel,
- isOpen: () => refLinksPanelVisible.value,
- });
- observeLastRecordHeight();
- const initialContent = props.content || "";
- if (initialContent && !showInterruptedState.value) {
- processRecordSections(initialContent);
- originContent.value = initialContent;
- count.value = initialContent.length;
- }
- });
- onBeforeUnmount(() => {
- closeRefLinksPanel();
- unregisterRefLinksModal?.();
- emitTypewriterStateChange(false);
- lastRecordResizeObserver?.disconnect();
- lastRecordResizeObserver = null;
- clearScopeExitTimer();
- scopeExitRevision += 1;
- if (!isEffectHumanState || !props.human) {
- return;
- }
- if (isEffectHumanState.getTaskState == SchedulerTaskState.Idle) {
- return;
- }
- if (isEffectHumanState != props.human.getCurrentState) {
- return;
- }
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
- props.human.setMainAnimationNameImmediateEffective(
- props.human.getIdlePoses[0],
- SchedulerTaskState.Idle
- );
- });
- let formBuffer = "";
- function recordParser(input: string) {
- const resultRows = xmlFilter.processChunk(input);
- resultRows.forEach((row) => {
- updateLastRecordRow(row.content, row.type, RecordRowStates.Displaying);
- });
- }
- // 流式处理文本,自动分段
- // 处理流式和完整输入,支持断续和完整的 val
- function openPreview(media: any, index: number, e: any) {
- emit("changeIdleState", "interruptSpeech");
- let rect = e.currentTarget?.getBoundingClientRect?.() || e.target.getBoundingClientRect();
- $mediaViewer.openModal({
- index,
- media: { ...media, rect },
- list: record.value.mediaList,
- });
- }
- const getUserAttachmentPreviewIndex = (attachment: any) => {
- const url = String(attachment?.url || "").trim();
- if (!url) {
- return 0;
- }
- const index = previewableUserAttachmentUrls.value.findIndex((item) => item === url);
- return index >= 0 ? index : 0;
- };
- function handleError(e: any) {
- e.target.style.objectFit = "none";
- e.target.src = defaultImage;
- }
- async function handleFeedbackChange(feedback: FeedbackType) {
- localFeedback.value = feedback;
- // [已移除] 反馈统计埋点:统计接口(老接口)已按用户要求删除(2026-09-18)。
- // 反馈本身仍写入 DMS(见 submitLikeFeedback / cancelFeedback / handleDislikeConfirm)
- emit("feedback", feedback, record.value.id);
- }
- </script>
- <style lang="scss">
- @use "./record-theme.scss";
- .record-modal-wrap {
- position: fixed;
- background: rgba(0, 0, 0, 0.7);
- top: 0;
- left: 0;
- width: 100vw;
- height: 100vh;
- z-index: 200;
- }
- .chat-record-line {
- font-size: 15px;
- pointer-events: auto;
- transition: all 0.3s ease-in-out;
- animation: slide-up-fade 0.3s forwards cubic-bezier(0.22, 1, 0.36, 1);
- &.with-feedback-margin {
- padding-bottom: 8px;
- }
- &.with-feedback-margin-rated {
- padding-bottom: 8px;
- }
- }
- .chat-record-me {
- background: rgba(176, 198, 253, 0.18);
- color: #333333;
- text-align: center;
- /* title/h5_regular */
- font-family: PingFang SC;
- font-style: normal;
- font-weight: 400;
- line-height: 24px;
- padding: 12px 15px 12px 15px;
- border-radius: 16px 16px 4px 16px;
- margin-bottom: 12px;
- backdrop-filter: blur(4px);
- -webkit-backdrop-filter: blur(4px);
- display: inline-block;
- margin-left: 10px;
- align-self: flex-end;
- flex-shrink: 0;
- text-align: left;
- position: relative;
- transform-origin: right bottom;
- span {
- &::selection {
- background: rgba(24, 144, 255, 0.24);
- }
- }
- &.full-mode {
- // background-color: rgba(176, 198, 253, 0.65);
- // color: #303133;
- }
- &.desktop {
- color: #000;
- box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.04);
- background: linear-gradient(180deg, rgba(222, 231, 255, 0.1) 0%, rgba(222, 231, 255, 0.2) 100%);
- position: relative;
- &:before {
- content: "";
- position: absolute;
- inset: 0;
- border-radius: inherit;
- padding: 1px;
- /* 控制描边厚度 */
- background: radial-gradient(
- 70.66% 143.6% at 37.72% 0%,
- #ffffff 0%,
- rgba(255, 255, 255, 0) 100%
- );
- /* 关键:中间镂空,仅保留“描边” */
- -webkit-mask:
- linear-gradient(#000 0 0) content-box,
- linear-gradient(#000 0 0);
- -webkit-mask-composite: xor;
- mask:
- linear-gradient(#000 0 0) content-box,
- linear-gradient(#000 0 0);
- mask-composite: exclude;
- pointer-events: none;
- /* 不挡交互 */
- z-index: 1;
- /* 在内容之上 */
- }
- }
- }
- .chat-record-ai {
- min-width: 45px;
- // background: rgba(255, 255, 255, 0.75);
- position: relative;
- // box-shadow: inset 1px 1px 44px rgba(255, 255, 255, 0.17), inset 0px -10px 25px rgba(255, 255, 255, 0.2), inset 0px 4px 19px rgba(255, 255, 255, 0.36);
- border-radius: 0px 10px 10px 10px;
- color: rgba(48, 49, 51, 1);
- /* title/h5_regular */
- font-family: PingFang SC;
- font-style: normal;
- font-weight: 400;
- line-height: 24px;
- // padding: 12px 15px 12px 15px;
- margin-bottom: 12px;
- // backdrop-filter: blur(8px);
- // -webkit-backdrop-filter: blur(8px);
- margin-right: 10px;
- display: inline-block;
- text-align: left;
- flex-shrink: 0;
- transform-origin: left bottom;
- span {
- &::selection {
- background: rgb(200, 204, 207);
- }
- }
- &.full-mode {
- background-color: rgba(255, 255, 255, 0.5);
- }
- }
- .record--business.ba-record-ai.is-loading {
- background: transparent;
- box-shadow: none;
- padding: 0;
- }
- .business-scope-content-outside {
- display: block;
- margin-bottom: 8px;
- text-align: left;
- }
- .business-record-body {
- min-width: 0;
- max-width: 100%;
- transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
- will-change: transform;
- }
- .business-record-body.is-scope-exit-transition-disabled {
- transition: none !important;
- }
- .business-record-body.is-scope-exiting {
- transform: translateY(calc(var(--scope-exit-offset, 0px) * -1));
- }
- .session-readable-log-row {
- display: flex;
- margin-top: 8px;
- }
- .session-readable-log-btn {
- border: 0;
- border-radius: 999px;
- padding: 6px 12px;
- background: rgba(53, 37, 205, 0.08);
- color: #3525cd;
- font-size: 12px;
- line-height: 1.4;
- cursor: pointer;
- }
- .session-readable-log-btn:hover {
- background: rgba(53, 37, 205, 0.14);
- }
- .ba-ref-links-summary {
- width: 100%;
- margin-top: 12px;
- padding-top: 12px;
- border-top: 1px solid rgba(199, 196, 216, 0.2);
- color: #141b2b;
- }
- .ba-ref-links-summary-title {
- margin-bottom: 8px;
- color: rgba(70, 69, 85, 0.6);
- font-size: 12px;
- font-weight: 500;
- line-height: 1.4;
- }
- .ba-ref-links-row {
- display: flex;
- align-items: center;
- gap: 8px;
- max-width: 100%;
- min-width: 0;
- }
- .ba-ref-links-chip-list {
- display: flex;
- align-items: center;
- gap: 8px;
- max-width: 100%;
- min-width: 0;
- overflow-x: hidden;
- overflow-y: hidden;
- }
- .ba-ref-links-chip {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- min-width: 0;
- max-width: 198px;
- height: 25px;
- padding: 3px 8px;
- border-radius: 4px;
- background: rgb(225, 232, 252);
- color: #3525cd;
- font-size: 12px;
- font-weight: 500;
- line-height: 18px;
- white-space: nowrap;
- text-decoration: none;
- flex-shrink: 0;
- }
- .ba-ref-links-chip-index {
- color: #3525cd;
- font-weight: 500;
- flex-shrink: 0;
- }
- .ba-ref-links-chip-title {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- max-width: 198px;
- }
- .ba-ref-links-more {
- height: 25px;
- padding: 3px 10px;
- border-radius: 4px;
- outline: none;
- border: none;
- background: rgb(225, 232, 252);
- color: #3525cd;
- font-size: 12px;
- font-weight: 700;
- line-height: 18px;
- cursor: pointer;
- flex-shrink: 0;
- }
- .ba-ref-links-more:hover {
- background: #e2dfff;
- }
- .ref-links-viewer-modal {
- position: fixed;
- inset: 0;
- z-index: 220;
- pointer-events: none;
- }
- .ref-links-viewer-content {
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- width: 480px;
- max-width: 100vw;
- background: #ffffff;
- box-shadow: -12px 0 32px rgba(20, 27, 43, 0.12);
- display: flex;
- flex-direction: column;
- overflow: hidden;
- pointer-events: auto;
- }
- .ref-links-viewer-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 16px;
- padding: 24px 24px 12px;
- flex-shrink: 0;
- }
- .ref-links-viewer-title {
- color: #141b2b;
- font-size: 24px;
- font-weight: 500;
- line-height: 1.4;
- }
- .ref-links-viewer-close {
- width: 40px;
- height: 40px;
- border: 0;
- border-radius: 999px;
- background: transparent;
- color: #464555;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- }
- .ref-links-viewer-close:hover {
- background: rgba(53, 37, 205, 0.06);
- }
- .ref-links-viewer-list {
- display: flex;
- flex-direction: column;
- gap: 16px;
- padding: 0 24px 32px;
- overflow-y: auto;
- min-height: 0;
- }
- .ref-links-card {
- display: flex;
- flex-direction: column;
- gap: 8px;
- padding: 24px;
- border: 1px solid #e9edff;
- border-radius: 12px;
- background: #ffffff;
- box-shadow: 0 1px 1.75px rgba(0, 0, 0, 0.05);
- }
- .ref-links-card-head {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- gap: 12px;
- }
- .ref-links-card-title {
- min-width: 0;
- color: #141b2b;
- font-size: 16px;
- font-weight: 500;
- line-height: 1.6;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- display: -webkit-box;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .ref-links-card-tag {
- max-width: 92px;
- padding: 2px 8px;
- border-radius: 4px;
- background: rgba(225, 232, 253, 1);
- color: #3525cd;
- font-size: 12px;
- font-weight: 500;
- line-height: 1.4;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- flex-shrink: 0;
- }
- .ref-links-card-content {
- color: #464555;
- font-size: 12px;
- font-weight: 500;
- line-height: 1.6;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- display: -webkit-box;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .ref-links-card-link {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- width: max-content;
- color: #3525cd;
- font-size: 12px;
- font-weight: 700;
- line-height: 1.4;
- margin-top: 8px;
- text-decoration: none;
- }
- .ref-links-card-link:hover {
- text-decoration: underline;
- text-underline-offset: 4px;
- }
- .ref-links-panel-enter-active,
- .ref-links-panel-leave-active {
- transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
- }
- .ref-links-panel-enter-from,
- .ref-links-panel-leave-to {
- transform: translateX(100%);
- }
- .chat-record-me .session-readable-log-row {
- justify-content: flex-end;
- }
- .chat-record-ai .session-readable-log-row {
- justify-content: flex-start;
- }
- .scope-content-shell {
- display: block;
- width: 100%;
- min-width: 0;
- }
- .business-record-body-fade-enter-active,
- .business-record-body-fade-leave-active {
- transition:
- opacity 300ms cubic-bezier(0.22, 1, 0.36, 1),
- transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
- }
- .business-record-body-fade-enter-from,
- .business-record-body-fade-leave-to {
- opacity: 0;
- }
- .business-record-body-fade-enter-to,
- .business-record-body-fade-leave-from {
- opacity: 1;
- }
- .ba-message-attachments {
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-end;
- align-self: flex-end;
- gap: 8px;
- width: 100%;
- margin-bottom: 12px;
- pointer-events: auto;
- clear: both;
- &.desktop {
- max-width: min(420px, 60vw);
- margin-left: auto;
- }
- }
- .ba-message-attachment {
- position: relative;
- overflow: hidden;
- border: 1px solid rgba(199, 196, 216, 0.3);
- border-radius: 12px;
- background: #ffffff;
- box-shadow: 0 1px 1.75px rgba(0, 0, 0, 0.05);
- }
- .ba-message-attachment.is-image {
- width: 68px;
- height: 68px;
- padding: 0;
- border: 0;
- background: transparent;
- box-shadow: none;
- }
- .ba-message-attachment.is-image :deep(.image-content-wrap) {
- width: 100%;
- height: 100%;
- margin: 0;
- }
- .ba-message-attachment.is-file {
- min-width: 180px;
- max-width: 240px;
- min-height: 68px;
- display: flex;
- align-items: center;
- gap: 10px;
- padding: 10px;
- }
- .ba-message-attachment-icon {
- width: 40px;
- height: 40px;
- border-radius: 8px;
- background: rgba(53, 37, 205, 0.1);
- color: #3525cd;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- font-size: 10px;
- font-weight: 600;
- }
- .ba-message-attachment-info {
- min-width: 0;
- flex: 1;
- }
- .ba-message-attachment-name {
- overflow: hidden;
- color: #141b2b;
- font-size: 13px;
- font-weight: 500;
- line-height: 1.4;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .ba-message-attachment-size {
- margin-top: 3px;
- color: #464555;
- font-size: 12px;
- line-height: 1.4;
- }
- .chat-record-tips {
- min-width: 45px;
- background: linear-gradient(180deg, #e0e7ff 0%, #f4f7ff 100%);
- border: 3px solid #ffffff;
- border-radius: 16px;
- position: relative;
- // box-shadow: inset 1px 1px 44px rgba(255, 255, 255, 0.17), inset 0px -10px 25px rgba(255, 255, 255, 0.2), inset 0px 4px 19px rgba(255, 255, 255, 0.36);
- color: #0a0b0d;
- /* title/h5_regular */
- font-family: PingFang SC;
- font-size: 15px;
- font-style: normal;
- font-weight: 400;
- line-height: 24px;
- padding: 22px 15px 12px 15px;
- margin-top: 40px;
- margin-bottom: 12px;
- backdrop-filter: blur(8px);
- -webkit-backdrop-filter: blur(8px);
- margin-right: 30px;
- margin-left: 30px;
- display: inline-block;
- text-align: left;
- flex-shrink: 0;
- transform-origin: center bottom;
- span {
- &::selection {
- background: rgb(200, 204, 207);
- }
- }
- &.full-mode {
- background-color: rgba(255, 255, 255, 0.5);
- }
- .tips-title {
- position: absolute;
- font-size: 14px;
- line-height: 24px;
- top: -15px;
- padding: 5px 60px;
- color: #fff;
- left: 50%;
- transform: translateX(-50%);
- border-radius: 0 0 10px 10px;
- margin-bottom: 8px;
- font-weight: bold;
- word-break: keep-all;
- .tips-deco {
- position: absolute;
- width: 90%;
- height: 100%;
- left: 0;
- top: 0;
- z-index: -1;
- &.mirror {
- transform: scaleX(-100%);
- left: auto;
- right: 0;
- }
- &:before {
- position: absolute;
- content: "";
- width: 0;
- height: 0;
- left: -9px;
- border-top: 0 solid transparent;
- border-left: 6px solid transparent;
- border-right: 6px solid transparent;
- border-bottom: 13px solid #0013c3;
- }
- &:after {
- position: absolute;
- content: "";
- width: 100%;
- height: 100%;
- left: 0;
- top: 0;
- background: linear-gradient(180deg, #485bff 0%, #3e51f5 100%);
- transform: skewX(10deg);
- border-radius: 0 0 0 8px;
- }
- }
- }
- }
- .business-record .content {
- line-height: 24px;
- text-align: left;
- flex-shrink: 0;
- display: block;
- width: 100%;
- max-width: 100%;
- min-width: 0;
- box-sizing: border-box;
- word-break: break-word;
- user-select: text;
- &.isTip {
- display: none;
- }
- a {
- color: rgba(255, 255, 255, 1);
- }
- p:last-child {
- margin-bottom: 0;
- }
- }
- .request-interrupted-status {
- display: inline-flex;
- align-items: center;
- min-height: 28px;
- padding: 2px 10px;
- border-radius: 6px;
- border: 1px solid rgba(148, 163, 184, 0.28);
- background: rgba(248, 250, 252, 0.9);
- color: #64748b;
- font-size: 13px;
- line-height: 22px;
- user-select: text;
- }
- .tips-wrap {
- padding-top: 5px;
- .tip {
- .title {
- display: flex;
- font-size: 14px;
- line-height: 24px;
- color: #333;
- font-weight: bold;
- margin-bottom: 6px;
- .order {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 22px;
- height: 22px;
- border-radius: 3px;
- color: #fff;
- background: linear-gradient(180deg, #485bff 0%, #3e51f5 100%);
- margin-right: 8px;
- font-family: PingFang SC;
- }
- }
- & + .tip {
- margin-top: 16px;
- }
- }
- .tip-footer {
- margin-top: 16px;
- font-weight: bold;
- }
- }
- @keyframes word-disappear {
- 0% {
- opacity: 1;
- transform: scale(1);
- }
- 100% {
- opacity: 0;
- transform: scale(0.5);
- }
- }
- .entry-anim {
- height: 14px;
- line-height: 14px;
- animation: text-fading 0.2s linear forwards;
- &.quick {
- animation: text-fading 0.1s linear forwards;
- }
- &.block {
- height: 0;
- display: block;
- }
- &.block + .block {
- margin-top: 14px;
- }
- }
- .recognizing-anim {
- margin-left: -4px;
- }
- @media screen and (width > 768px) {
- .desktop {
- .business-record .content {
- color: rgba(255, 255, 255, 1);
- a {
- color: rgba(255, 255, 255, 1);
- }
- }
- }
- }
- @media (max-width: 767px) {
- .ba-ref-links-summary {
- max-width: 100%;
- }
- .ref-links-viewer-content {
- left: 0;
- width: 100vw;
- height: 100dvh;
- box-shadow: none;
- }
- .ref-links-viewer-header {
- padding: 32px 16px 12px;
- }
- .ref-links-viewer-title {
- font-size: 24px;
- }
- .ref-links-viewer-close {
- width: 40px;
- height: 40px;
- }
- .ref-links-viewer-list {
- gap: 12px;
- padding: 0 16px 32px;
- }
- .ref-links-card {
- padding: 16px;
- box-shadow: none;
- }
- .ref-links-card-head {
- align-items: flex-start;
- }
- .ref-links-card-title {
- font-size: 14px;
- }
- }
- @keyframes text-fading {
- 0% {
- opacity: 0;
- // filter: blur(40px);
- }
- 100% {
- opacity: 1;
- // filter: blur(0);
- }
- }
- .thinking-anim {
- display: inline-flex;
- height: 21px;
- vertical-align: top;
- align-items: center;
- .random-text {
- margin-left: -4px;
- min-width: 14px;
- height: 14px;
- line-height: 14px;
- background-color: rgba(0, 0, 0, 0.6);
- color: white;
- text-align: left;
- vertical-align: top;
- }
- .insert-block {
- width: 14px;
- height: 14px;
- background-color: rgba(0, 0, 0, 0.6);
- }
- .lds-ellipsis {
- display: inline-block;
- position: relative;
- width: 80px;
- height: 80px;
- transform: scale(0.4);
- }
- .lds-ellipsis div {
- position: absolute;
- top: 33px;
- width: 13px;
- height: 13px;
- border-radius: 50%;
- background: rgba(0, 0, 0, 0.6);
- animation-timing-function: cubic-bezier(0, 1, 1, 0);
- }
- .lds-ellipsis div:nth-child(1) {
- left: 8px;
- background: gray;
- animation: lds-ellipsis1 0.8s infinite;
- }
- .lds-ellipsis div:nth-child(2) {
- left: 8px;
- animation: lds-ellipsis2 0.8s infinite;
- }
- .lds-ellipsis div:nth-child(3) {
- left: 32px;
- animation: lds-ellipsis3 0.8s infinite;
- }
- .lds-ellipsis div:nth-child(4) {
- left: 56px;
- animation: lds-ellipsis4 0.8s infinite;
- }
- @keyframes lds-ellipsis1 {
- 0% {
- transform: scale(2);
- border-radius: 50%;
- }
- 75% {
- transform: scale(2.5);
- border-radius: 4px;
- }
- 100% {
- transform: scale(2);
- border-radius: 50%;
- }
- }
- @keyframes lds-ellipsis2 {
- 0% {
- opacity: 0.5;
- transform: translate(24px, 0) scale(1.5);
- }
- 75% {
- transform: translate(0, 0) scale(2);
- }
- 100% {
- opacity: 1;
- transform: translate(0, 0) scale(1);
- }
- }
- @keyframes lds-ellipsis3 {
- 0% {
- opacity: 0.25;
- transform: translate(24px, 0) scale(1);
- }
- 100% {
- opacity: 0.5;
- transform: translate(0, 0) scale(1.5);
- }
- }
- @keyframes lds-ellipsis4 {
- 0% {
- opacity: 0;
- transform: scale(0);
- }
- 100% {
- opacity: 0.25;
- transform: scale(1);
- }
- }
- }
- .media-row {
- display: block;
- margin-top: 8px;
- margin-bottom: 8px;
- }
- .rest-media-wrapper {
- width: 140px;
- margin-bottom: 4px;
- border-radius: 8px;
- background-color: white;
- display: flex;
- flex-wrap: wrap;
- padding: 4px;
- box-sizing: border-box;
- }
- .media-placeholder {
- width: 140px;
- height: 140px;
- animation: zoom-in 0.3s forwards ease-in-out;
- border-radius: 8px;
- overflow: hidden;
- position: relative;
- background: white;
- .play-button {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 40px;
- height: 40px;
- border-radius: 50%;
- background-color: rgba(0, 0, 0, 0.6);
- background-image: url(@/assets/play-button.svg);
- background-size: 100% 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- z-index: 10;
- }
- &.head-media {
- width: 140px;
- height: 140px;
- }
- &.several {
- width: 64.5px;
- height: 64.5px;
- margin-top: 3px;
- margin-right: 3px;
- &:nth-child(1),
- &:nth-child(2) {
- margin-top: 0;
- }
- &:nth-child(2n) {
- margin-right: 0;
- }
- .play-button {
- width: 36px;
- height: 36px;
- }
- }
- &.multi {
- width: 42px;
- height: 42px;
- margin-top: 3px;
- margin-right: 3px;
- &:nth-child(1),
- &:nth-child(2),
- &:nth-child(3) {
- margin-top: 0;
- }
- &:nth-child(3n) {
- margin-right: 0;
- }
- .play-button {
- width: 24px;
- height: 24px;
- }
- }
- img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- video {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- }
- @keyframes zoom-in {
- 0% {
- transform: scale(0.5);
- opacity: 0;
- }
- 100% {
- transform: scale(1);
- opacity: 1;
- }
- }
- @keyframes slide-up-fade {
- 0% {
- transform: translateY(12px);
- opacity: 0;
- }
- 100% {
- transform: translateY(0);
- opacity: 1;
- }
- }
- </style>
|