mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 10:33:50 +08:00
chore: fix type:check error (#3159)
This commit is contained in:
parent
0bb76a86d2
commit
18222ab0b6
@ -1,4 +1,5 @@
|
||||
import type { BarMap } from './types';
|
||||
import type { MergeAll } from '/@/utils/types';
|
||||
|
||||
export const BAR_MAP: BarMap = {
|
||||
vertical: {
|
||||
@ -40,8 +41,16 @@ function extend<T extends object, K extends object>(to: T, _from: K): T & K {
|
||||
return Object.assign(to, _from);
|
||||
}
|
||||
|
||||
export function toObject<T extends object>(arr: Array<T>): Recordable<T> {
|
||||
const res = {};
|
||||
/**
|
||||
* [
|
||||
* { name: 'zhangsan', age: 18 },
|
||||
* { sex: 'male', age: 20 }
|
||||
* ]
|
||||
* =>
|
||||
* { name: 'zhangsan', sex: 'male', age: 20 }
|
||||
*/
|
||||
export function toObject<T extends object[]>(arr: T): MergeAll<T> {
|
||||
const res = {} as MergeAll<T>;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i]) {
|
||||
extend(res, arr[i]);
|
||||
|
@ -45,11 +45,18 @@
|
||||
},
|
||||
emits: ['select', 'open-change'],
|
||||
setup(props, { emit }) {
|
||||
const rootMenuEmitter = mitt();
|
||||
const rootMenuEmitter = mitt<{
|
||||
'on-update-opened': (string | number)[];
|
||||
'on-menu-item-select': string | number;
|
||||
'open-name-change': {
|
||||
name: string;
|
||||
opened: boolean;
|
||||
};
|
||||
}>();
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
const currentActiveName = ref<string | number>('');
|
||||
const openedNames = ref<string[]>([]);
|
||||
const openedNames = ref<(string | number)[]>([]);
|
||||
|
||||
const { prefixCls } = useDesign('menu');
|
||||
|
||||
@ -95,13 +102,13 @@
|
||||
rootMenuEmitter.emit('on-update-opened', openedNames.value);
|
||||
}
|
||||
|
||||
function addSubMenu(name: string) {
|
||||
function addSubMenu(name: string | number) {
|
||||
if (openedNames.value.includes(name)) return;
|
||||
openedNames.value.push(name);
|
||||
updateOpened();
|
||||
}
|
||||
|
||||
function removeSubMenu(name: string) {
|
||||
function removeSubMenu(name: string | number) {
|
||||
openedNames.value = openedNames.value.filter((item) => item !== name);
|
||||
updateOpened();
|
||||
}
|
||||
@ -131,7 +138,7 @@
|
||||
onMounted(() => {
|
||||
openedNames.value = !props.collapse ? [...props.openNames] : [];
|
||||
updateOpened();
|
||||
rootMenuEmitter.on('on-menu-item-select', (name: string) => {
|
||||
rootMenuEmitter.on('on-menu-item-select', (name: string | number) => {
|
||||
currentActiveName.value = name;
|
||||
|
||||
nextTick(() => {
|
||||
|
@ -5,6 +5,7 @@ import type {
|
||||
TableRowSelection as ITableRowSelection,
|
||||
Key,
|
||||
} from 'ant-design-vue/lib/table/interface';
|
||||
|
||||
import type { ColumnProps } from 'ant-design-vue/lib/table';
|
||||
|
||||
import { ComponentType } from './componentType';
|
||||
@ -94,7 +95,7 @@ export interface TableActionType {
|
||||
expandRows: (keys: (string | number)[]) => void;
|
||||
collapseAll: () => void;
|
||||
scrollTo: (pos: string) => void; // pos: id | "top" | "bottom"
|
||||
getSelectRowKeys: () => string[];
|
||||
getSelectRowKeys: () => Key[];
|
||||
deleteSelectRowByKey: (key: string) => void;
|
||||
setPagination: (info: Partial<PaginationProps>) => void;
|
||||
setTableData: <T = Recordable>(values: T[]) => void;
|
||||
|
@ -46,7 +46,7 @@ export const treeProps = buildProps({
|
||||
},
|
||||
|
||||
renderIcon: {
|
||||
type: Function as PropType<(params: Recordable) => string>,
|
||||
type: Function as PropType<(...params: any[]) => string>,
|
||||
},
|
||||
|
||||
helpMessage: {
|
||||
|
@ -113,11 +113,15 @@
|
||||
const isTitleClickable = computed(() => !!props.onTitleClick);
|
||||
const getPagination = computed(() => {
|
||||
const { list, pageSize } = props;
|
||||
if (pageSize > 0 && list && list.length > pageSize) {
|
||||
|
||||
// compatible line 104
|
||||
// if typeof pageSize is boolean, Number(true) && 5 = 5, Number(false) && 5 = 0
|
||||
const size = isNumber(pageSize) ? pageSize : Number(pageSize) && 5;
|
||||
|
||||
if (size > 0 && list && list.length > size) {
|
||||
return {
|
||||
total: list.length,
|
||||
pageSize,
|
||||
//size: 'small',
|
||||
pageSize: size,
|
||||
current: unref(current),
|
||||
onChange(page) {
|
||||
current.value = page;
|
||||
|
@ -40,3 +40,26 @@ export type ComponentSize = 'large' | 'medium' | 'small' | 'mini';
|
||||
export type StyleValue = string | CSSProperties | Array<StyleValue>;
|
||||
|
||||
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|
||||
|
||||
type Merge<O extends object, T extends object> = {
|
||||
[K in keyof O | keyof T]: K extends keyof T ? T[K] : K extends keyof O ? O[K] : never;
|
||||
};
|
||||
|
||||
/**
|
||||
* T = [
|
||||
* { name: string; age: number; },
|
||||
* { sex: 'male' | 'female'; age: string }
|
||||
* ]
|
||||
* =>
|
||||
* MergeAll<T> = {
|
||||
* name: string;
|
||||
* sex: 'male' | 'female';
|
||||
* age: string
|
||||
* }
|
||||
*/
|
||||
export type MergeAll<T extends object[], R extends object = {}> = T extends [
|
||||
infer F extends object,
|
||||
...infer Rest extends object[],
|
||||
]
|
||||
? MergeAll<Rest, Merge<R, F>>
|
||||
: R;
|
||||
|
@ -31,7 +31,12 @@
|
||||
/>
|
||||
<a-button type="primary" class="my-4" @click="handleCreatePrompt"> Prompt </a-button>
|
||||
|
||||
<component :is="currentModal" v-model:open="modalOpen" :userData="userData" />
|
||||
<component
|
||||
v-if="currentModal"
|
||||
:is="currentModal"
|
||||
v-model:open="modalOpen"
|
||||
:userData="userData"
|
||||
/>
|
||||
|
||||
<Modal1 @register="register1" :minHeight="100" />
|
||||
<Modal2 @register="register2" />
|
||||
|
@ -58,6 +58,8 @@
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import { PageWrapper } from '/@/components/Page';
|
||||
|
||||
import { EventDataNode } from 'ant-design-vue/es/vc-tree/interface';
|
||||
|
||||
export default defineComponent({
|
||||
components: { BasicTree, PageWrapper, Row, Col },
|
||||
setup() {
|
||||
@ -65,8 +67,8 @@
|
||||
console.log(node);
|
||||
}
|
||||
|
||||
function getRightMenuList(node: any): ContextMenuItem[] {
|
||||
return [
|
||||
function getRightMenuList(node: EventDataNode): Promise<ContextMenuItem[]> {
|
||||
const menu = [
|
||||
{
|
||||
label: '新增',
|
||||
handler: () => {
|
||||
@ -82,6 +84,9 @@
|
||||
icon: 'bx:bxs-folder-open',
|
||||
},
|
||||
];
|
||||
return new Promise((resolve) => {
|
||||
resolve(menu);
|
||||
});
|
||||
}
|
||||
const actionList: TreeActionItem[] = [
|
||||
{
|
||||
|
@ -14,17 +14,18 @@
|
||||
<!-- 处理数组属性,placeholder -->
|
||||
|
||||
<div v-if="item.children">
|
||||
<component
|
||||
v-for="(child, index) of item.children"
|
||||
:key="index"
|
||||
v-bind="child.componentProps"
|
||||
:is="child.component"
|
||||
v-model:value="formConfig.currentItem.componentProps[item.name][index]"
|
||||
/>
|
||||
<template v-for="(child, index) of item.children" :key="index">
|
||||
<component
|
||||
v-if="child.component"
|
||||
v-bind="child.componentProps"
|
||||
v-model:value="formConfig.currentItem.componentProps[item.name][index]"
|
||||
:is="child.component"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
<!-- 如果不是数组,则正常处理属性值 -->
|
||||
<component
|
||||
v-else
|
||||
v-else-if="item.component"
|
||||
class="component-prop"
|
||||
v-bind="item.componentProps"
|
||||
:is="item.component"
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div v-for="item of baseItemColumnProps" :key="item.name">
|
||||
<FormItem :label="item.label" v-if="showProps(item.exclude)">
|
||||
<component
|
||||
v-if="formConfig.currentItem.colProps"
|
||||
v-if="formConfig.currentItem.colProps && item.component"
|
||||
class="component-props"
|
||||
v-bind="item.componentProps"
|
||||
:is="item.component"
|
||||
|
@ -9,6 +9,7 @@
|
||||
<div v-for="item of baseFormItemProps" :key="item.name">
|
||||
<FormItem :label="item.label" v-if="showProps(item.exclude)">
|
||||
<component
|
||||
v-if="item.component"
|
||||
class="component-props"
|
||||
v-bind="item.componentProps"
|
||||
:is="item.component"
|
||||
@ -19,6 +20,7 @@
|
||||
<div v-for="item of advanceFormItemProps" :key="item.name">
|
||||
<FormItem :label="item.label" v-if="showProps(item.exclude)">
|
||||
<component
|
||||
v-if="item.component"
|
||||
class="component-props"
|
||||
v-bind="item.componentProps"
|
||||
:is="item.component"
|
||||
@ -28,6 +30,7 @@
|
||||
><div v-for="item of advanceFormItemColProps" :key="item.name">
|
||||
<FormItem :label="item.label" v-if="showProps(item.exclude)">
|
||||
<component
|
||||
v-if="item.component"
|
||||
class="component-props"
|
||||
v-bind="item.componentProps"
|
||||
:is="item.component"
|
||||
|
Loading…
Reference in New Issue
Block a user