🌶 feat(Web): 增加全局可空类型定义
This commit is contained in:
parent
0290bcbdef
commit
89533cb060
@ -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
|
||||
|
||||
@ -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,
|
||||
},
|
||||
|
||||
6
Web/src/types/global.d.ts
vendored
6
Web/src/types/global.d.ts
vendored
@ -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[];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user