Files
filecodebox/src/components/common/TextInputArea.vue
T

94 lines
2.3 KiB
Vue

<template>
<div class="flex flex-col">
<textarea
:value="modelValue"
@input="updateValue"
:rows="rows"
:placeholder="placeholderText"
:class="[
'flex-grow px-4 py-3 rounded-xl placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 transition duration-300 resize-none custom-scrollbar',
isDarkMode
? 'bg-gray-800 bg-opacity-50 text-white'
: 'bg-white text-gray-900 border border-gray-300'
]"
></textarea>
</div>
</template>
<script setup lang="ts">
import { inject, computed } from 'vue'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
interface Props {
modelValue: string
rows?: number
placeholder?: string
}
interface Emits {
'update:modelValue': [value: string]
}
const props = withDefaults(defineProps<Props>(), {
rows: 7,
placeholder: '在此输入要发送的文本...'
})
const emit = defineEmits<Emits>()
const isDarkMode = inject('isDarkMode')
// 使用computed属性处理多语言文本
const placeholderText = computed(() => props.placeholder || t('send.uploadArea.textInput'))
const updateValue = (event: Event) => {
const target = event.target as HTMLTextAreaElement
emit('update:modelValue', target.value)
}
</script>
<style scoped>
/* 自定义滚动条样式 */
.custom-scrollbar {
scrollbar-width: thin;
scrollbar-color: rgba(156, 163, 175, 0.3) rgba(243, 244, 246, 0.5);
}
.custom-scrollbar::-webkit-scrollbar {
width: 6px;
height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: rgba(243, 244, 246, 0.5);
border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background-color: rgba(156, 163, 175, 0.5);
border-radius: 3px;
transition: background-color 0.3s;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background-color: rgba(156, 163, 175, 0.7);
}
/* 深色模式下的滚动条样式 */
:deep([class*='dark']) .custom-scrollbar {
scrollbar-color: rgba(75, 85, 99, 0.5) rgba(31, 41, 55, 0.5);
}
:deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-track {
background: rgba(31, 41, 55, 0.5);
}
:deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-thumb {
background-color: rgba(75, 85, 99, 0.5);
}
:deep([class*='dark']) .custom-scrollbar::-webkit-scrollbar-thumb:hover {
background-color: rgba(75, 85, 99, 0.7);
}
</style>