fix: fixed bug image preview im mobile chat session page

This commit is contained in:
RockYang 2024-02-29 15:41:45 +08:00
parent ca69341024
commit 02a9c422fe
4 changed files with 15 additions and 5 deletions

View File

@ -131,6 +131,7 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
c.Abort() c.Abort()
return return
} }
h.Init()
// 保存会话连接 // 保存会话连接
h.App.ChatClients.Put(sessionId, client) h.App.ChatClients.Put(sessionId, client)

View File

@ -393,9 +393,6 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
}), }),
fx.Invoke(func(h *chatimpl.ChatHandler) {
h.Init()
}),
// 注册生命周期回调函数 // 注册生命周期回调函数
fx.Invoke(func(lifecycle fx.Lifecycle, lc *AppLifecycle) { fx.Invoke(func(lifecycle fx.Lifecycle, lc *AppLifecycle) {
lifecycle.Append(fx.Hook{ lifecycle.Append(fx.Hook{

View File

@ -15,7 +15,7 @@
</template> </template>
<script setup> <script setup>
import {onMounted, ref} from "vue" import {nextTick, onMounted, ref} from "vue"
import {showImagePreview} from "vant"; import {showImagePreview} from "vant";

View File

@ -104,7 +104,7 @@
<script setup> <script setup>
import {nextTick, onMounted, ref} from "vue"; import {nextTick, onMounted, ref} from "vue";
import {showNotify, showToast} from "vant"; import {showImagePreview, showNotify, showToast} from "vant";
import {onBeforeRouteLeave, useRouter} from "vue-router"; import {onBeforeRouteLeave, useRouter} from "vue-router";
import {dateFormat, processContent, randString, renderInputText, UUID} from "@/utils/libs"; import {dateFormat, processContent, randString, renderInputText, UUID} from "@/utils/libs";
import {getChatConfig} from "@/store/chat"; import {getChatConfig} from "@/store/chat";
@ -326,6 +326,18 @@ const connect = function (chat_id, role_id) {
hl.highlightElement(block) hl.highlightElement(block)
}) })
scrollListBox() scrollListBox()
const items = document.querySelectorAll('.message-line')
const imgs = items[items.length - 1].querySelectorAll('img')
for (let i = 0; i < imgs.length; i++) {
if (!imgs[i].src) {
continue
}
imgs[i].addEventListener('click', (e) => {
e.stopPropagation()
showImagePreview([imgs[i].src]);
})
}
}) })
} }