* 新增自适应数值与窗口分析工具,提升交互体验 * 优化回收站模块逻辑,增加展示与选择功能 * 引入 Macaron 主题配置文件并更新 Tailwind 配置 * 精简基础组件代码,移除冗余样式与设置项 * 完善测试用例,覆盖 UI 系统与回收站工作流 * 更新多语言配置,支持功能变更后的文案需求
113 lines
4.1 KiB
Vue
113 lines
4.1 KiB
Vue
<template>
|
|
<div class="space-y-3 fcb-expiration">
|
|
<label for="send-expiration-value" class="block text-sm font-semibold" :class="isDarkMode ? 'text-gray-300' : 'text-gray-700'">
|
|
{{ t('send.expiration.label') }}
|
|
</label>
|
|
|
|
<div v-if="expirationMethod !== 'forever'" class="grid grid-cols-[2.75rem_minmax(0,1fr)_2.75rem] gap-2">
|
|
<button
|
|
type="button"
|
|
class="fcb-action fcb-icon-action flex h-11 w-11 items-center justify-center rounded-xl border text-xl font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-40"
|
|
:class="controlClass"
|
|
:disabled="numericValue <= 1"
|
|
:aria-label="t('send.expiration.decrement')"
|
|
@click="incrementValue(-1)"
|
|
>
|
|
<MinusIcon class="h-5 w-5" aria-hidden="true" />
|
|
</button>
|
|
|
|
<input
|
|
id="send-expiration-value"
|
|
:value="expirationValue"
|
|
type="number"
|
|
min="1"
|
|
inputmode="numeric"
|
|
class="h-11 min-w-0 rounded-xl border px-3 text-center font-semibold tabular-nums outline-none transition-colors focus:ring-2 focus:ring-indigo-500 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
|
:class="controlClass"
|
|
:placeholder="getPlaceholder()"
|
|
@input="updateValue"
|
|
/>
|
|
|
|
<button
|
|
type="button"
|
|
class="fcb-action fcb-icon-action flex h-11 w-11 items-center justify-center rounded-xl border text-xl font-semibold transition-colors"
|
|
:class="controlClass"
|
|
:aria-label="t('send.expiration.increment')"
|
|
@click="incrementValue(1)"
|
|
>
|
|
<PlusIcon class="h-5 w-5" aria-hidden="true" />
|
|
</button>
|
|
</div>
|
|
|
|
<label class="block">
|
|
<span class="sr-only">{{ t('send.expiration.method') }}</span>
|
|
<div class="relative">
|
|
<select
|
|
:value="expirationMethod"
|
|
class="min-h-11 w-full cursor-pointer appearance-none rounded-xl border py-2.5 pl-4 pr-11 text-sm font-medium outline-none transition-colors focus:ring-2 focus:ring-indigo-500"
|
|
:class="controlClass"
|
|
:aria-label="t('send.expiration.method')"
|
|
@change="updateMethod"
|
|
>
|
|
<option v-for="option in options" :key="option.value" :value="option.value">
|
|
{{ option.label }}
|
|
</option>
|
|
</select>
|
|
<ChevronDownIcon class="pointer-events-none absolute right-4 top-1/2 h-4 w-4 -translate-y-1/2 opacity-70" aria-hidden="true" />
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, inject } from 'vue'
|
|
import { ChevronDownIcon, MinusIcon, PlusIcon } from 'lucide-vue-next'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
const { t } = useI18n()
|
|
|
|
interface Props {
|
|
expirationMethod: string
|
|
expirationValue: string
|
|
options: Array<{ label: string; value: string }>
|
|
}
|
|
|
|
interface Emits {
|
|
'update:expirationMethod': [value: string]
|
|
'update:expirationValue': [value: string]
|
|
}
|
|
|
|
const props = defineProps<Props>()
|
|
const emit = defineEmits<Emits>()
|
|
const isDarkMode = inject('isDarkMode')
|
|
|
|
const numericValue = computed(() => Math.max(1, Number.parseInt(props.expirationValue) || 1))
|
|
const controlClass = computed(() =>
|
|
isDarkMode
|
|
? 'border-gray-600 bg-gray-800/70 text-gray-100 hover:border-[#9fc9bd]'
|
|
: 'border-[#d7e0e4] bg-[#eef3f5] text-[#405466] shadow-[inset_2px_2px_5px_rgba(167,183,191,.22),inset_-2px_-2px_5px_rgba(255,255,255,.9)] hover:border-[#9fc9bd]'
|
|
)
|
|
|
|
const updateMethod = (event: Event) => {
|
|
emit('update:expirationMethod', (event.target as HTMLSelectElement).value)
|
|
}
|
|
|
|
const updateValue = (event: Event) => {
|
|
emit('update:expirationValue', (event.target as HTMLInputElement).value)
|
|
}
|
|
|
|
const incrementValue = (delta: number) => {
|
|
emit('update:expirationValue', Math.max(1, numericValue.value + delta).toString())
|
|
}
|
|
|
|
const getPlaceholder = () => {
|
|
switch (props.expirationMethod) {
|
|
case 'count': return t('send.expiration.placeholders.count')
|
|
case 'minute': return t('send.expiration.placeholders.minutes')
|
|
case 'hour': return t('send.expiration.placeholders.hours')
|
|
case 'day': return t('send.expiration.placeholders.days')
|
|
default: return t('send.expiration.placeholders.default')
|
|
}
|
|
}
|
|
</script>
|