优化发布页默认输入与在线时间校验

This commit is contained in:
yml2213
2026-06-08 07:12:26 +08:00
parent 04f42e5a96
commit ff2aa2df9d
6 changed files with 203 additions and 55 deletions
@@ -4,6 +4,7 @@ const props = withDefaults(
options: Array<string | number>
modelValue?: string | number
activeValues?: Array<string | number>
disabledValues?: Array<string | number>
keyPrefix?: string
compact?: boolean
suffix?: string
@@ -11,6 +12,7 @@ const props = withDefaults(
{
modelValue: undefined,
activeValues: () => [],
disabledValues: () => [],
keyPrefix: '',
compact: false,
suffix: '',
@@ -26,7 +28,12 @@ function isActive(value: string | number) {
return props.activeValues.includes(value) || props.modelValue === value
}
function isDisabled(value: string | number) {
return props.disabledValues.includes(value)
}
function selectValue(value: string | number) {
if (isDisabled(value)) return
emit('update:modelValue', value)
emit('select', value)
}
@@ -39,7 +46,8 @@ function selectValue(value: string | number) {
:key="`${keyPrefix}${option}`"
type="button"
class="chip"
:class="{ active: isActive(option) }"
:class="{ active: isActive(option), disabled: isDisabled(option) }"
:disabled="isDisabled(option)"
@click="selectValue(option)"
>
{{ option }}{{ suffix }}
@@ -81,4 +89,11 @@ function selectValue(value: string | number) {
background: #ff6a00;
color: #fff;
}
.chip.disabled {
border-color: #e5e7eb;
background: #f3f4f6;
color: #a8b0bd;
cursor: not-allowed;
}
</style>