<template>
  <div id="root">
    <div class="cb86951c">
      <div class="c3ecdb44">
        <div class="f2eea526">
          <div class="a5cd95be">
            <div class="b83ee326">
              <div class="f6004764">
                <div class="dad65929" v-if="showList" @wheel="handleScroll" style="flex-grow: 0;margin: 0px auto;overflow: auto;"
                  ref="chatContainerRef" >
                  <div v-for="item in paramMsg">
                    <div v-if="item.role == 'user'" class="fa81">
                      <div class="fbb737a4">{{ item.content }}<div class="ds-flex e0558cb1"
                          style="position: absolute; right: calc(100% + 18px); top: 12px; gap: 12px;">
                          <div class="ds-icon-button" tabindex="0"
                            style="--ds-icon-button-text-color: #909090; --ds-icon-button-size: 20px;">
                            <div @click="copy(item.content)" class="ds-icon"
                              style="font-size: 20px; width: 20px; height: 20px;"><svg viewBox="0 0 20 20" fill="none"
                                xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                                <defs>
                                  <clippath id="clip1257_20794">
                                    <rect id="复制" width="20.000000" height="20.000000" fill="white" fill-opacity="0">
                                    </rect>
                                  </clippath>
                                </defs>
                                <g clip-path="url(#clip1257_20794)">
                                  <g clip-path="url(#clip1248_20193)">
                                    <path id="path"
                                      d="M5.03 14.64C4.77 14.64 4.5 14.62 4.24 14.56C3.98 14.51 3.73 14.43 3.49 14.33C3.24 14.23 3.01 14.1 2.79 13.96C2.57 13.81 2.37 13.64 2.18 13.45C1.99 13.26 1.82 13.05 1.68 12.83C1.53 12.61 1.4 12.37 1.3 12.13C1.2 11.88 1.13 11.63 1.07 11.36C1.02 11.1 1 10.84 1 10.57L1 5.07C1 4.8 1.02 4.54 1.07 4.27C1.13 4.01 1.2 3.76 1.3 3.51C1.4 3.26 1.53 3.03 1.68 2.81C1.82 2.58 1.99 2.38 2.18 2.19C2.37 2 2.57 1.83 2.79 1.68C3.01 1.53 3.24 1.41 3.49 1.31C3.73 1.2 3.98 1.13 4.24 1.07C4.5 1.02 4.77 1 5.03 1L10.49 1C10.75 1 11.01 1.02 11.27 1.07C11.53 1.13 11.78 1.2 12.03 1.31C12.27 1.41 12.51 1.53 12.73 1.68C12.95 1.83 13.15 2 13.34 2.19C13.53 2.38 13.69 2.58 13.84 2.81C13.99 3.03 14.11 3.26 14.21 3.51C14.31 3.76 14.39 4.01 14.44 4.27C14.5 4.54 14.52 4.8 14.52 5.07L12.94 5.07C12.94 4.91 12.92 4.75 12.89 4.58C12.86 4.43 12.81 4.27 12.75 4.12C12.69 3.97 12.61 3.83 12.52 3.69C12.43 3.56 12.33 3.43 12.22 3.32C12.1 3.2 11.98 3.1 11.85 3.01C11.71 2.92 11.57 2.84 11.42 2.78C11.27 2.72 11.12 2.67 10.96 2.64C10.81 2.61 10.65 2.59 10.49 2.59L5.03 2.59C4.87 2.59 4.71 2.61 4.55 2.64C4.4 2.67 4.24 2.72 4.09 2.78C3.95 2.84 3.8 2.92 3.67 3.01C3.54 3.1 3.41 3.2 3.3 3.32C3.18 3.43 3.08 3.56 2.99 3.69C2.9 3.83 2.83 3.97 2.77 4.12C2.71 4.27 2.66 4.43 2.63 4.58C2.6 4.75 2.58 4.91 2.58 5.07L2.58 10.57C2.58 10.73 2.6 10.89 2.63 11.05C2.66 11.21 2.71 11.37 2.77 11.52C2.83 11.67 2.9 11.81 2.99 11.94C3.08 12.08 3.18 12.2 3.3 12.32C3.41 12.43 3.54 12.54 3.67 12.63C3.8 12.72 3.95 12.79 4.09 12.86C4.24 12.92 4.4 12.96 4.55 13C4.71 13.03 4.87 13.04 5.03 13.04L5.03 14.64Z"
                                      fill="currentColor" fill-opacity="1.000000" fill-rule="evenodd"></path>
                                  </g>
                                  <path id="path"
                                    d="M14.75 18.91L9.3 18.91C9.03 18.91 8.77 18.88 8.51 18.83C8.25 18.78 8 18.7 7.75 18.6C7.51 18.49 7.27 18.37 7.05 18.22C6.83 18.07 6.63 17.9 6.44 17.71C6.25 17.52 6.09 17.32 5.94 17.1C5.79 16.87 5.67 16.64 5.57 16.39C5.47 16.14 5.39 15.89 5.34 15.63C5.28 15.37 5.26 15.1 5.26 14.83L5.26 9.33C5.26 9.06 5.28 8.8 5.34 8.54C5.39 8.28 5.47 8.02 5.57 7.77C5.67 7.53 5.79 7.29 5.94 7.07C6.09 6.85 6.25 6.64 6.44 6.45C6.63 6.26 6.83 6.09 7.05 5.95C7.27 5.8 7.51 5.67 7.75 5.57C8 5.47 8.25 5.39 8.51 5.34C8.77 5.29 9.03 5.26 9.3 5.26L14.75 5.26C15.01 5.26 15.28 5.29 15.54 5.34C15.8 5.39 16.05 5.47 16.29 5.57C16.54 5.67 16.77 5.8 16.99 5.95C17.21 6.09 17.41 6.26 17.6 6.45C17.79 6.64 17.96 6.85 18.1 7.07C18.25 7.29 18.37 7.53 18.48 7.77C18.58 8.02 18.65 8.28 18.71 8.54C18.76 8.8 18.78 9.06 18.78 9.33L18.78 14.83C18.78 15.1 18.76 15.37 18.71 15.63C18.65 15.89 18.58 16.14 18.48 16.39C18.37 16.64 18.25 16.87 18.1 17.1C17.96 17.32 17.79 17.52 17.6 17.71C17.41 17.9 17.21 18.07 16.99 18.22C16.77 18.37 16.54 18.49 16.29 18.6C16.05 18.7 15.8 18.78 15.54 18.83C15.28 18.88 15.01 18.91 14.75 18.91ZM9.3 6.86C9.13 6.86 8.97 6.87 8.82 6.91C8.66 6.94 8.51 6.98 8.36 7.05C8.21 7.11 8.07 7.18 7.93 7.28C7.8 7.37 7.68 7.47 7.56 7.58C7.45 7.7 7.35 7.82 7.26 7.96C7.17 8.09 7.09 8.24 7.03 8.38C6.97 8.54 6.92 8.69 6.89 8.85C6.86 9.01 6.84 9.17 6.84 9.33L6.84 14.83C6.84 15 6.86 15.16 6.89 15.32C6.92 15.48 6.97 15.63 7.03 15.78C7.09 15.93 7.17 16.07 7.26 16.21C7.35 16.34 7.45 16.47 7.56 16.58C7.68 16.7 7.8 16.8 7.93 16.89C8.07 16.98 8.21 17.06 8.36 17.12C8.51 17.18 8.66 17.23 8.82 17.26C8.97 17.29 9.13 17.31 9.3 17.31L14.75 17.31C14.91 17.31 15.07 17.29 15.23 17.26C15.38 17.23 15.54 17.18 15.69 17.12C15.83 17.06 15.98 16.98 16.11 16.89C16.24 16.8 16.37 16.7 16.48 16.58C16.59 16.47 16.7 16.34 16.79 16.21C16.87 16.07 16.95 15.93 17.01 15.78C17.07 15.63 17.12 15.48 17.15 15.32C17.18 15.16 17.2 15 17.2 14.83L17.2 9.33C17.2 9.17 17.18 9.01 17.15 8.85C17.12 8.69 17.07 8.54 17.01 8.38C16.95 8.24 16.87 8.09 16.79 7.96C16.7 7.82 16.59 7.7 16.48 7.58C16.37 7.47 16.24 7.37 16.11 7.28C15.98 7.19 15.83 7.11 15.69 7.05C15.54 6.98 15.38 6.94 15.23 6.91C15.07 6.87 14.91 6.86 14.75 6.86L9.3 6.86Z"
                                    fill="currentColor" fill-opacity="1.000000" fill-rule="nonzero"></path>
                                </g>
                              </svg></div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div v-if="item.role == 'assistant'" class="f9bf7997 d7dc56a8 c05b5566">
                      <div class="eb23581b dfa60d66">
                        <img src="@/assets/ai-logo.png" style="width: 100%;border-radius: 50%;">
                      </div>
                      <div class="edb250b1">
                        <div v-if="item.skLong && item.msgCode == 1" class="a6d716f5 db5991dd">
                          <div class="ds-icon acbf4957" style="font-size: 12px; width: 12px; height: 12px;"><svg
                              width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
                              <path
                                d="M2.656 17.344c-1.016-1.015-1.15-2.75-.313-4.925.325-.825.73-1.617 1.205-2.365L3.582 10l-.033-.054c-.5-.799-.91-1.596-1.206-2.365-.836-2.175-.703-3.91.313-4.926.56-.56 1.364-.86 2.335-.86 1.425 0 3.168.636 4.957 1.756l.053.034.053-.034c1.79-1.12 3.532-1.757 4.957-1.757.972 0 1.776.3 2.335.86 1.014 1.015 1.148 2.752.312 4.926a13.892 13.892 0 0 1-1.206 2.365l-.034.054.034.053c.5.8.91 1.596 1.205 2.365.837 2.175.704 3.911-.311 4.926-.56.56-1.364.861-2.335.861-1.425 0-3.168-.637-4.957-1.757L10 16.415l-.053.033c-1.79 1.12-3.532 1.757-4.957 1.757-.972 0-1.776-.3-2.335-.86zm13.631-4.399c-.187-.488-.429-.988-.71-1.492l-.075-.132-.092.12a22.075 22.075 0 0 1-3.968 3.968l-.12.093.132.074c1.308.734 2.559 1.162 3.556 1.162.563 0 1.006-.138 1.298-.43.3-.3.436-.774.428-1.346-.008-.575-.159-1.264-.449-2.017zm-6.345 1.65l.058.042.058-.042a19.881 19.881 0 0 0 4.551-4.537l.043-.058-.043-.058a20.123 20.123 0 0 0-2.093-2.458 19.732 19.732 0 0 0-2.458-2.08L10 5.364l-.058.042A19.883 19.883 0 0 0 5.39 9.942L5.348 10l.042.059c.631.874 1.332 1.695 2.094 2.457a19.74 19.74 0 0 0 2.458 2.08zm6.366-10.902c-.293-.293-.736-.431-1.298-.431-.998 0-2.248.429-3.556 1.163l-.132.074.12.092a21.938 21.938 0 0 1 3.968 3.968l.092.12.074-.132c.282-.504.524-1.004.711-1.492.29-.753.442-1.442.45-2.017.007-.572-.129-1.045-.429-1.345zM3.712 7.055c.202.514.44 1.013.712 1.493l.074.13.092-.119a21.94 21.94 0 0 1 3.968-3.968l.12-.092-.132-.074C7.238 3.69 5.987 3.262 4.99 3.262c-.563 0-1.006.138-1.298.43-.3.301-.436.774-.428 1.346.007.575.159 1.264.448 2.017zm0 5.89c-.29.753-.44 1.442-.448 2.017-.008.572.127 1.045.428 1.345.293.293.736.431 1.298.431.997 0 2.247-.428 3.556-1.162l.131-.074-.12-.093a21.94 21.94 0 0 1-3.967-3.968l-.093-.12-.074.132a11.712 11.712 0 0 0-.71 1.492z"
                                fill="currentColor" stroke="currentColor" stroke-width=".1"></path>
                              <path d="M10.706 11.704A1.843 1.843 0 0 1 8.155 10a1.845 1.845 0 1 1 2.551 1.704z"
                                fill="currentColor" stroke="currentColor" stroke-width=".2"></path>
                            </svg>
                          </div>思考中...
                        </div>
                        <div v-if="!item.skLong && item.msgCode == 0" class="a6d716f5 db5991dd">
                          <div class="ds-icon acbf4957" style="font-size: 12px; width: 12px; height: 12px;"><svg
                              width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
                              <path
                                d="M2.656 17.344c-1.016-1.015-1.15-2.75-.313-4.925.325-.825.73-1.617 1.205-2.365L3.582 10l-.033-.054c-.5-.799-.91-1.596-1.206-2.365-.836-2.175-.703-3.91.313-4.926.56-.56 1.364-.86 2.335-.86 1.425 0 3.168.636 4.957 1.756l.053.034.053-.034c1.79-1.12 3.532-1.757 4.957-1.757.972 0 1.776.3 2.335.86 1.014 1.015 1.148 2.752.312 4.926a13.892 13.892 0 0 1-1.206 2.365l-.034.054.034.053c.5.8.91 1.596 1.205 2.365.837 2.175.704 3.911-.311 4.926-.56.56-1.364.861-2.335.861-1.425 0-3.168-.637-4.957-1.757L10 16.415l-.053.033c-1.79 1.12-3.532 1.757-4.957 1.757-.972 0-1.776-.3-2.335-.86zm13.631-4.399c-.187-.488-.429-.988-.71-1.492l-.075-.132-.092.12a22.075 22.075 0 0 1-3.968 3.968l-.12.093.132.074c1.308.734 2.559 1.162 3.556 1.162.563 0 1.006-.138 1.298-.43.3-.3.436-.774.428-1.346-.008-.575-.159-1.264-.449-2.017zm-6.345 1.65l.058.042.058-.042a19.881 19.881 0 0 0 4.551-4.537l.043-.058-.043-.058a20.123 20.123 0 0 0-2.093-2.458 19.732 19.732 0 0 0-2.458-2.08L10 5.364l-.058.042A19.883 19.883 0 0 0 5.39 9.942L5.348 10l.042.059c.631.874 1.332 1.695 2.094 2.457a19.74 19.74 0 0 0 2.458 2.08zm6.366-10.902c-.293-.293-.736-.431-1.298-.431-.998 0-2.248.429-3.556 1.163l-.132.074.12.092a21.938 21.938 0 0 1 3.968 3.968l.092.12.074-.132c.282-.504.524-1.004.711-1.492.29-.753.442-1.442.45-2.017.007-.572-.129-1.045-.429-1.345zM3.712 7.055c.202.514.44 1.013.712 1.493l.074.13.092-.119a21.94 21.94 0 0 1 3.968-3.968l.12-.092-.132-.074C7.238 3.69 5.987 3.262 4.99 3.262c-.563 0-1.006.138-1.298.43-.3.301-.436.774-.428 1.346.007.575.159 1.264.448 2.017zm0 5.89c-.29.753-.44 1.442-.448 2.017-.008.572.127 1.045.428 1.345.293.293.736.431 1.298.431.997 0 2.247-.428 3.556-1.162l.131-.074-.12-.093a21.94 21.94 0 0 1-3.967-3.968l-.093-.12-.074.132a11.712 11.712 0 0 0-.71 1.492z"
                                fill="currentColor" stroke="currentColor" stroke-width=".1"></path>
                              <path d="M10.706 11.704A1.843 1.843 0 0 1 8.155 10a1.845 1.845 0 1 1 2.551 1.704z"
                                fill="currentColor" stroke="currentColor" stroke-width=".2"></path>
                            </svg>
                          </div>您的请求过于频繁，请您稍后再试...
                        </div>
                        <!--思考的转圈图标-->
                        <div v-if="item.skLong && item.msgCode == 1" class="ds-loading b4e4476b"
                          style="font-size: 20px;">
                          <svg viewBox="0 0 36 36" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            data-icon="spin">
                            <defs>
                              <linearGradient x1="0%" y1="100%" x2="100%" y2="100%" id="linearGradient-1">
                                <stop stop-color="currentColor" stop-opacity="0" offset="0%"></stop>
                                <stop stop-color="currentColor" stop-opacity="0.50" offset="39.9430698%"></stop>
                                <stop stop-color="currentColor" offset="100%"></stop>
                              </linearGradient>
                            </defs>
                            <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                              <rect fill-opacity="0.01" fill="none" x="0" y="0" width="36" height="36"></rect>
                              <path
                                d="M34,18 C34,9.163444 26.836556,2 18,2 C11.6597233,2 6.18078805,5.68784135 3.59122325,11.0354951"
                                stroke="url(#linearGradient-1)" stroke-width="4" stroke-linecap="round"></path>
                            </g>
                          </svg>
                        </div>
                        <!--思考的内容-->
                        <div class="e1675d8b" v-if="isNotEmpty(item.sk)">
                          <div class="ecc93a3b"></div>
                          <p class="ba94db8a">
                            {{ item.sk }}
                          </p>
                        </div>
                      </div>
                      <!--回答的内容-->
                      <div class="ds-markdown ds-markdown--block" style="--ds-md-zoom: 1.143;">
                        <div v-html="item.content"></div>
                      </div>
                      <div class="ds-flex" style="margin-top: 12px; height: 20px; align-items: center; gap: 12px;">
                        <div class="ds-flex abe97156" style="align-items: center; gap: 12px;">
                          <div class="ds-icon-button" tabindex="0"
                            style="--ds-icon-button-text-color: #909090; --ds-icon-button-size: 20px;">
                            <div @click="copy(item.content)" class="ds-icon"
                              style="font-size: 20px; width: 20px; height: 20px;"><svg viewBox="0 0 20 20" fill="none"
                                xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                                <defs>
                                  <clippath id="clip1257_20794">
                                    <rect id="复制" width="20.000000" height="20.000000" fill="white" fill-opacity="0">
                                    </rect>
                                  </clippath>
                                </defs>
                                <g clip-path="url(#clip1257_20794)">
                                  <g clip-path="url(#clip1248_20193)">
                                    <path id="path"
                                      d="M5.03 14.64C4.77 14.64 4.5 14.62 4.24 14.56C3.98 14.51 3.73 14.43 3.49 14.33C3.24 14.23 3.01 14.1 2.79 13.96C2.57 13.81 2.37 13.64 2.18 13.45C1.99 13.26 1.82 13.05 1.68 12.83C1.53 12.61 1.4 12.37 1.3 12.13C1.2 11.88 1.13 11.63 1.07 11.36C1.02 11.1 1 10.84 1 10.57L1 5.07C1 4.8 1.02 4.54 1.07 4.27C1.13 4.01 1.2 3.76 1.3 3.51C1.4 3.26 1.53 3.03 1.68 2.81C1.82 2.58 1.99 2.38 2.18 2.19C2.37 2 2.57 1.83 2.79 1.68C3.01 1.53 3.24 1.41 3.49 1.31C3.73 1.2 3.98 1.13 4.24 1.07C4.5 1.02 4.77 1 5.03 1L10.49 1C10.75 1 11.01 1.02 11.27 1.07C11.53 1.13 11.78 1.2 12.03 1.31C12.27 1.41 12.51 1.53 12.73 1.68C12.95 1.83 13.15 2 13.34 2.19C13.53 2.38 13.69 2.58 13.84 2.81C13.99 3.03 14.11 3.26 14.21 3.51C14.31 3.76 14.39 4.01 14.44 4.27C14.5 4.54 14.52 4.8 14.52 5.07L12.94 5.07C12.94 4.91 12.92 4.75 12.89 4.58C12.86 4.43 12.81 4.27 12.75 4.12C12.69 3.97 12.61 3.83 12.52 3.69C12.43 3.56 12.33 3.43 12.22 3.32C12.1 3.2 11.98 3.1 11.85 3.01C11.71 2.92 11.57 2.84 11.42 2.78C11.27 2.72 11.12 2.67 10.96 2.64C10.81 2.61 10.65 2.59 10.49 2.59L5.03 2.59C4.87 2.59 4.71 2.61 4.55 2.64C4.4 2.67 4.24 2.72 4.09 2.78C3.95 2.84 3.8 2.92 3.67 3.01C3.54 3.1 3.41 3.2 3.3 3.32C3.18 3.43 3.08 3.56 2.99 3.69C2.9 3.83 2.83 3.97 2.77 4.12C2.71 4.27 2.66 4.43 2.63 4.58C2.6 4.75 2.58 4.91 2.58 5.07L2.58 10.57C2.58 10.73 2.6 10.89 2.63 11.05C2.66 11.21 2.71 11.37 2.77 11.52C2.83 11.67 2.9 11.81 2.99 11.94C3.08 12.08 3.18 12.2 3.3 12.32C3.41 12.43 3.54 12.54 3.67 12.63C3.8 12.72 3.95 12.79 4.09 12.86C4.24 12.92 4.4 12.96 4.55 13C4.71 13.03 4.87 13.04 5.03 13.04L5.03 14.64Z"
                                      fill="currentColor" fill-opacity="1.000000" fill-rule="evenodd"></path>
                                  </g>
                                  <path id="path"
                                    d="M14.75 18.91L9.3 18.91C9.03 18.91 8.77 18.88 8.51 18.83C8.25 18.78 8 18.7 7.75 18.6C7.51 18.49 7.27 18.37 7.05 18.22C6.83 18.07 6.63 17.9 6.44 17.71C6.25 17.52 6.09 17.32 5.94 17.1C5.79 16.87 5.67 16.64 5.57 16.39C5.47 16.14 5.39 15.89 5.34 15.63C5.28 15.37 5.26 15.1 5.26 14.83L5.26 9.33C5.26 9.06 5.28 8.8 5.34 8.54C5.39 8.28 5.47 8.02 5.57 7.77C5.67 7.53 5.79 7.29 5.94 7.07C6.09 6.85 6.25 6.64 6.44 6.45C6.63 6.26 6.83 6.09 7.05 5.95C7.27 5.8 7.51 5.67 7.75 5.57C8 5.47 8.25 5.39 8.51 5.34C8.77 5.29 9.03 5.26 9.3 5.26L14.75 5.26C15.01 5.26 15.28 5.29 15.54 5.34C15.8 5.39 16.05 5.47 16.29 5.57C16.54 5.67 16.77 5.8 16.99 5.95C17.21 6.09 17.41 6.26 17.6 6.45C17.79 6.64 17.96 6.85 18.1 7.07C18.25 7.29 18.37 7.53 18.48 7.77C18.58 8.02 18.65 8.28 18.71 8.54C18.76 8.8 18.78 9.06 18.78 9.33L18.78 14.83C18.78 15.1 18.76 15.37 18.71 15.63C18.65 15.89 18.58 16.14 18.48 16.39C18.37 16.64 18.25 16.87 18.1 17.1C17.96 17.32 17.79 17.52 17.6 17.71C17.41 17.9 17.21 18.07 16.99 18.22C16.77 18.37 16.54 18.49 16.29 18.6C16.05 18.7 15.8 18.78 15.54 18.83C15.28 18.88 15.01 18.91 14.75 18.91ZM9.3 6.86C9.13 6.86 8.97 6.87 8.82 6.91C8.66 6.94 8.51 6.98 8.36 7.05C8.21 7.11 8.07 7.18 7.93 7.28C7.8 7.37 7.68 7.47 7.56 7.58C7.45 7.7 7.35 7.82 7.26 7.96C7.17 8.09 7.09 8.24 7.03 8.38C6.97 8.54 6.92 8.69 6.89 8.85C6.86 9.01 6.84 9.17 6.84 9.33L6.84 14.83C6.84 15 6.86 15.16 6.89 15.32C6.92 15.48 6.97 15.63 7.03 15.78C7.09 15.93 7.17 16.07 7.26 16.21C7.35 16.34 7.45 16.47 7.56 16.58C7.68 16.7 7.8 16.8 7.93 16.89C8.07 16.98 8.21 17.06 8.36 17.12C8.51 17.18 8.66 17.23 8.82 17.26C8.97 17.29 9.13 17.31 9.3 17.31L14.75 17.31C14.91 17.31 15.07 17.29 15.23 17.26C15.38 17.23 15.54 17.18 15.69 17.12C15.83 17.06 15.98 16.98 16.11 16.89C16.24 16.8 16.37 16.7 16.48 16.58C16.59 16.47 16.7 16.34 16.79 16.21C16.87 16.07 16.95 15.93 17.01 15.78C17.07 15.63 17.12 15.48 17.15 15.32C17.18 15.16 17.2 15 17.2 14.83L17.2 9.33C17.2 9.17 17.18 9.01 17.15 8.85C17.12 8.69 17.07 8.54 17.01 8.38C16.95 8.24 16.87 8.09 16.79 7.96C16.7 7.82 16.59 7.7 16.48 7.58C16.37 7.47 16.24 7.37 16.11 7.28C15.98 7.19 15.83 7.11 15.69 7.05C15.54 6.98 15.38 6.94 15.23 6.91C15.07 6.87 14.91 6.86 14.75 6.86L9.3 6.86Z"
                                    fill="currentColor" fill-opacity="1.000000" fill-rule="nonzero"></path>
                                </g>
                              </svg></div>
                          </div>
                        </div>
                        <div style="flex: 1 1 0%;"></div>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="a85a674a" v-if="!showList">
                  <div class="c7e7df4d">
                    <div class="ds-icon da6cda9a" style="font-size: 60px; width: 60px; height: 60px;"><svg
                        viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"
                        xmlns:xlink="http://www.w3.org/1999/xlink">
                        <path id="path"
                          d="M27.501 8.46875C27.249 8.3457 27.1406 8.58008 26.9932 8.69922C26.9434 8.73828 26.9004 8.78906 26.8584 8.83398C26.4902 9.22852 26.0605 9.48633 25.5 9.45508C24.6787 9.41016 23.9785 9.66797 23.3594 10.2969C23.2275 9.52148 22.79 9.05859 22.125 8.76172C21.7764 8.60742 21.4238 8.45312 21.1807 8.11719C21.0098 7.87891 20.9639 7.61328 20.8779 7.35156C20.8242 7.19336 20.7695 7.03125 20.5879 7.00391C20.3906 6.97266 20.3135 7.13867 20.2363 7.27734C19.9258 7.84375 19.8066 8.46875 19.8174 9.10156C19.8447 10.5234 20.4453 11.6562 21.6367 12.4629C21.7725 12.5547 21.8076 12.6484 21.7646 12.7832C21.6836 13.0605 21.5869 13.3301 21.501 13.6074C21.4473 13.7852 21.3662 13.8242 21.1768 13.7461C20.5225 13.4727 19.957 13.0684 19.458 12.5781C18.6104 11.7578 17.8438 10.8516 16.8877 10.1426C16.6631 9.97656 16.4395 9.82227 16.207 9.67578C15.2314 8.72656 16.335 7.94727 16.5898 7.85547C16.8574 7.75977 16.6826 7.42773 15.8193 7.43164C14.957 7.43555 14.167 7.72461 13.1611 8.10938C13.0137 8.16797 12.8594 8.21094 12.7002 8.24414C11.7871 8.07227 10.8389 8.0332 9.84766 8.14453C7.98242 8.35352 6.49219 9.23633 5.39648 10.7441C4.08105 12.5547 3.77148 14.6133 4.15039 16.7617C4.54883 19.0234 5.70215 20.8984 7.47559 22.3633C9.31348 23.8809 11.4307 24.625 13.8457 24.4824C15.3125 24.3984 16.9463 24.2012 18.7881 22.6406C19.2529 22.8711 19.7402 22.9629 20.5498 23.0332C21.1729 23.0918 21.7725 23.002 22.2373 22.9062C22.9648 22.752 22.9141 22.0781 22.6514 21.9531C20.5186 20.959 20.9863 21.3633 20.5605 21.0371C21.6445 19.752 23.2783 18.418 23.917 14.0977C23.9668 13.7539 23.9238 13.5391 23.917 13.2598C23.9131 13.0918 23.9512 13.0254 24.1445 13.0059C24.6787 12.9453 25.1973 12.7988 25.6738 12.5352C27.0557 11.7793 27.6123 10.5391 27.7441 9.05078C27.7637 8.82422 27.7402 8.58789 27.501 8.46875ZM15.46 21.8613C13.3926 20.2344 12.3906 19.6992 11.9766 19.7227C11.5898 19.7441 11.6592 20.1875 11.7441 20.4766C11.833 20.7617 11.9492 20.959 12.1123 21.209C12.2246 21.375 12.3018 21.623 12 21.8066C11.334 22.2207 10.1768 21.668 10.1221 21.6406C8.77539 20.8477 7.64941 19.7988 6.85547 18.3652C6.08984 16.9844 5.64453 15.5039 5.57129 13.9238C5.55176 13.541 5.66406 13.4062 6.04297 13.3379C6.54199 13.2461 7.05762 13.2266 7.55664 13.2988C9.66602 13.6074 11.4619 14.5527 12.9668 16.0469C13.8262 16.9004 14.4766 17.918 15.1465 18.9121C15.8584 19.9688 16.625 20.9746 17.6006 21.7988C17.9443 22.0879 18.2197 22.3086 18.4824 22.4707C17.6895 22.5586 16.3652 22.5781 15.46 21.8613ZM16.4502 15.4805C16.4502 15.3105 16.5859 15.1758 16.7568 15.1758C16.7949 15.1758 16.8301 15.1836 16.8613 15.1953C16.9033 15.2109 16.9424 15.2344 16.9727 15.2695C17.0273 15.3223 17.0586 15.4004 17.0586 15.4805C17.0586 15.6504 16.9229 15.7852 16.7529 15.7852C16.582 15.7852 16.4502 15.6504 16.4502 15.4805ZM19.5273 17.0625C19.3301 17.1426 19.1328 17.2129 18.9434 17.2207C18.6494 17.2344 18.3281 17.1152 18.1533 16.9688C17.8828 16.7422 17.6895 16.6152 17.6074 16.2168C17.5732 16.0469 17.5928 15.7852 17.623 15.6348C17.6934 15.3105 17.6152 15.1035 17.3877 14.9141C17.2012 14.7598 16.9658 14.7188 16.7061 14.7188C16.6094 14.7188 16.5205 14.6758 16.4541 14.6406C16.3457 14.5859 16.2568 14.4512 16.3418 14.2852C16.3691 14.2324 16.501 14.1016 16.5322 14.0781C16.8838 13.877 17.29 13.9434 17.666 14.0938C18.0146 14.2363 18.2773 14.498 18.6562 14.8672C19.0439 15.3145 19.1133 15.4395 19.334 15.7734C19.5078 16.0371 19.667 16.3066 19.7754 16.6152C19.8408 16.8066 19.7559 16.9648 19.5273 17.0625Z"
                          fill-rule="nonzero" fill="#4D6BFE"></path>
                      </svg></div>昇腾+deepseek，很高兴见到你！
                  </div>
                  <div class="a8d0e1d3">我可以帮你写代码、读文件、写作各种创意内容，请把你的任务交给我吧~</div>
                </div>
                <div v-if="false" class="e886deb9">
                  <div class="e214291b"><svg width="18" height="18" viewBox="0 0 18 18" fill="none"
                      xmlns="http://www.w3.org/2000/svg">
                      <path
                        d="M5.856 17.121a.979.979 0 0 1-.327-.06.839.839 0 0 1-.283-.177.739.739 0 0 1-.187-.255.724.724 0 0 1-.07-.303l-.02-1.609a4.663 4.663 0 0 1-1.446-.455 4.252 4.252 0 0 1-.637-.401c-.199-.146-.385-.31-.553-.492a4.442 4.442 0 0 1-.45-.577 4.303 4.303 0 0 1-.327-.637 3.823 3.823 0 0 1-.206-.686 3.729 3.729 0 0 1-.064-.704V6.478c0-.261.025-.516.077-.771a4.43 4.43 0 0 1 .244-.747 4.062 4.062 0 0 1 .932-1.28c.2-.183.418-.347.65-.493.23-.145.482-.267.739-.364a4.21 4.21 0 0 1 .81-.225c.27-.054.553-.078.835-.078H8.55c.103 0 .2.018.29.054a.7.7 0 0 1 .411.376.667.667 0 0 1-.161.766.736.736 0 0 1-.25.151.764.764 0 0 1-.29.055H5.573c-.186 0-.366.012-.54.049-.18.03-.353.079-.52.145-.52.145-.167.061-.328.14-.482-.267-.739-.364a4.21 4.21 0 0 1 .81-.225c.27-.054.553-.078.835-.078H8.55c.103 0 .2.018.29.054a.7.7 0 0 1 .411.376.667.667 0 0 1-.161.766.736.736 0 0 1-.25.151.764.764 0 0 1-.29.055H5.573c-.186 0-.366.012-.54.049-.18.03-.353.079-.52.145-.52.145-.167.061-.328.14-.482.267-.148.091-.29.2-.418.316a2.897 2.897 0 0 0-.347.388c-.097.14-.187.286-.257.444a2.473 2.473 0 0 0-.206.977v4.287c0 .17.013.333.051.503a2.549 2.549 0 0 0 .772 1.33 2.721 2.721 0 0 0 .913.559c.167.066.347.115.527.152.18.03.36.048.546.048a.904.904 0 0 1 .61.23.848.848 0 0 1 .194.262.84.84 0 0 1 .07.303l.007.99 1.915-1.293a2.877 2.877 0 0 1 1.64-.492h2.372c.186 0 .366-.018.54-.048.18-.03.353-.08.52-.146.168-.067.329-.146.483-.237.148-.091.29-.2.418-.316.128-.121.244-.249.347-.388a2.8 2.8 0 0 0 .257-.444 2.47 2.47 0 0 0 .206-.977V8.585a.646.646 0 0 1 .225-.492.679.679 0 0 1 .244-.152.814.814 0 0 1 .585 0c.09.03.174.085.244.244.244.244.244.244.152a.657.657 0 0 1 .225.492V10.8c0 .261-.032.516-.083.771a4.192 4.192 0 0 1-.245.74c-.109.244-.244.468-.398.687a3.735 3.735 0 0 1-.534.6c-.2.183-.418.347-.65.493a4.134 4.134 0 0 1-.738.364 4.7 4.7 0 0 1-.81.225c-.27.054-.553.079-.836.079h-1.877c-.604 0-1.144.164-1.633.491l-2.54 1.713a.913.913 0 0 1-.514.157z"
                        fill="currentColor"></path>
                      <path
                        d="M15.866 4.125h-4.174c-.41 0-.741.313-.741.7 0 .387.332.741.7h4.174c.41 0 .742-.313.742-.7 0-.387-.332-.7-.742-.7z"
                        fill="currentColor"></path>
                      <path
                        d="M14.537 2.932c0-.396-.34-.717-.759-.717s-.758.32-.758.717v3.786c0 .396.34.717.758.717.717.717.42 0 .76-.321.76-.717V2.932z"
                        fill="currentColor"></path>
                    </svg><span>开启新对话</span></div>
                </div>
                <div class="cbcaa82c" :style="{ bottom: showList ? '0px' : '200px' }">
                  <div class="aaff8b8f">
                    <div class="cefa5c26">
                      <div class="dd442025 b699646e" @click="focusTextarea">
                        <div class="fad49dec">
                          <textarea v-model="message" id="chat-input" class="c92459f0" placeholder="给 DeepSeek 发送消息 "
                            rows="2" @keyup.enter.prevent="handleEnterPress" ref="textareaRef"></textarea>
                          <div class="b13855df">
                          </div>
                        </div>
                        <div class="ec4f5d61">
                          <div class="bf38813a">
                            <div @click="MesdsetQuestionStorp" v-if="!chatHdEnd" role="button" aria-disabled="false"
                              class="f6d670">
                              <div class="f286936b">
                                <div class="be24146b"></div>
                              </div>
                            </div>
                            <div @click="MesdsetQuestion" v-if="chatHdEnd" role="button" aria-disabled="false"
                              class="f6d670">
                              <div class="f286936b">
                                <div class="ds-icon" style="font-size: 16px; width: 16px; height: 16px;"><svg width="14"
                                    height="16" viewBox="0 0 14 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd" clip-rule="evenodd"
                                      d="M7 16c-.595 0-1.077-.462-1.077-1.032V1.032C5.923.462 6.405 0 7 0s1.077.462 1.077 1.032v13.936C8.077 15.538 7.595 16 7 16z"
                                      fill="currentColor"></path>
                                    <path fill-rule="evenodd" clip-rule="evenodd"
                                      d="M.315 7.44a1.002 1.002 0 0 1 0-1.46L6.238.302a1.11 1.11 0 0 1 1.523 0c.421.403.421 1.057 0 1.46L1.838 7.44a1.11 1.11 0 0 1-1.523 0z"
                                      fill="currentColor"></path>
                                    <path fill-rule="evenodd" clip-rule="evenodd"
                                      d="M13.685 7.44a1.11 1.11 0 0 1-1.523 0L6.238 1.762a1.002 1.002 0 0 1 0-1.46 1.11 1.11 0 0 1 1.523 0l5.924 5.678c.42.403.42 1.056 0 1.46z"
                                      fill="currentColor"></path>
                                  </svg></div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="fcaa63f8">内容由 AI 生成，请仔细甄别</div>
                  <div class="fcaa63f8" style="margin-top: 60px;font-size: 16px;font-weight: 600;color: #1A9BFF;">
                    <div style="margin-bottom: 20px;">支持单位：</div>
                    <div class="support-units">
                      <div>洛阳市行政审批和政务信息管理局</div>
                      <div>洛阳国晟投资控股集团有限公司</div>
                      <div>洛阳弘义公用事业投资发展集团有限公司</div>
                      <div>洛阳弘义智慧城市建设服务有限公司</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { getQuestion, setQuestion } from "@/api/index";
import "highlight.js/styles/monokai-sublime.css";
import { marked } from 'marked';
import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
const Nevkey = ref('');
const showList = ref(false);
const message = ref('');
const paramMsg = ref([]);
//分页
const page = reactive({ page: 1, limit: 1 });
//记录已处理的数据ID，避免重复
const processedIds = ref(new Set());

const chatContainerRef = ref(null);
// 添加用户是否手动滚动的标志
const userScrolled = ref(false);
const chatHdEnd = ref(true);
// 修改滚动到底部的函数
const scrollToBottom = async () => {
  await nextTick();
  setTimeout(() => {
    const container = chatContainerRef.value;
    // 只有当用户没有手动滚动或者是新消息时才自动滚动到底部
    if (container && (!userScrolled.value || chatHdEnd.value)) {
      container.scrollTop = container.scrollHeight;
    }
  }, 100);
};
const handleScroll = (event: WheelEvent) => {
  const container = event.currentTarget as HTMLElement;
  const isAtBottom = Math.abs(container.scrollHeight - container.scrollTop - container.clientHeight) < 50;
  console.log(container.scrollHeight - container.scrollTop - container.clientHeight);

  // 如果不在底部,说明用户手动滚动了
  if (!isAtBottom) {
    userScrolled.value = true;
  } else {
    userScrolled.value = false;
  }
};
onMounted(() => {
  Nevkey.value = Date.now().toString();
})

//提问回答列表
const getQuestionList = () => {

  if (storp.value == true) {
    storp.value = false;
    chatHdEnd.value = true;
    return;
  }
  const index = paramMsg.value.length - 1;

  if (paramMsg.value[index].role != 'assistant') {
    paramMsg.value.push({ role: 'assistant', sk: '', content: '', skLong: false, msgCode: 1 });
  }
  if (paramMsg.value[index].msgCode == 0) {
    storp.value = false;
    chatHdEnd.value = true;
    return;
  }
  getQuestion({ 'key': Nevkey.value, 'page': page.page, 'limit': page.limit }).then(res => {
    if (res.code == 1) {
      for (let i = 0; i < res.data.list.length; i++) {
        const item = res.data.list[i];
        if (!processedIds.value.has(item.id)) {
          processedIds.value.add(item.id);
          const lastIndex = paramMsg.value.length - 1;
          if (item.reasoning == 1) {
            paramMsg.value[lastIndex].skLong = true;
            paramMsg.value[lastIndex].sk += item.content;
          } else {
            //paramMsg.value[lastIndex].sk = '';
            paramMsg.value[lastIndex].skLong = false;
            paramMsg.value[lastIndex].content += item.content;
          }
        }
        if (item.usage_json.length > 0 || item.usage_json.prompt_tokens) {
          const lIndex = paramMsg.value.length - 1;
          paramMsg.value[lIndex].content = marked(paramMsg.value[lIndex].content);
          paramMsg.value[lIndex].skLong = false;
          chatHdEnd.value = true;
          return;
        }
        scrollToBottom(); // 每次添加新消息后滚动
      }
      if (res.data.list.length == page.limit) {
        page.page++;
        getQuestionList();
      } else {
        getQuestionList();
      }
    }
  })
}

const storp = ref(false);
// 发送问题时重置状态
const MesdsetQuestion = () => {
  if (!message.value || message.value.trim() === '') return
  console.log(chatHdEnd.value);
  if (chatHdEnd.value == true) {
    showList.value = true;
    paramMsg.value.push({ role: 'user', content: message.value })
    Nevkey.value = Date.now().toString();
    // 重置各种状态
    page.page = 1;
    processedIds.value.clear();
    message.value = '';
    chatHdEnd.value = false;
    userScrolled.value = false;
    let lastElement = paramMsg.value.at(-1);
    if (lastElement.role == 'assistant' && lastElement.content == '') {
      paramMsg.value.pop();
    }
    scrollToBottom(); // 添加滚动到底部
    setQuestion({ 'key': Nevkey.value, 'messages': JSON.stringify(paramMsg.value) }).then(res => {
      console.log(res);
      if (res.code == 0) {
        const lastIndex = paramMsg.value.length - 1;
        paramMsg.value[lastIndex].skLong = false;
        paramMsg.value[lastIndex].msgCode = 0;
      }
    });
    getQuestionList();
  }

}
const MesdsetQuestionStorp = () => {
  window.location.reload();
  // storp.value = true;
  // paramMsg.value = [];
  // chatHdEnd.value = true;
  // showList.value = false;
  // const lIndex = paramMsg.value.length - 1;
  // paramMsg.value[lIndex].skLong = false;
}
// 清理状态
onUnmounted(() => {
  processedIds.value.clear();
  page.page = 1;
});
const copy = (d) => {
  navigator.clipboard.writeText(d);
  //AllMessage.success('复制成功！');
}

// 添加计算属性来处理移动端高度
const getMobileHeight = computed(() => {
  // 检查是否为移动设备
  const isMobile = window.innerWidth <= 768;
  //return isMobile ? '30%' : '60%';
  return '10%';
});

// 在 script setup 部分添加处理函数
const handleEnterPress = (e: KeyboardEvent) => {
  // 如果同时按下 shift 键,则不提交
  if (e.shiftKey) {
    return;
  }

  // 阻止默认的换行行为
  e.preventDefault();

  // 调用发送消息的方法
  MesdsetQuestion();
};

// 在 script setup 中添加
const isNotEmpty = (str: string) => {
  return str && str.trim().replace(/[\s\r\n\t]/g, '').length > 0;
}

// 在 script setup 部分添加:
const textareaRef = ref<HTMLTextAreaElement | null>(null);

const focusTextarea = () => {
  if (textareaRef.value) {
    textareaRef.value.focus();
  }
};
</script>
<style src="@/assets/home.css"></style>

import "highlight.js/styles/monokai-sublime.css";
<style>
.language-markdown {
  color: #000 !important;
}

.ds-markdown .ds-markdown--block {
  color: #000 !important;
}

code[class*=language-],
pre[class*=language-] {
  color: #000 !important;
}

.support-units {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

@media screen and (min-width: 768px) {
  .support-units {
    flex-direction: row;
    gap: 30px;
  }
}

/* 修改输入框容器的样式 */
.cbcaa82c {
  position: sticky;
  bottom: 0;
  /* 移动端默认值 */
  background: #fff;
  z-index: 10;
  padding: 16px;
  margin-top: auto;
}

/* PC端的底部间距调整 */
@media screen and (min-width: 769px) {
  .cbcaa82c {
    bottom: 0px;
    /* PC端的底部间距 */
  }
}

/* 移动端的底部间距保持为0 */
@media screen and (max-width: 768px) {
  .cbcaa82c {
    bottom: 0;
  }
}

/* 确保聊天内容区域可以正常滚动 */
.f6004764 {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

/* 聊天内容容器样式 */
.f72b0bab {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
  /* 添加底部padding，防止内容被输入框遮挡 */
}


/* 调整欢迎内容与顶部的距离 - 基础样式 */
.a85a674a {
  padding-top: 10px;
  /* 减少默认的顶部padding */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  /* 减少最小高度 */
}

/* PC端的样式调整 */
@media screen and (min-width: 769px) {
  .a85a674a {
    padding-top: 5px;
    /* PC端更小的顶部间距 */
    min-height: 120px;
    /* PC端更小的最小高度 */
  }

  .c7e7df4d {
    margin-bottom: 12px;
    /* PC端更小的底部间距 */
  }

  .a8d0e1d3 {
    margin-top: 6px;
    /* PC端更小的顶部间距 */
  }
}

/* 移动端的样式保持原样 */
@media screen and (max-width: 768px) {
  .a85a674a {
    padding-top: 20px;
    min-height: 200px;
  }
}

/* 调整欢迎文字的样式 */
.c7e7df4d {
  margin-bottom: 16px;
  /* 减少底部间距 */
  font-size: 18px;
  font-weight: 500;
}

.a85a674a .c7e7df4d {
  margin-top: 100px;
}

/* 调整描述文字的样式 */
.a8d0e1d3 {
  margin-top: 8px;
  /* 减少与上方内容的间距 */
  color: #666;
}
/* ... existing code ... */

/* 自定义滚动条样式 */
.dad65929::-webkit-scrollbar {
  width: 1px; /* 滚动条宽度 */
  height: 1px; /* 滚动条高度 */
}

.dad65929::-webkit-scrollbar-track {
  background: #f1f1f1; /* 滚动条轨道背景颜色 */
  border-radius: 1px; /* 轨道圆角 */
}

.dad65929::-webkit-scrollbar-thumb {
  background: #888; /* 滚动条滑块颜色 */
  border-radius: 1px; /* 滑块圆角 */
}

.dad65929::-webkit-scrollbar-thumb:hover {
  background: #555; /* 鼠标悬停时滑块颜色 */
}

/* 兼容 Firefox */
.dad65929 {
  scrollbar-width: thin; /* 滚动条宽度 */
  scrollbar-color: #888 #f1f1f1; /* 滑块颜色和轨道颜色 */
}
</style>