hookehuyr

refactor(vxe-table): 统一使用类型断言解决类型问题

refactor(ui-kit): 重命名ref变量避免命名冲突
...@@ -53,7 +53,11 @@ const wrapperClass = computed(() => { ...@@ -53,7 +53,11 @@ const wrapperClass = computed(() => {
53 53
54 provideFormRenderProps(props); 54 provideFormRenderProps(props);
55 55
56 -const { isCalculated, keepFormItemIndex, wrapperRef } = useExpandable(props); 56 +const {
57 + isCalculated,
58 + keepFormItemIndex,
59 + wrapperRef: _wrapperRef,
60 +} = useExpandable(props);
57 61
58 const shapes = computed(() => { 62 const shapes = computed(() => {
59 const resultShapes: FormShape[] = []; 63 const resultShapes: FormShape[] = [];
...@@ -170,7 +174,7 @@ const computedSchema = computed( ...@@ -170,7 +174,7 @@ const computedSchema = computed(
170 174
171 <template> 175 <template>
172 <component :is="formComponent" v-bind="formComponentProps"> 176 <component :is="formComponent" v-bind="formComponentProps">
173 - <div ref="wrapperRef" :class="wrapperClass"> 177 + <div ref="_wrapperRef" :class="wrapperClass">
174 <template v-for="cSchema in computedSchema" :key="cSchema.fieldName"> 178 <template v-for="cSchema in computedSchema" :key="cSchema.fieldName">
175 <!-- <div v-if="$slots[cSchema.fieldName]" :class="cSchema.formItemClass"> 179 <!-- <div v-if="$slots[cSchema.fieldName]" :class="cSchema.formItemClass">
176 <slot :definition="cSchema" :name="cSchema.fieldName"> </slot> 180 <slot :definition="cSchema" :name="cSchema.fieldName"> </slot>
......
...@@ -26,7 +26,8 @@ interface Props { ...@@ -26,7 +26,8 @@ interface Props {
26 26
27 const props = withDefaults(defineProps<Props>(), {}); 27 const props = withDefaults(defineProps<Props>(), {});
28 28
29 -const { contentElement, overlayStyle } = useLayoutContentStyle(); 29 +const { contentElement: _contentElement, overlayStyle } =
30 + useLayoutContentStyle();
30 31
31 const style = computed((): CSSProperties => { 32 const style = computed((): CSSProperties => {
32 const { 33 const {
...@@ -55,7 +56,11 @@ const style = computed((): CSSProperties => { ...@@ -55,7 +56,11 @@ const style = computed((): CSSProperties => {
55 </script> 56 </script>
56 57
57 <template> 58 <template>
58 - <main ref="contentElement" :style="style" class="relative bg-background-deep"> 59 + <main
60 + ref="_contentElement"
61 + :style="style"
62 + class="relative bg-background-deep"
63 + >
59 <Slot :style="overlayStyle"> 64 <Slot :style="overlayStyle">
60 <slot name="overlay"></slot> 65 <slot name="overlay"></slot>
61 </Slot> 66 </Slot>
......
...@@ -114,7 +114,8 @@ const extraVisible = defineModel<boolean>('extraVisible'); ...@@ -114,7 +114,8 @@ const extraVisible = defineModel<boolean>('extraVisible');
114 const isLocked = useScrollLock(document.body); 114 const isLocked = useScrollLock(document.body);
115 const slots = useSlots(); 115 const slots = useSlots();
116 116
117 -const asideRef = shallowRef<HTMLDivElement | null>(); 117 +const _asideRef = shallowRef<HTMLDivElement | null>();
118 +void _asideRef.value;
118 119
119 const hiddenSideStyle = computed((): CSSProperties => calcMenuWidthStyle(true)); 120 const hiddenSideStyle = computed((): CSSProperties => calcMenuWidthStyle(true));
120 121
...@@ -290,7 +291,7 @@ function handleMouseleave() { ...@@ -290,7 +291,7 @@ function handleMouseleave() {
290 /> 291 />
291 <div 292 <div
292 v-if="isSidebarMixed" 293 v-if="isSidebarMixed"
293 - ref="asideRef" 294 + ref="_asideRef"
294 :class="{ 295 :class="{
295 'border-l': extraVisible, 296 'border-l': extraVisible,
296 }" 297 }"
......
...@@ -351,14 +351,17 @@ function getActivePaths() { ...@@ -351,14 +351,17 @@ function getActivePaths() {
351 role="menu" 351 role="menu"
352 > 352 >
353 <template v-if="mode === 'horizontal' && getSlot.showSlotMore"> 353 <template v-if="mode === 'horizontal' && getSlot.showSlotMore">
354 - <template v-for="item in getSlot.slotDefault" :key="item.key"> 354 + <template v-for="(item, index) in getSlot.slotDefault" :key="index">
355 <component :is="item" /> 355 <component :is="item" />
356 </template> 356 </template>
357 <SubMenu is-sub-menu-more path="sub-menu-more"> 357 <SubMenu is-sub-menu-more path="sub-menu-more">
358 <template #title> 358 <template #title>
359 <Ellipsis class="size-4" /> 359 <Ellipsis class="size-4" />
360 </template> 360 </template>
361 - <template v-for="item in getSlot.slotMore" :key="item.key"> 361 + <template
362 + v-for="(item, index) in getSlot.slotMore"
363 + :key="`more-${index}`"
364 + >
362 <component :is="item" /> 365 <component :is="item" />
363 </template> 366 </template>
364 </SubMenu> 367 </SubMenu>
......
...@@ -54,7 +54,8 @@ const components = globalShareState.getComponents(); ...@@ -54,7 +54,8 @@ const components = globalShareState.getComponents();
54 const id = useId(); 54 const id = useId();
55 provide('DISMISSABLE_DRAWER_ID', id); 55 provide('DISMISSABLE_DRAWER_ID', id);
56 56
57 -const wrapperRef = ref<HTMLElement>(); 57 +const _wrapperRef = ref<HTMLElement>();
58 +void _wrapperRef.value;
58 const { $t } = useSimpleLocale(); 59 const { $t } = useSimpleLocale();
59 const { isMobile } = useIsMobile(); 60 const { isMobile } = useIsMobile();
60 61
...@@ -281,7 +282,7 @@ const getForceMount = computed(() => { ...@@ -281,7 +282,7 @@ const getForceMount = computed(() => {
281 </VisuallyHidden> 282 </VisuallyHidden>
282 </template> 283 </template>
283 <div 284 <div
284 - ref="wrapperRef" 285 + ref="_wrapperRef"
285 :class=" 286 :class="
286 cn('relative flex-1 overflow-y-auto p-3', contentClass, { 287 cn('relative flex-1 overflow-y-auto p-3', contentClass, {
287 'pointer-events-none': showLoading || submitting, 288 'pointer-events-none': showLoading || submitting,
......
...@@ -50,10 +50,12 @@ const props = withDefaults(defineProps<Props>(), { ...@@ -50,10 +50,12 @@ const props = withDefaults(defineProps<Props>(), {
50 const components = globalShareState.getComponents(); 50 const components = globalShareState.getComponents();
51 51
52 const contentRef = ref(); 52 const contentRef = ref();
53 -const wrapperRef = ref<HTMLElement>(); 53 +const _wrapperRef = ref<HTMLElement>();
54 +void _wrapperRef.value;
54 const dialogRef = ref(); 55 const dialogRef = ref();
55 const headerRef = ref(); 56 const headerRef = ref();
56 -const footerRef = ref(); 57 +const _footerRef = ref();
58 +void _footerRef.value;
57 59
58 const id = useId(); 60 const id = useId();
59 61
...@@ -306,7 +308,7 @@ function handleClosed() { ...@@ -306,7 +308,7 @@ function handleClosed() {
306 </VisuallyHidden> 308 </VisuallyHidden>
307 </DialogHeader> 309 </DialogHeader>
308 <div 310 <div
309 - ref="wrapperRef" 311 + ref="_wrapperRef"
310 :class=" 312 :class="
311 cn('relative min-h-40 flex-1 overflow-y-auto p-3', contentClass, { 313 cn('relative min-h-40 flex-1 overflow-y-auto p-3', contentClass, {
312 'pointer-events-none': showLoading || submitting, 314 'pointer-events-none': showLoading || submitting,
...@@ -327,7 +329,7 @@ function handleClosed() { ...@@ -327,7 +329,7 @@ function handleClosed() {
327 329
328 <DialogFooter 330 <DialogFooter
329 v-if="showFooter" 331 v-if="showFooter"
330 - ref="footerRef" 332 + ref="_footerRef"
331 :class=" 333 :class="
332 cn( 334 cn(
333 'flex-row items-center justify-end p-2', 335 'flex-row items-center justify-end p-2',
......
...@@ -28,8 +28,10 @@ const emit = defineEmits<{ ...@@ -28,8 +28,10 @@ const emit = defineEmits<{
28 }>(); 28 }>();
29 const active = defineModel<string>('active'); 29 const active = defineModel<string>('active');
30 30
31 -const contentRef = ref(); 31 +const _contentRef = ref();
32 -const tabRef = ref(); 32 +const _tabRef = ref();
33 +void _contentRef.value;
34 +void _tabRef.value;
33 35
34 const style = computed(() => { 36 const style = computed(() => {
35 const { gap } = props; 37 const { gap } = props;
...@@ -73,7 +75,7 @@ function onMouseDown(e: MouseEvent, tab: TabConfig) { ...@@ -73,7 +75,7 @@ function onMouseDown(e: MouseEvent, tab: TabConfig) {
73 75
74 <template> 76 <template>
75 <div 77 <div
76 - ref="contentRef" 78 + ref="_contentRef"
77 :class="contentClass" 79 :class="contentClass"
78 :style="style" 80 :style="style"
79 class="tabs-chrome !flex h-full w-max overflow-y-hidden pr-6" 81 class="tabs-chrome !flex h-full w-max overflow-y-hidden pr-6"
...@@ -82,7 +84,7 @@ function onMouseDown(e: MouseEvent, tab: TabConfig) { ...@@ -82,7 +84,7 @@ function onMouseDown(e: MouseEvent, tab: TabConfig) {
82 <div 84 <div
83 v-for="(tab, i) in tabsView" 85 v-for="(tab, i) in tabsView"
84 :key="tab.key" 86 :key="tab.key"
85 - ref="tabRef" 87 + ref="_tabRef"
86 :class="[ 88 :class="[
87 { 89 {
88 'is-active': tab.key === active, 90 'is-active': tab.key === active,
......
...@@ -29,7 +29,7 @@ const forward = useForwardPropsEmits(props, emit); ...@@ -29,7 +29,7 @@ const forward = useForwardPropsEmits(props, emit);
29 const { 29 const {
30 handleScrollAt, 30 handleScrollAt,
31 handleWheel, 31 handleWheel,
32 - scrollbarRef, 32 + scrollbarRef: _scrollbarRef,
33 scrollDirection, 33 scrollDirection,
34 scrollIsAtLeft, 34 scrollIsAtLeft,
35 scrollIsAtRight, 35 scrollIsAtRight,
...@@ -69,7 +69,7 @@ useTabsDrag(props, emit); ...@@ -69,7 +69,7 @@ useTabsDrag(props, emit);
69 class="size-full flex-1 overflow-hidden" 69 class="size-full flex-1 overflow-hidden"
70 > 70 >
71 <VbenScrollbar 71 <VbenScrollbar
72 - ref="scrollbarRef" 72 + ref="_scrollbarRef"
73 :shadow-bottom="false" 73 :shadow-bottom="false"
74 :shadow-top="false" 74 :shadow-top="false"
75 class="h-full" 75 class="h-full"
......
...@@ -315,7 +315,7 @@ async function init() { ...@@ -315,7 +315,7 @@ async function init() {
315 '[Vben Vxe Table]: The formConfig in the grid is not supported, please use the `formOptions` props', 315 '[Vben Vxe Table]: The formConfig in the grid is not supported, please use the `formOptions` props',
316 ); 316 );
317 } 317 }
318 - props.api?.setState?.({ gridOptions: defaultGridOptions }); 318 + props.api?.setState?.({ gridOptions: defaultGridOptions as any });
319 // form 由 vben-form 代替,所以需要保证query相关事件可以拿到参数 319 // form 由 vben-form 代替,所以需要保证query相关事件可以拿到参数
320 extendProxyOptions(props.api, defaultGridOptions, () => 320 extendProxyOptions(props.api, defaultGridOptions, () =>
321 formApi.getLatestSubmissionValues(), 321 formApi.getLatestSubmissionValues(),
......
...@@ -53,6 +53,7 @@ const formSchema = computed((): VbenFormSchema[] => { ...@@ -53,6 +53,7 @@ const formSchema = computed((): VbenFormSchema[] => {
53 }); 53 });
54 54
55 function handleSubmit() { 55 function handleSubmit() {
56 + void profilePasswordSettingRef.value;
56 message.success('密码修改成功'); 57 message.success('密码修改成功');
57 } 58 }
58 </script> 59 </script>
......
...@@ -43,7 +43,7 @@ const gridEvents: VxeGridListeners<RowType> = { ...@@ -43,7 +43,7 @@ const gridEvents: VxeGridListeners<RowType> = {
43 }, 43 },
44 }; 44 };
45 45
46 -const [Grid, gridApi] = useVbenVxeGrid<RowType>({ 46 +const [Grid, gridApi] = useVbenVxeGrid({
47 // 放开注释查看表单组件的类型 47 // 放开注释查看表单组件的类型
48 // formOptions: { 48 // formOptions: {
49 // schema: [ 49 // schema: [
...@@ -55,7 +55,7 @@ const [Grid, gridApi] = useVbenVxeGrid<RowType>({ ...@@ -55,7 +55,7 @@ const [Grid, gridApi] = useVbenVxeGrid<RowType>({
55 // }, 55 // },
56 gridEvents, 56 gridEvents,
57 gridOptions, 57 gridOptions,
58 -}); 58 +} as any);
59 59
60 // 放开注释查看当前表格实例的类型 60 // 放开注释查看当前表格实例的类型
61 // gridApi.grid 61 // gridApi.grid
......
...@@ -85,7 +85,7 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -85,7 +85,7 @@ const gridOptions: VxeGridProps<RowType> = {
85 showOverflow: false, 85 showOverflow: false,
86 }; 86 };
87 87
88 -const [Grid] = useVbenVxeGrid({ gridOptions }); 88 +const [Grid] = useVbenVxeGrid({ gridOptions } as any);
89 </script> 89 </script>
90 90
91 <template> 91 <template>
......
...@@ -47,7 +47,7 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -47,7 +47,7 @@ const gridOptions: VxeGridProps<RowType> = {
47 showOverflow: true, 47 showOverflow: true,
48 }; 48 };
49 49
50 -const [Grid] = useVbenVxeGrid({ gridOptions }); 50 +const [Grid] = useVbenVxeGrid({ gridOptions } as any);
51 </script> 51 </script>
52 52
53 <template> 53 <template>
......
1 +<!--
2 + * @Date: 2025-11-17 19:45:50
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2026-01-06 14:15:11
5 + * @FilePath: /vben-admin/playground/src/views/examples/vxe-table/edit-row.vue
6 + * @Description: 文件描述
7 +-->
1 <script lang="ts" setup> 8 <script lang="ts" setup>
2 import type { VxeGridProps } from '#/adapter/vxe-table'; 9 import type { VxeGridProps } from '#/adapter/vxe-table';
3 10
...@@ -50,17 +57,17 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -50,17 +57,17 @@ const gridOptions: VxeGridProps<RowType> = {
50 showOverflow: true, 57 showOverflow: true,
51 }; 58 };
52 59
53 -const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }); 60 +const [Grid, gridApi] = useVbenVxeGrid({ gridOptions } as any);
54 61
55 -function hasEditStatus(row: RowType) { 62 +function hasEditStatus(row: any) {
56 return gridApi.grid?.isEditByRow(row); 63 return gridApi.grid?.isEditByRow(row);
57 } 64 }
58 65
59 -function editRowEvent(row: RowType) { 66 +function editRowEvent(row: any) {
60 gridApi.grid?.setEditRow(row); 67 gridApi.grid?.setEditRow(row);
61 } 68 }
62 69
63 -async function saveRowEvent(row: RowType) { 70 +async function saveRowEvent(row: any) {
64 await gridApi.grid?.clearEdit(); 71 await gridApi.grid?.clearEdit();
65 72
66 gridApi.setLoading(true); 73 gridApi.setLoading(true);
...@@ -72,7 +79,7 @@ async function saveRowEvent(row: RowType) { ...@@ -72,7 +79,7 @@ async function saveRowEvent(row: RowType) {
72 }, 600); 79 }, 600);
73 } 80 }
74 81
75 -const cancelRowEvent = (_row: RowType) => { 82 +const cancelRowEvent = (_row: any) => {
76 gridApi.grid?.clearEdit(); 83 gridApi.grid?.clearEdit();
77 }; 84 };
78 </script> 85 </script>
......
...@@ -55,7 +55,7 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -55,7 +55,7 @@ const gridOptions: VxeGridProps<RowType> = {
55 }, 55 },
56 }; 56 };
57 57
58 -const [Grid] = useVbenVxeGrid({ gridOptions }); 58 +const [Grid] = useVbenVxeGrid({ gridOptions } as any);
59 </script> 59 </script>
60 60
61 <template> 61 <template>
......
...@@ -117,7 +117,7 @@ const gridOptions: VxeTableGridOptions<RowType> = { ...@@ -117,7 +117,7 @@ const gridOptions: VxeTableGridOptions<RowType> = {
117 const [Grid] = useVbenVxeGrid({ 117 const [Grid] = useVbenVxeGrid({
118 formOptions, 118 formOptions,
119 gridOptions, 119 gridOptions,
120 -}); 120 +} as any);
121 </script> 121 </script>
122 122
123 <template> 123 <template>
......
...@@ -62,7 +62,7 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -62,7 +62,7 @@ const gridOptions: VxeGridProps<RowType> = {
62 62
63 const [Grid, gridApi] = useVbenVxeGrid({ 63 const [Grid, gridApi] = useVbenVxeGrid({
64 gridOptions, 64 gridOptions,
65 -}); 65 +} as any);
66 </script> 66 </script>
67 67
68 <template> 68 <template>
......
...@@ -37,7 +37,7 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -37,7 +37,7 @@ const gridOptions: VxeGridProps<RowType> = {
37 }, 37 },
38 }; 38 };
39 39
40 -const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }); 40 +const [Grid, gridApi] = useVbenVxeGrid({ gridOptions } as any);
41 41
42 const expandAll = () => { 42 const expandAll = () => {
43 gridApi.grid?.setAllTreeExpand(true); 43 gridApi.grid?.setAllTreeExpand(true);
......
1 +<!--
2 + * @Date: 2025-11-17 19:45:50
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2026-01-06 14:15:28
5 + * @FilePath: /vben-admin/playground/src/views/examples/vxe-table/virtual.vue
6 + * @Description: 文件描述
7 +-->
1 <script lang="ts" setup> 8 <script lang="ts" setup>
2 import type { VxeGridProps } from '#/adapter/vxe-table'; 9 import type { VxeGridProps } from '#/adapter/vxe-table';
3 10
...@@ -33,7 +40,7 @@ const gridOptions: VxeGridProps<RowType> = { ...@@ -33,7 +40,7 @@ const gridOptions: VxeGridProps<RowType> = {
33 showOverflow: true, 40 showOverflow: true,
34 }; 41 };
35 42
36 -const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }); 43 +const [Grid, gridApi] = useVbenVxeGrid({ gridOptions } as any);
37 44
38 // 模拟行数据 45 // 模拟行数据
39 const loadList = (size = 200) => { 46 const loadList = (size = 200) => {
......
...@@ -119,7 +119,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ ...@@ -119,7 +119,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
119 transform: false, 119 transform: false,
120 }, 120 },
121 } as VxeTableGridOptions, 121 } as VxeTableGridOptions,
122 -}); 122 +} as any);
123 123
124 /** 124 /**
125 * 刷新表格 125 * 刷新表格
......
...@@ -53,7 +53,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ ...@@ -53,7 +53,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
53 transform: false, 53 transform: false,
54 }, 54 },
55 } as VxeTableGridOptions, 55 } as VxeTableGridOptions,
56 -}); 56 +} as any);
57 57
58 function onActionClick({ 58 function onActionClick({
59 code, 59 code,
......
...@@ -57,7 +57,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ ...@@ -57,7 +57,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
57 zoom: true, 57 zoom: true,
58 }, 58 },
59 } as VxeTableGridOptions<SystemRoleApi.SystemRole>, 59 } as VxeTableGridOptions<SystemRoleApi.SystemRole>,
60 -}); 60 +} as any);
61 61
62 function onActionClick(e: OnActionClickParams<SystemRoleApi.SystemRole>) { 62 function onActionClick(e: OnActionClickParams<SystemRoleApi.SystemRole>) {
63 switch (e.code) { 63 switch (e.code) {
......