perf: 【ANTD】优化一些 todo 提到的问题

This commit is contained in:
puhui999
2025-05-20 15:08:54 +08:00
parent 074eb0e83d
commit 98a742895d
20 changed files with 87 additions and 101 deletions

View File

@@ -3,7 +3,10 @@ import type { TableToolbar } from '#/components/table-toolbar';
import { ref, watch } from 'vue';
// TODO @puhui999这里的注释、目的写下
/**
* vxe 原生工具栏挂载封装
* 解决每个组件使用 vxe-table 组件时都需要写一遍的问题
*/
export function useTableToolbar() {
const hiddenSearchBar = ref(false); // 隐藏搜索栏
const tableToolbarRef = ref<InstanceType<typeof TableToolbar>>();
@@ -15,7 +18,7 @@ export function useTableToolbar() {
const table = tableRef.value;
const tableToolbar = tableToolbarRef.value;
if (table && tableToolbar) {
// TODO @puhui999通过 nexttick 可以解决么?
// TODO @puhui999通过 nexttick 可以解决么?试过不得行🤣刚好列表组件出现后延迟一秒挂载很稳
setTimeout(async () => {
const toolbar = tableToolbar.getToolbarRef();
if (!toolbar) {
@@ -29,10 +32,9 @@ export function useTableToolbar() {
watch(
() => tableRef.value,
(val) => {
async (val) => {
if (!val || isBound.value) return;
// TODO @puhui999这里要处理下 promise 的告警么?
bindTableToolbar();
await bindTableToolbar();
},
{ immediate: true },
);