feat(mini-program): 统一 chat 视图,删除 clarifying/outlining/result 独立视图
This commit is contained in:
@@ -86,105 +86,8 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-else-if="viewState === 'clarifying'" class="clarifying-view">
|
<view v-else-if="viewState === 'chat'" class="chat-page">
|
||||||
<scroll-view class="clarifying-scroll" scroll-y>
|
<view class="chat-top-actions">
|
||||||
<view class="clarifying-content">
|
|
||||||
<view class="clarifying-intro">
|
|
||||||
<text class="intro-title">在开始创作前,我想再了解你一点</text>
|
|
||||||
</view>
|
|
||||||
<ClarificationCard
|
|
||||||
v-if="clarificationCard"
|
|
||||||
:card="clarificationCard"
|
|
||||||
@submit="submitClarification"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-else-if="viewState === 'outlining'" class="outlining-view">
|
|
||||||
<scroll-view class="outlining-scroll" scroll-y>
|
|
||||||
<view class="outlining-content">
|
|
||||||
<view v-if="novelOutline" class="outline-card">
|
|
||||||
<view v-if="novelOutline.title" class="outline-title">
|
|
||||||
<text>{{ novelOutline.title }}</text>
|
|
||||||
</view>
|
|
||||||
<view v-if="novelOutline.logline" class="outline-logline">
|
|
||||||
<text>{{ novelOutline.logline }}</text>
|
|
||||||
</view>
|
|
||||||
<view v-if="Array.isArray(novelOutline.beats)" class="outline-beats">
|
|
||||||
<view v-for="(beat, idx) in novelOutline.beats" :key="idx" class="beat-item">
|
|
||||||
<text class="beat-order">{{ beat.order || idx + 1 }}</text>
|
|
||||||
<view class="beat-content">
|
|
||||||
<text class="beat-title">{{ beat.title || '' }}</text>
|
|
||||||
<text v-if="beat.summary" class="beat-summary">{{ beat.summary }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view v-if="novelOutline.ending" class="outline-ending">
|
|
||||||
<text class="ending-label">结局</text>
|
|
||||||
<text class="ending-text">{{ novelOutline.ending }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="outline-actions">
|
|
||||||
<input v-model="outlineFeedback" placeholder="如需修改请输入意见" class="outline-feedback" />
|
|
||||||
<view class="outline-buttons">
|
|
||||||
<view class="btn-secondary" @click="modifyOutline(outlineFeedback)">修改大纲</view>
|
|
||||||
<view class="btn-primary" @click="confirmOutline">确认大纲</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-else-if="viewState === 'generating'" class="generation-view">
|
|
||||||
<scroll-view
|
|
||||||
class="generation-scroll"
|
|
||||||
scroll-y
|
|
||||||
:scroll-top="generationScrollTop"
|
|
||||||
:scroll-into-view="generationScrollTarget"
|
|
||||||
:scroll-with-animation="true"
|
|
||||||
:enhanced="true"
|
|
||||||
:show-scrollbar="false"
|
|
||||||
>
|
|
||||||
<view class="generation-scroll-content">
|
|
||||||
<view class="conversation">
|
|
||||||
<view class="chat-bubble user">
|
|
||||||
<text>{{ generationDisplayText }}</text>
|
|
||||||
<text class="bubble-time">{{ currentMessageTime }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="chat-bubble system">
|
|
||||||
<text>{{ generationTitle }}</text>
|
|
||||||
<view v-if="showThinkingDots" class="thinking-dots">
|
|
||||||
<view></view>
|
|
||||||
<view></view>
|
|
||||||
<view></view>
|
|
||||||
</view>
|
|
||||||
<text v-if="generationStatus === 'failed'" class="generation-error">{{ generationFailureCopy }}</text>
|
|
||||||
<text v-else-if="visibleStreamContent" class="stream-preview typing">{{ visibleStreamContent }}<text v-if="generating" class="typing-cursor">|</text></text>
|
|
||||||
<text class="bubble-time">{{ currentMessageTime }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="generation-loading">
|
|
||||||
<view class="loading-orbit" :class="{ streaming: generationStatus === 'streaming', failed: generationStatus === 'failed' }">
|
|
||||||
<view class="orbit-ring outer"></view>
|
|
||||||
<view class="orbit-ring inner"></view>
|
|
||||||
<view class="orbit-core"></view>
|
|
||||||
</view>
|
|
||||||
<text class="loading-copy">{{ generationCopy }}</text>
|
|
||||||
<text v-if="generationStatus !== 'failed'" class="loading-subcopy">{{ generationSubcopy }}</text>
|
|
||||||
<view v-else class="generation-actions">
|
|
||||||
<button v-if="resumeableSessionId" class="generation-action primary" @click="resumeSession">继续创作</button>
|
|
||||||
<button v-else class="generation-action primary" @click="retryGeneration">再试一次</button>
|
|
||||||
<button class="generation-action secondary" @click="returnToEdit">返回修改</button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view :id="generationScrollAnchor" class="generation-scroll-anchor"></view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-else class="result-page">
|
|
||||||
<view class="result-top-actions">
|
|
||||||
<view class="history-button" @click="openScriptLibrary">
|
<view class="history-button" @click="openScriptLibrary">
|
||||||
<view class="history-lines">
|
<view class="history-lines">
|
||||||
<view></view>
|
<view></view>
|
||||||
@@ -197,7 +100,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view
|
<scroll-view
|
||||||
class="result-view"
|
class="chat-scroll"
|
||||||
scroll-y
|
scroll-y
|
||||||
:scroll-top="resultCommandScrollTop"
|
:scroll-top="resultCommandScrollTop"
|
||||||
:scroll-into-view="resultScrollTarget"
|
:scroll-into-view="resultScrollTarget"
|
||||||
@@ -206,100 +109,105 @@
|
|||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
@scroll="handleResultScroll"
|
@scroll="handleResultScroll"
|
||||||
>
|
>
|
||||||
<view class="result-scroll-content">
|
<view class="chat-scroll-content">
|
||||||
<view id="result-scroll-top" class="result-scroll-top"></view>
|
<view id="result-scroll-top" class="result-scroll-top"></view>
|
||||||
|
|
||||||
<!-- 聊天模式 -->
|
|
||||||
<view>
|
|
||||||
<view class="conversation compact">
|
<view class="conversation compact">
|
||||||
<view class="chat-bubble user">
|
|
||||||
<text>{{ wishText }}</text>
|
|
||||||
<text class="bubble-time">{{ currentMessageTime }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="chat-bubble system done">
|
|
||||||
<text>心愿已实现,故事已为你展开</text>
|
|
||||||
<text class="bubble-time">{{ currentResultTime }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-if="displayMessages.length" class="result-chat-list">
|
|
||||||
<view
|
<view
|
||||||
v-for="message in displayMessages"
|
v-for="msg in resultMessages"
|
||||||
:key="message.id"
|
:key="msg.id"
|
||||||
>
|
>
|
||||||
<MessageCard
|
<view v-if="msg.role === 'user' && msg.kind === 'text'" class="chat-bubble user">
|
||||||
v-if="message.sender === 'assistant' || message.type === 'script'"
|
<text>{{ msg.content }}</text>
|
||||||
:version-label="formatVersionLabel(message)"
|
<text class="bubble-time">{{ msg.time }}</text>
|
||||||
:has-children="messageHasChildren(message)"
|
</view>
|
||||||
:can-delete="message.id !== currentVersionMessageId && message.parentMessageId !== null"
|
|
||||||
:can-rewrite="true"
|
<view v-else-if="msg.kind === 'card'" class="chat-bubble system">
|
||||||
:can-continue="true"
|
<ClarificationCard
|
||||||
:content="message.content"
|
v-if="!msg.submitted && msg.card"
|
||||||
:collapsed="isMessageCollapsed(message)"
|
:card="msg.card"
|
||||||
:content-length="message.content.length"
|
@submit="(answer) => submitClarification(msg, answer)"
|
||||||
:is-short-message="false"
|
|
||||||
:tts-icon="ttsPlayer.playing.value ? 'Ⅱ' : '▶'"
|
|
||||||
:tts-text="ttsPlayer.playing.value ? '暂停' : '播放'"
|
|
||||||
@toggle-collapse="toggleMessageCollapse(message)"
|
|
||||||
@copy="copyMessageContent(message)"
|
|
||||||
@rewrite="rewriteMessage(message)"
|
|
||||||
@continue-script="continueMessage(message)"
|
|
||||||
@view-versions="viewMessageVersions(message)"
|
|
||||||
@delete-version="removeVersion(message)"
|
|
||||||
@play-tts="playMessageTts(message)"
|
|
||||||
@change-direction="changeDirection"
|
|
||||||
@not-like-me="notLikeMe"
|
|
||||||
/>
|
/>
|
||||||
<view v-else class="chat-bubble user">
|
<view v-else class="card-answered">
|
||||||
<text>{{ message.content }}</text>
|
<text>已回答:{{ msg.answer }}</text>
|
||||||
<text class="bubble-time">{{ message.time || formatMessageTime() }}</text>
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="msg.kind === 'outline'" class="chat-bubble system">
|
||||||
|
<view v-if="msg.outline">
|
||||||
|
<view v-if="msg.outline.title" class="outline-title">
|
||||||
|
<text>{{ msg.outline.title }}</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="msg.outline.logline" class="outline-logline">
|
||||||
|
<text>{{ msg.outline.logline }}</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="Array.isArray(msg.outline.beats)" class="outline-beats">
|
||||||
|
<view v-for="(beat, idx) in msg.outline.beats" :key="idx" class="beat-item">
|
||||||
|
<text class="beat-order">{{ beat.order || idx + 1 }}</text>
|
||||||
|
<view class="beat-content">
|
||||||
|
<text class="beat-title">{{ beat.title || '' }}</text>
|
||||||
|
<text v-if="beat.summary" class="beat-summary">{{ beat.summary }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="msg.outline.ending" class="outline-ending">
|
||||||
|
<text class="ending-label">结局</text>
|
||||||
|
<text class="ending-text">{{ msg.outline.ending }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="!msg.confirmed" class="outline-actions">
|
||||||
|
<input v-model="msg.feedback" placeholder="如需修改请输入意见" class="outline-feedback" />
|
||||||
|
<view class="outline-buttons">
|
||||||
|
<view class="btn-secondary" @click="modifyOutline(msg)">修改大纲</view>
|
||||||
|
<view class="btn-primary" @click="confirmOutline(msg)">确认大纲</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="generating" class="generation-loading">
|
<view v-else-if="msg.kind === 'novel'" class="chat-bubble system">
|
||||||
<view class="loading-orbit streaming">
|
<text class="novel-text">{{ msg.content }}<text v-if="msg.pending" class="typing-cursor">|</text></text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else class="chat-bubble system">
|
||||||
|
<text :class="{ 'generation-error': msg.failed }">{{ msg.content }}</text>
|
||||||
|
<text class="bubble-time">{{ msg.time }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="generating && generationStatus !== 'failed'" class="chat-loading">
|
||||||
|
<view class="loading-orbit" :class="{ streaming: generationStatus === 'streaming' }">
|
||||||
<view class="orbit-ring outer"></view>
|
<view class="orbit-ring outer"></view>
|
||||||
<view class="orbit-ring inner"></view>
|
<view class="orbit-ring inner"></view>
|
||||||
<view class="orbit-core"></view>
|
<view class="orbit-core"></view>
|
||||||
</view>
|
</view>
|
||||||
<text class="loading-copy">正在为你重写人生</text>
|
<text class="loading-copy">{{ generationCopy }}</text>
|
||||||
<text class="loading-subcopy">AI 正在思考下一步方向</text>
|
</view>
|
||||||
|
|
||||||
|
<view v-if="generationStatus === 'failed' && resumeableSessionId" class="resume-action">
|
||||||
|
<button class="generation-action primary" @click="resumeSession">继续创作</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view :id="resultScrollAnchor" class="result-scroll-anchor"></view>
|
<view :id="resultScrollAnchor" class="result-scroll-anchor"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 聊天模式输入栏 -->
|
|
||||||
<view v-if="viewMode === 'chat'" class="result-chat-bar">
|
|
||||||
<view
|
|
||||||
class="chat-voice-btn"
|
|
||||||
:class="{ pressing: voiceState === 'pressing', recognizing: voiceState === 'recognizing' }"
|
|
||||||
@touchstart.prevent="startVoicePress"
|
|
||||||
@touchend.prevent="endVoicePress"
|
|
||||||
@touchcancel.prevent="cancelVoicePress"
|
|
||||||
>
|
|
||||||
<text class="voice-icon">🎤</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="result-input-shell" :class="{ twoLine: resultInputLevel === 'two', expanded: resultInputLevel === 'multi' }">
|
</scroll-view>
|
||||||
<text v-if="!chatInput" class="custom-input-placeholder result-input-placeholder">输入修改建议,或让 AI 继续生成</text>
|
|
||||||
|
<view v-if="generationPhase === 'done'" class="chat-input-bar">
|
||||||
|
<view class="result-input-shell">
|
||||||
<textarea
|
<textarea
|
||||||
class="result-chat-input"
|
class="result-chat-input"
|
||||||
v-model="chatInput"
|
v-model="chatInput"
|
||||||
:auto-height="resultInputLevel !== 'single'"
|
:auto-height="true"
|
||||||
:show-confirm-bar="false"
|
:show-confirm-bar="false"
|
||||||
maxlength="500"
|
maxlength="500"
|
||||||
confirm-type="send"
|
confirm-type="send"
|
||||||
@focus="resultInputFocused = true"
|
placeholder="输入修改建议,或让 AI 继续生成"
|
||||||
@blur="resultInputFocused = false"
|
|
||||||
@confirm="sendChat"
|
@confirm="sendChat"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="chat-send-btn" :class="{ disabled: !chatInput.trim() || generating }" @click="sendChat">发送</view>
|
<view class="chat-send-btn" :class="{ disabled: !chatInput.trim() || generating }" @click="sendChat">发送</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -3601,4 +3509,198 @@ onUnmounted(() => {
|
|||||||
box-shadow: 0 16rpx 36rpx rgba(168, 85, 247, 0.24);
|
box-shadow: 0 16rpx 36rpx rgba(168, 85, 247, 0.24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-page {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: #13091f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-top-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 24rpx 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-scroll {
|
||||||
|
flex: 1;
|
||||||
|
height: calc(100vh - 220rpx);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-scroll-content {
|
||||||
|
padding: 0 24rpx 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-answered {
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
font-size: 26rpx;
|
||||||
|
padding: 16rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-title {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-logline {
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-beats {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20rpx;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.beat-item {
|
||||||
|
display: flex;
|
||||||
|
gap: 20rpx;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.beat-order {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 56rpx;
|
||||||
|
height: 56rpx;
|
||||||
|
background: #087e8b;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.beat-content {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.beat-title {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.beat-summary {
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
font-size: 26rpx;
|
||||||
|
margin-top: 8rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-ending {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
padding-top: 24rpx;
|
||||||
|
border-top: 2rpx solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ending-label {
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 24rpx;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ending-text {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-actions {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-feedback {
|
||||||
|
width: 100%;
|
||||||
|
padding: 20rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 16rpx;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.novel-text {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.8;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typing-cursor {
|
||||||
|
color: #087e8b;
|
||||||
|
animation: blink 900ms steps(1) infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
padding: 24rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resume-action {
|
||||||
|
padding: 24rpx 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-input-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 16rpx;
|
||||||
|
padding: 16rpx 24rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
border-top: 2rpx solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-input-shell {
|
||||||
|
flex: 1;
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
padding: 8rpx 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-chat-input {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 60rpx;
|
||||||
|
padding: 12rpx 0;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-send-btn {
|
||||||
|
padding: 16rpx 32rpx;
|
||||||
|
background: #087e8b;
|
||||||
|
border-radius: 32rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-send-btn.disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes blink {
|
||||||
|
50% { opacity: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user