wupengfei
1 天以前 fb243f3345c6f3ed7e7c8c2d98c39b5afc782b9a
apps/cMiniApp/src/hooks/router.ts
@@ -1,15 +1,16 @@
import Taro from '@tarojs/taro';
import { TabBarPageRouter } from '@/constants';
import { TabBarPageRouter, TabBarPageRouterList } from '@/constants';
import { useSystemStore } from '@/stores/modules/system';
export function useSwitchTab() {
  const systemStore = useSystemStore();
  const switchTab = (option: Taro.switchTab.Option) => {
    const index = Object.values(TabBarPageRouter).findIndex((x) => option.url.includes(x));
    const index = TabBarPageRouterList.findIndex((x) => option.url.includes(x));
    console.log('index: ', index);
    systemStore.setTabIndex(index);
    Taro.switchTab(option);
    Taro.switchTab(option).then(() => {
      systemStore.setTabIndex(index);
    });
  };
  return switchTab;
}