fix: demo validator usage & types import

This commit is contained in:
allen
2026-04-13 20:15:47 +08:00
parent e808fe74c1
commit 12a81a7a7d
6 changed files with 23 additions and 12 deletions

View File

@@ -15,12 +15,13 @@ const modelValue = defineModel('value');
const finalOption = computed(() => {
const { type, ...otherOption } = props.data.option;
if (type === 'number') {
if (type === 'number' || type === 'exponential') {
return {
step: props.data.option.step ?? 1,
min: props.data.option.min,
max: props.data.option.max,
precision: props.data.option.precision ?? 0,
...otherOption,
};
}

View File

@@ -55,6 +55,10 @@ const bodyStyle = computed(() => {
});
function init() {
if (!modelValue.value) {
modelValue.value = {};
}
for (const param of props.params) {
modelValue.value[param.key] = param.defaultValue ?? null;
}

View File

@@ -1,6 +1,8 @@
<script setup lang="ts">
import type { CollapsibleRootEmits, CollapsibleRootProps } from 'reka-ui';
import type { ClassType } from '@vben-core/typings';
import { computed } from 'vue';
import { ChevronsDown } from 'lucide-vue-next';

View File

@@ -4,11 +4,11 @@ export interface CollapsibleParamOption {
min?: number;
precision?: number;
step?: number;
type: 'exponential' | 'number' | 'select' | 'string';
type?: 'exponential' | 'number' | 'select' | 'string';
}
export interface CollapsibleParamSchema {
defaultValue: number | number[] | string | string[];
defaultValue?: number | number[] | string | string[];
description: string;
key: string;
option: CollapsibleParamOption;