openxiangda 1.0.246 → 1.0.248

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44436,6 +44436,7 @@ function AdminList(props) {
44436
44436
  const [notificationApi, notificationHolder] = notification.useNotification();
44437
44437
  const [modalApi, modalHolder] = Modal6.useModal();
44438
44438
  const sourceKey = dataSource.key || "anonymous";
44439
+ const listIdentity = JSON.stringify([listKey, sourceKey]);
44439
44440
  const [rawPreference, setRawPreference] = useState15(null);
44440
44441
  const [preference, setPreference] = useState15(
44441
44442
  () => mergeAdminListPreference({
@@ -44455,7 +44456,8 @@ function AdminList(props) {
44455
44456
  const [settingsTab, setSettingsTab] = useState15("search");
44456
44457
  const [columnSearch, setColumnSearch] = useState15("");
44457
44458
  const [expanded, setExpanded] = useState15(false);
44458
- const [ready, setReady] = useState15(false);
44459
+ const [readyIdentity, setReadyIdentity] = useState15(null);
44460
+ const ready = readyIdentity === listIdentity;
44459
44461
  const [rows, setRows] = useState15([]);
44460
44462
  const [total, setTotal] = useState15(0);
44461
44463
  const [allowedColumnKeys, setAllowedColumnKeys] = useState15(void 0);
@@ -44478,9 +44480,12 @@ function AdminList(props) {
44478
44480
  const [draggedSearchKey, setDraggedSearchKey] = useState15("");
44479
44481
  const selectedKeysRef = useRef8([]);
44480
44482
  const dataSourceRef = useRef8(dataSource);
44483
+ const listIdentityRef = useRef8(listIdentity);
44484
+ const requestVersionRef = useRef8(0);
44481
44485
  const onQueryChangeRef = useRef8(onQueryChange);
44482
44486
  const onSelectionChangeRef = useRef8(onSelectionChange);
44483
44487
  dataSourceRef.current = dataSource;
44488
+ listIdentityRef.current = listIdentity;
44484
44489
  onQueryChangeRef.current = onQueryChange;
44485
44490
  onSelectionChangeRef.current = onSelectionChange;
44486
44491
  const definitionFingerprint = JSON.stringify({
@@ -44551,10 +44556,19 @@ function AdminList(props) {
44551
44556
  }, [rowKey, rowSelectable, rows]);
44552
44557
  useEffect14(() => {
44553
44558
  let active = true;
44554
- setReady(false);
44559
+ const initializationVersion = ++requestVersionRef.current;
44560
+ setReadyIdentity(null);
44561
+ setRows([]);
44562
+ setTotal(0);
44563
+ setAllowedColumnKeys(void 0);
44564
+ setHiddenFieldsCount(0);
44565
+ setLoading(false);
44566
+ setError(null);
44555
44567
  const load = async () => {
44556
44568
  const saved = dataSourceRef.current.preferences ? await dataSourceRef.current.preferences.get(listKey).catch(() => null) : null;
44557
- if (!active) return;
44569
+ if (!active || initializationVersion !== requestVersionRef.current || listIdentityRef.current !== listIdentity) {
44570
+ return;
44571
+ }
44558
44572
  setRawPreference(saved);
44559
44573
  const merged = mergeAdminListPreference({
44560
44574
  version: configVersion,
@@ -44582,7 +44596,7 @@ function AdminList(props) {
44582
44596
  selectedKeysRef.current = [];
44583
44597
  setSelectedKeys([]);
44584
44598
  previousFingerprintRef.current = "";
44585
- setReady(true);
44599
+ setReadyIdentity(listIdentity);
44586
44600
  };
44587
44601
  void load();
44588
44602
  return () => {
@@ -44594,8 +44608,7 @@ function AdminList(props) {
44594
44608
  defaultVisibleSearchCount,
44595
44609
  definitionFingerprint,
44596
44610
  form,
44597
- listKey,
44598
- sourceKey
44611
+ listIdentity
44599
44612
  ]);
44600
44613
  useEffect14(() => {
44601
44614
  if (!allowedColumnKeys) return;
@@ -44630,28 +44643,34 @@ function AdminList(props) {
44630
44643
  ]);
44631
44644
  const loadData = useCallback12(async () => {
44632
44645
  if (!ready) return;
44646
+ const requestVersion = ++requestVersionRef.current;
44647
+ const requestedIdentity = listIdentity;
44648
+ const requestedDataSource = dataSourceRef.current;
44649
+ const isCurrentRequest = () => requestVersion === requestVersionRef.current && requestedIdentity === listIdentityRef.current;
44633
44650
  setLoading(true);
44634
44651
  setError(null);
44635
44652
  onQueryChangeRef.current?.(query);
44636
44653
  try {
44637
- const result = await dataSourceRef.current.query(query);
44654
+ const result = await requestedDataSource.query(query);
44655
+ if (!isCurrentRequest()) return;
44638
44656
  setRows(result.rows || []);
44639
44657
  setTotal(Math.max(0, Number(result.total || 0)));
44640
44658
  setAllowedColumnKeys(result.allowedColumnKeys);
44641
44659
  setHiddenFieldsCount(Math.max(0, Number(result.hiddenFieldsCount || 0)));
44642
44660
  } catch (requestError) {
44661
+ if (!isCurrentRequest()) return;
44643
44662
  setRows([]);
44644
44663
  setTotal(0);
44645
44664
  setError(
44646
44665
  requestError instanceof Error ? requestError : new Error(String(requestError || "\u6570\u636E\u52A0\u8F7D\u5931\u8D25"))
44647
44666
  );
44648
44667
  } finally {
44649
- setLoading(false);
44668
+ if (isCurrentRequest()) setLoading(false);
44650
44669
  }
44651
- }, [query, ready]);
44670
+ }, [listIdentity, query, ready]);
44652
44671
  useEffect14(() => {
44653
44672
  if (!ready) return;
44654
- const fingerprint = queryFingerprint(query, sourceKey);
44673
+ const fingerprint = queryFingerprint(query, listIdentity);
44655
44674
  if (previousFingerprintRef.current && previousFingerprintRef.current !== fingerprint && selectedKeysRef.current.length) {
44656
44675
  clearSelection("\u67E5\u8BE2\u6761\u4EF6\u6216\u6392\u5E8F\u5DF2\u53D8\u5316\uFF0C\u5DF2\u6E05\u7A7A\u8DE8\u9875\u9009\u62E9");
44657
44676
  }
@@ -44662,7 +44681,7 @@ function AdminList(props) {
44662
44681
  loadData,
44663
44682
  query,
44664
44683
  ready,
44665
- sourceKey
44684
+ listIdentity
44666
44685
  ]);
44667
44686
  const visibleSearchFields = useMemo17(() => {
44668
44687
  const searchMap = new Map(searchFields.map((field) => [field.key, field]));