useShortcutBar.js 956 Bytes
import { useRoute } from 'vue-router';
import { ref } from 'vue';
import { Cookies } from '@/utils/generatePackage'

export const useShortcutBar = (item) => {
  const $route = useRoute();
  const path = $route.path;
  const isClient = Cookies.get('userType') === 'client' ? true : false; // 判断C端入口位置,访客/客户
  // const case1 = ['home', 'me', 'rank'];
  // const case2 = ['home'];
  // const case3 = ['me'];
  const shortcutItem = ref([]);

  // 配置快捷跳转条
  if (item) {
    shortcutItem.value = item;
  } else {
    if (path === '/client/chooseBook') { // 爱心捐书页面
      if (isClient) {
        shortcutItem.value = ['home', 'me', 'rank']
      } else {
        shortcutItem.value = ['me']
      }
    }

    if (path === '/client/donateCertificate') {
      shortcutItem.value = ['home']
    }

    if (path === '/business/index') {
      shortcutItem.value = ['me']
    }
  }

  return {
    shortcutItem
  }
}