Skip to content

Commit

Permalink
fix: 🐛 修复方向键无法选中提示词最后一个
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed May 15, 2023
1 parent 9bac8bc commit 6994fad
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 50 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "go-proxy-bingai",
"version": "1.6.1",
"version": "1.6.2",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
35 changes: 18 additions & 17 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions frontend/src/views/chat/components/ChatPrompt/ChatPrompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const isInput = ref(false);
const maxTryCreateConversationIdCount = 10;
const userTokenCookieName = '_U';
const randIpCookieName = 'BingAI_Rand_IP';
const isPromptScrolling = ref(false);
const promptItemHeight = 130;
onMounted(async () => {
await initChat();
Expand Down Expand Up @@ -154,15 +156,10 @@ const handleInputBlur = (ev: FocusEvent) => {
};
const handleInputTextKey = (ev: KeyboardEvent) => {
// console.log('key : ', ev.key);
const itemHeight = 130;
switch (ev.key) {
case 'ArrowUp':
{
ev.preventDefault();
const offset = scrollbarRef.value?.getOffset() || 0;
selectedPromptIndex.value = Math.round(offset / itemHeight);
// console.log('selectedPromptIndex : ', selectedPromptIndex.value);
if (selectedPromptIndex.value > 0) {
selectedPromptIndex.value--;
if (scrollbarRef.value) {
Expand All @@ -174,9 +171,6 @@ const handleInputTextKey = (ev: KeyboardEvent) => {
case 'ArrowDown':
{
ev.preventDefault();
const offset = scrollbarRef.value?.getOffset() || 0;
selectedPromptIndex.value = Math.round(offset / itemHeight);
// console.log('selectedPromptIndex : ', selectedPromptIndex.value);
if (selectedPromptIndex.value < searchPromptList.value.length - 1) {
selectedPromptIndex.value++;
if (scrollbarRef.value) {
Expand Down Expand Up @@ -207,6 +201,18 @@ const selectPrompt = (item: IPrompt) => {
CIB.vm.actionBar.inputText = item.prompt;
isShowChatPrompt.value = false;
};
const handlePromptListScroll = () => {
isPromptScrolling.value = true;
setTimeout(() => {
if (isPromptScrolling.value === true) {
isPromptScrolling.value = false;
// 滚动结束设置选中
const offset = scrollbarRef.value?.getOffset() || 0;
selectedPromptIndex.value = Math.round(offset / promptItemHeight);
}
}, 100);
};
</script>

<template>
Expand All @@ -221,6 +227,7 @@ const selectPrompt = (item: IPrompt) => {
:data-sources="searchPromptList"
:data-component="ChatPromptItem"
:keeps="10"
@scroll="handlePromptListScroll"
/>
<NEmpty v-else class="bg-white w-full max-w-[1060px] max-h-[390px] rounded-xl py-6" description="暂无提示词数据">
<template #extra>
Expand Down
42 changes: 21 additions & 21 deletions web/assets/index-084936e6.js → web/assets/index-3fee6899.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script src="/web/js/bing/chat/global.js"></script>
<script src="/web/js/bing/chat/amd.js"></script>
<script src="/web/js/bing/chat/config.js"></script>
<script type="module" crossorigin src="/web/assets/index-662279a2.js"></script>
<script type="module" crossorigin src="/web/assets/index-464a60e7.js"></script>
<link rel="stylesheet" href="/web/assets/index-2128d00b.css">
<link rel="manifest" href="/web/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/web/registerSW.js"></script></head>

Expand Down
2 changes: 1 addition & 1 deletion web/sw.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6994fad

Please sign in to comment.