AIQuestions.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. <template>
  2. <!-- 数字人智能问答 -->
  3. <div class="home-container">
  4. <!-- 展开收起侧边栏 -->
  5. <div
  6. class="icon-expand"
  7. :style="{
  8. backgroundColor: drawerVisible ? '#44449c' : '#7F70C840',
  9. left: drawerVisible ? '18%' : '0',
  10. }"
  11. @click="toggleDrawer"
  12. >
  13. <span
  14. class="vertical-lines"
  15. :style="{
  16. color: drawerVisible ? '#8a78d0' : 'white',
  17. }"
  18. >||</span
  19. >
  20. </div>
  21. <!-- 左侧折叠面板 -->
  22. <LeftPanel ref="leftPanelRef" v-if="drawerVisible" />
  23. <!-- 原左侧折叠面板和右侧AI问答 -->
  24. <div class="content-wrapper">
  25. <div class="left-group2">
  26. <div class="title-box">
  27. <div class="box-icon" @click="goBack">
  28. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  29. {{ personName }}
  30. </div>
  31. </div>
  32. <div class="selected-image">
  33. <img :src="selectedImage" alt="" />
  34. </div>
  35. </div>
  36. <!-- 右侧AI问答 -->
  37. <div class="number-people">
  38. <div class="content-box">
  39. <!-- AI对话框 -->
  40. <div class="chat-dialog">
  41. <!-- 对话消息列表 -->
  42. <div class="message-list" ref="messageListRef">
  43. <div v-for="(item, index) in messageList" :key="index">
  44. <!-- AI消息 -->
  45. <div class="ai-message" v-if="item.type !== 'user'">
  46. <MarkdownView class="left-text" :content="item.content" />
  47. <!-- {{item.content}} -->
  48. </div>
  49. <!-- 用户消息 -->
  50. <div class="user-message" v-if="item.type === 'user'">
  51. {{ item.content }}
  52. </div>
  53. </div>
  54. </div>
  55. <!-- 默认消息 -->
  56. <DefaultMessage
  57. v-if="showDefaultMessages"
  58. @select-message="handleDefaultMessageSelect"
  59. :category="route.query.category"
  60. :quest-tip="route.query.default"
  61. />
  62. <!-- 输入框和发送按钮 -->
  63. <div class="input-section">
  64. <input
  65. type="text"
  66. v-model="prompt"
  67. placeholder="问我任何问题..."
  68. @keyup.enter="handleSendByKeydown"
  69. />
  70. <button @click="handleSendByButton">发送</button>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script setup>
  79. import {ref, onMounted, computed, watch, nextTick} from "vue";
  80. import { CreateDialogue, sendChatMessageStream } from "@/api/questions.js";
  81. import { useRouter, useRoute } from "vue-router";
  82. import { saveRecord } from '@/api/personalized/index.js'
  83. // 导入全局状态
  84. import { globalState } from '@/utils/globalState.js'
  85. import MarkdownView from "@/components/MarkdownView/index.vue";
  86. import {
  87. Document,
  88. Menu as IconMenu,
  89. Location,
  90. Setting,
  91. ArrowLeftBold,
  92. MagicStick,
  93. ChatLineRound,
  94. Fold,
  95. Expand,
  96. Picture,
  97. Tickets,
  98. User,
  99. } from "@element-plus/icons-vue";
  100. import DefaultMessage from "@/components/DefaultMessage/index.vue";
  101. // 导入图片
  102. // import question from '@/assets/icon/question.png'
  103. // import painting from '@/assets/icon/painting.png'
  104. // import human from '@/assets/icon/human.png'
  105. import LeftPanel from "@/components/LeftPanel.vue";
  106. const leftPanelRef = ref(null);
  107. // 默认消息控制
  108. const showDefaultMessages = ref(true);
  109. const handleDefaultMessageSelect = (message) => {
  110. prompt.value = message;
  111. handleSendByButton();
  112. showDefaultMessages.value = false;
  113. };
  114. // 添加抽屉显示状态
  115. const drawerVisible = ref(true);
  116. // 添加切换抽屉显示状态的函数
  117. const toggleDrawer = () => {
  118. drawerVisible.value = !drawerVisible.value;
  119. };
  120. // 处理菜单展开和关闭
  121. const handleOpen = () => {};
  122. const handleClose = () => {};
  123. // 返回上一页
  124. const goBack = () => {
  125. router.push("/ai-laboratory");
  126. };
  127. const router = useRouter();
  128. const route = useRoute();
  129. const personId = ref(route.query.id);
  130. const personName = ref(route.query.name);
  131. const personIntroduce = ref(route.query.message);
  132. const personImage = ref(route.query.image);
  133. // 渲染实验室携带的人物形象图片
  134. const selectedImage = ref("");
  135. onMounted(() => {
  136. const image = route.query.image;
  137. if (image) {
  138. selectedImage.value = image;
  139. }
  140. });
  141. // 聊天对话
  142. const activeConversationModelPath = ref(null); // 选中的对话编号
  143. const activeConversationId = ref(null); // 选中的对话编号
  144. const activeConversation = ref(null); // 选中的 Conversation
  145. const conversationInProgress = ref(false); // 对话是否正在进行中。目前只有【发送】消息时,会更新为 true,避免切换对话、删除对话等操作,导致 stream 中断
  146. // 消息列表
  147. const messageRef = ref();
  148. const activeMessageList = ref([]); // 选中对话的消息列表
  149. const activeMessageListLoading = ref(false); // activeMessageList 是否正在加载中
  150. const activeMessageListLoadingTimer = ref(); // activeMessageListLoading Timer 定时器。如果加载速度很快,就不进入加载中
  151. // 消息滚动
  152. const textSpeed = ref(50); // Typing speed in milliseconds
  153. const textRoleRunning = ref(false); // Typing speed in milliseconds
  154. // 发送消息输入框
  155. const isComposing = ref(false); // 判断用户是否在输入
  156. const conversationInAbortController = ref(); // 对话进行中 abort 控制器(控制 stream 对话)
  157. const inputTimeout = ref(); // 处理输入中回车的定时器
  158. const prompt = ref(); // prompt
  159. const enableContext = ref(true); // 是否开启上下文
  160. // 接收 Stream 消息
  161. const receiveMessageFullText = ref("");
  162. const receiveMessageDisplayedText = ref("");
  163. const messageListRef = ref(null);
  164. // =========== 【聊天对话】相关 ===========
  165. /** 获取对话信息 */
  166. const getConversation = async (id) => {
  167. if (!id) {
  168. return;
  169. }
  170. const conversation = ref({});
  171. if (!conversation) {
  172. return;
  173. }
  174. conversation.systemMessage = personIntroduce.value;
  175. activeConversation.value = conversation;
  176. // activeConversationId.value = personId.value
  177. activeConversationModelPath.value = personImage.value;
  178. };
  179. // =========== 【发送消息】相关 ===========
  180. /** 处理来自 keydown 的发送消息 */
  181. const handleSendByKeydown = async (event) => {
  182. // 判断用户是否在输入
  183. if (isComposing.value) {
  184. return;
  185. }
  186. // 进行中不允许发送
  187. if (conversationInProgress.value) {
  188. return;
  189. }
  190. const content = prompt.value?.trim();
  191. if (event.key === "Enter") {
  192. if (event.shiftKey) {
  193. // 插入换行
  194. prompt.value += "\r\n";
  195. event.preventDefault(); // 防止默认的换行行为
  196. } else {
  197. // 发送消息
  198. await doSendMessage(content);
  199. event.preventDefault(); // 防止默认的提交行为
  200. }
  201. }
  202. };
  203. /** 处理来自【发送】按钮的发送消息 */
  204. const handleSendByButton = () => {
  205. doSendMessage(prompt.value?.trim());
  206. };
  207. /** 处理 prompt 输入变化 */
  208. const handlePromptInput = (event) => {
  209. // 非输入法 输入设置为 true
  210. if (!isComposing.value) {
  211. // 回车 event data 是 null
  212. if (event.data == null) {
  213. return;
  214. }
  215. isComposing.value = true;
  216. }
  217. // 清理定时器
  218. if (inputTimeout.value) {
  219. clearTimeout(inputTimeout.value);
  220. }
  221. // 重置定时器
  222. inputTimeout.value = setTimeout(() => {
  223. isComposing.value = false;
  224. }, 400);
  225. };
  226. // TODO注:是不是可以通过 @keydown.enter、@keydown.shift.enter 来实现,回车发送、shift+回车换行;主要看看,是不是可以简化 isComposing 相关的逻辑
  227. const onCompositionstart = () => {
  228. isComposing.value = true;
  229. };
  230. const onCompositionend = () => {
  231. setTimeout(() => {
  232. isComposing.value = false;
  233. }, 200);
  234. };
  235. // 保存记录
  236. // 年级ID相关
  237. const gradeId = ref('')
  238. // 添加消息计数器变量
  239. const messageCount = ref(0)
  240. onMounted(() => {
  241. // 从全局状态初始化年级ID
  242. gradeId.value = globalState.initGradeId()
  243. });
  244. /** 真正执行【发送】消息操作 */
  245. const doSendMessage = async (content) => {
  246. // 校验
  247. if (content.length < 1) {
  248. console.error("发送失败,原因:内容为空!");
  249. return;
  250. }
  251. if (activeConversationId.value == null) {
  252. console.error("还没创建对话,不能发送!");
  253. return;
  254. }
  255. // 递增消息计数器
  256. messageCount.value++
  257. // 发送saveRecord请求 保存消息次数
  258. try{
  259. await saveRecord({
  260. brpNjId: gradeId.value,
  261. brpType: "aiCount",
  262. brpProgress: messageCount.value
  263. });
  264. }catch(error){
  265. console.error('保存记录失败:', error);
  266. }
  267. // 清空输入框
  268. prompt.value = "";
  269. // 执行发送
  270. await doSendMessageStream({
  271. conversationId: activeConversationId.value,
  272. content: content,
  273. });
  274. };
  275. import { useAudioPlayer } from '@/components/TTS/useAudioPlayer';
  276. const { playAudioChunk } = useAudioPlayer();
  277. /** 真正执行【发送】消息操作 */
  278. const doSendMessageStream = async (userMessage) => {
  279. // 创建 AbortController 实例,以便中止请求
  280. conversationInAbortController.value = new AbortController();
  281. // 标记对话进行中
  282. conversationInProgress.value = true;
  283. // 设置为空
  284. receiveMessageFullText.value = "";
  285. try {
  286. // 1.1 先添加两个假数据,等 stream 返回再替换
  287. activeMessageList.value.push({
  288. id: -1,
  289. conversationId: activeConversationId.value,
  290. type: "user",
  291. content: userMessage.content,
  292. createTime: new Date(),
  293. });
  294. activeMessageList.value.push({
  295. id: -2,
  296. conversationId: activeConversationId.value,
  297. type: "assistant",
  298. content: "思考中...",
  299. createTime: new Date(),
  300. });
  301. // 1.3 开始滚动
  302. textRoll();
  303. // 2. 发送 event stream
  304. let isFirstChunk = true; // 是否是第一个 chunk 消息段
  305. await sendChatMessageStream(
  306. userMessage.conversationId,
  307. userMessage.content,
  308. conversationInAbortController.value,
  309. enableContext.value,
  310. async (res) => {
  311. const { code, data, msg } = JSON.parse(res.data);
  312. if (code !== 0) {
  313. console.log(`对话异常! ${msg}`);
  314. return;
  315. }
  316. // 根据事件类型处理
  317. if (data.eventType === 'TEXT') {
  318. // 如果内容为空,就不处理。
  319. if (data.receive?.content === '') {
  320. return
  321. }
  322. // 处理文本消息
  323. receiveMessageFullText.value += data.receive.content;
  324. // 首次返回需要添加一个 message 到页面,后面的都是更新
  325. if (isFirstChunk) {
  326. isFirstChunk = false;
  327. // 弹出两个假数据
  328. activeMessageList.value.pop();
  329. activeMessageList.value.pop();
  330. // 更新返回的数据
  331. activeMessageList.value.push(data.send);
  332. activeMessageList.value.push(data.receive);
  333. }
  334. } else if (data.eventType === 'AUDIO') {
  335. // 处理音频消息
  336. await playAudioChunk(data.audioData);
  337. }
  338. },
  339. (error) => {
  340. console.log(`对话异常! ${error}`);
  341. stopStream();
  342. // 需要抛出异常,禁止重试
  343. throw error;
  344. },
  345. () => {
  346. stopStream();
  347. }
  348. );
  349. } catch {}
  350. };
  351. /** 停止 stream 流式调用 */
  352. const stopStream = async () => {
  353. // tip:如果 stream 进行中的 message,就需要调用 controller 结束
  354. if (conversationInAbortController.value) {
  355. conversationInAbortController.value.abort();
  356. }
  357. // 设置为 false
  358. conversationInProgress.value = false;
  359. };
  360. /**
  361. * 消息列表
  362. *
  363. * 和 {@link #getMessageList()} 的差异是,把 systemMessage 考虑进去
  364. */
  365. const messageList = computed(() => {
  366. if (activeMessageList.value.length > 0) {
  367. return activeMessageList.value;
  368. }
  369. // 没有消息时,如果有 systemMessage 则展示它
  370. if (activeConversation.value?.systemMessage) {
  371. let systemMessage = {
  372. id: 0,
  373. type: "system",
  374. content: activeConversation.value.systemMessage,
  375. };
  376. activeMessageList.value.push(systemMessage);
  377. return [systemMessage];
  378. }
  379. return [];
  380. });
  381. // ============== 【消息滚动】相关 =============
  382. /** 滚动到 message 底部 */
  383. const scrollToBottom = async (isIgnore = false) => {
  384. await nextTick();
  385. if (messageListRef.value) {
  386. messageListRef.value.scrollTop = messageListRef.value.scrollHeight;
  387. }
  388. };
  389. /** 自提滚动效果 */
  390. const textRoll = async () => {
  391. let index = 0;
  392. try {
  393. // 只能执行一次
  394. if (textRoleRunning.value) {
  395. return;
  396. }
  397. // 设置状态
  398. textRoleRunning.value = true;
  399. receiveMessageDisplayedText.value = "";
  400. const task = async () => {
  401. // 调整速度
  402. const diff =
  403. (receiveMessageFullText.value.length -
  404. receiveMessageDisplayedText.value.length) /
  405. 10;
  406. if (diff > 5) {
  407. textSpeed.value = 10;
  408. } else if (diff > 2) {
  409. textSpeed.value = 30;
  410. } else if (diff > 1.5) {
  411. textSpeed.value = 50;
  412. } else {
  413. textSpeed.value = 100;
  414. }
  415. // 对话结束,就按 30 的速度
  416. if (!conversationInProgress.value) {
  417. textSpeed.value = 10;
  418. }
  419. if (index < receiveMessageFullText.value.length) {
  420. receiveMessageDisplayedText.value += receiveMessageFullText.value[index];
  421. index++;
  422. // 更新 message
  423. const lastMessage =
  424. activeMessageList.value[activeMessageList.value.length - 1];
  425. lastMessage.content = receiveMessageDisplayedText.value;
  426. // 滚动到住下面
  427. await scrollToBottom();
  428. // 重新设置任务
  429. timer = setTimeout(task, textSpeed.value);
  430. } else {
  431. // 不是对话中可以结束
  432. if (!conversationInProgress.value) {
  433. textRoleRunning.value = false;
  434. clearTimeout(timer);
  435. } else {
  436. // 重新设置任务
  437. timer = setTimeout(task, textSpeed.value);
  438. }
  439. }
  440. };
  441. let timer = setTimeout(task, textSpeed.value);
  442. } catch {}
  443. };
  444. /** 初始化 **/
  445. onMounted(async () => {
  446. if (personId.value) {
  447. // 智能问答
  448. CreateDialogue({ roleId: personId.value })
  449. .then((res) => {
  450. console.log("创建会话:", res);
  451. activeConversationId.value = res.data;
  452. })
  453. .catch((error) => {
  454. console.error("请求出错:", error);
  455. });
  456. await getConversation(personId.value);
  457. }
  458. // 获取列表数据
  459. // activeMessageListLoading.value = true
  460. });
  461. </script>
  462. <style scoped lang="scss">
  463. @use "sass:math";
  464. // 定义rpx转换函数
  465. @function rpx($px) {
  466. @return math.div($px, 750) * 100vw;
  467. }
  468. /* 添加过渡样式 */
  469. .drawer-slide-enter-active,
  470. .drawer-slide-leave-active {
  471. transition: all 0.3s ease;
  472. }
  473. .drawer-slide-enter-from,
  474. .drawer-slide-leave-to {
  475. transform: translateX(-100%);
  476. opacity: 0;
  477. }
  478. .home-container {
  479. position: fixed;
  480. top: 0;
  481. left: 0;
  482. right: 0;
  483. bottom: 0;
  484. display: flex;
  485. flex-direction: row;
  486. gap: rpx(0);
  487. background: linear-gradient(to bottom, #e2ddfc, #f1effd);
  488. }
  489. .icon-expand {
  490. width: rpx(8);
  491. height: rpx(35);
  492. border-top-right-radius: rpx(5);
  493. border-bottom-right-radius: rpx(5);
  494. z-index: 9999;
  495. position: absolute;
  496. top: 50%;
  497. left: 18%;
  498. transform: translateY(-50%);
  499. background-color: #44449c;
  500. cursor: pointer; // 添加鼠标指针样式
  501. clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  502. display: flex;
  503. justify-content: center;
  504. align-items: center;
  505. transition: all 0.3s ease;
  506. }
  507. .icon-expand .vertical-lines {
  508. color: #8a78d0;
  509. font-size: rpx(10);
  510. }
  511. .menu-icon {
  512. width: rpx(11);
  513. height: rpx(11);
  514. margin-right: rpx(2);
  515. }
  516. .content-wrapper {
  517. display: flex;
  518. flex: 1;
  519. }
  520. .left-group {
  521. width: rpx(135);
  522. height: 100%;
  523. background: linear-gradient(to bottom, #001169, #8a78d0);
  524. }
  525. .mb-2 {
  526. color: black;
  527. margin-top: rpx(1);
  528. }
  529. .tac ::v-deep(.el-menu) {
  530. background-color: transparent;
  531. border: none;
  532. width: 100%;
  533. margin-top: rpx(55);
  534. margin-left: rpx(10);
  535. }
  536. .el-menu-item {
  537. width: rpx(115);
  538. height: rpx(25);
  539. margin-bottom: rpx(5);
  540. border-radius: rpx(6);
  541. color: white;
  542. font-size: rpx(8);
  543. }
  544. .el-menu-item .el-icon svg {
  545. font-size: rpx(15);
  546. color: white;
  547. }
  548. .el-menu ::v-deep(.el-menu-item:hover),
  549. .el-menu ::v-deep(.el-menu-item:focus),
  550. .el-menu ::v-deep(.el-menu-item:active) {
  551. background: linear-gradient(
  552. to bottom,
  553. #ffefb0,
  554. #ffcc00
  555. ); /* 设置悬停、聚焦、点击状态下的背景色 */
  556. box-shadow: 0 8px 8px rgb(0, 0, 0, 0.3);
  557. color: black;
  558. font-size: rpx(8);
  559. }
  560. .el-menu .el-menu-item.is-active {
  561. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  562. color: black;
  563. font-size: rpx(8);
  564. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  565. }
  566. // 侧边栏
  567. .left-group2 {
  568. width: rpx(150);
  569. height: 100%;
  570. display: flex;
  571. background-color: #ece9fd;
  572. }
  573. .left-group2 img {
  574. width: rpx(120);
  575. // height: auto;
  576. }
  577. .selected-image {
  578. flex: 1;
  579. margin: auto;
  580. margin-left: rpx(-60);
  581. }
  582. .title-box {
  583. height: rpx(50);
  584. }
  585. .box-icon {
  586. width: 100%;
  587. height: 100%;
  588. flex: 1;
  589. display: flex; // 添加 flex 布局
  590. align-items: center; // 垂直居中
  591. color: black; // 设置图标颜色为白色
  592. padding-left: rpx(15);
  593. font-size: rpx(10); // 设置图标大小,可按需调整
  594. cursor: pointer; // 添加鼠标指针样式
  595. }
  596. .box-icon .left-icon {
  597. margin-left: rpx(10);
  598. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  599. }
  600. .number-people {
  601. flex: 1;
  602. height: 100%;
  603. display: flex;
  604. background-color: #ece9fd;
  605. }
  606. .content-box {
  607. flex: 1;
  608. margin-top: rpx(10);
  609. margin-bottom: rpx(10);
  610. margin-right: rpx(10);
  611. border-radius: rpx(15);
  612. background: rgba($color: #ffffff, $alpha: 0.5);
  613. }
  614. // 对话框
  615. .chat-dialog {
  616. display: flex;
  617. flex-direction: column;
  618. height: 100%;
  619. }
  620. .message-list {
  621. flex: 1;
  622. overflow-y: auto;
  623. padding: rpx(15);
  624. }
  625. /* 自定义滚动条样式 */
  626. .message-list::-webkit-scrollbar {
  627. width: rpx(2); /* 滚动条宽度 */
  628. }
  629. .message-list::-webkit-scrollbar-track {
  630. background: #f1effd; /* 滚动条轨道背景色 */
  631. border-radius: rpx(4);
  632. }
  633. .message-list::-webkit-scrollbar-thumb {
  634. background: #e2ddfc; /* 滚动条滑块颜色 */
  635. border-radius: rpx(4);
  636. }
  637. .message-list::-webkit-scrollbar-thumb:hover {
  638. background: #e2ddfc; /* 滚动条滑块 hover 状态颜色 */
  639. }
  640. .message-list .user-message {
  641. background-color: #ffffff;
  642. margin-left: auto; // 消息靠右显示
  643. margin-right: 0; // 重置右边距
  644. margin-bottom: rpx(10);
  645. max-width: rpx(400);
  646. font-size: rpx(8);
  647. width: fit-content; // 宽度随文字内容变化
  648. border-radius: rpx(5);
  649. padding: rpx(5);
  650. text-align: left; // 文字左对齐
  651. }
  652. .message-list .ai-message {
  653. background-color: #ffdd55;
  654. margin-left: 0; // 消息靠左显示
  655. margin-right: auto; // 重置右边距
  656. margin-bottom: rpx(10);
  657. width: fit-content;
  658. max-width: rpx(400);
  659. padding: rpx(5);
  660. font-size: rpx(8);
  661. border-radius: rpx(5);
  662. text-align: left; // 文字左对齐
  663. }
  664. .input-section {
  665. display: flex;
  666. padding: rpx(10);
  667. gap: rpx(10);
  668. }
  669. .input-section input {
  670. flex: 1;
  671. padding: rpx(5);
  672. font-size: rpx(7);
  673. border: 1px solid #ccc;
  674. border-radius: rpx(5);
  675. }
  676. .input-section button {
  677. padding: rpx(5) rpx(15);
  678. background: linear-gradient(
  679. to bottom,
  680. #fee78a,
  681. #ffce1b
  682. ); /* 设置悬停、聚焦、点击状态下的背景色 */
  683. color: black;
  684. border: none;
  685. font-size: rpx(7);
  686. border-radius: rpx(5);
  687. cursor: pointer;
  688. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.3);
  689. }
  690. </style>