feat: 移动端下按钮收缩

main
ChenZhaoYu 2 years ago
parent c4baccdc48
commit 222b3eaa4c

@ -34,6 +34,7 @@ const conversationList = computed(() => dataSources.value.filter(item => (!item.
const prompt = ref<string>('') const prompt = ref<string>('')
const loading = ref<boolean>(false) const loading = ref<boolean>(false)
const usingContext = ref<boolean>(true) const usingContext = ref<boolean>(true)
const actionVisible = ref<boolean>(true)
function handleSubmit() { function handleSubmit() {
onConversation() onConversation()
@ -367,20 +368,20 @@ function handleStop() {
function toggleUsingContext() { function toggleUsingContext() {
usingContext.value = !usingContext.value usingContext.value = !usingContext.value
if (usingContext.value) { if (usingContext.value)
dialog.info({ ms.success(t('chat.turnOnContext'))
title: t('chat.usingContext'), else
content: t('chat.turnOnContext'), ms.warning(t('chat.turnOffContext'))
positiveText: t('common.yes'), }
})
} function onInputFocus() {
else { if (isMobile.value)
dialog.info({ actionVisible.value = false
title: t('chat.usingContext'), }
content: t('chat.turnOffContext'),
positiveText: t('common.yes'), function onInputBlur() {
}) if (isMobile.value)
} actionVisible.value = true
} }
const placeholder = computed(() => { const placeholder = computed(() => {
@ -402,7 +403,7 @@ const wrapClass = computed(() => {
const footerClass = computed(() => { const footerClass = computed(() => {
let classes = ['p-4'] let classes = ['p-4']
if (isMobile.value) if (isMobile.value)
classes = ['sticky', 'left-0', 'bottom-0', 'right-0', 'p-2', 'pr-4', 'overflow-hidden'] classes = ['sticky', 'left-0', 'bottom-0', 'right-0', 'p-2', 'overflow-hidden']
return classes return classes
}) })
@ -464,26 +465,30 @@ onUnmounted(() => {
<footer :class="footerClass"> <footer :class="footerClass">
<div class="w-full max-w-screen-xl m-auto"> <div class="w-full max-w-screen-xl m-auto">
<div class="flex items-center justify-between space-x-2"> <div class="flex items-center justify-between space-x-2">
<HoverButton @click="handleClear"> <div v-if="actionVisible" class="flex items-center space-x-2">
<span class="text-xl text-[#4f555e] dark:text-white"> <HoverButton @click="handleClear">
<SvgIcon icon="ri:delete-bin-line" /> <span class="text-xl text-[#4f555e] dark:text-white">
</span> <SvgIcon icon="ri:delete-bin-line" />
</HoverButton> </span>
<HoverButton @click="handleExport"> </HoverButton>
<span class="text-xl text-[#4f555e] dark:text-white"> <HoverButton @click="handleExport">
<SvgIcon icon="ri:download-2-line" /> <span class="text-xl text-[#4f555e] dark:text-white">
</span> <SvgIcon icon="ri:download-2-line" />
</HoverButton> </span>
<HoverButton @click="toggleUsingContext"> </HoverButton>
<span class="text-xl" :class="{ 'text-[#4b9e5f]': usingContext, 'text-[#a8071a]': !usingContext }"> <HoverButton @click="toggleUsingContext">
<SvgIcon icon="ri:chat-history-line" /> <span class="text-xl" :class="{ 'text-[#4b9e5f]': usingContext, 'text-[#a8071a]': !usingContext }">
</span> <SvgIcon icon="ri:chat-history-line" />
</HoverButton> </span>
</HoverButton>
</div>
<NInput <NInput
v-model:value="prompt" v-model:value="prompt"
type="textarea" type="textarea"
:autosize="{ minRows: 1, maxRows: 2 }" :autosize="{ minRows: 1, maxRows: 2 }"
:placeholder="placeholder" :placeholder="placeholder"
@focus="onInputFocus"
@blur="onInputBlur"
@keypress="handleEnter" @keypress="handleEnter"
/> />
<NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit"> <NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit">

Loading…
Cancel
Save