zhengyiming
2025-02-26 be661965399aac1a93f2a57f79d9fbce7cda8ba2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Taro from '@tarojs/taro';
import { TabBarPageRouter } 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));
    console.log('index: ', index);
    systemStore.setTabIndex(index);
    Taro.switchTab(option);
  };
  return switchTab;
}
 
// export function useFirstEnter() {
//   const systemStore = useSystemStore();
//   const { isFirstEnter } = storeToRefs(systemStore);
//   console.log('isFirstEnter: ', isFirstEnter);
 
//   onMounted(() => {
//     systemStore.setIsFirstEnter(false);
//   });
 
//   return { isFirstEnter };
// }
 
export function useFocus() {
  const isFocus = ref(false);
 
  Taro.useDidShow(() => {
    isFocus.value = true;
  });
 
  Taro.useDidHide(() => {
    isFocus.value = false;
  });
 
  return {
    isFocus,
  };
}