🌶 feat(Web): 增加全局可空类型定义

This commit is contained in:
喵你个汪呀 2025-08-23 22:39:49 +08:00
parent 0290bcbdef
commit 89533cb060
3 changed files with 12 additions and 8 deletions

View File

@ -1,13 +1,11 @@
<script setup lang="ts">
import { PropType, reactive, watch } from 'vue';
import { number } from 'echarts';
import { auth } from '/@/utils/authFunction';
const emit = defineEmits(['update:modelValue', 'change']);
type BadgeTabsItem = {
label: string; //
value: string; //
label: NullableString | NullableNumber; //
value: NullableString | NullableNumber; //
count?: number; //
visible?: boolean; //
disabled?: boolean; //
@ -25,7 +23,7 @@ const props = defineProps({
* <BadgeTabs v-model="state.active" :data="[
* { label: '履约中', value: 10, count: state.total?.ly ?? 0 },
* { label: '解约申请', value: 20, count: state.total?.jysq ?? 0 },
* { label: '解约审核', value: 21, count: state.total?.jysh ?? 0, visible: auth('jtysqyQyd/approve') },
* { label: '解约审核', value: 21, count: state.total?.jysh ?? 0, visible: auth('xxx') },
* { label: '已解约', value: 22, count: state.total?.yjy ?? 0 },
* { label: '已超期', value: 11, count: state.total?.ycq ?? 0 },
* { label: '已失效', value: 199, count: state.total?.ysx ?? 0 },
@ -69,8 +67,8 @@ const props = defineProps({
* @example [5, -2]
*/
offset: {
type: Array as PropType<[int, int]>,
default: [5, -2],
type: (Array as unknown) as PropType<[number, number]>,
default: [5, -2] as const,
},
/**
* 隐藏小于等于0的badge

View File

@ -114,7 +114,7 @@ const props = defineProps({
* <g-sys-dict v-model="selectedValues" code="roles" renderAs="select" multiple multiple-model="comma" />
*/
modelValue: {
type: [String, Number, Boolean, Array, null] as PropType<string | number | boolean | any[] | null>,
type: [String, Number, Boolean, Array, null] as PropType<string | number | boolean | any[] | Nullable>,
default: null,
required: true,
},

View File

@ -77,6 +77,12 @@ declare interface RouteToFrom<T = any> extends RouteItem {
children?: T[];
}
// 声明 Nullable 可空类型
declare type Nullable = null | undefined;
declare type NullableString = Nullable | String;
declare type NullableNumber = Nullable | Number;
declare type NullableBoolean = Nullable | Boolean;
// 声明路由当前项类型集合
declare type RouteItems<T extends RouteItem = any> = T[];